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

Last change on this file since 12957 was 12300, checked in by lyard, 13 years ago
added RMS tab and fixed time for old format
File size: 4.9 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 <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)
25struct edge
26{
27 int first;
28 int second;
29};
30
31///structure for storing neighbors of pixels. For camera position calculation and blurry display
32struct 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
44class BasicGlCamera : public QGLWidget
45{
46 Q_OBJECT
47
48public:
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 static int pixelsPatch[NPIX];
64
65 bool pixelColorUpToDate;
66
67 GLfloat patchColour[3];
68 GLfloat pixelContourColour[3];
69 GLfloat patchesCoulour[3];
70 GLfloat highlightedPatchesCoulour[3];
71 GLfloat highlightedPixelsCoulour[3];
72 GLfloat tooHighValueCoulour[3];
73 GLfloat tooLowValueCoulour[3];
74
75 std::string dataText;
76 std::string unitsText;
77 std::string titleText;
78
79 void setUnits(const std::string& units);
80 void setTitle(const std::string& title);
81 void SetWhite(int idx);
82 void SetMin(int64_t min);
83 void SetMax(int64_t max);
84 void SetAutoRefresh(bool on);
85 void updateCamera();
86 void assignPixelMap(const PixelMap& );
87 void enableText(bool);
88
89 bool fTextEnabled;
90
91 float ss[5];// = {0.00, 0.25, 0.5, 0.75, 1.00};
92 float rr[5];// = {0.15, 0.00, 0.00, 1.00, 0.85};
93 float gg[5];// = {0.15, 0.00, 1.00, 0.00, 0.85};
94 float bb[5];// = {0.15, 1.00, 0.00, 0.00, 0.85};
95
96public Q_SLOTS:
97 void linearScalePlease(bool);
98 void logScalePlease(bool);
99 void regularPalettePlease(bool);
100 void prettyPalettePlease(bool);
101 void greyScalePalettePlease(bool);
102 void glowingPalettePlease(bool);
103 void zeroRotationPlease(bool);
104 void plus90RotationPlease(bool);
105 void minus90RotationPlease(bool);
106 void timedUpdate();
107
108Q_SIGNALS:
109 void signalCurrentPixel(int pixel);
110 void signalPixelMoveOver(int pixel);
111 void signalPixelDoubleClick(int pixel);
112 void colorPaletteHasChanged();
113 void signalUpdateCamera();
114
115
116
117protected:
118 virtual void initializeGL();
119 virtual void resizeGL(int width, int height);
120 virtual void paintGL();
121 virtual void mousePressEvent(QMouseEvent *event);
122 virtual void mouseMoveEvent(QMouseEvent *event);
123 virtual void mouseDoubleClickEvent(QMouseEvent *event);
124 virtual void drawCamera(bool alsoWire);
125 virtual void drawPatches();
126 virtual void setPatchColor(int id, float color[3]);
127 virtual int PixelAtPosition(const QPoint &pos);
128 virtual void DrawCameraText();
129 void drawHexagon(int index, bool solid);
130
131 int fPixelStride;
132 int fcSlice;
133 std::vector<double>fData;
134
135 // bool recalcColorPlease;
136 static GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
137 static PixelsNeighbors neighbors[MAX_NUM_PIXELS];
138 static int hardwareMapping[NPIX];
139 GLfloat pixelsColor[NPIX][3];
140 static GLfloat verticesList[NPIX*6][2];
141 static std::vector<edge> patchesIndices[160];
142 static int verticesIndices[NPIX][6];
143 static int softwareMapping[NPIX];
144 float shownSizex;
145 float shownSizey;
146 float pixelSize;
147 virtual void UpdateText();
148 void DrawScale();
149 void toggleInterfaceDisplay();
150 QRadioButton* linearButton;
151 QRadioButton* logButton;
152 QRadioButton* regularPaletteButton;
153 QRadioButton* prettyPaletteButton;
154 QRadioButton* greyScalePaletteButton;
155 QRadioButton* glowingPaletteButton;
156 QRadioButton* zeroRotationButton;
157 QRadioButton* minus90RotationButton;
158 QRadioButton* plus90Rotationbutton;
159 QLabel* scaleLabel;
160 QLabel* colorPaletteLabel;
161 QLabel* rotationLabel;
162 QButtonGroup* scaleGroup;
163 QButtonGroup* colorGroup;
164 QButtonGroup* rotationGroup;
165
166
167 bool logScale;
168 int cameraRotation;
169 void buildVerticesList();
170 virtual void buildPatchesIndices();
171 void updateNeighbors(int currentPixel);
172 void calculatePixelsCoords();
173 float viewSize;
174 bool autoRefresh;
175
176 private:
177 void skipPixels(int start, int howMany);
178 float hexRadius;
179 float hexTolerance;
180 int numVertices;
181 protected:
182 float fmin, fmax, fmean, frms, fmedian;
183
184
185};
186
187#endif
Note: See TracBrowser for help on using the repository browser.