-
Notifications
You must be signed in to change notification settings - Fork 8
/
zoomwidget.hpp
87 lines (62 loc) · 1.54 KB
/
zoomwidget.hpp
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
#ifndef ZOOMWIDGET_HPP
#define ZOOMWIDGET_HPP
#include <QGLWidget>
namespace Ui {
class zoomwidget;
}
// User data structs.
struct UserObjectData {
QPoint startPoint;
QPoint endPoint;
QPen pen;
};
enum ZoomWidgetState {
STATE_MOVING,
STATE_DRAWING,
};
enum ZoomWidgetDrawMode {
DRAWMODE_ARROW,
DRAWMODE_LINE,
DRAWMODE_RECT,
};
class ZoomWidget : public QGLWidget
{
Q_OBJECT
public:
explicit ZoomWidget(QWidget *parent = 0);
~ZoomWidget();
void grabDesktop();
protected:
virtual void paintEvent(QPaintEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void wheelEvent(QWheelEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
private:
Ui::zoomwidget *ui;
// Desktop pixmap properties.
QPixmap _desktopPixmap;
QPoint _desktopPixmapPos;
QSize _desktopPixmapSize;
float _desktopPixmapScale;
// User objects.
QVector<UserObjectData> _userRects;
QVector<UserObjectData> _userLines;
// Moving properties.
int _shiftMultiplier;
float _scaleSensivity;
ZoomWidgetState _state;
QPoint _lastMousePos;
// Drawing properties.
ZoomWidgetDrawMode _drawMode;
QPoint _startDrawPoint;
QPoint _endDrawPoint;
QPen _activePen;
void shiftPixmap(const QPoint delta);
void scalePixmapAt(const QPoint pos);
void checkPixmapPos();
void getRealUserObjectPos(const UserObjectData &userObj, int *x, int *y, int *w, int *h);
};
#endif // ZOOMWIDGET_HPP