| 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 | virtual 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[NPIX][3];
|
|---|
| 67 | GLfloat verticesList[NPIX*6][2];
|
|---|
| 68 | vector<edge> patchesIndices[160];
|
|---|
| 69 | int verticesIndices[NPIX][6];
|
|---|
| 70 | int pixelsPatch[NPIX];
|
|---|
| 71 | int softwareMapping[NPIX];
|
|---|
| 72 | int patches[160][9];
|
|---|
| 73 | float shownSizex;
|
|---|
| 74 | float shownSizey;
|
|---|
| 75 | float pixelSize;
|
|---|
| 76 | private:
|
|---|
| 77 | void updateNeighbors(int currentPixel);
|
|---|
| 78 | void skipPixels(int start, int howMany);
|
|---|
| 79 | void calculatePixelsCoords();
|
|---|
| 80 | void buildVerticesList();
|
|---|
| 81 | void buildPatchesIndices();
|
|---|
| 82 | float hexRadius;
|
|---|
| 83 | float hexTolerance;
|
|---|
| 84 | float viewSize;
|
|---|
| 85 | GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
|
|---|
| 86 | PixelsNeighbors neighbors[MAX_NUM_PIXELS];
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | int hardwareMapping[NPIX];
|
|---|
| 90 | int numVertices;
|
|---|
| 91 |
|
|---|
| 92 | };
|
|---|
| 93 |
|
|---|
| 94 | #endif
|
|---|