source: trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h@ 19312

Last change on this file since 19312 was 19312, checked in by tbretz, 7 years ago
Defining a preprocessor directive for our __CMAKE__ build avoids to produce two additional unnecessray output files.
File size: 8.8 KB
Line 
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#include <string>
16#include <valarray>
17
18#include <QObject>
19
20#include "BasicGlCamera.h"
21
22#include <qwt_plot_curve.h>
23
24class QwtPlotZoomer;
25class QwtPlotGrid;
26
27#ifndef Q_MOC_RUN
28#include "src/DataCalib.h"
29#include "externals/ofits.h"
30#endif
31
32/*************************************************
33 * Class Raw Data Viewer. FACT raw data diplayer
34 *************************************************/
35class RawDataViewer : public BasicGlCamera//QGLWidget
36{
37 Q_OBJECT
38
39 friend class UIConnector;
40
41 enum CalibDataTypes {
42 CALIB_BASELINE,
43 CALIB_GAIN,
44 CALIB_TRIG_OFFSET
45 };
46
47public:
48 DrsCalibration fDrsCalib;
49
50 bool fIsDrsCalibration;
51
52 RawDataViewer(QWidget *parent = 0);
53 ~RawDataViewer();
54 void openFile(std::string& file);
55 void openCalibFile(std::string& file);
56
57 template <typename T>
58 void getCalibrationDataForDisplay(const CalibDataTypes calibTypes,
59 const vector<T>& inputData,
60 const int roi,
61 const int roiTM);
62 int getCurrentPixel(){return selectedPixel;}
63 void assignPixelMapFile(const string& map="");
64public Q_SLOTS:
65 void plusEvent();
66 void minusEvent();
67 void setEventStep(int step);
68 void nextSlice();
69 void previousSlice();
70 void setCurrentPixel(int);
71
72
73Q_SIGNALS:
74 void signalCurrentEvent(int event);
75 void signalCurrentSlice(int slice);
76 void newFileLoaded();
77 void signalCurrentPixel(int pixel);
78 void signalAutoScaleNeeded();
79
80protected:
81// void initializeGL();
82// void resizeGL(int width, int height);
83 void paintGL();
84 void mousePressEvent(QMouseEvent *event);
85 void mouseMoveEvent(QMouseEvent *event);
86 void mouseDoubleClickEvent(QMouseEvent *event);
87 void drawCamera(bool alsoWire);
88// void drawPatches();
89// int PixelAtPosition(const QPoint &pos);
90// void drawHexagon(int index, bool solid);
91 int selectedPixel;
92 float *eventData;
93 float *rmsData;
94 int16_t* rawEventData;
95 int16_t* waveLetArray;
96 valarray<double> RMSvalues;//(1440);
97 valarray<double> Meanvalues;
98 valarray<double> Maxvalues;
99 valarray<double> PosOfMaxvalues;
100
101 ///Used to load zero data in case of missing fits columns
102 void allocateZeroArray();
103 char* fZeroArray;
104 //bool telling whether the data is natively ordered in software or hardware id
105 //used to correctly display monte-carlo data.
106 bool _softwareOrdering;
107
108private:
109 void drawPixelCurve();
110// void updateNeighbors(int currentPixel);
111// void skipPixels(int start, int howMany);
112// void calculatePixelsCoords();
113 bool setCorrectSlice(QMouseEvent* event);
114 void eventStepping(bool plus);
115// void buildVerticesList();
116// void buildPatchesIndices();
117 void calcBlurColor(int pixel, int vertex);
118 void calcMidBlurColor(int pixel, int vertex);
119 void drawBlurryHexagon(int index);
120 int whichSlice;
121 // float shownSizex;
122 // float shownSizey;
123 bool drawPatch;
124 bool drawImpulse;
125 bool drawBlur;
126 bool loopCurrentEvent;
127 //allocate the maximum size for one event
128 uint32_t boardTime[NBOARDS];
129 int16_t startPix[NPIX];
130 int16_t startTM[NTMARK];
131 int32_t pcTime[2];
132 uint32_t softTrig;
133 uint16_t triggerType;
134 int nRows;
135 int rowNum;
136 int eventNum;
137 int nRoi;
138 int nRoiTM;
139 int offSetRoi;
140 int runNumber;
141 int nTM;
142 std::string runType;
143 int firstDataTime;
144 int lastDataTime;
145 int revision;
146 int builderVersion;
147 int nBoards;
148 int nPixels;
149 std::string timeSystem;
150 std::string creationDate;
151 int nightInt;
152 std::string camera;
153 std::string daq;
154 float adcCount;
155 int nbOk;
156 int nbRej;
157 int nbBad;
158
159 int eventStep;
160
161
162
163
164
165// int hardwareMapping[1440];
166// int softwareMapping[1440];
167//// int patches[160][9];
168 GLfloat patchesColor[160][3];
169// vector<edge> patchesIndices[160];
170 fits* inputFile;
171// std::fits* calibInputFile;
172// float baseLineMean[1440*1024];
173// float gainMean[1440*1024];
174// float triggerOffsetMean[1440*1024];
175// bool calibrationLoaded;
176 bool drawCalibrationLoaded;
177
178 QPoint lastPos;
179public:
180 void computePulsesStatistics();
181 double aMeas[1024];
182 double n1mean[1024];
183 double n2mean[1024];
184 double vCorr[1024];
185 int64_t VALUES_SPAN;
186
187 void ApplyCalibration();
188
189// GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
190// PixelsNeighbors neighbors[MAX_NUM_PIXELS];
191 // GLfloat pixelsColor[ACTUAL_NUM_PIXELS][3];
192// GLfloat verticesList[ACTUAL_NUM_PIXELS*6][2];
193// int verticesIndices[ACTUAL_NUM_PIXELS][6];
194// int numVertices;
195};
196
197/*************************************************
198 * Class UIConnector. used to connect the interface to the raw data displayer
199 *************************************************/
200#ifndef __CMAKE__
201#include "viewer.h"
202#else
203#include "ui_viewer.h"
204#endif
205
206class Configuration;
207
208class UIConnector : public QMainWindow, protected Ui::MainWindow
209{
210 Q_OBJECT
211private:
212 QTimer timer;
213 std::string currentFile;
214 std::string currentCalibFile;
215
216 QRectF scaleBoundingRectangle(QRectF rectangle, float scale);
217
218 bool updateSpinnerDisplay;
219 bool updating;
220
221 void initHistograms();
222
223public:
224 UIConnector(QWidget *parent = 0);
225 ~UIConnector();
226
227public Q_SLOTS:
228 void fileSelected(QString file);
229 void calibFileSelected(QString file);
230
231 void newFileLoaded();
232 void slicesPerSecondChanged(double value);
233 void nextSlicePlease();
234 void currentSliceHasChanged(int slice);
235 void currentEventHasChanged(int event);
236
237 void on_playPauseButton_clicked();
238 void on_loadNewFileButton_clicked();
239 void on_loadDRSCalibButton_clicked();
240
241 void on_drawPatchCheckBox_stateChanged(int);
242 void on_drawImpulseCheckBox_stateChanged(int);
243 void on_drawBlurCheckBox_stateChanged(int);
244 void on_loopOverCurrentEventBox_stateChanged(int);
245
246 void on_colorRange0_valueChanged(double);
247 void on_colorRange1_valueChanged(double);
248 void on_colorRange2_valueChanged(double);
249 void on_colorRange3_valueChanged(double);
250 void on_colorRange4_valueChanged(double);
251 void on_redValue0_valueChanged(double);
252 void on_redValue1_valueChanged(double);
253 void on_redValue2_valueChanged(double);
254 void on_redValue3_valueChanged(double);
255 void on_redValue4_valueChanged(double);
256 void on_greenValue0_valueChanged(double);
257 void on_greenValue1_valueChanged(double);
258 void on_greenValue2_valueChanged(double);
259 void on_greenValue3_valueChanged(double);
260 void on_greenValue4_valueChanged(double);
261 void on_blueValue0_valueChanged(double);
262 void on_blueValue1_valueChanged(double);
263 void on_blueValue2_valueChanged(double);
264 void on_blueValue3_valueChanged(double);
265 void on_blueValue4_valueChanged(double);
266
267 void on_slicesPerSecValue_valueChanged(double);
268
269 void pixelChanged(int);
270
271 void cbpxChanged();
272
273 void on_HwIDBox_valueChanged(int = 0);
274 void on_SwIDBox_valueChanged(int);
275 void on_crateIDBox_valueChanged(int) { cbpxChanged(); }
276 void on_boardIDBox_valueChanged(int) { cbpxChanged(); }
277 void on_patchIDBox_valueChanged(int) { cbpxChanged(); }
278 void on_pixelIDBox_valueChanged(int) { cbpxChanged(); }
279
280 void on_autoScaleColor_clicked();
281 void on_entireCameraScale_toggled(bool) { on_autoScaleColor_clicked(); }
282 void on_currentPixelScale_toggled(bool) { on_autoScaleColor_clicked(); }
283
284 void slicesPlusPlus();
285 void slicesMinusMinus();
286
287 void on_calibratedCheckBox_stateChanged(int state);
288 void on_displayingSliceBox_valueChanged(int);
289 void on_displayingEventBox_valueChanged(int);
290
291 void displaySliceValue();
292
293 int SetupConfiguration(Configuration &conf);
294
295private:
296 QwtPlotCurve boardsTimeHistoItem;
297 QwtPlotCurve startCellHistoItem;
298 QwtPlotCurve startTimeMarkHistoItem;
299 QwtPlotCurve pixelValueCurveItem;
300 QwtPlotCurve pixelAverageCurveItem;
301 QwtPlotCurve aMeanCurveItem;
302 QwtPlotCurve vCorrCurveItem;
303 QwtPlotCurve meanCurveItem;
304 QwtPlotCurve triggerDelayHistoItem;
305
306 QwtPlotZoomer* curveZoom;
307 QwtPlotZoomer* averageCurveZoom;
308 QwtPlotZoomer* boardsTimeHistoZoom;
309 QwtPlotZoomer* startCellHistoZoom;
310 QwtPlotZoomer* startTimeMarkHistoZoom;
311 QwtPlotZoomer* triggerDelayHistoZoom;
312
313 //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)
314 QwtPlotGrid* grid1;
315 QwtPlotGrid* grid2;
316 QwtPlotGrid* grid3;
317 QwtPlotGrid* grid4;
318 QwtPlotGrid* grid5;
319 QwtPlotGrid* grid6;
320};
321
322#endif /* QTGL_H_ */
Note: See TracBrowser for help on using the repository browser.