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

Last change on this file since 12158 was 12158, checked in by lyard, 13 years ago
oops, forgot .h
File size: 8.5 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
41#include <qwt_plot_zoomer.h>
42
43#include <valarray>
44
45#include <string>
46
47namespace std
48{
49 class fits;
50}
51
52/*************************************************
53 * Class Raw Data Viewer. FACT raw data diplayer
54 *************************************************/
55class RawDataViewer : public BasicGlCamera//QGLWidget
56{
57 Q_OBJECT
58
59 friend class UIConnector;
60public:
61 RawDataViewer(QWidget *parent = 0);
62 ~RawDataViewer();
63 void openFile(std::string& file);
64 void openCalibFile(std::string& file);
65
66
67
68public Q_SLOTS:
69 void plusEvent();
70 void minusEvent();
71 void setEventStep(int step);
72 void nextSlice();
73 void previousSlice();
74
75Q_SIGNALS:
76 void signalCurrentEvent(int event);
77 void signalCurrentSlice(int slice);
78 void newFileLoaded();
79 void signalCurrentPixel(int pixel);
80 void signalAutoScaleNeeded();
81
82protected:
83// void initializeGL();
84// void resizeGL(int width, int height);
85 void paintGL();
86 void mousePressEvent(QMouseEvent *event);
87 void mouseMoveEvent(QMouseEvent *event);
88 void mouseDoubleClickEvent(QMouseEvent *event);
89 void drawCamera(bool alsoWire);
90// void drawPatches();
91// int PixelAtPosition(const QPoint &pos);
92// void drawHexagon(int index, bool solid);
93 int selectedPixel;
94 float *eventData;
95 int16_t* rawEventData;
96 int16_t* waveLetArray;
97
98private:
99 void drawPixelCurve();
100// void updateNeighbors(int currentPixel);
101// void skipPixels(int start, int howMany);
102// void calculatePixelsCoords();
103 void setCorrectSlice(QMouseEvent* event);
104 void eventStepping(bool plus);
105// void buildVerticesList();
106 void buildPatchesIndices();
107 void calcBlurColor(int pixel, int vertex);
108 void drawBlurryHexagon(int index);
109 int whichSlice;
110 // float shownSizex;
111 // float shownSizey;
112 bool drawPatch;
113 bool drawImpulse;
114 bool drawBlur;
115 bool loopCurrentEvent;
116 //allocate the maximum size for one event
117 uint32_t boardTime[NBOARDS];
118 int16_t startPix[NPIX];
119 int16_t startTM[NTMARK];
120 int32_t pcTime[2];
121 uint32_t softTrig;
122 uint16_t triggerType;
123 int nRows;
124 int rowNum;
125 int eventNum;
126 int nRoi;
127 int nRoiTM;
128 int runNumber;
129 int nTM;
130 int runType;
131 int firstDataTime;
132 int lastDataTime;
133 int revision;
134 int builderVersion;
135 int nBoards;
136 int nPixels;
137 std::string timeSystem;
138 std::string creationDate;
139 int nightInt;
140 std::string camera;
141 std::string daq;
142 float adcCount;
143 int nbOk;
144 int nbRej;
145 int nbBad;
146
147 int eventStep;
148
149// int hardwareMapping[1440];
150// int softwareMapping[1440];
151//// int patches[160][9];
152 GLfloat patchesColor[160][3];
153// vector<edge> patchesIndices[160];
154 std::fits* inputFile;
155 std::fits* calibInputFile;
156 float baseLineMean[1440*1024];
157 float gainMean[1440*1024];
158 float triggerOffsetMean[1440*1024];
159 bool calibrationLoaded;
160 bool drawCalibrationLoaded;
161
162 QPoint lastPos;
163
164 void doMyWaveletTestPlease();
165 void doWaveLetOnCurrentEventPlease();
166 bool doWaveLetsPlease(int givenSpan, int16_t* orig, int16_t* wavelets, bool verifyResult);
167public:
168 void computePulsesStatistics();
169 double aMeas[1024];
170 double n1mean[1024];
171 double n2mean[1024];
172 double vCorr[1024];
173
174// GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
175// PixelsNeighbors neighbors[MAX_NUM_PIXELS];
176 // GLfloat pixelsColor[ACTUAL_NUM_PIXELS][3];
177// GLfloat verticesList[ACTUAL_NUM_PIXELS*6][2];
178// int verticesIndices[ACTUAL_NUM_PIXELS][6];
179// int numVertices;
180};
181
182/*************************************************
183 * Class UIConnector. used to connect the interface to the raw data displayer
184 *************************************************/
185class UIConnector : public QObject
186{
187 Q_OBJECT
188public:
189 UIConnector(QWidget *parent = 0);
190 void setViewer(RawDataViewer* v);
191
192public Q_SLOTS:
193 void loadNewFileClicked();
194 void loadNewCalibFileClicked();
195 void fileSelected(QString file);
196 void calibFileSelected(QString file);
197 void drawPatchesCheckChange(int state);
198 void drawImpulseCheckChange(int state);
199 void drawBlurCheckChange(int state);
200 void loopEventCheckChange(int state);
201 void newFileLoaded();
202 void playPauseClicked();
203 void slicesPerSecondChanged(double value);
204 void nextSlicePlease();
205 void currentSliceHasChanged(int slice);
206 void currentEventHasChanged(int event);
207 void rangeChanged0(double value);
208 void rangeChanged1(double value);
209 void rangeChanged2(double value);
210 void rangeChanged3(double value);
211 void rangeChanged4(double value);
212 void redChanged0(double value);
213 void redChanged1(double value);
214 void redChanged2(double value);
215 void redChanged3(double value);
216 void redChanged4(double value);
217 void greenChanged0(double value);
218 void greenChanged1(double value);
219 void greenChanged2(double value);
220 void greenChanged3(double value);
221 void greenChanged4(double value);
222 void blueChanged0(double value);
223 void blueChanged1(double value);
224 void blueChanged2(double value);
225 void blueChanged3(double value);
226 void blueChanged4(double value);
227 void pixelChanged(int pixel);
228 void hwIDChanged(int hwid);
229 void swIDChanged(int swid);
230 void crateIDChanged(int cid);
231 void boardIDChanged(int bid);
232 void patchIDChanged(int pid);
233 void autoScalePressed();
234 void entireCameraChanged(bool state);
235 void currentPixelChanged(bool state);
236 void slicesPlusPlus();
237 void slicesMinusMinus();
238 void drawCalibratedDataChanged(int state);
239 void eventChangedFromSpinner(int cEvent);
240 void sliceChangedFromSpinner(int cSlice);
241
242Q_SIGNALS:
243 void updateCurrentSliceDisplay(int);
244 void updateCurrentEventDisplay(int);
245 void updateCurrentPCTime(QString);
246 void updateCurrentSoftTrigger(QString);
247 void updateCurrentTriggerType(QString);
248 void updateCurrentPixelSliceValue(QString);
249
250
251private:
252 RawDataViewer* viewer;
253 QTimer timer;
254 std::string currentFile;
255 std::string currentCalibFile;
256 int crateID;
257 int boardID;
258 int patchID;
259 int hwID;
260 int swID;
261 bool rescaleWholeCamera;
262 QRectF scaleBoundingRectangle(QRectF rectangle, float scale);
263 bool updateSpinnerDisplay;
264
265public:
266 QListWidget *boardsTimeList;
267 QListWidget* startPixelsList;
268 QListWidget* startTimeMarksList;
269// QLabel* fileLoadedLabel;
270// QLabel* runNumberLabel;
271// QLabel* numberOfSlicesLabel;
272// QLabel* numberOfTimeMarksLabel;
273// QLabel* runTypeLabel;
274// QLabel* firstTimeLabel;
275// QLabel* lastTimeLabel;
276 QLabel* currentPixelValue;
277 QLabel* extraInfoLabel;
278
279 QwtPlot* boardsTimeHisto;
280 QwtPlot* startCellHisto;
281 QwtPlot* startTimeMarkHisto;
282 QwtPlot* pixelValueCurve;
283 QwtPlotCurve boardsTimeHistoItem;
284 QwtPlotCurve startCellHistoItem;
285 QwtPlotCurve startTimeMarkHistoItem;
286 QwtPlotCurve pixelValueCurveItem;
287 QwtPlotCurve aMeanCurveItem;
288 QwtPlotCurve vCorrCurveItem;
289 QwtPlotCurve meanCurveItem;
290 QwtPlotZoomer* curveZoom;
291 QwtPlotZoomer* boardsTimeHistoZoom;
292 QwtPlotZoomer* startCellHistoZoom;
293 QwtPlotZoomer* startTimeMarkHistoZoom;
294
295 QwtPlot* triggerDelayHisto;
296 QwtPlotCurve triggerDelayHistoItem;
297 QwtPlotZoomer* triggerDelayHistoZoom;
298
299 QPushButton* autoScaleColor;
300
301 QListWidget* triggerDelayList;
302
303 QSpinBox* HwIDBox;
304 QSpinBox* SwIDBox;
305 QSpinBox* crateIDBox;
306 QSpinBox* boardIDBox;
307 QSpinBox* patchIDBox;
308
309 QSpinBox* eventNumberBox;
310
311 QRadioButton* currentPixelScale;
312 QRadioButton* entireCameraScale;
313 QRadioButton* playEventsRadio;
314
315 QDoubleSpinBox* range0;
316 QDoubleSpinBox* range1;
317 QDoubleSpinBox* range2;
318 QDoubleSpinBox* range3;
319 QDoubleSpinBox* range4;
320
321 QCheckBox* drawCalibrationCheckBox;
322
323 void initHistograms();
324
325};
326
327#endif /* QTGL_H_ */
Note: See TracBrowser for help on using the repository browser.