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 1438
|
---|
10 |
|
---|
11 | #include <QtOpenGL/QGLWidget>
|
---|
12 | #include <QtGui/QMouseEvent>
|
---|
13 | #include <vector>
|
---|
14 |
|
---|
15 | using namespace std;
|
---|
16 | //#include <QtGui/QMouseEvent>
|
---|
17 | ///structure for storing edges of hexagons (for blurry display)
|
---|
18 | struct edge
|
---|
19 | {
|
---|
20 | int first;
|
---|
21 | int second;
|
---|
22 | };
|
---|
23 |
|
---|
24 | ///structure for storing neighbors of pixels. For camera position calculation and blurry display
|
---|
25 | struct PixelsNeighbors
|
---|
26 | {
|
---|
27 | //neighbors. clockwise, starting from top
|
---|
28 | int neighbors[6];
|
---|
29 | PixelsNeighbors()
|
---|
30 | {
|
---|
31 | for (int i=0;i<6;i++)
|
---|
32 | neighbors[i] = -1;
|
---|
33 | }
|
---|
34 | int& operator[](int index){return neighbors[index];}
|
---|
35 | };
|
---|
36 |
|
---|
37 | class BasicGlCamera : public QGLWidget
|
---|
38 | {
|
---|
39 | Q_OBJECT
|
---|
40 |
|
---|
41 | public:
|
---|
42 | BasicGlCamera(QWidget* parent = 0);
|
---|
43 | ~BasicGlCamera();
|
---|
44 |
|
---|
45 | protected:
|
---|
46 | void initializeGL();
|
---|
47 | void resizeGL(int width, int height);
|
---|
48 | virtual void paintGL();
|
---|
49 | virtual void mousePressEvent(QMouseEvent *event);
|
---|
50 | virtual void mouseMoveEvent(QMouseEvent *event);
|
---|
51 | virtual void mouseDoubleClickEvent(QMouseEvent *event);
|
---|
52 | virtual void drawCamera(bool alsoWire);
|
---|
53 | void drawPatches();
|
---|
54 | int PixelAtPosition(const QPoint &pos);
|
---|
55 | void drawHexagon(int index, bool solid);
|
---|
56 |
|
---|
57 | int fPixelStride;
|
---|
58 | int fcSlice;
|
---|
59 | vector<double>fData;
|
---|
60 |
|
---|
61 | float ss[5];// = {0.00, 0.25, 0.5, 0.75, 1.00};
|
---|
62 | float rr[5];// = {0.15, 0.00, 0.00, 1.00, 0.85};
|
---|
63 | float gg[5];// = {0.15, 0.00, 1.00, 0.00, 0.85};
|
---|
64 | float bb[5];// = {0.15, 1.00, 0.00, 0.00, 0.85};
|
---|
65 | // bool recalcColorPlease;
|
---|
66 | GLfloat pixelsColor[ACTUAL_NUM_PIXELS][3];
|
---|
67 | private:
|
---|
68 | void updateNeighbors(int currentPixel);
|
---|
69 | void skipPixels(int start, int howMany);
|
---|
70 | void calculatePixelsCoords();
|
---|
71 | void buildVerticesList();
|
---|
72 | void buildPatchesIndices();
|
---|
73 | float hexRadius;
|
---|
74 | float hexTolerance;
|
---|
75 | float viewSize;
|
---|
76 | float pixelSize;
|
---|
77 | float shownSizex;
|
---|
78 | float shownSizey;
|
---|
79 | GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
|
---|
80 | PixelsNeighbors neighbors[MAX_NUM_PIXELS];
|
---|
81 |
|
---|
82 | GLfloat verticesList[ACTUAL_NUM_PIXELS*6][2];
|
---|
83 |
|
---|
84 | int hardwareMapping[1440];
|
---|
85 | int softwareMapping[1440];
|
---|
86 | int patches[160][9];
|
---|
87 | vector<edge> patchesIndices[160];
|
---|
88 | int verticesIndices[ACTUAL_NUM_PIXELS][6];
|
---|
89 | int numVertices;
|
---|
90 |
|
---|
91 | };
|
---|
92 |
|
---|
93 | #endif
|
---|