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

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