source: branches/testFACT++branch/gui/RawEventsViewer/RawEventsViewer.h@ 19688

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