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