-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawingObjects.h
197 lines (158 loc) · 5.07 KB
/
drawingObjects.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#ifndef DRAWINGOBJECTS_H
#define DRAWINGOBJECTS_H
#include <QObject>
#include <QPainter>
#include "globals.h"
#define _POINT_OBJECT_SIZE 7
class PaintQLabel;
class drawingObject {
public:
drawingObject();
drawingObject(PaintQLabel* parent);
drawingObject(const drawingObject &other):
m_pRect(other.m_pRect),
m_bHighLight(other.m_bHighLight),
m_pParent(other.m_pParent),
m_fillColour(other.m_fillColour),
m_type(other.m_type),
m_bClickedItem(other.m_bClickedItem),
m_bHoveredOver(other.m_bHoveredOver),
m_bSelected(other.m_bSelected),
m_bDragging(other.m_bDragging),
ID(other.ID),
name(other.name),
desc(other.desc),
regionType(other.regionType),
m_ImageIndex(other.m_ImageIndex){ }
~drawingObject();
virtual void moveObject(QPoint offset);
virtual void draw(QPainter* painter) = 0;
virtual bool hitTest(QPoint pt, bool bMouseDown = false) = 0;
virtual const QPoint getCenter() { return m_pRect->center(); }
//QBrush getFillBrush() {};
void getPenBrush(QPainter* painter);
void setHighlight(bool bHighlight) {
m_bHighLight = bHighlight;
}
// variables
QSharedPointer<QRect> m_pRect;
bool m_bHighLight;
// image scale parameters
PaintQLabel* m_pParent;
// drawing parameters
drawingColour::colour m_fillColour;
drawingMode::drawingMode m_type;
// state parameters
bool m_bClickedItem;
bool m_bHoveredOver;
bool m_bSelected;
bool m_bDragging;
// annotation information
QString ID;
QString name;
QString desc;
shapeAnnotationType::Type regionType;
// which image does object belong to
int m_ImageIndex;
protected:
};
class pointObject : public drawingObject {
public:
pointObject() { m_objectSize = QSize(_POINT_OBJECT_SIZE, _POINT_OBJECT_SIZE); m_pRect->setWidth(1); m_pRect->setHeight(1); };
pointObject(PaintQLabel* parent) : drawingObject(parent) {m_objectSize = QSize(_POINT_OBJECT_SIZE, _POINT_OBJECT_SIZE);};
pointObject(const pointObject &other) : drawingObject(other), m_objectSize(other.m_objectSize), m_pointCenter(other.m_pointCenter) {};
const QPoint getCenter() { return m_pRect->center(); }
const QSize getSize() { return m_objectSize; }
protected:
QSize m_objectSize;
private:
QPoint m_pointCenter;
};
class rectObject : public drawingObject {
public:
rectObject() {};
rectObject(const rectObject &other) : drawingObject(other) {};
rectObject(PaintQLabel* parent) : drawingObject(parent) {};
void drawRect(QPainter* painter);
};
class drawingRect : public rectObject
{
public:
drawingRect(){};
drawingRect(PaintQLabel* parent) : rectObject(parent) {};
drawingRect(const drawingRect &other) : rectObject(other){};
void draw(QPainter* painter) { rectObject::drawRect(painter); };
bool hitTest(QPoint pt, bool bMouseDown = false);
protected:
};
class drawingEllipse : public rectObject
{
public:
drawingEllipse(PaintQLabel* parent) : rectObject(parent) {};
void draw(QPainter* painter);
bool hitTest(QPoint pt, bool bMouseDown = false);
protected:
};
class drawingPoly : public rectObject
{
public:
drawingPoly(PaintQLabel* parent) : rectObject(parent) { m_pPoly = QSharedPointer<QPolygon>(new QPolygon); };
drawingPoly() : rectObject() { m_pPoly = QSharedPointer<QPolygon>(new QPolygon); }
drawingPoly(const drawingPoly &other) : rectObject(other) {
drawingPoly& poly = (drawingPoly)other;
for (int i = 0; i < poly.m_pPoly->length(); i++)
m_pPoly->append(poly.m_pPoly->at(i));
};
~drawingPoly() { m_pPoly->empty(); }
void moveObject(QPoint offset);
void draw(QPainter* painter);
bool hitTest(QPoint pt, bool bMouseDown = false);
void addPoint(QPoint pt) { m_pPoly->append(pt); };
QSharedPointer<QPolygon> getPoly() { return m_pPoly; };
protected:
QSharedPointer<QPolygon> m_pPoly;
};
class drawingSampling : public drawingPoly
{
public:
drawingSampling(PaintQLabel* parent) : drawingPoly(parent) {};
drawingSampling() : drawingPoly() {};
void draw(QPainter* painter);
bool hitTest(QPoint pt, bool bMouseDown = false);
void addPoint(QPoint pt) {
if(m_pPoly->length()>2)
m_pPoly->remove(0); // keep only three points in list
m_pPoly->append(pt);
};
};
class drawingFiducial : public pointObject
{
public:
drawingFiducial(PaintQLabel* parent) : pointObject(parent) { m_position = FIDUCIAL::topleft_overview; };
drawingFiducial(const drawingFiducial &other) : pointObject(other) {};
void setPosition(FIDUCIAL::position position) { m_position = position; };
FIDUCIAL::position getPosition() { return m_position; };
void draw(QPainter* painter);
bool hitTest(QPoint pt, bool bMouseDown = false);
protected:
FIDUCIAL::position m_position;
};
class drawingMoveObjective : public pointObject
{
public:
drawingMoveObjective(PaintQLabel* parent) : pointObject(parent) {};
drawingMoveObjective(const drawingMoveObjective &other) : pointObject(other) {};
void draw(QPainter* painter);
bool hitTest(QPoint pt, bool bMouseDown = false);
protected:
};
class drawingCross : public pointObject
{
public:
drawingCross(PaintQLabel* parent) : pointObject(parent) {};
drawingCross(const drawingCross &other) : pointObject(other) {};
void draw(QPainter* painter);
bool hitTest(QPoint pt, bool bMouseDown = false);
protected:
};
#endif