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

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