source: trunk/FACT++/gui/BasicGlCamera.h@ 11967

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