source: tools/ddd/GUI.cpp@ 30

Last change on this file since 30 was 29, checked in by ogrimm, 17 years ago
First check-in of ddd. There is still an occasional segmentation fault issue to be tracked, possibly related to some qwt stuff.
File size: 8.5 KB
Line 
1/* ============================================================
2
3DRS Data Display
4
5Qt-based graphical user interface for displaying data taken with
6the drsdaq program.
7There are two operation modes: inspection of a raw data file and
8data taking via the socket interface. Connecting to a socket server
9automatically disables raw data file operation and closes any open
10file.
11
12Oliver Grimm
13
14============================================================ */
15
16#include "GUI.h"
17
18ddd::ddd() {
19
20 WaitForData = false;
21
22 // Instantiate without console output
23 RD = new RawDataCTX(true);
24 PixMap = new PixelMap("../../config/PixelMap.txt", false);
25
26 //---------------------------------------------------------------------
27 //**************************** Main window ****************************
28 //---------------------------------------------------------------------
29
30 Central = new QWidget(this);
31 setCentralWidget(Central);
32
33 Socket = new QTcpSocket(Central);
34 connect(Socket, SIGNAL(readyRead()), this, SLOT(ReadFromSocket()));
35 connect(Socket, SIGNAL(disconnected()), this, SLOT(GotDisconnected()));
36
37 // SpinBox for event number
38 EventNo = new QSpinBox(Central);
39 EventNo->setEnabled(false);
40 connect(EventNo, SIGNAL(valueChanged(int)), this, SLOT(DisplayEvent(int)));
41 EventNo->setToolTip("Event number in file");
42 SpinLayout = new QFormLayout();
43 SpinLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
44 SpinLayout->addRow("E&vent #", EventNo);
45
46 // SpinBox for channel number
47 ChannelNo = new QSpinBox(Central);
48 ChannelNo->setEnabled(false);
49 connect(ChannelNo, SIGNAL(valueChanged(int)), this, SLOT(DisplayEvent(int)));
50 ChannelNo->setToolTip("Channels 0-19 for 2 DRS chips per mezzanine board");
51
52 // SpinBox for board number
53 BoardNo = new QSpinBox(Central);
54 BoardNo->setEnabled(false);
55 connect(BoardNo, SIGNAL(valueChanged(int)), this, SLOT(DisplayEvent(int)));
56 BoardNo->setToolTip("Mezzanine board number");
57
58 // TextBox for pixel ID
59 PixelID = new QLineEdit(Central);
60 PixelID->setEnabled(false);
61 connect(PixelID, SIGNAL(returnPressed()), this, SLOT(TranslatePixelID()));
62 PixelID->setToolTip("Pixel identification");
63
64 // Layout of pixel addressing widgets
65 FormLayout = new QFormLayout;
66 FormLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
67 FormLayout->addRow("&Channel #", ChannelNo);
68 FormLayout->addRow("&Board #", BoardNo);
69 FormLayout->addRow("Pixel ID", PixelID);
70
71 // Socket button
72 SocketButton = new QPushButton("Socke&t\nInterface", Central);
73 SocketButton->setFont(QFont("Times", 10, QFont::Bold));
74 connect(SocketButton, SIGNAL(clicked()), this, SLOT(OpenSocketWindow()));
75 SocketButton->setToolTip("Open window for socket communication");
76
77 // Acquire button and Continuous check box
78 GetButton = new QPushButton("&Acquire", Central);
79 GetButton->setFont(QFont("Times", 10, QFont::Bold));
80 GetButton->setEnabled(false);
81 connect(GetButton, SIGNAL(clicked()), this, SLOT(GetSignalFromSocket()));
82 GetButton->setToolTip("Acquire event over socket interface");
83 ContinuousBox = new QCheckBox("Continuous", Central);
84 ContinuousBox->setFont(QFont("Times", 10, QFont::Bold));
85 ContinuousBox->setToolTip("Acquire continuously");
86
87 // Plot area
88 Graph = new QwtPlot(Central);
89 Graph->setAxisTitle(QwtPlot::xBottom, "Time (ns)");
90 Graph->setAxisTitle(QwtPlot::yLeft, "Signal (mV)");
91 Graph->setAutoReplot(true);
92 Graph->setCanvasBackground(QColor(Qt::yellow));
93 Graph->setToolTip("Left mouse button to zoom (+Shift to pan)");
94 Zoomer = new QwtPlotZoomer(QwtPlot::xBottom,QwtPlot::yLeft,Graph->canvas());
95 Panner = new QwtPlotPanner(Graph->canvas());
96 Panner->setMouseButton(Qt::LeftButton, Qt::ShiftModifier);
97 Grid = new QwtPlotGrid;
98 Grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
99 Grid->attach(Graph);
100 Signal = new QwtPlotCurve;
101 Signal->attach(Graph);
102
103 // Text boxes for run and event header
104 RunHeaderDisplay = new QPlainTextEdit(Central);
105 EventHeaderDisplay = new QPlainTextEdit(Central);
106 RunHeaderDisplay->setReadOnly(true);
107 EventHeaderDisplay->setReadOnly(true);
108
109 // Browse botton
110 LoadButton = new QToolButton(Central);
111 LoadButton->setToolButtonStyle (Qt::ToolButtonTextOnly);
112 LoadButton->setText("...");
113 connect(LoadButton, SIGNAL(clicked()), this, SLOT(FileDialog()));
114 LoadButton->setToolTip("Open file dialog to select raw data file");
115
116 // Filename box
117 FilenameBox = new QLineEdit(Central);
118 connect(FilenameBox, SIGNAL(returnPressed()), this, SLOT(OpenDatafile()));
119 FilenameBox->setToolTip("Raw data file name");
120
121 // Tab widget
122 TabWidget = new QTabWidget(Central);
123 TabWidget->addTab(Graph, "&Signal");
124 TabWidget->addTab(RunHeaderDisplay, "&Run Header");
125 TabWidget->addTab(EventHeaderDisplay, "&Event Header");
126
127 // Layout of all widgets
128 MainLayout = new QGridLayout(Central);
129 MainLayout->addWidget(FilenameBox, 0, 0, 1, 3);
130 MainLayout->addWidget(LoadButton, 0, 3);
131 MainLayout->addLayout(SpinLayout, 1, 0);
132 MainLayout->addLayout(FormLayout, 2, 0);
133 MainLayout->addWidget(SocketButton, 6,0);
134 MainLayout->addWidget(GetButton, 4,0);
135 MainLayout->addWidget(ContinuousBox, 5,0);
136 MainLayout->addWidget(TabWidget, 1, 1, 6, 5);
137 MainLayout->setColumnStretch(1, 10);
138
139 // Menu bar
140 QMenu* Menu = menuBar()->addMenu("&Menu");
141 OpenAction = Menu->addAction("Open data file", this, SLOT(FileDialog()));
142 OpenAction->setShortcut(Qt::CTRL + Qt::Key_O);
143 QAction* SaveAction = Menu->addAction("Save plot", this, SLOT(MenuSave()));
144 SaveAction->setShortcut(Qt::CTRL + Qt::Key_S);
145 Menu->addAction("Print plot", this, SLOT(MenuPrint()));
146 Menu->addSeparator();
147 ConnectAction = Menu->addAction("Connect", this, SLOT(MakeConnection()));
148 ConnectAction->setShortcut(Qt::CTRL + Qt::Key_C);
149 Menu->addSeparator();
150 Menu->addAction("Help", this, SLOT(MenuHelp()));
151 Menu->addAction("About", this, SLOT(MenuAbout()));
152 Menu->addSeparator();
153 QAction* QuitAction = Menu->addAction("Quit", qApp, SLOT(quit()));
154 QuitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
155
156 //-----------------------------------------------------------------------
157 //**************************** Socket window ****************************
158 //-----------------------------------------------------------------------
159
160 // Create widget (initially hidden)
161 SocketWindow = new QWidget();
162 SocketWindow->setWindowTitle("ddd - Socket Interface");
163
164 // Edit box for IP Address
165 IPAddress = new QLineEdit(SocketWindow);
166 IPAddress->setText("eth-vme02");
167 IPAddress->setToolTip("Address of socket server");
168 AddressLayout = new QFormLayout;
169 AddressLayout->addRow("&Remote Address", IPAddress);
170
171 // SpinBox for port selection
172 Port = new QSpinBox(SocketWindow);
173 Port->setRange(0,65535);
174 Port->setValue(2000);
175 Port->setToolTip("Port number of socket server");
176 PortLayout = new QFormLayout;
177 PortLayout->addRow("&Port", Port);
178
179 // Button to make connection
180 Connect = new QPushButton("Connect", SocketWindow);
181 Connect->setFont(QFont("Times", 10, QFont::Bold));
182 connect(Connect, SIGNAL(clicked()), this, SLOT(MakeConnection()));
183 Connect->setToolTip("Connect to server");
184
185 // Edit box for command
186 Command = new QLineEdit(SocketWindow);
187 CommandLayout = new QFormLayout;
188 CommandLayout->addRow("&Command", Command);
189 Command->setEnabled(false);
190 connect(Command, SIGNAL(returnPressed()), this, SLOT(SendToSocket()));
191 Command->setToolTip("Command to send to socket server");
192
193 // Text box for socket output
194 SocketOutput= new QPlainTextEdit(SocketWindow);
195 SocketOutput->setReadOnly(true);
196 SocketOutput->setMaximumBlockCount(MAX_OUTPUT_LINES);
197 SocketOutput->setToolTip("Output of socket server");
198
199 // Layout of all widgets
200 SocketLayout = new QGridLayout(SocketWindow);
201 SocketLayout->addLayout(AddressLayout, 0, 0, 0, 1);
202 SocketLayout->addLayout(PortLayout, 0, 2);
203 SocketLayout->addWidget(Connect, 0, 3);
204 SocketLayout->addLayout(CommandLayout, 1, 0, 1, 4);
205 SocketLayout->addWidget(SocketOutput, 2, 0, 4, 4);
206}
207
208ddd::~ddd() {
209 // Qwt items
210 delete Grid; delete Signal;
211 // Layout items
212 delete PortLayout; delete CommandLayout;
213 delete AddressLayout; delete FormLayout;
214 delete SpinLayout;
215 // Other items
216 delete SocketWindow;
217 delete PixMap; delete RD;
218}
219
220
221//---------------------------------------------------------------------
222//**************************** Main program ***************************
223//---------------------------------------------------------------------
224
225int main(int argc, char *argv[]) {
226 QApplication app(argc, argv);
227
228 ddd MainWindow;
229 MainWindow.setGeometry(100, 100, 800, 500);
230 MainWindow.setWindowTitle("ddd - DRS Data Display");
231 MainWindow.show();
232
233 return app.exec();
234}
Note: See TracBrowser for help on using the repository browser.