-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSVGRect.cpp
executable file
·106 lines (94 loc) · 3.01 KB
/
SVGRect.cpp
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
//------------------------------------------------------------------------------
/// Filename: SVGRect.cpp
/// Description: Base Class of SVG Objects
/// Authors:
/// Robin Ankele(0931953)
/// Tutor: Manuel Weber
/// Group: 24
/// Created: 08.09.2011
/// Last change: 25.09.2011
//------------------------------------------------------------------------------
#include "SVGRect.h"
#include "UserInterface.h"
#include "Database.h"
#include "SVGHandler.h"
#include <iostream>
//------------------------------------------------------------------------------
SVGRect::SVGRect(UserInterface *ui,
Database *db,
SVGHandler *svgh,
signed int id,
signed int group_id,
std::vector<Coordinates> coordinates,
signed int width,
signed int height,
std::string fill,
std::string stroke,
std::string stroke_width): SVGObject(ui, db, svgh, id,
group_id, coordinates),
width_(width),
height_(height),
fill_(""),
stroke_(""),
stroke_width_(stroke_width)
{
fill_.assign(fill);
stroke_.assign(stroke);
}
//------------------------------------------------------------------------------
SVGRect::~SVGRect() throw()
{
}
//------------------------------------------------------------------------------
bool SVGRect::resize()
{
std::string str_value;
std::cout << "id: " << id_ << std::endl;
std::cout << "width: " << width_ << std::endl;
std::cout << "height: " << height_ << std::endl;
while(true)
{
if(ui_->getParam(" width? ", false, false, width_, str_value, true))
break;
}
while(true)
{
if(ui_->getParam(" height? ", false, false, height_, str_value, true))
break;
}
return true;
}
//------------------------------------------------------------------------------
bool SVGRect::rotate(std::string direction)
{
signed int temp_height = height_;
signed int temp_width = width_;
if(!direction.compare("cw"))
{
height_ = temp_width;
width_ = -temp_height;
return true;
}
if(!direction.compare("ccw"))
{
height_ = -temp_width;
width_ = temp_height;
return true;
}
return false;
}
//------------------------------------------------------------------------------
std::string SVGRect::getSVGTag()
{
tag_ << "<rect ";
for (std::vector<Coordinates>::iterator it = coordinates_.begin();
it != coordinates_.end(); ++it)
{
tag_ << "x=\"" << (*it).getX() << "\" ";
tag_ << "y=\"" << (*it).getY() << "\" ";
}
tag_ << "width=\"" << width_ << "\" height=\"" << height_ << "\" fill=\""
<< fill_ << "\" stroke=\"" << stroke_ << "\" stroke-width=\""
<< stroke_width_ <<"\" />";
return tag_.str();
}