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

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