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

Last change on this file since 11540 was 11540, checked in by lyard, 13 years ago
added raw events viewer code
File size: 5.7 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 <iostream>
27#include <GL/gl.h>
28
29#define __MARS__
30#include <MFits.h>
31#include <string>
32using namespace std;
33
34
35#define NUM_STORED_EVENTS 5
36#define MAX_NUM_PIXELS 1600
37#define ACTUAL_NUM_PIXELS 1440
38
39///structure for storing edges of hexagons (for blurry display)
40struct edge
41{
42 int first;
43 int second;
44};
45
46///structure for storing neighbors of pixels. For camera position calculation and blurry display
47struct PixelsNeighbors
48{
49 //neighbors. clockwise, starting from top
50 int neighbors[6];
51 PixelsNeighbors()
52 {
53 for (int i=0;i<6;i++)
54 neighbors[i] = -1;
55 }
56 int& operator[](int index){return neighbors[index];}
57};
58
59/*************************************************
60 * Class Raw Data Viewer. FACT raw data diplayer
61 *************************************************/
62class RawDataViewer : public QGLWidget
63{
64 Q_OBJECT
65
66 friend class UIConnector;
67public:
68 RawDataViewer(QWidget *parent = 0);
69 ~RawDataViewer();
70 void openFile(string& filename);
71
72public Q_SLOTS:
73 void plusEvent();
74 void minusEvent();
75 void setEventStep(int step);
76 void nextSlice();
77
78Q_SIGNALS:
79 void signalCurrentEvent(int event);
80 void signalCurrentSlice(int slice);
81 void newFileLoaded();
82
83protected:
84 void initializeGL();
85 void resizeGL(int width, int height);
86 void paintGL();
87 void mousePressEvent(QMouseEvent *event);
88 void mouseMoveEvent(QMouseEvent *event);
89 void mouseDoubleClickEvent(QMouseEvent *event);
90
91private:
92 void drawCamera(bool alsoWire);
93 void drawPixelCurve();
94 void drawPatches();
95 int PixelAtPosition(const QPoint &pos);
96 void updateNeighbors(int currentPixel);
97 void skipPixels(int start, int howMany);
98 void calculatePixelsCoords();
99 void drawHexagon(int index, bool solid);
100 void setCorrectSlice(QMouseEvent* event);
101 bool IsFits(const char* name);
102 void eventStepping(bool plus);
103 void buildVerticesList();
104 void buildPatchesIndices();
105 void calcBlurColor(int pixel, int vertex);
106 void drawBlurryHexagon(int index);
107 float hexRadius;
108 float hexTolerance;
109 float viewSize;
110 int whichSlice;
111 int selectedPixel;
112 float pixelSize;
113 float shownSizex;
114 float shownSizey;
115 bool drawPatch;
116 bool drawImpulse;
117 bool drawBlur;
118 //allocate the maximum size for one event
119 int16_t *eventData;
120 uint32_t boardTime[NBOARDS];
121 int16_t startPix[NPIX];
122 int16_t startTM[NTMARK];
123 uint32_t pcTime;
124 uint32_t softTrig;
125 uint16_t triggerType;
126 int nRows;
127 int rowNum;
128 int eventNum;
129 int nRoi;
130 int runNumber;
131 int nTM;
132 int runType;
133 int firstDataTime;
134 int lastDataTime;
135 int eventStep;
136
137 int hardwareMapping[1440];
138 int patches[160][9];
139 GLfloat patchesColor[160][3];
140 vector<edge> patchesIndices[160];
141 MFits* inputFile;
142
143 QPoint lastPos;
144
145 GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
146 PixelsNeighbors neighbors[MAX_NUM_PIXELS];
147 GLfloat pixelsColor[ACTUAL_NUM_PIXELS][3];
148 GLfloat verticesList[ACTUAL_NUM_PIXELS*6][2];
149 int verticesIndices[ACTUAL_NUM_PIXELS][6];
150 int numVertices;
151};
152/*************************************************
153 * Class UIConnector. used to connect the interface to the raw data displayer
154 *************************************************/
155class UIConnector : public QObject
156{
157 Q_OBJECT
158public:
159 UIConnector(QWidget *parent = 0);
160 void setViewer(RawDataViewer* v);
161
162public Q_SLOTS:
163 void loadNewFileClicked();
164 void fileSelected(QString file);
165 void drawPatchesCheckChange(int state);
166 void drawImpulseCheckChange(int state);
167 void drawBlurCheckChange(int state);
168 void newFileLoaded();
169 void playPauseClicked();
170 void slicesPerSecondChanged(double value);
171 void nextSlicePlease();
172 void currentSliceHasChanged(int slice);
173 void currentEventHasChanged(int event);
174 void rangeChanged0(double value);
175 void rangeChanged1(double value);
176 void rangeChanged2(double value);
177 void rangeChanged3(double value);
178 void rangeChanged4(double value);
179 void redChanged0(double value);
180 void redChanged1(double value);
181 void redChanged2(double value);
182 void redChanged3(double value);
183 void redChanged4(double value);
184 void greenChanged0(double value);
185 void greenChanged1(double value);
186 void greenChanged2(double value);
187 void greenChanged3(double value);
188 void greenChanged4(double value);
189 void blueChanged0(double value);
190 void blueChanged1(double value);
191 void blueChanged2(double value);
192 void blueChanged3(double value);
193 void blueChanged4(double value);
194
195Q_SIGNALS:
196 void updateCurrentSliceDisplay(QString);
197 void updateCurrentEventDisplay(QString);
198 void updateCurrentPCTime(QString);
199 void updateCurrentSoftTrigger(QString);
200 void updateCurrentTriggerType(QString);
201
202
203private:
204 RawDataViewer* viewer;
205 QTimer timer;
206 string currentFile;
207public:
208 QListWidget *boardsTimeList;
209 QListWidget* startPixelsList;
210 QListWidget* startTimeMarksList;
211 QLabel* fileLoadedLabel;
212 QLabel* runNumberLabel;
213 QLabel* numberOfSlicesLabel;
214 QLabel* numberOfTimeMarksLabel;
215 QLabel* runTypeLabel;
216 QLabel* firstTimeLabel;
217 QLabel* lastTimeLabel;
218
219};
220
221#endif /* QTGL_H_ */
Note: See TracBrowser for help on using the repository browser.