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

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