1 | #include <string>
|
---|
2 |
|
---|
3 | #include <QtGui>
|
---|
4 | #include <QtNetwork/QTcpSocket>
|
---|
5 | #include <QtNetwork/QAbstractSocket>
|
---|
6 |
|
---|
7 | #include <qwt_plot.h>
|
---|
8 | #include <qwt_plot_curve.h>
|
---|
9 | #include <qwt_plot_grid.h>
|
---|
10 | #include <qwt_plot_zoomer.h>
|
---|
11 | #include <qwt_plot_panner.h>
|
---|
12 | #include <qwt_plot_spectrogram.h>
|
---|
13 | #include <qwt_raster_data.h>
|
---|
14 | #include <qwt_scale_widget.h>
|
---|
15 | #include <qwt_plot_layout.h>
|
---|
16 | #include <qwt_color_map.h>
|
---|
17 |
|
---|
18 | #include "../../drsdaq/RawDataCTX.h"
|
---|
19 | #include "../../pixelmap/PixelMap.h"
|
---|
20 |
|
---|
21 | #define SOCKET_TIMEOUT 10000 // Milliseconds to wait for socket connection
|
---|
22 | #define MAX_OUTPUT_LINES 200 // Maximum number of lines in socket output window
|
---|
23 | #define MAX_COM_SIZE 10000
|
---|
24 | #define INITIAL_DIRECTORY ""
|
---|
25 |
|
---|
26 | // Main window class
|
---|
27 | class ddd : public QMainWindow {
|
---|
28 | Q_OBJECT
|
---|
29 |
|
---|
30 | QPushButton *GetButton, *SocketButton, *Connect, *M0Display;
|
---|
31 | QCheckBox *ContinuousBox;
|
---|
32 | QToolButton *LoadButton;
|
---|
33 | QLineEdit *FilenameBox, *IPAddress, *Command, *PixelID;
|
---|
34 | QSpinBox *EventNo, *ChannelNo, *BoardNo, *Port, *M0Start, *M0Stop;
|
---|
35 | QPlainTextEdit *RunHeaderDisplay, *EventHeaderDisplay, *SocketOutput;
|
---|
36 | QTabWidget *TabWidget;
|
---|
37 | QTcpSocket *Socket;
|
---|
38 | QWidget *SocketWindow, *Central, *M0Window;
|
---|
39 | QAction *OpenAction, *ConnectAction;
|
---|
40 | QGridLayout *SocketLayout, *MainLayout, *M0Layout;
|
---|
41 | QFormLayout *CommandLayout, *PortLayout, *AddressLayout, *FormLayout, *SpinLayout, *M0StartLayout, *M0StopLayout;
|
---|
42 |
|
---|
43 | QwtPlot *Graph, *Graph2D;
|
---|
44 | QwtPlotZoomer *Zoomer;
|
---|
45 | QwtPlotCurve *Signal;
|
---|
46 | QwtPlotPanner *Panner;
|
---|
47 | QwtPlotGrid *Grid;
|
---|
48 | QwtPlotSpectrogram *Signal2D;
|
---|
49 | QwtLinearColorMap colorMap;
|
---|
50 |
|
---|
51 | void closeEvent(QCloseEvent *);
|
---|
52 |
|
---|
53 | bool ManualDisconnect, WaitForData;
|
---|
54 | RawDataCTX *RD;
|
---|
55 | PixelMap *PixMap;
|
---|
56 | FILE *Tmpfile;
|
---|
57 |
|
---|
58 | public:
|
---|
59 | ddd();
|
---|
60 | ~ddd();
|
---|
61 | void CloseDatafile();
|
---|
62 |
|
---|
63 | private slots:
|
---|
64 | void OpenDatafile();
|
---|
65 | void DisplayEvent(int=0);
|
---|
66 | void FileDialog();
|
---|
67 | void OpenSocketWindow();
|
---|
68 | void OpenM0Window();
|
---|
69 | void GetSignalFromSocket();
|
---|
70 | void MakeConnection();
|
---|
71 | void SendToSocket();
|
---|
72 | void ReadFromSocket();
|
---|
73 | void GotDisconnected();
|
---|
74 | void HandleZoom(const QwtDoubleRect &);
|
---|
75 | void TranslatePixelID();
|
---|
76 |
|
---|
77 | void MenuSave();
|
---|
78 | void MenuPrint();
|
---|
79 | void MenuHelp();
|
---|
80 | void MenuAbout();
|
---|
81 | };
|
---|
82 |
|
---|
83 | //Data class for 2D spectrogram (MO display specific)
|
---|
84 | class SpectrogramDataM0: public QwtRasterData {
|
---|
85 |
|
---|
86 | private:
|
---|
87 |
|
---|
88 | double _z[6][6];
|
---|
89 | double _zmin;
|
---|
90 | double _zmax;
|
---|
91 |
|
---|
92 | public:
|
---|
93 |
|
---|
94 | SpectrogramDataM0(const double z[6][6]): QwtRasterData(QwtDoubleRect(0, 0, 6, 6)) {
|
---|
95 | for (int i = 0; i<6; i++){
|
---|
96 | for (int j = 0; j<6; j++){
|
---|
97 | _z[i][j] = z[i][j];
|
---|
98 | if (z[i][j] > _zmax) _zmax = z[i][j];
|
---|
99 | if (z[i][j] < _zmin) _zmin = z[i][j];
|
---|
100 | }
|
---|
101 | }
|
---|
102 | }
|
---|
103 |
|
---|
104 | virtual QwtRasterData *copy() const {
|
---|
105 | return new SpectrogramDataM0(_z);
|
---|
106 | }
|
---|
107 |
|
---|
108 | virtual QwtDoubleInterval range() const {
|
---|
109 | return QwtDoubleInterval(_zmin, _zmax);
|
---|
110 | }
|
---|
111 |
|
---|
112 | virtual void initRaster(const QwtDoubleRect = QwtDoubleRect(0, 0, 6, 6),
|
---|
113 | const QSize =QSize(1,1)) {};
|
---|
114 |
|
---|
115 | virtual double value(double x, double y) const {
|
---|
116 |
|
---|
117 | unsigned int first = (unsigned int)x;
|
---|
118 | unsigned int second = (unsigned int)y;
|
---|
119 |
|
---|
120 | const double v = _z[first][second];
|
---|
121 | return v;
|
---|
122 |
|
---|
123 | }
|
---|
124 |
|
---|
125 | };
|
---|