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 <QtCore/QObject>
|
---|
18 | #include <QtCore/QTimer>
|
---|
19 | #include <QtGui/QLabel>
|
---|
20 | #include <QtGui/QListWidget>
|
---|
21 | #include <QtGui/QMainWindow>
|
---|
22 | #include <QtGui/QPushButton>
|
---|
23 |
|
---|
24 | //#include <QtOpenGL/QGLWidget>
|
---|
25 | #include "../BasicGlCamera.h"
|
---|
26 |
|
---|
27 | #include <QtGui/QMouseEvent>
|
---|
28 | #include <QtGui/QColorDialog>
|
---|
29 | #include <QtGui/QApplication>
|
---|
30 | #include <QtGui/QSpinBox>
|
---|
31 | #include <QtGui/QDoubleSpinBox>
|
---|
32 | #include <QtGui/QRadioButton>
|
---|
33 | #include <QtGui/QCheckBox>
|
---|
34 | #include <iostream>
|
---|
35 | #include <GL/gl.h>
|
---|
36 |
|
---|
37 | #include <qwt-qt4/qwt_plot.h>
|
---|
38 | //#include "qwt_plot_histogram.h"
|
---|
39 | #include <qwt-qt4/qwt_plot_curve.h>
|
---|
40 |
|
---|
41 | #include <qwt-qt4/qwt_plot_zoomer.h>
|
---|
42 |
|
---|
43 | #include <valarray>
|
---|
44 |
|
---|
45 | #include <string>
|
---|
46 |
|
---|
47 | #include "externals/fits.h"
|
---|
48 |
|
---|
49 | /*************************************************
|
---|
50 | * Class Raw Data Viewer. FACT raw data diplayer
|
---|
51 | *************************************************/
|
---|
52 | class RawDataViewer : public BasicGlCamera//QGLWidget
|
---|
53 | {
|
---|
54 | Q_OBJECT
|
---|
55 |
|
---|
56 | friend class UIConnector;
|
---|
57 | public:
|
---|
58 | RawDataViewer(QWidget *parent = 0);
|
---|
59 | ~RawDataViewer();
|
---|
60 | void openFile(string& file);
|
---|
61 | void openCalibFile(string& file);
|
---|
62 |
|
---|
63 |
|
---|
64 |
|
---|
65 | public Q_SLOTS:
|
---|
66 | void plusEvent();
|
---|
67 | void minusEvent();
|
---|
68 | void setEventStep(int step);
|
---|
69 | void nextSlice();
|
---|
70 | void previousSlice();
|
---|
71 |
|
---|
72 | Q_SIGNALS:
|
---|
73 | void signalCurrentEvent(int event);
|
---|
74 | void signalCurrentSlice(int slice);
|
---|
75 | void newFileLoaded();
|
---|
76 | void signalCurrentPixel(int pixel);
|
---|
77 | void signalAutoScaleNeeded();
|
---|
78 |
|
---|
79 | protected:
|
---|
80 | // void initializeGL();
|
---|
81 | // void resizeGL(int width, int height);
|
---|
82 | void paintGL();
|
---|
83 | void mousePressEvent(QMouseEvent *event);
|
---|
84 | void mouseMoveEvent(QMouseEvent *event);
|
---|
85 | void mouseDoubleClickEvent(QMouseEvent *event);
|
---|
86 | void drawCamera(bool alsoWire);
|
---|
87 | // void drawPatches();
|
---|
88 | // int PixelAtPosition(const QPoint &pos);
|
---|
89 | // void drawHexagon(int index, bool solid);
|
---|
90 | int selectedPixel;
|
---|
91 | float *eventData;
|
---|
92 | int16_t* rawEventData;
|
---|
93 | int16_t* waveLetArray;
|
---|
94 |
|
---|
95 | private:
|
---|
96 | void drawPixelCurve();
|
---|
97 | // void updateNeighbors(int currentPixel);
|
---|
98 | // void skipPixels(int start, int howMany);
|
---|
99 | // void calculatePixelsCoords();
|
---|
100 | void setCorrectSlice(QMouseEvent* event);
|
---|
101 | void eventStepping(bool plus);
|
---|
102 | // void buildVerticesList();
|
---|
103 | void buildPatchesIndices();
|
---|
104 | void calcBlurColor(int pixel, int vertex);
|
---|
105 | void drawBlurryHexagon(int index);
|
---|
106 | int whichSlice;
|
---|
107 | // float shownSizex;
|
---|
108 | // float shownSizey;
|
---|
109 | bool drawPatch;
|
---|
110 | bool drawImpulse;
|
---|
111 | bool drawBlur;
|
---|
112 | bool loopCurrentEvent;
|
---|
113 | //allocate the maximum size for one event
|
---|
114 | uint32_t boardTime[NBOARDS];
|
---|
115 | int16_t startPix[NPIX];
|
---|
116 | int16_t startTM[NTMARK];
|
---|
117 | uint32_t pcTime;
|
---|
118 | uint32_t softTrig;
|
---|
119 | uint16_t triggerType;
|
---|
120 | int nRows;
|
---|
121 | int rowNum;
|
---|
122 | int eventNum;
|
---|
123 | int nRoi;
|
---|
124 | int nRoiTM;
|
---|
125 | int runNumber;
|
---|
126 | int nTM;
|
---|
127 | int runType;
|
---|
128 | int firstDataTime;
|
---|
129 | int lastDataTime;
|
---|
130 | int revision;
|
---|
131 | int builderVersion;
|
---|
132 | int nBoards;
|
---|
133 | int nPixels;
|
---|
134 | string timeSystem;
|
---|
135 | string creationDate;
|
---|
136 | int nightInt;
|
---|
137 | string camera;
|
---|
138 | string daq;
|
---|
139 | float adcCount;
|
---|
140 | int nbOk;
|
---|
141 | int nbRej;
|
---|
142 | int nbBad;
|
---|
143 |
|
---|
144 | int eventStep;
|
---|
145 |
|
---|
146 | // int hardwareMapping[1440];
|
---|
147 | // int softwareMapping[1440];
|
---|
148 | //// int patches[160][9];
|
---|
149 | GLfloat patchesColor[160][3];
|
---|
150 | // vector<edge> patchesIndices[160];
|
---|
151 | fits* inputFile;
|
---|
152 | fits* calibInputFile;
|
---|
153 | float baseLineMean[1440*1024];
|
---|
154 | float gainMean[1440*1024];
|
---|
155 | float triggerOffsetMean[1440*1024];
|
---|
156 | bool calibrationLoaded;
|
---|
157 | bool drawCalibrationLoaded;
|
---|
158 |
|
---|
159 | QPoint lastPos;
|
---|
160 |
|
---|
161 | void doMyWaveletTestPlease();
|
---|
162 | void doWaveLetOnCurrentEventPlease();
|
---|
163 | bool doWaveLetsPlease(int givenSpan, int16_t* orig, int16_t* wavelets, bool verifyResult);
|
---|
164 | public:
|
---|
165 | void computePulsesStatistics();
|
---|
166 | double aMeas[1024];
|
---|
167 | double n1mean[1024];
|
---|
168 | double n2mean[1024];
|
---|
169 | double vCorr[1024];
|
---|
170 |
|
---|
171 | // GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
|
---|
172 | // PixelsNeighbors neighbors[MAX_NUM_PIXELS];
|
---|
173 | // GLfloat pixelsColor[ACTUAL_NUM_PIXELS][3];
|
---|
174 | // GLfloat verticesList[ACTUAL_NUM_PIXELS*6][2];
|
---|
175 | // int verticesIndices[ACTUAL_NUM_PIXELS][6];
|
---|
176 | // int numVertices;
|
---|
177 | };
|
---|
178 |
|
---|
179 | /*************************************************
|
---|
180 | * Class UIConnector. used to connect the interface to the raw data displayer
|
---|
181 | *************************************************/
|
---|
182 | class UIConnector : public QObject
|
---|
183 | {
|
---|
184 | Q_OBJECT
|
---|
185 | public:
|
---|
186 | UIConnector(QWidget *parent = 0);
|
---|
187 | void setViewer(RawDataViewer* v);
|
---|
188 |
|
---|
189 | public Q_SLOTS:
|
---|
190 | void loadNewFileClicked();
|
---|
191 | void loadNewCalibFileClicked();
|
---|
192 | void fileSelected(QString file);
|
---|
193 | void calibFileSelected(QString file);
|
---|
194 | void drawPatchesCheckChange(int state);
|
---|
195 | void drawImpulseCheckChange(int state);
|
---|
196 | void drawBlurCheckChange(int state);
|
---|
197 | void loopEventCheckChange(int state);
|
---|
198 | void newFileLoaded();
|
---|
199 | void playPauseClicked();
|
---|
200 | void slicesPerSecondChanged(double value);
|
---|
201 | void nextSlicePlease();
|
---|
202 | void currentSliceHasChanged(int slice);
|
---|
203 | void currentEventHasChanged(int event);
|
---|
204 | void rangeChanged0(double value);
|
---|
205 | void rangeChanged1(double value);
|
---|
206 | void rangeChanged2(double value);
|
---|
207 | void rangeChanged3(double value);
|
---|
208 | void rangeChanged4(double value);
|
---|
209 | void redChanged0(double value);
|
---|
210 | void redChanged1(double value);
|
---|
211 | void redChanged2(double value);
|
---|
212 | void redChanged3(double value);
|
---|
213 | void redChanged4(double value);
|
---|
214 | void greenChanged0(double value);
|
---|
215 | void greenChanged1(double value);
|
---|
216 | void greenChanged2(double value);
|
---|
217 | void greenChanged3(double value);
|
---|
218 | void greenChanged4(double value);
|
---|
219 | void blueChanged0(double value);
|
---|
220 | void blueChanged1(double value);
|
---|
221 | void blueChanged2(double value);
|
---|
222 | void blueChanged3(double value);
|
---|
223 | void blueChanged4(double value);
|
---|
224 | void pixelChanged(int pixel);
|
---|
225 | void hwIDChanged(int hwid);
|
---|
226 | void swIDChanged(int swid);
|
---|
227 | void crateIDChanged(int cid);
|
---|
228 | void boardIDChanged(int bid);
|
---|
229 | void patchIDChanged(int pid);
|
---|
230 | void autoScalePressed();
|
---|
231 | void entireCameraChanged(bool state);
|
---|
232 | void currentPixelChanged(bool state);
|
---|
233 | void slicesPlusPlus();
|
---|
234 | void slicesMinusMinus();
|
---|
235 | void drawCalibratedDataChanged(int state);
|
---|
236 | void eventChangedFromSpinner(int cEvent);
|
---|
237 | void sliceChangedFromSpinner(int cSlice);
|
---|
238 |
|
---|
239 | Q_SIGNALS:
|
---|
240 | void updateCurrentSliceDisplay(int);
|
---|
241 | void updateCurrentEventDisplay(int);
|
---|
242 | void updateCurrentPCTime(QString);
|
---|
243 | void updateCurrentSoftTrigger(QString);
|
---|
244 | void updateCurrentTriggerType(QString);
|
---|
245 | void updateCurrentPixelSliceValue(QString);
|
---|
246 |
|
---|
247 |
|
---|
248 | private:
|
---|
249 | RawDataViewer* viewer;
|
---|
250 | QTimer timer;
|
---|
251 | string currentFile;
|
---|
252 | string currentCalibFile;
|
---|
253 | int crateID;
|
---|
254 | int boardID;
|
---|
255 | int patchID;
|
---|
256 | int hwID;
|
---|
257 | int swID;
|
---|
258 | bool rescaleWholeCamera;
|
---|
259 | QRectF scaleBoundingRectangle(QRectF rectangle, float scale);
|
---|
260 | bool updateSpinnerDisplay;
|
---|
261 |
|
---|
262 | public:
|
---|
263 | QListWidget *boardsTimeList;
|
---|
264 | QListWidget* startPixelsList;
|
---|
265 | QListWidget* startTimeMarksList;
|
---|
266 | // QLabel* fileLoadedLabel;
|
---|
267 | // QLabel* runNumberLabel;
|
---|
268 | // QLabel* numberOfSlicesLabel;
|
---|
269 | // QLabel* numberOfTimeMarksLabel;
|
---|
270 | // QLabel* runTypeLabel;
|
---|
271 | // QLabel* firstTimeLabel;
|
---|
272 | // QLabel* lastTimeLabel;
|
---|
273 | QLabel* currentPixelValue;
|
---|
274 | QLabel* extraInfoLabel;
|
---|
275 |
|
---|
276 | QwtPlot* boardsTimeHisto;
|
---|
277 | QwtPlot* startCellHisto;
|
---|
278 | QwtPlot* startTimeMarkHisto;
|
---|
279 | QwtPlot* pixelValueCurve;
|
---|
280 | QwtPlotCurve boardsTimeHistoItem;
|
---|
281 | QwtPlotCurve startCellHistoItem;
|
---|
282 | QwtPlotCurve startTimeMarkHistoItem;
|
---|
283 | QwtPlotCurve pixelValueCurveItem;
|
---|
284 | QwtPlotCurve aMeanCurveItem;
|
---|
285 | QwtPlotCurve vCorrCurveItem;
|
---|
286 | QwtPlotCurve meanCurveItem;
|
---|
287 | QwtPlotZoomer* curveZoom;
|
---|
288 | QwtPlotZoomer* boardsTimeHistoZoom;
|
---|
289 | QwtPlotZoomer* startCellHistoZoom;
|
---|
290 | QwtPlotZoomer* startTimeMarkHistoZoom;
|
---|
291 |
|
---|
292 | QwtPlot* triggerDelayHisto;
|
---|
293 | QwtPlotCurve triggerDelayHistoItem;
|
---|
294 | QwtPlotZoomer* triggerDelayHistoZoom;
|
---|
295 |
|
---|
296 | QPushButton* autoScaleColor;
|
---|
297 |
|
---|
298 | QListWidget* triggerDelayList;
|
---|
299 |
|
---|
300 | QSpinBox* HwIDBox;
|
---|
301 | QSpinBox* SwIDBox;
|
---|
302 | QSpinBox* crateIDBox;
|
---|
303 | QSpinBox* boardIDBox;
|
---|
304 | QSpinBox* patchIDBox;
|
---|
305 |
|
---|
306 | QSpinBox* eventNumberBox;
|
---|
307 |
|
---|
308 | QRadioButton* currentPixelScale;
|
---|
309 | QRadioButton* entireCameraScale;
|
---|
310 | QRadioButton* playEventsRadio;
|
---|
311 |
|
---|
312 | QDoubleSpinBox* range0;
|
---|
313 | QDoubleSpinBox* range1;
|
---|
314 | QDoubleSpinBox* range2;
|
---|
315 | QDoubleSpinBox* range3;
|
---|
316 | QDoubleSpinBox* range4;
|
---|
317 |
|
---|
318 | QCheckBox* drawCalibrationCheckBox;
|
---|
319 |
|
---|
320 | void initHistograms();
|
---|
321 |
|
---|
322 | };
|
---|
323 |
|
---|
324 | #endif /* QTGL_H_ */
|
---|