1 | /*
|
---|
2 | * QtGl.h
|
---|
3 | *
|
---|
4 | * Created on: Jul 20, 2011
|
---|
5 | * Author: lyard
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef QTGL_H_
|
---|
9 | #define QTGL_H_
|
---|
10 |
|
---|
11 | #define NBOARDS 40 // max. number of boards
|
---|
12 | #define NPIX 1440 // max. number of pixels
|
---|
13 | #define NTMARK 160 // max. number of timeMarker signals
|
---|
14 |
|
---|
15 | //#define LOAD_RAW
|
---|
16 |
|
---|
17 | #include <QObject>
|
---|
18 | #include <QTimer>
|
---|
19 | #include <QLabel>
|
---|
20 | #include <QListWidget>
|
---|
21 | #include <QMainWindow>
|
---|
22 | #include <QPushButton>
|
---|
23 |
|
---|
24 | //#include <QtOpenGL/QGLWidget>
|
---|
25 | #include "../BasicGlCamera.h"
|
---|
26 |
|
---|
27 | #include <QMouseEvent>
|
---|
28 | #include <QColorDialog>
|
---|
29 | #include <QApplication>
|
---|
30 | #include <QSpinBox>
|
---|
31 | #include <QDoubleSpinBox>
|
---|
32 | #include <QRadioButton>
|
---|
33 | #include <QCheckBox>
|
---|
34 | #include <iostream>
|
---|
35 | #include <GL/gl.h>
|
---|
36 |
|
---|
37 | #include <qwt_plot.h>
|
---|
38 | //#include "qwt_plot_histogram.h"
|
---|
39 | #include <qwt_plot_curve.h>
|
---|
40 | #include <qwt_plot_grid.h>
|
---|
41 | #include <qwt_plot_zoomer.h>
|
---|
42 |
|
---|
43 | #include <valarray>
|
---|
44 |
|
---|
45 | #include <string>
|
---|
46 |
|
---|
47 | #include "../../src/DataCalib.h"
|
---|
48 |
|
---|
49 |
|
---|
50 | namespace std
|
---|
51 | {
|
---|
52 | class fits;
|
---|
53 | }
|
---|
54 |
|
---|
55 | /*************************************************
|
---|
56 | * Class Raw Data Viewer. FACT raw data diplayer
|
---|
57 | *************************************************/
|
---|
58 | class RawDataViewer : public BasicGlCamera//QGLWidget
|
---|
59 | {
|
---|
60 | Q_OBJECT
|
---|
61 |
|
---|
62 | friend class UIConnector;
|
---|
63 | public:
|
---|
64 | RawDataViewer(QWidget *parent = 0);
|
---|
65 | ~RawDataViewer();
|
---|
66 | void openFile(std::string& file);
|
---|
67 | void openCalibFile(std::string& file);
|
---|
68 |
|
---|
69 |
|
---|
70 |
|
---|
71 | public Q_SLOTS:
|
---|
72 | void plusEvent();
|
---|
73 | void minusEvent();
|
---|
74 | void setEventStep(int step);
|
---|
75 | void nextSlice();
|
---|
76 | void previousSlice();
|
---|
77 | void setCurrentPixel(int);
|
---|
78 |
|
---|
79 | Q_SIGNALS:
|
---|
80 | void signalCurrentEvent(int event);
|
---|
81 | void signalCurrentSlice(int slice);
|
---|
82 | void newFileLoaded();
|
---|
83 | void signalCurrentPixel(int pixel);
|
---|
84 | void signalAutoScaleNeeded();
|
---|
85 |
|
---|
86 | protected:
|
---|
87 | // void initializeGL();
|
---|
88 | // void resizeGL(int width, int height);
|
---|
89 | void paintGL();
|
---|
90 | void mousePressEvent(QMouseEvent *event);
|
---|
91 | void mouseMoveEvent(QMouseEvent *event);
|
---|
92 | void mouseDoubleClickEvent(QMouseEvent *event);
|
---|
93 | void drawCamera(bool alsoWire);
|
---|
94 | // void drawPatches();
|
---|
95 | // int PixelAtPosition(const QPoint &pos);
|
---|
96 | // void drawHexagon(int index, bool solid);
|
---|
97 | int selectedPixel;
|
---|
98 | float *eventData;
|
---|
99 | float *rmsData;
|
---|
100 | int16_t* rawEventData;
|
---|
101 | int16_t* waveLetArray;
|
---|
102 | valarray<double> RMSvalues;//(1440);
|
---|
103 |
|
---|
104 | private:
|
---|
105 | void drawPixelCurve();
|
---|
106 | // void updateNeighbors(int currentPixel);
|
---|
107 | // void skipPixels(int start, int howMany);
|
---|
108 | // void calculatePixelsCoords();
|
---|
109 | void setCorrectSlice(QMouseEvent* event);
|
---|
110 | void eventStepping(bool plus);
|
---|
111 | // void buildVerticesList();
|
---|
112 | // void buildPatchesIndices();
|
---|
113 | void calcBlurColor(int pixel, int vertex);
|
---|
114 | void drawBlurryHexagon(int index);
|
---|
115 | int whichSlice;
|
---|
116 | // float shownSizex;
|
---|
117 | // float shownSizey;
|
---|
118 | bool drawPatch;
|
---|
119 | bool drawImpulse;
|
---|
120 | bool drawBlur;
|
---|
121 | bool loopCurrentEvent;
|
---|
122 | //allocate the maximum size for one event
|
---|
123 | uint32_t boardTime[NBOARDS];
|
---|
124 | int16_t startPix[NPIX];
|
---|
125 | int16_t startTM[NTMARK];
|
---|
126 | int32_t pcTime[2];
|
---|
127 | uint32_t softTrig;
|
---|
128 | uint16_t triggerType;
|
---|
129 | int nRows;
|
---|
130 | int rowNum;
|
---|
131 | int eventNum;
|
---|
132 | int nRoi;
|
---|
133 | int nRoiTM;
|
---|
134 | int runNumber;
|
---|
135 | int nTM;
|
---|
136 | int runType;
|
---|
137 | int firstDataTime;
|
---|
138 | int lastDataTime;
|
---|
139 | int revision;
|
---|
140 | int builderVersion;
|
---|
141 | int nBoards;
|
---|
142 | int nPixels;
|
---|
143 | std::string timeSystem;
|
---|
144 | std::string creationDate;
|
---|
145 | int nightInt;
|
---|
146 | std::string camera;
|
---|
147 | std::string daq;
|
---|
148 | float adcCount;
|
---|
149 | int nbOk;
|
---|
150 | int nbRej;
|
---|
151 | int nbBad;
|
---|
152 |
|
---|
153 | int eventStep;
|
---|
154 |
|
---|
155 | // int hardwareMapping[1440];
|
---|
156 | // int softwareMapping[1440];
|
---|
157 | //// int patches[160][9];
|
---|
158 | GLfloat patchesColor[160][3];
|
---|
159 | // vector<edge> patchesIndices[160];
|
---|
160 | std::fits* inputFile;
|
---|
161 | // std::fits* calibInputFile;
|
---|
162 | // float baseLineMean[1440*1024];
|
---|
163 | // float gainMean[1440*1024];
|
---|
164 | // float triggerOffsetMean[1440*1024];
|
---|
165 | // bool calibrationLoaded;
|
---|
166 | bool drawCalibrationLoaded;
|
---|
167 |
|
---|
168 | QPoint lastPos;
|
---|
169 |
|
---|
170 | void doMyWaveletTestPlease();
|
---|
171 | void doWaveLetOnCurrentEventPlease();
|
---|
172 | bool doWaveLetsPlease(int givenSpan, int16_t* orig, int16_t* wavelets, bool verifyResult);
|
---|
173 | public:
|
---|
174 | void computePulsesStatistics();
|
---|
175 | double aMeas[1024];
|
---|
176 | double n1mean[1024];
|
---|
177 | double n2mean[1024];
|
---|
178 | double vCorr[1024];
|
---|
179 |
|
---|
180 | // GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
|
---|
181 | // PixelsNeighbors neighbors[MAX_NUM_PIXELS];
|
---|
182 | // GLfloat pixelsColor[ACTUAL_NUM_PIXELS][3];
|
---|
183 | // GLfloat verticesList[ACTUAL_NUM_PIXELS*6][2];
|
---|
184 | // int verticesIndices[ACTUAL_NUM_PIXELS][6];
|
---|
185 | // int numVertices;
|
---|
186 | };
|
---|
187 |
|
---|
188 | /*************************************************
|
---|
189 | * Class UIConnector. used to connect the interface to the raw data displayer
|
---|
190 | *************************************************/
|
---|
191 | #include "viewer.h"
|
---|
192 |
|
---|
193 | class Configuration;
|
---|
194 |
|
---|
195 | class UIConnector : public QMainWindow, protected Ui::MainWindow
|
---|
196 | {
|
---|
197 | Q_OBJECT
|
---|
198 | private:
|
---|
199 | QTimer timer;
|
---|
200 | std::string currentFile;
|
---|
201 | std::string currentCalibFile;
|
---|
202 |
|
---|
203 | QRectF scaleBoundingRectangle(QRectF rectangle, float scale);
|
---|
204 |
|
---|
205 | bool updateSpinnerDisplay;
|
---|
206 | bool updating;
|
---|
207 |
|
---|
208 | void initHistograms();
|
---|
209 |
|
---|
210 | public:
|
---|
211 | UIConnector(QWidget *parent = 0);
|
---|
212 | ~UIConnector();
|
---|
213 |
|
---|
214 | public Q_SLOTS:
|
---|
215 | void fileSelected(QString file);
|
---|
216 | void calibFileSelected(QString file);
|
---|
217 |
|
---|
218 | void newFileLoaded();
|
---|
219 | void slicesPerSecondChanged(double value);
|
---|
220 | void nextSlicePlease();
|
---|
221 | void currentSliceHasChanged(int slice);
|
---|
222 | void currentEventHasChanged(int event);
|
---|
223 |
|
---|
224 | void on_playPauseButton_clicked();
|
---|
225 | void on_loadNewFileButton_clicked();
|
---|
226 | void on_loadDRSCalibButton_clicked();
|
---|
227 |
|
---|
228 | void on_drawPatchCheckBox_stateChanged(int);
|
---|
229 | void on_drawImpulseCheckBox_stateChanged(int);
|
---|
230 | void on_drawBlurCheckBox_stateChanged(int);
|
---|
231 | void on_loopOverCurrentEventBox_stateChanged(int);
|
---|
232 |
|
---|
233 | void on_colorRange0_valueChanged(double);
|
---|
234 | void on_colorRange1_valueChanged(double);
|
---|
235 | void on_colorRange2_valueChanged(double);
|
---|
236 | void on_colorRange3_valueChanged(double);
|
---|
237 | void on_colorRange4_valueChanged(double);
|
---|
238 | void on_redValue0_valueChanged(double);
|
---|
239 | void on_redValue1_valueChanged(double);
|
---|
240 | void on_redValue2_valueChanged(double);
|
---|
241 | void on_redValue3_valueChanged(double);
|
---|
242 | void on_redValue4_valueChanged(double);
|
---|
243 | void on_greenValue0_valueChanged(double);
|
---|
244 | void on_greenValue1_valueChanged(double);
|
---|
245 | void on_greenValue2_valueChanged(double);
|
---|
246 | void on_greenValue3_valueChanged(double);
|
---|
247 | void on_greenValue4_valueChanged(double);
|
---|
248 | void on_blueValue0_valueChanged(double);
|
---|
249 | void on_blueValue1_valueChanged(double);
|
---|
250 | void on_blueValue2_valueChanged(double);
|
---|
251 | void on_blueValue3_valueChanged(double);
|
---|
252 | void on_blueValue4_valueChanged(double);
|
---|
253 |
|
---|
254 | void pixelChanged(int);
|
---|
255 |
|
---|
256 | void cbpxChanged();
|
---|
257 |
|
---|
258 | void on_HwIDBox_valueChanged(int = 0);
|
---|
259 | void on_SwIDBox_valueChanged(int);
|
---|
260 | void on_crateIDBox_valueChanged(int) { cbpxChanged(); }
|
---|
261 | void on_boardIDBox_valueChanged(int) { cbpxChanged(); }
|
---|
262 | void on_patchIDBox_valueChanged(int) { cbpxChanged(); }
|
---|
263 | void on_pixelIDBox_valueChanged(int) { cbpxChanged(); }
|
---|
264 |
|
---|
265 | void on_autoScaleColor_clicked();
|
---|
266 | void on_entireCameraScale_toggled(bool) { on_autoScaleColor_clicked(); }
|
---|
267 | void on_currentPixelScale_toggled(bool) { on_autoScaleColor_clicked(); }
|
---|
268 |
|
---|
269 | void slicesPlusPlus();
|
---|
270 | void slicesMinusMinus();
|
---|
271 |
|
---|
272 | void on_calibratedCheckBox_stateChanged(int state);
|
---|
273 | void on_displayingSliceBox_valueChanged(int);
|
---|
274 | void on_displayingEventBox_valueChanged(int);
|
---|
275 |
|
---|
276 | void displaySliceValue();
|
---|
277 |
|
---|
278 | int SetupConfiguration(Configuration &conf);
|
---|
279 |
|
---|
280 | private:
|
---|
281 | QwtPlotCurve boardsTimeHistoItem;
|
---|
282 | QwtPlotCurve startCellHistoItem;
|
---|
283 | QwtPlotCurve startTimeMarkHistoItem;
|
---|
284 | QwtPlotCurve pixelValueCurveItem;
|
---|
285 | QwtPlotCurve aMeanCurveItem;
|
---|
286 | QwtPlotCurve vCorrCurveItem;
|
---|
287 | QwtPlotCurve meanCurveItem;
|
---|
288 | QwtPlotCurve triggerDelayHistoItem;
|
---|
289 |
|
---|
290 | QwtPlotZoomer* curveZoom;
|
---|
291 | QwtPlotZoomer* boardsTimeHistoZoom;
|
---|
292 | QwtPlotZoomer* startCellHistoZoom;
|
---|
293 | QwtPlotZoomer* startTimeMarkHistoZoom;
|
---|
294 | QwtPlotZoomer* triggerDelayHistoZoom;
|
---|
295 |
|
---|
296 | //declare the grids here, because I must have access to them to detach them properly at destruction time (bug and crash with "bad" versions of qwt)
|
---|
297 | QwtPlotGrid* grid1;
|
---|
298 | QwtPlotGrid* grid2;
|
---|
299 | QwtPlotGrid* grid3;
|
---|
300 | QwtPlotGrid* grid4;
|
---|
301 | QwtPlotGrid* grid5;
|
---|
302 | };
|
---|
303 |
|
---|
304 | #endif /* QTGL_H_ */
|
---|