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

Last change on this file since 11650 was 11642, checked in by lyard, 14 years ago
removed references to Mars
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>
32#include "fits.h"
33
34using namespace std;
35
36#define NUM_STORED_EVENTS 5
37#define MAX_NUM_PIXELS 1600
38#define ACTUAL_NUM_PIXELS 1440
39
40///structure for storing edges of hexagons (for blurry display)
41struct edge
42{
43 int first;
44 int second;
45};
46
47///structure for storing neighbors of pixels. For camera position calculation and blurry display
48struct PixelsNeighbors
49{
50 //neighbors. clockwise, starting from top
51 int neighbors[6];
52 PixelsNeighbors()
53 {
54 for (int i=0;i<6;i++)
55 neighbors[i] = -1;
56 }
57 int& operator[](int index){return neighbors[index];}
58};
59
60/*************************************************
61 * Class Raw Data Viewer. FACT raw data diplayer
62 *************************************************/
63class RawDataViewer : public QGLWidget
64{
65 Q_OBJECT
66
67 friend class UIConnector;
68public:
69 RawDataViewer(QWidget *parent = 0);
70 ~RawDataViewer();
71 void openFile(string& filename);
72
73public Q_SLOTS:
74 void plusEvent();
75 void minusEvent();
76 void setEventStep(int step);
77 void nextSlice();
78
79Q_SIGNALS:
80 void signalCurrentEvent(int event);
81 void signalCurrentSlice(int slice);
82 void newFileLoaded();
83
84protected:
85 void initializeGL();
86 void resizeGL(int width, int height);
87 void paintGL();
88 void mousePressEvent(QMouseEvent *event);
89 void mouseMoveEvent(QMouseEvent *event);
90 void mouseDoubleClickEvent(QMouseEvent *event);
91
92private:
93 void drawCamera(bool alsoWire);
94 void drawPixelCurve();
95 void drawPatches();
96 int PixelAtPosition(const QPoint &pos);
97 void updateNeighbors(int currentPixel);
98 void skipPixels(int start, int howMany);
99 void calculatePixelsCoords();
100 void drawHexagon(int index, bool solid);
101 void setCorrectSlice(QMouseEvent* event);
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 fits* 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.