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

Last change on this file since 11753 was 11753, checked in by lyard, 13 years ago
added display of calibrated data
File size: 8.4 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 <QtCore/QObject>
18#include <QtCore/QTimer>
19#include <QtGui/QLabel>
20#include <QtGui/QListWidget>
21#include <QtGui/QMainWindow>
22#include <QtOpenGL/QGLWidget>
23#include <QtGui/QMouseEvent>
24#include <QtGui/QColorDialog>
25#include <QtGui/QApplication>
26#include <QtGui/QSpinBox>
27#include <QtGui/QDoubleSpinBox>
28#include <QtGui/QRadioButton>
29#include <QtGui/QCheckBox>
30#include <iostream>
31#include <GL/gl.h>
32
33#include <qwt-qt4/qwt_plot.h>
34//#include "qwt_plot_histogram.h"
35#include <qwt-qt4/qwt_plot_curve.h>
36
37#include <qwt-qt4/qwt_plot_zoomer.h>
38
39
40//#define __MARS__
41//#include "MFits.h"
42#include <string>
43#include "fits.h"
44
45using namespace std;
46
47#define NUM_STORED_EVENTS 5
48#define MAX_NUM_PIXELS 1600
49#define ACTUAL_NUM_PIXELS 1440
50
51///structure for storing edges of hexagons (for blurry display)
52struct edge
53{
54 int first;
55 int second;
56};
57
58///structure for storing neighbors of pixels. For camera position calculation and blurry display
59struct PixelsNeighbors
60{
61 //neighbors. clockwise, starting from top
62 int neighbors[6];
63 PixelsNeighbors()
64 {
65 for (int i=0;i<6;i++)
66 neighbors[i] = -1;
67 }
68 int& operator[](int index){return neighbors[index];}
69};
70
71/*************************************************
72 * Class Raw Data Viewer. FACT raw data diplayer
73 *************************************************/
74class RawDataViewer : public QGLWidget
75{
76 Q_OBJECT
77
78 friend class UIConnector;
79public:
80 RawDataViewer(QWidget *parent = 0);
81 ~RawDataViewer();
82 void openFile(string& file);
83 void openCalibFile(string& file);
84
85public Q_SLOTS:
86 void plusEvent();
87 void minusEvent();
88 void setEventStep(int step);
89 void nextSlice();
90 void previousSlice();
91
92Q_SIGNALS:
93 void signalCurrentEvent(int event);
94 void signalCurrentSlice(int slice);
95 void newFileLoaded();
96 void signalCurrentPixel(int pixel);
97
98protected:
99 void initializeGL();
100 void resizeGL(int width, int height);
101 void paintGL();
102 void mousePressEvent(QMouseEvent *event);
103 void mouseMoveEvent(QMouseEvent *event);
104 void mouseDoubleClickEvent(QMouseEvent *event);
105
106private:
107 void drawCamera(bool alsoWire);
108 void drawPixelCurve();
109 void drawPatches();
110 int PixelAtPosition(const QPoint &pos);
111 void updateNeighbors(int currentPixel);
112 void skipPixels(int start, int howMany);
113 void calculatePixelsCoords();
114 void drawHexagon(int index, bool solid);
115 void setCorrectSlice(QMouseEvent* event);
116 void eventStepping(bool plus);
117 void buildVerticesList();
118 void buildPatchesIndices();
119 void calcBlurColor(int pixel, int vertex);
120 void drawBlurryHexagon(int index);
121 float hexRadius;
122 float hexTolerance;
123 float viewSize;
124 int whichSlice;
125 int selectedPixel;
126 float pixelSize;
127 float shownSizex;
128 float shownSizey;
129 bool drawPatch;
130 bool drawImpulse;
131 bool drawBlur;
132 bool loopCurrentEvent;
133 //allocate the maximum size for one event
134 int16_t *eventData;
135 uint32_t boardTime[NBOARDS];
136 int16_t startPix[NPIX];
137 int16_t startTM[NTMARK];
138 uint32_t pcTime;
139 uint32_t softTrig;
140 uint16_t triggerType;
141 int nRows;
142 int rowNum;
143 int eventNum;
144 int nRoi;
145 int nRoiTM;
146 int runNumber;
147 int nTM;
148 int runType;
149 int firstDataTime;
150 int lastDataTime;
151 int revision;
152 int builderVersion;
153 int nBoards;
154 int nPixels;
155 string timeSystem;
156 string creationDate;
157 int nightInt;
158 string camera;
159 string daq;
160 float adcCount;
161 int nbOk;
162 int nbRej;
163 int nbBad;
164
165 int eventStep;
166
167 int hardwareMapping[1440];
168 int softwareMapping[1440];
169 int patches[160][9];
170 GLfloat patchesColor[160][3];
171 vector<edge> patchesIndices[160];
172 fits* inputFile;
173 fits* calibInputFile;
174 float baseLineMean[1440*1024];
175 float gainMean[1440*1024];
176 float triggerOffsetMean[1440*1024];
177 bool calibrationLoaded;
178 bool drawCalibrationLoaded;
179
180 QPoint lastPos;
181
182 GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
183 PixelsNeighbors neighbors[MAX_NUM_PIXELS];
184 GLfloat pixelsColor[ACTUAL_NUM_PIXELS][3];
185 GLfloat verticesList[ACTUAL_NUM_PIXELS*6][2];
186 int verticesIndices[ACTUAL_NUM_PIXELS][6];
187 int numVertices;
188};
189/*************************************************
190 * Class UIConnector. used to connect the interface to the raw data displayer
191 *************************************************/
192class UIConnector : public QObject
193{
194 Q_OBJECT
195public:
196 UIConnector(QWidget *parent = 0);
197 void setViewer(RawDataViewer* v);
198
199public Q_SLOTS:
200 void loadNewFileClicked();
201 void loadNewCalibFileClicked();
202 void fileSelected(QString file);
203 void calibFileSelected(QString file);
204 void drawPatchesCheckChange(int state);
205 void drawImpulseCheckChange(int state);
206 void drawBlurCheckChange(int state);
207 void loopEventCheckChange(int state);
208 void newFileLoaded();
209 void playPauseClicked();
210 void slicesPerSecondChanged(double value);
211 void nextSlicePlease();
212 void currentSliceHasChanged(int slice);
213 void currentEventHasChanged(int event);
214 void rangeChanged0(double value);
215 void rangeChanged1(double value);
216 void rangeChanged2(double value);
217 void rangeChanged3(double value);
218 void rangeChanged4(double value);
219 void redChanged0(double value);
220 void redChanged1(double value);
221 void redChanged2(double value);
222 void redChanged3(double value);
223 void redChanged4(double value);
224 void greenChanged0(double value);
225 void greenChanged1(double value);
226 void greenChanged2(double value);
227 void greenChanged3(double value);
228 void greenChanged4(double value);
229 void blueChanged0(double value);
230 void blueChanged1(double value);
231 void blueChanged2(double value);
232 void blueChanged3(double value);
233 void blueChanged4(double value);
234 void pixelChanged(int pixel);
235 void hwIDChanged(int hwid);
236 void swIDChanged(int swid);
237 void crateIDChanged(int cid);
238 void boardIDChanged(int bid);
239 void patchIDChanged(int pid);
240 void autoScalePressed();
241 void entireCameraChanged(bool state);
242 void currentPixelChanged(bool state);
243 void slicesPlusPlus();
244 void slicesMinusMinus();
245 void drawCalibratedDataChanged(int state);
246
247Q_SIGNALS:
248 void updateCurrentSliceDisplay(QString);
249 void updateCurrentEventDisplay(QString);
250 void updateCurrentPCTime(QString);
251 void updateCurrentSoftTrigger(QString);
252 void updateCurrentTriggerType(QString);
253 void updateCurrentPixelSliceValue(QString);
254
255
256private:
257 RawDataViewer* viewer;
258 QTimer timer;
259 string currentFile;
260 string currentCalibFile;
261 int crateID;
262 int boardID;
263 int patchID;
264 int hwID;
265 int swID;
266 bool rescaleWholeCamera;
267 QRectF scaleBoundingRectangle(QRectF rectangle, float scale);
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 QwtPlotZoomer* curveZoom;
291 QwtPlotZoomer* boardsTimeHistoZoom;
292 QwtPlotZoomer* startCellHistoZoom;
293 QwtPlotZoomer* startTimeMarkHistoZoom;
294
295 QwtPlot* triggerDelayHisto;
296 QwtPlotCurve triggerDelayHistoItem;
297 QwtPlotZoomer* triggerDelayHistoZoom;
298 QListWidget* triggerDelayList;
299
300 QSpinBox* HwIDBox;
301 QSpinBox* SwIDBox;
302 QSpinBox* crateIDBox;
303 QSpinBox* boardIDBox;
304 QSpinBox* patchIDBox;
305
306 QRadioButton* currentPixelScale;
307 QRadioButton* entireCameraScale;
308
309 QDoubleSpinBox* range0;
310 QDoubleSpinBox* range1;
311 QDoubleSpinBox* range2;
312 QDoubleSpinBox* range3;
313 QDoubleSpinBox* range4;
314
315 QCheckBox* drawCalibrationCheckBox;
316
317 void initHistograms();
318
319};
320
321#endif /* QTGL_H_ */
Note: See TracBrowser for help on using the repository browser.