1 | #ifndef BASIC_GL_CAMERA_H_
|
---|
2 | #define BASIC_GL_CAMERA_H_
|
---|
3 |
|
---|
4 | #define NBOARDS 40 // max. number of boards
|
---|
5 | #define NPIX 1440 // max. number of pixels
|
---|
6 | #define NTMARK 160 // max. number of timeMarker signals
|
---|
7 |
|
---|
8 | #define MAX_NUM_PIXELS 1600
|
---|
9 | #define ACTUAL_NUM_PIXELS 1440
|
---|
10 |
|
---|
11 | #include <set>
|
---|
12 | #include <vector>
|
---|
13 |
|
---|
14 | #include <QtOpenGL/QGLWidget>
|
---|
15 | #include <QtGui/QMouseEvent>
|
---|
16 |
|
---|
17 | #include <QtGui/QRadioButton>
|
---|
18 | #include <QtGui/QLabel>
|
---|
19 | #include <QtGui/QButtonGroup>
|
---|
20 |
|
---|
21 | #include "src/PixelMap.h"
|
---|
22 |
|
---|
23 | //#include <QtGui/QMouseEvent>
|
---|
24 | ///structure for storing edges of hexagons (for blurry display)
|
---|
25 | struct edge
|
---|
26 | {
|
---|
27 | int first;
|
---|
28 | int second;
|
---|
29 | };
|
---|
30 |
|
---|
31 | ///structure for storing neighbors of pixels. For camera position calculation and blurry display
|
---|
32 | struct PixelsNeighbors
|
---|
33 | {
|
---|
34 | //neighbors. clockwise, starting from top
|
---|
35 | int neighbors[6];
|
---|
36 | PixelsNeighbors()
|
---|
37 | {
|
---|
38 | for (int i=0;i<6;i++)
|
---|
39 | neighbors[i] = -1;
|
---|
40 | }
|
---|
41 | int& operator[](int index){return neighbors[index];}
|
---|
42 | };
|
---|
43 |
|
---|
44 | class BasicGlCamera : public QGLWidget
|
---|
45 | {
|
---|
46 | Q_OBJECT
|
---|
47 |
|
---|
48 | public:
|
---|
49 | BasicGlCamera(QWidget* parent = 0);
|
---|
50 | ~BasicGlCamera();
|
---|
51 |
|
---|
52 | int fWhite;
|
---|
53 | int fWhitePatch;
|
---|
54 |
|
---|
55 | int64_t fMin;
|
---|
56 | int64_t fMax;
|
---|
57 | float fScaleLimit;
|
---|
58 | void setAutoscaleLowerLimit(float);
|
---|
59 |
|
---|
60 | int fTextSize;
|
---|
61 |
|
---|
62 | static PixelMap fPixelMap;
|
---|
63 |
|
---|
64 | bool pixelColorUpToDate;
|
---|
65 |
|
---|
66 | GLfloat patchColour[3];
|
---|
67 | GLfloat pixelContourColour[3];
|
---|
68 | GLfloat patchesCoulour[3];
|
---|
69 | GLfloat highlightedPatchesCoulour[3];
|
---|
70 | GLfloat highlightedPixelsCoulour[3];
|
---|
71 | GLfloat tooHighValueCoulour[3];
|
---|
72 | GLfloat tooLowValueCoulour[3];
|
---|
73 |
|
---|
74 | std::string dataText;
|
---|
75 | std::string unitsText;
|
---|
76 | std::string titleText;
|
---|
77 |
|
---|
78 | void setUnits(const std::string& units);
|
---|
79 | void setTitle(const std::string& title);
|
---|
80 | void SetWhite(int idx);
|
---|
81 | void SetMin(int64_t min);
|
---|
82 | void SetMax(int64_t max);
|
---|
83 | void SetAutoRefresh(bool on);
|
---|
84 | void updateCamera();
|
---|
85 | void assignPixelMap(const PixelMap& );
|
---|
86 | void assignTriggerPatchesMap(const std::vector<int>& );
|
---|
87 |
|
---|
88 | float ss[5];// = {0.00, 0.25, 0.5, 0.75, 1.00};
|
---|
89 | float rr[5];// = {0.15, 0.00, 0.00, 1.00, 0.85};
|
---|
90 | float gg[5];// = {0.15, 0.00, 1.00, 0.00, 0.85};
|
---|
91 | float bb[5];// = {0.15, 1.00, 0.00, 0.00, 0.85};
|
---|
92 |
|
---|
93 | public Q_SLOTS:
|
---|
94 | void linearScalePlease(bool);
|
---|
95 | void logScalePlease(bool);
|
---|
96 | void regularPalettePlease(bool);
|
---|
97 | void prettyPalettePlease(bool);
|
---|
98 | void greyScalePalettePlease(bool);
|
---|
99 | void glowingPalettePlease(bool);
|
---|
100 | void zeroRotationPlease(bool);
|
---|
101 | void plus90RotationPlease(bool);
|
---|
102 | void minus90RotationPlease(bool);
|
---|
103 | void timedUpdate();
|
---|
104 |
|
---|
105 | Q_SIGNALS:
|
---|
106 | void signalCurrentPixel(int pixel);
|
---|
107 | void signalPixelMoveOver(int pixel);
|
---|
108 | void signalPixelDoubleClick(int pixel);
|
---|
109 | void colorPaletteHasChanged();
|
---|
110 | void signalUpdateCamera();
|
---|
111 |
|
---|
112 |
|
---|
113 |
|
---|
114 | protected:
|
---|
115 | virtual void initializeGL();
|
---|
116 | virtual void resizeGL(int width, int height);
|
---|
117 | virtual void paintGL();
|
---|
118 | virtual void mousePressEvent(QMouseEvent *event);
|
---|
119 | virtual void mouseMoveEvent(QMouseEvent *event);
|
---|
120 | virtual void mouseDoubleClickEvent(QMouseEvent *event);
|
---|
121 | virtual void drawCamera(bool alsoWire);
|
---|
122 | virtual void drawPatches();
|
---|
123 | virtual void setPatchColor(int id, float color[3]);
|
---|
124 | virtual int PixelAtPosition(const QPoint &pos);
|
---|
125 | virtual void DrawCameraText();
|
---|
126 | void drawHexagon(int index, bool solid);
|
---|
127 |
|
---|
128 | int fPixelStride;
|
---|
129 | int fcSlice;
|
---|
130 | std::vector<double>fData;
|
---|
131 |
|
---|
132 | // bool recalcColorPlease;
|
---|
133 | static GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
|
---|
134 | static PixelsNeighbors neighbors[MAX_NUM_PIXELS];
|
---|
135 | static int hardwareMapping[NPIX];
|
---|
136 | GLfloat pixelsColor[NPIX][3];
|
---|
137 | static GLfloat verticesList[NPIX*6][2];
|
---|
138 | static std::vector<edge> patchesIndices[160];
|
---|
139 | static int verticesIndices[NPIX][6];
|
---|
140 | static int pixelsPatch[NPIX];
|
---|
141 | static int softwareMapping[NPIX];
|
---|
142 | static int patches[160][9];
|
---|
143 | float shownSizex;
|
---|
144 | float shownSizey;
|
---|
145 | float pixelSize;
|
---|
146 | virtual void UpdateText();
|
---|
147 | void DrawScale();
|
---|
148 | void toggleInterfaceDisplay();
|
---|
149 | QRadioButton* linearButton;
|
---|
150 | QRadioButton* logButton;
|
---|
151 | QRadioButton* regularPaletteButton;
|
---|
152 | QRadioButton* prettyPaletteButton;
|
---|
153 | QRadioButton* greyScalePaletteButton;
|
---|
154 | QRadioButton* glowingPaletteButton;
|
---|
155 | QRadioButton* zeroRotationButton;
|
---|
156 | QRadioButton* minus90RotationButton;
|
---|
157 | QRadioButton* plus90Rotationbutton;
|
---|
158 | QLabel* scaleLabel;
|
---|
159 | QLabel* colorPaletteLabel;
|
---|
160 | QLabel* rotationLabel;
|
---|
161 | QButtonGroup* scaleGroup;
|
---|
162 | QButtonGroup* colorGroup;
|
---|
163 | QButtonGroup* rotationGroup;
|
---|
164 |
|
---|
165 |
|
---|
166 | bool logScale;
|
---|
167 | int cameraRotation;
|
---|
168 | void buildVerticesList();
|
---|
169 | virtual void buildPatchesIndices();
|
---|
170 | void updateNeighbors(int currentPixel);
|
---|
171 | void calculatePixelsCoords();
|
---|
172 | float viewSize;
|
---|
173 | bool autoRefresh;
|
---|
174 |
|
---|
175 | private:
|
---|
176 | void skipPixels(int start, int howMany);
|
---|
177 | float hexRadius;
|
---|
178 | float hexTolerance;
|
---|
179 | int numVertices;
|
---|
180 | protected:
|
---|
181 | float fmin, fmax, fmean, frms, fmedian;
|
---|
182 |
|
---|
183 |
|
---|
184 | };
|
---|
185 |
|
---|
186 | #endif
|
---|