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

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