1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#ifndef MATRIX_GL_WIDGET_HPP
#define MATRIX_GL_WIDGET_HPP
#include "Configuration.hpp"
#include <QtOpenGL/QtOpenGL>
#ifdef USE_QT5
#include <QOpenGLFunctions>
#include <QOpenGLWidget>
#else
#include <QGLWidget>
#endif
#include <QKeyEvent>
#include <stack>
#include "../Formats/SymbolMatrix.hpp"
#include "../Common/Zooming.hpp"
class MatrixGLWidget :
#ifdef USE_QT5
public QOpenGLWidget, protected QOpenGLFunctions
#else
public QGLWidget
#endif
{
public:
MatrixGLWidget(QWidget* parent, symbol_matrix_t* matrix, QLabel* label);
~MatrixGLWidget();
protected:
void initializeGL() override;
void resizeGL(int w, int h) override;
void paintGL() override;
void keyPressEvent(QKeyEvent *keyEvent);
void mousePressEvent(QMouseEvent* mouseEvent);
void mouseReleaseEvent(QMouseEvent* mouseEvent);
void mouseMoveEvent(QMouseEvent* mouseEvent);
private:
typedef struct CameraPosition
{
double m_cameraX;
double m_cameraY;
double m_cameraDx;
double m_cameraDy;
} CameraPosition;
private:
void refreshCamera();
private:
uint32_t m_frameCount;
QTime m_time;
QLabel* m_label;
char m_fpsString[256] = { '\0' };
double m_qtToGLWidthCoeff;
double m_qtToGLHeightCoeff;
// Zoom
Zooming* m_zooming;
int m_mouseXClicked;
int m_mouseYClicked;
CameraPosition m_camera;
int m_drawTempSelection = 0;
int m_tempSelectionX = 0;
int m_tempSelectionY = 0;
int m_tempSelectionDx = 0;
int m_tempSelectionDy = 0;
// Zoom stack
std::stack<CameraPosition> m_savedPositions;
};
#endif
|