-
Notifications
You must be signed in to change notification settings - Fork 4
/
GLContainer.h
92 lines (66 loc) · 1.77 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
#ifndef GLCONTAINER_H
#define GLCONTAINER_H
//#include "stdafx.h"
#include <QAbstractScrollArea>
#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();
// 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;
bool _scrollMoved;
bool _justInitialized;
private:
// update opengl viewport
void UpdateViewport(bool putInMiddle = false);
signals:
private slots:
// vertical scroll
void VScrollChanged(int val);
// horizontal scroll
void HScrollChanged(int val);
// for double click effect
void DummyFunction();
};
#endif // GLCONTAINER_H