-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolygon.cpp
More file actions
47 lines (31 loc) · 989 Bytes
/
Copy pathpolygon.cpp
File metadata and controls
47 lines (31 loc) · 989 Bytes
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
#include "polygon.h"
Polygon::Polygon(QPoint center, QPoint start) : m_center(center), m_start(start) {
}
void Polygon::draw(QPainter& painter, const Shape* selectedShape) const {
}
bool Polygon::contains(const QPoint& point) const {
QPoint pt = m_start;
if (pt.x() == -1 && pt.y() == -1) {
pt = m_center;
}
QPolygon polygon;
for (const QPoint& vertice: vertices) {
QPoint scaledVertice = (vertice - pt) * SF + pt;
polygon << scaledVertice;
}
QTransform transform;
transform.translate(pt.x(), pt.y());
transform.rotate(rotation);
transform.translate(-pt.x(), -pt.y());
QPolygon transformedPolygon = transform.map(polygon);
return transformedPolygon.containsPoint(point, Qt::OddEvenFill);
}
void Polygon::updatePos(QPoint diff) {
}
void Polygon::scale(double scalefactor) {
}
void Polygon::showInformation(QPainter& painter, int height) {
}
void Polygon::rotate(double angle){
rotation += angle;
}