| 1 | /* ============================================================
|
|---|
| 2 |
|
|---|
| 3 | DRS Data Display
|
|---|
| 4 |
|
|---|
| 5 | Qt-based graphical user interface for displaying data taken with
|
|---|
| 6 | the drsdaq program.
|
|---|
| 7 | There are two operation modes: inspection of a raw data file and
|
|---|
| 8 | data taking via the socket interface. Connecting to a socket server
|
|---|
| 9 | automatically disables raw data file operation and closes any open
|
|---|
| 10 | file.
|
|---|
| 11 |
|
|---|
| 12 | Oliver Grimm
|
|---|
| 13 |
|
|---|
| 14 | ============================================================ */
|
|---|
| 15 |
|
|---|
| 16 | #include "GUI.h"
|
|---|
| 17 |
|
|---|
| 18 | ddd::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 | Signal->setStyle(QwtPlotCurve::Steps);
|
|---|
| 103 |
|
|---|
| 104 | // Text boxes for run and event header
|
|---|
| 105 | RunHeaderDisplay = new QPlainTextEdit(Central);
|
|---|
| 106 | EventHeaderDisplay = new QPlainTextEdit(Central);
|
|---|
| 107 | RunHeaderDisplay->setReadOnly(true);
|
|---|
| 108 | EventHeaderDisplay->setReadOnly(true);
|
|---|
| 109 |
|
|---|
| 110 | // Browse botton
|
|---|
| 111 | LoadButton = new QToolButton(Central);
|
|---|
| 112 | LoadButton->setToolButtonStyle (Qt::ToolButtonTextOnly);
|
|---|
| 113 | LoadButton->setText("...");
|
|---|
| 114 | connect(LoadButton, SIGNAL(clicked()), this, SLOT(FileDialog()));
|
|---|
| 115 | LoadButton->setToolTip("Open file dialog to select raw data file");
|
|---|
| 116 |
|
|---|
| 117 | // Filename box
|
|---|
| 118 | FilenameBox = new QLineEdit(Central);
|
|---|
| 119 | connect(FilenameBox, SIGNAL(returnPressed()), this, SLOT(OpenDatafile()));
|
|---|
| 120 | FilenameBox->setToolTip("Raw data file name");
|
|---|
| 121 |
|
|---|
| 122 | // Tab widget
|
|---|
| 123 | TabWidget = new QTabWidget(Central);
|
|---|
| 124 | TabWidget->addTab(Graph, "&Signal");
|
|---|
| 125 | TabWidget->addTab(RunHeaderDisplay, "&Run Header");
|
|---|
| 126 | TabWidget->addTab(EventHeaderDisplay, "&Event Header");
|
|---|
| 127 |
|
|---|
| 128 | // Layout of all widgets
|
|---|
| 129 | MainLayout = new QGridLayout(Central);
|
|---|
| 130 | MainLayout->addWidget(FilenameBox, 0, 0, 1, 3);
|
|---|
| 131 | MainLayout->addWidget(LoadButton, 0, 3);
|
|---|
| 132 | MainLayout->addLayout(SpinLayout, 1, 0);
|
|---|
| 133 | MainLayout->addLayout(FormLayout, 2, 0);
|
|---|
| 134 | MainLayout->addWidget(SocketButton, 6,0);
|
|---|
| 135 | MainLayout->addWidget(GetButton, 4,0);
|
|---|
| 136 | MainLayout->addWidget(ContinuousBox, 5,0);
|
|---|
| 137 | MainLayout->addWidget(TabWidget, 1, 1, 6, 5);
|
|---|
| 138 | MainLayout->setColumnStretch(1, 10);
|
|---|
| 139 |
|
|---|
| 140 | // Menu bar
|
|---|
| 141 | QMenu* Menu = menuBar()->addMenu("&Menu");
|
|---|
| 142 | OpenAction = Menu->addAction("Open data file", this, SLOT(FileDialog()));
|
|---|
| 143 | OpenAction->setShortcut(Qt::CTRL + Qt::Key_O);
|
|---|
| 144 | QAction* SaveAction = Menu->addAction("Save plot", this, SLOT(MenuSave()));
|
|---|
| 145 | SaveAction->setShortcut(Qt::CTRL + Qt::Key_S);
|
|---|
| 146 | Menu->addAction("Print plot", this, SLOT(MenuPrint()));
|
|---|
| 147 | Menu->addSeparator();
|
|---|
| 148 | ConnectAction = Menu->addAction("Connect", this, SLOT(MakeConnection()));
|
|---|
| 149 | ConnectAction->setShortcut(Qt::CTRL + Qt::Key_C);
|
|---|
| 150 | Menu->addSeparator();
|
|---|
| 151 | Menu->addAction("Help", this, SLOT(MenuHelp()));
|
|---|
| 152 | Menu->addAction("About", this, SLOT(MenuAbout()));
|
|---|
| 153 | Menu->addSeparator();
|
|---|
| 154 | QAction* QuitAction = Menu->addAction("Quit", qApp, SLOT(quit()));
|
|---|
| 155 | QuitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
|
|---|
| 156 |
|
|---|
| 157 | //-----------------------------------------------------------------------
|
|---|
| 158 | //**************************** Socket window ****************************
|
|---|
| 159 | //-----------------------------------------------------------------------
|
|---|
| 160 |
|
|---|
| 161 | // Create widget (initially hidden)
|
|---|
| 162 | SocketWindow = new QWidget();
|
|---|
| 163 | SocketWindow->setWindowTitle("ddd - Socket Interface");
|
|---|
| 164 |
|
|---|
| 165 | // Edit box for IP Address
|
|---|
| 166 | IPAddress = new QLineEdit(SocketWindow);
|
|---|
| 167 | IPAddress->setText("eth-vme02");
|
|---|
| 168 | IPAddress->setToolTip("Address of socket server");
|
|---|
| 169 | AddressLayout = new QFormLayout;
|
|---|
| 170 | AddressLayout->addRow("&Remote Address", IPAddress);
|
|---|
| 171 |
|
|---|
| 172 | // SpinBox for port selection
|
|---|
| 173 | Port = new QSpinBox(SocketWindow);
|
|---|
| 174 | Port->setRange(0,65535);
|
|---|
| 175 | Port->setValue(2000);
|
|---|
| 176 | Port->setToolTip("Port number of socket server");
|
|---|
| 177 | PortLayout = new QFormLayout;
|
|---|
| 178 | PortLayout->addRow("&Port", Port);
|
|---|
| 179 |
|
|---|
| 180 | // Button to make connection
|
|---|
| 181 | Connect = new QPushButton("Connect", SocketWindow);
|
|---|
| 182 | Connect->setFont(QFont("Times", 10, QFont::Bold));
|
|---|
| 183 | connect(Connect, SIGNAL(clicked()), this, SLOT(MakeConnection()));
|
|---|
| 184 | Connect->setToolTip("Connect to server");
|
|---|
| 185 |
|
|---|
| 186 | // Edit box for command
|
|---|
| 187 | Command = new QLineEdit(SocketWindow);
|
|---|
| 188 | CommandLayout = new QFormLayout;
|
|---|
| 189 | CommandLayout->addRow("&Command", Command);
|
|---|
| 190 | Command->setEnabled(false);
|
|---|
| 191 | connect(Command, SIGNAL(returnPressed()), this, SLOT(SendToSocket()));
|
|---|
| 192 | Command->setToolTip("Command to send to socket server");
|
|---|
| 193 |
|
|---|
| 194 | // Text box for socket output
|
|---|
| 195 | SocketOutput= new QPlainTextEdit(SocketWindow);
|
|---|
| 196 | SocketOutput->setReadOnly(true);
|
|---|
| 197 | SocketOutput->setMaximumBlockCount(MAX_OUTPUT_LINES);
|
|---|
| 198 | SocketOutput->setToolTip("Output of socket server");
|
|---|
| 199 |
|
|---|
| 200 | // Layout of all widgets
|
|---|
| 201 | SocketLayout = new QGridLayout(SocketWindow);
|
|---|
| 202 | SocketLayout->addLayout(AddressLayout, 0, 0, 0, 1);
|
|---|
| 203 | SocketLayout->addLayout(PortLayout, 0, 2);
|
|---|
| 204 | SocketLayout->addWidget(Connect, 0, 3);
|
|---|
| 205 | SocketLayout->addLayout(CommandLayout, 1, 0, 1, 4);
|
|---|
| 206 | SocketLayout->addWidget(SocketOutput, 2, 0, 4, 4);
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | ddd::~ddd() {
|
|---|
| 210 | // Qwt items
|
|---|
| 211 | delete Grid; delete Signal;
|
|---|
| 212 | // Layout items
|
|---|
| 213 | delete PortLayout; delete CommandLayout;
|
|---|
| 214 | delete AddressLayout; delete FormLayout;
|
|---|
| 215 | delete SpinLayout;
|
|---|
| 216 | // Other items
|
|---|
| 217 | delete SocketWindow;
|
|---|
| 218 | delete PixMap; delete RD;
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 | //---------------------------------------------------------------------
|
|---|
| 223 | //**************************** Main program ***************************
|
|---|
| 224 | //---------------------------------------------------------------------
|
|---|
| 225 |
|
|---|
| 226 | int main(int argc, char *argv[]) {
|
|---|
| 227 | QApplication app(argc, argv);
|
|---|
| 228 |
|
|---|
| 229 | ddd MainWindow;
|
|---|
| 230 | MainWindow.setGeometry(100, 100, 800, 500);
|
|---|
| 231 | MainWindow.setWindowTitle("ddd - DRS Data Display");
|
|---|
| 232 | MainWindow.show();
|
|---|
| 233 |
|
|---|
| 234 | return app.exec();
|
|---|
| 235 | }
|
|---|