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

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