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

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