-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSVGObject.cpp
More file actions
executable file
·84 lines (72 loc) · 2.26 KB
/
SVGObject.cpp
File metadata and controls
executable file
·84 lines (72 loc) · 2.26 KB
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
//------------------------------------------------------------------------------
/// Filename: SVGObject.cpp
/// Description: Base Class of SVG Objects
/// Authors:
/// Ralph Ankele(0931953)
/// Tutor: Manuel Weber
/// Group: 24
/// Created: 08.09.2011
/// Last change: 25.09.2011
//------------------------------------------------------------------------------
#include "SVGObject.h"
#include "UserInterface.h"
#include "Database.h"
//------------------------------------------------------------------------------
SVGObject::SVGObject(UserInterface *ui,
Database *db,
SVGHandler *svgh,
signed int id,
signed int group_id,
std::vector<Coordinates> coordinates):
ui_(ui),
db_(db),
svgh_(svgh),
id_(id),
group_id_(group_id),
coordinates_(coordinates)
{
}
//------------------------------------------------------------------------------
SVGObject::~SVGObject() throw()
{
}
//------------------------------------------------------------------------------
bool SVGObject::move(signed int x, signed int y)
{
coordinates_.front().setX(coordinates_.front().getX() + x);
coordinates_.front().setY(coordinates_.front().getY() + y);
return true;
}
//------------------------------------------------------------------------------
bool SVGObject::rotate(std::string direction)
{
signed int x_temp = 0, y_temp = 0;
signed int x_start = 0, y_start = 0;
x_start = coordinates_.front().getX();
y_start = coordinates_.front().getY();
move(-x_start, -y_start);
if(!direction.compare("cw"))
{
for(std::vector<Coordinates>::iterator it = coordinates_.begin() + 1;
it != coordinates_.end(); ++it)
{
x_temp = (*it).getX();
y_temp = (*it).getY();
(*it).setX(-y_temp);
(*it).setY(x_temp);
}
}
if(!direction.compare("ccw"))
{
for(std::vector<Coordinates>::iterator it = coordinates_.begin() + 1;
it != coordinates_.end(); ++it)
{
x_temp = (*it).getX();
y_temp = (*it).getY();
(*it).setX(y_temp);
(*it).setY(-x_temp);
}
}
move(x_start, y_start);
return true;
}