-
Notifications
You must be signed in to change notification settings - Fork 0
/
ovalViewer.h
111 lines (85 loc) · 2.68 KB
/
ovalViewer.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
100
101
102
103
104
105
106
107
108
109
110
111
//
// Created by Hugo Ayala on 5/16/24.
//
#ifndef OVALVIEWER_H
#define OVALVIEWER_H
#include <vector>
#include <QWidget>
#include "ovalRasterizer.h"
/** ----------------------------------------------------------------------------
\class mouse_cmd
---------------------------------------------------------------------------- */
class mouse_cmd
{
public:
virtual ~mouse_cmd() = default;
virtual void update( const QPoint& pos ) = 0;
};
/** ----------------------------------------------------------------------------
\class ovalViewer
---------------------------------------------------------------------------- */
class ovalViewer : public QWidget
{
Q_OBJECT
public:
ovalViewer( QWidget *parent = nullptr );
int scale() const { return scale_; }
public slots:
void dumpOvalRender();
void clearOvals();
void writeOvals();
protected:
void paintEvent( QPaintEvent *event ) override;
void mousePressEvent( QMouseEvent *event ) override;
void mouseMoveEvent( QMouseEvent *event ) override;
void mouseReleaseEvent( QMouseEvent *event ) override;
private:
void renderOnePixel( const QPoint& where );
std::vector<ovalRecord> ovalList_;
mouse_cmd *cmd_;
int scale_;
QString msg_;
};
/** ----------------------------------------------------------------------------
\class move_oval_cmd
---------------------------------------------------------------------------- */
class move_oval_cmd : public mouse_cmd
{
public:
move_oval_cmd( ovalViewer *view, ovalRecord *oval, const QPoint& where );
void update( const QPoint& pos ) override;
private:
ovalViewer *view_;
ovalRecord *oval_;
QPoint start_;
float centerx_;
float centery_;
};
/** ----------------------------------------------------------------------------
\class rotate_oval_cmd
---------------------------------------------------------------------------- */
class rotate_oval_cmd : public mouse_cmd
{
public:
rotate_oval_cmd( ovalViewer *view, ovalRecord *oval, const QPoint& where );
void update( const QPoint& pos ) override;
private:
ovalViewer *view_;
ovalRecord *oval_;
QPoint start_;
float angle_;
};
/** ----------------------------------------------------------------------------
\class new_oval_cmd
---------------------------------------------------------------------------- */
class new_oval_cmd : public mouse_cmd
{
public:
new_oval_cmd( ovalViewer *view, ovalRecord *oval, const QPoint& where );
void update( const QPoint& pos ) override;
private:
ovalViewer *view_;
ovalRecord *oval_;
QPoint start_;
};
#endif //OVALVIEWER_H