source: tools/ddd/GUI.cpp@ 75

Last change on this file since 75 was 66, checked in by qweitzel, 15 years ago
MO event display improved: start- and stopbin spinbox added
File size: 10.9 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 // M0 display button
78 M0Display = new QPushButton("M0 Display",Central);
79 M0Display->setFont(QFont("Times", 10, QFont::Bold));
80 connect(M0Display, SIGNAL(clicked()), this, SLOT(OpenM0Window()));
81 M0Display->setToolTip("Open window for M0 display");
82
83 // Acquire button and Continuous check box
84 GetButton = new QPushButton("&Acquire", Central);
85 GetButton->setFont(QFont("Times", 10, QFont::Bold));
86 GetButton->setEnabled(false);
87 connect(GetButton, SIGNAL(clicked()), this, SLOT(GetSignalFromSocket()));
88 GetButton->setToolTip("Acquire event over socket interface");
89 ContinuousBox = new QCheckBox("Continuous", Central);
90 ContinuousBox->setFont(QFont("Times", 10, QFont::Bold));
91 ContinuousBox->setToolTip("Acquire continuously");
92
93 // Plot area
94 Graph = new QwtPlot(Central);
95 Graph->setAxisTitle(QwtPlot::xBottom, "Time (ns)");
96 Graph->setAxisTitle(QwtPlot::yLeft, "Signal (mV)");
97 Graph->setAutoReplot(true);
98 Graph->setCanvasBackground(QColor(Qt::yellow));
99 Graph->setToolTip("Left mouse button to zoom (+Shift to pan)");
100 Zoomer = new QwtPlotZoomer(QwtPlot::xBottom,QwtPlot::yLeft,Graph->canvas());
101 Panner = new QwtPlotPanner(Graph->canvas());
102 Panner->setMouseButton(Qt::LeftButton, Qt::ShiftModifier);
103 Grid = new QwtPlotGrid;
104 Grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
105 Grid->attach(Graph);
106 Signal = new QwtPlotCurve;
107 Signal->attach(Graph);
108 Signal->setStyle(QwtPlotCurve::Steps);
109
110 // Text boxes for run and event header
111 RunHeaderDisplay = new QPlainTextEdit(Central);
112 EventHeaderDisplay = new QPlainTextEdit(Central);
113 RunHeaderDisplay->setReadOnly(true);
114 EventHeaderDisplay->setReadOnly(true);
115
116 // Browse botton
117 LoadButton = new QToolButton(Central);
118 LoadButton->setToolButtonStyle (Qt::ToolButtonTextOnly);
119 LoadButton->setText("...");
120 connect(LoadButton, SIGNAL(clicked()), this, SLOT(FileDialog()));
121 LoadButton->setToolTip("Open file dialog to select raw data file");
122
123 // Filename box
124 FilenameBox = new QLineEdit(Central);
125 connect(FilenameBox, SIGNAL(returnPressed()), this, SLOT(OpenDatafile()));
126 FilenameBox->setToolTip("Raw data file name");
127
128 // Tab widget
129 TabWidget = new QTabWidget(Central);
130 TabWidget->addTab(Graph, "&Signal");
131 TabWidget->addTab(RunHeaderDisplay, "&Run Header");
132 TabWidget->addTab(EventHeaderDisplay, "&Event Header");
133
134 // Layout of all widgets
135 MainLayout = new QGridLayout(Central);
136 MainLayout->addWidget(FilenameBox, 0, 0, 1, 3);
137 MainLayout->addWidget(LoadButton, 0, 3);
138 MainLayout->addLayout(SpinLayout, 1, 0);
139 MainLayout->addLayout(FormLayout, 2, 0);
140 MainLayout->addWidget(SocketButton, 6,0);
141 MainLayout->addWidget(M0Display, 3,0);
142 MainLayout->addWidget(GetButton, 4,0);
143 MainLayout->addWidget(ContinuousBox, 5,0);
144 MainLayout->addWidget(TabWidget, 1, 1, 6, 5);
145 MainLayout->setColumnStretch(1, 10);
146
147 // Menu bar
148 QMenu* Menu = menuBar()->addMenu("&Menu");
149 OpenAction = Menu->addAction("Open data file", this, SLOT(FileDialog()));
150 OpenAction->setShortcut(Qt::CTRL + Qt::Key_O);
151 QAction* SaveAction = Menu->addAction("Save plot", this, SLOT(MenuSave()));
152 SaveAction->setShortcut(Qt::CTRL + Qt::Key_S);
153 Menu->addAction("Print plot", this, SLOT(MenuPrint()));
154 Menu->addSeparator();
155 ConnectAction = Menu->addAction("Connect", this, SLOT(MakeConnection()));
156 ConnectAction->setShortcut(Qt::CTRL + Qt::Key_C);
157 Menu->addSeparator();
158 Menu->addAction("Help", this, SLOT(MenuHelp()));
159 Menu->addAction("About", this, SLOT(MenuAbout()));
160 Menu->addSeparator();
161 QAction* QuitAction = Menu->addAction("Quit", qApp, SLOT(quit()));
162 QuitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
163
164 //-----------------------------------------------------------------------
165 //**************************** Socket window ****************************
166 //-----------------------------------------------------------------------
167
168 // Create widget (initially hidden)
169 SocketWindow = new QWidget();
170 SocketWindow->setWindowTitle("ddd - Socket Interface");
171
172 // Edit box for IP Address
173 IPAddress = new QLineEdit(SocketWindow);
174 IPAddress->setText("eth-vme02");
175 IPAddress->setToolTip("Address of socket server");
176 AddressLayout = new QFormLayout;
177 AddressLayout->addRow("&Remote Address", IPAddress);
178
179 // SpinBox for port selection
180 Port = new QSpinBox(SocketWindow);
181 Port->setRange(0,65535);
182 Port->setValue(2000);
183 Port->setToolTip("Port number of socket server");
184 PortLayout = new QFormLayout;
185 PortLayout->addRow("&Port", Port);
186
187 // Button to make connection
188 Connect = new QPushButton("Connect", SocketWindow);
189 Connect->setFont(QFont("Times", 10, QFont::Bold));
190 connect(Connect, SIGNAL(clicked()), this, SLOT(MakeConnection()));
191 Connect->setToolTip("Connect to server");
192
193 // Edit box for command
194 Command = new QLineEdit(SocketWindow);
195 CommandLayout = new QFormLayout;
196 CommandLayout->addRow("&Command", Command);
197 Command->setEnabled(false);
198 connect(Command, SIGNAL(returnPressed()), this, SLOT(SendToSocket()));
199 Command->setToolTip("Command to send to socket server");
200
201 // Text box for socket output
202 SocketOutput= new QPlainTextEdit(SocketWindow);
203 SocketOutput->setReadOnly(true);
204 SocketOutput->setMaximumBlockCount(MAX_OUTPUT_LINES);
205 SocketOutput->setToolTip("Output of socket server");
206
207 // Layout of all widgets
208 SocketLayout = new QGridLayout(SocketWindow);
209 SocketLayout->addLayout(AddressLayout, 0, 0, 0, 1);
210 SocketLayout->addLayout(PortLayout, 0, 2);
211 SocketLayout->addWidget(Connect, 0, 3);
212 SocketLayout->addLayout(CommandLayout, 1, 0, 1, 4);
213 SocketLayout->addWidget(SocketOutput, 2, 0, 4, 4);
214
215 //-----------------------------------------------------------------------
216 //**************************** M0 window ****************************
217 //-----------------------------------------------------------------------
218
219 M0Window = new QWidget();
220 M0Window->setWindowTitle("ddd - M0 Display");
221
222 Graph2D = new QwtPlot(M0Window);
223 Graph2D->setAutoReplot(true);
224 Graph2D->setCanvasBackground(QColor(Qt::white));
225
226 M0Start = new QSpinBox(M0Window);
227 M0Start->setEnabled(false);
228 connect(M0Start, SIGNAL(valueChanged(int)), this, SLOT(DisplayEvent(int)));
229 M0Start->setToolTip("First bin/sample of time window");
230 M0StartLayout = new QFormLayout;
231 M0StartLayout->addRow("First Bin", M0Start);
232
233 M0Stop = new QSpinBox(M0Window);
234 M0Stop->setEnabled(false);
235 connect(M0Stop, SIGNAL(valueChanged(int)), this, SLOT(DisplayEvent(int)));
236 M0Stop->setToolTip("Last bin/sample of time window");
237 M0StopLayout = new QFormLayout;
238 M0StopLayout->addRow("Last Bin", M0Stop);
239
240 M0Layout = new QGridLayout(M0Window);
241 M0Layout->addWidget(Graph2D, 1,1,3,3);
242 M0Layout->addLayout(M0StartLayout,4,1);
243 M0Layout->addLayout(M0StopLayout,4,2);
244
245 Signal2D = new QwtPlotSpectrogram;
246 Signal2D->attach(Graph2D);
247
248 //initialize raster data of M0 display
249 double z[6][6];
250 for (int i=0; i<6; i++){
251 for (int j=0; j<6; j++){
252 z[i][j]=i+j;
253 }
254 }
255 Signal2D->setData(SpectrogramDataM0(z));
256
257 //color (z-) axis of M0 display
258 colorMap = QwtLinearColorMap(Qt::yellow, Qt::red);
259 Signal2D->setColorMap(colorMap);
260
261 Graph2D->axisWidget(QwtPlot::yRight)->setTitle("Maximum Sample Amplitude (mV)");
262 Graph2D->axisWidget(QwtPlot::yRight)->setColorBarEnabled(true);
263 Graph2D->axisWidget(QwtPlot::yRight)->setColorMap(Signal2D->data().range(),Signal2D->colorMap());
264
265 Graph2D->setAxisScale(QwtPlot::yRight,Signal2D->data().range().minValue(),Signal2D->data().range().maxValue());
266 Graph2D->enableAxis(QwtPlot::yRight);
267 Graph2D->plotLayout()->setAlignCanvasToScales(true);
268 Graph2D->replot();
269
270}
271
272ddd::~ddd() {
273 // Qwt items
274 delete Grid; delete Signal;
275 delete Signal2D;
276 // Layout items
277 delete PortLayout; delete CommandLayout;
278 delete M0StartLayout; delete M0StopLayout;
279 delete AddressLayout; delete FormLayout;
280 delete SpinLayout;
281 // Other items
282 delete SocketWindow;
283 delete M0Window;
284 delete PixMap; delete RD;
285}
286
287
288//---------------------------------------------------------------------
289//**************************** Main program ***************************
290//---------------------------------------------------------------------
291
292int main(int argc, char *argv[]) {
293 QApplication app(argc, argv);
294
295 ddd MainWindow;
296 MainWindow.setGeometry(100, 100, 800, 500);
297 MainWindow.setWindowTitle("ddd - DRS Data Display");
298 MainWindow.show();
299
300 return app.exec();
301}
Note: See TracBrowser for help on using the repository browser.