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

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