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

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