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

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