| 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 | using namespace std;
|
|---|
| 22 | //#include <QtGui/QMouseEvent>
|
|---|
| 23 | ///structure for storing edges of hexagons (for blurry display)
|
|---|
| 24 | struct edge
|
|---|
| 25 | {
|
|---|
| 26 | int first;
|
|---|
| 27 | int second;
|
|---|
| 28 | };
|
|---|
| 29 |
|
|---|
| 30 | ///structure for storing neighbors of pixels. For camera position calculation and blurry display
|
|---|
| 31 | struct 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 |
|
|---|
| 43 | class BasicGlCamera : public QGLWidget
|
|---|
| 44 | {
|
|---|
| 45 | Q_OBJECT
|
|---|
| 46 |
|
|---|
| 47 | public:
|
|---|
| 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 |
|
|---|
| 77 | float ss[5];// = {0.00, 0.25, 0.5, 0.75, 1.00};
|
|---|
| 78 | float rr[5];// = {0.15, 0.00, 0.00, 1.00, 0.85};
|
|---|
| 79 | float gg[5];// = {0.15, 0.00, 1.00, 0.00, 0.85};
|
|---|
| 80 | float bb[5];// = {0.15, 1.00, 0.00, 0.00, 0.85};
|
|---|
| 81 |
|
|---|
| 82 | public Q_SLOTS:
|
|---|
| 83 | void linearScalePlease(bool);
|
|---|
| 84 | void logScalePlease(bool);
|
|---|
| 85 | void regularPalettePlease(bool);
|
|---|
| 86 | void prettyPalettePlease(bool);
|
|---|
| 87 | void greyScalePalettePlease(bool);
|
|---|
| 88 | void glowingPalettePlease(bool);
|
|---|
| 89 | void zeroRotationPlease(bool);
|
|---|
| 90 | void plus90RotationPlease(bool);
|
|---|
| 91 | void minus90RotationPlease(bool);
|
|---|
| 92 |
|
|---|
| 93 | Q_SIGNALS:
|
|---|
| 94 | void signalCurrentPixel(int pixel);
|
|---|
| 95 | void signalPixelMoveOver(int pixel);
|
|---|
| 96 | void signalPixelDoubleClick(int pixel);
|
|---|
| 97 | void colorPaletteHasChanged();
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 | protected:
|
|---|
| 102 | virtual void initializeGL();
|
|---|
| 103 | virtual void resizeGL(int width, int height);
|
|---|
| 104 | virtual void paintGL();
|
|---|
| 105 | virtual void mousePressEvent(QMouseEvent *event);
|
|---|
| 106 | virtual void mouseMoveEvent(QMouseEvent *event);
|
|---|
| 107 | virtual void mouseDoubleClickEvent(QMouseEvent *event);
|
|---|
| 108 | virtual void drawCamera(bool alsoWire);
|
|---|
| 109 | virtual void drawPatches();
|
|---|
| 110 | int PixelAtPosition(const QPoint &pos);
|
|---|
| 111 | void drawHexagon(int index, bool solid);
|
|---|
| 112 |
|
|---|
| 113 | int fPixelStride;
|
|---|
| 114 | int fcSlice;
|
|---|
| 115 | vector<double>fData;
|
|---|
| 116 |
|
|---|
| 117 | // bool recalcColorPlease;
|
|---|
| 118 | GLfloat pixelsCoords[MAX_NUM_PIXELS][3];
|
|---|
| 119 | PixelsNeighbors neighbors[MAX_NUM_PIXELS];
|
|---|
| 120 | int hardwareMapping[NPIX];
|
|---|
| 121 | GLfloat pixelsColor[NPIX][3];
|
|---|
| 122 | GLfloat verticesList[NPIX*6][2];
|
|---|
| 123 | vector<edge> patchesIndices[160];
|
|---|
| 124 | int verticesIndices[NPIX][6];
|
|---|
| 125 | int pixelsPatch[NPIX];
|
|---|
| 126 | int softwareMapping[NPIX];
|
|---|
| 127 | int patches[160][9];
|
|---|
| 128 | float shownSizex;
|
|---|
| 129 | float shownSizey;
|
|---|
| 130 | float pixelSize;
|
|---|
| 131 | void DrawCameraText();
|
|---|
| 132 | void UpdateText();
|
|---|
| 133 | void DrawScale();
|
|---|
| 134 | void toggleInterfaceDisplay();
|
|---|
| 135 | QRadioButton* linearButton;
|
|---|
| 136 | QRadioButton* logButton;
|
|---|
| 137 | QRadioButton* regularPaletteButton;
|
|---|
| 138 | QRadioButton* prettyPaletteButton;
|
|---|
| 139 | QRadioButton* greyScalePaletteButton;
|
|---|
| 140 | QRadioButton* glowingPaletteButton;
|
|---|
| 141 | QRadioButton* zeroRotationButton;
|
|---|
| 142 | QRadioButton* minus90RotationButton;
|
|---|
| 143 | QRadioButton* plus90Rotationbutton;
|
|---|
| 144 | QLabel* scaleLabel;
|
|---|
| 145 | QLabel* colorPaletteLabel;
|
|---|
| 146 | QLabel* rotationLabel;
|
|---|
| 147 | QButtonGroup* scaleGroup;
|
|---|
| 148 | QButtonGroup* colorGroup;
|
|---|
| 149 | QButtonGroup* rotationGroup;
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 | bool logScale;
|
|---|
| 153 | int cameraRotation;
|
|---|
| 154 | void buildVerticesList();
|
|---|
| 155 | virtual void buildPatchesIndices();
|
|---|
| 156 | void updateNeighbors(int currentPixel);
|
|---|
| 157 | void calculatePixelsCoords();
|
|---|
| 158 | float viewSize;
|
|---|
| 159 | private:
|
|---|
| 160 | void skipPixels(int start, int howMany);
|
|---|
| 161 | float hexRadius;
|
|---|
| 162 | float hexTolerance;
|
|---|
| 163 | int numVertices;
|
|---|
| 164 |
|
|---|
| 165 | };
|
|---|
| 166 |
|
|---|
| 167 | #endif
|
|---|