File: MatrixGLWidget.hpp

package info (click to toggle)
vite 1.4-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,112 kB
  • sloc: cpp: 30,167; makefile: 467; sh: 233; python: 140; ansic: 67
file content (86 lines) | stat: -rw-r--r-- 1,884 bytes parent folder | download | duplicates (3)
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
82
83
84
85
86
/**
 *
 * @file plugins/MatrixVisualizer/Windows/MatrixGLWidget.hpp
 *
 * @copyright 2008-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 *                      Univ. Bordeaux. All rights reserved.
 *
 * @author Camille Ordronneau
 * @author Arthur Chevalier
 * @author Johnny Jazeix
 * @author Mathieu Faverge
 *
 * @date 2024-07-17
 */
#ifndef MATRIX_GL_WIDGET_HPP
#define MATRIX_GL_WIDGET_HPP

#include "Configuration.hpp"

#include <QLabel>
#include <QElapsedTimer>

#include <QOpenGLFunctions>
#include <QOpenGLWidget>
#include <QKeyEvent>

#include <stack>

class Zoom;

class MatrixGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
public:
    MatrixGLWidget(QWidget *parent, symbol_matrix_t *matrix, QLabel *label, bool quadtree_checked);
    ~MatrixGLWidget();

protected:
    void initializeGL() override;
    void resizeGL(int w, int h) override;
    void paintGL() override;

    void keyPressEvent(QKeyEvent *keyEvent) override;

    void mousePressEvent(QMouseEvent *mouseEvent) override;
    void mouseReleaseEvent(QMouseEvent *mouseEvent) override;
    void mouseMoveEvent(QMouseEvent *mouseEvent) override;

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;
    QElapsedTimer m_time;
    QLabel *m_label;

    char m_fpsString[256] = { '\0' };

    double m_qtToGLWidthCoeff;
    double m_qtToGLHeightCoeff;

    // Zoom
    Zoom *m_zoom;
    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