-
Notifications
You must be signed in to change notification settings - Fork 0
/
GLContainer.h
99 lines (71 loc) · 1.93 KB
/
GLContainer.h
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
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef GLCONTAINER_H
#define GLCONTAINER_H
#include "stdafx.h"
#include "GLWidget.h"
class GLContainer : public QAbstractScrollArea
{
Q_OBJECT
public:
// constructor
GLContainer(QWidget *parent = 0);
// for Qt internal use
void setWidget(QWidget *widget);
QWidget *widget() const;
// get renderer
GLWidget* GetGLWidget();
QSize GetCanvasSize();
void SetCanvas(int canvas_witdh, int canvas_height);
// set up scrolls (vertical and horizontal)
void SetScrolls();
protected:
// global event
bool event( QEvent * event );
// draw
void paintEvent(QPaintEvent *event);
// mouse events
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
// mouse wheel
void wheelEvent(QWheelEvent* event);
// keyboard
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
private:
GLWidget* glWidget;
QPoint prevScrollPos;
QPoint prevMousePos;
bool ctrlPressed;
bool mousePressed;
int sWidth;
int sHeight;
QPoint mousePos;
// for updating opengl when scrolling display
float xPrevF;
float yPrevF;
float prevZoomFactor;
// previous number of strokes (not used)
int prevNum;
// timer for double click
QTimer* doubleClickTimer;
// timing for double click
int doubleClickTimeout;
private:
// update opengl viewport
void UpdateViewport(bool putInMiddle = false);
signals:
// send message to UI (bottom left)
//void SendMessage(QString msg);
// drawing stroke is released (not used)
//void StrokeRelease();
// tell system to update
//void UpdateThings();
private slots:
// vertical scroll
void VScrollChanged(int val);
// horizontal scroll
void HScrollChanged(int val);
// for double click effect
void DummyFunction();
};
#endif // GLCONTAINER_H