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

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