insilmaril@0
|
1 |
#include "frameobj.h"
|
insilmaril@0
|
2 |
|
insilmaril@0
|
3 |
#include <qcolor.h>
|
insilmaril@0
|
4 |
|
insilmaril@0
|
5 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
6 |
// FrameObj
|
insilmaril@0
|
7 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
8 |
FrameObj::FrameObj() : MapObj()
|
insilmaril@0
|
9 |
{
|
insilmaril@0
|
10 |
// cout << "Const FrameObj ()\n";
|
insilmaril@0
|
11 |
init ();
|
insilmaril@0
|
12 |
}
|
insilmaril@0
|
13 |
|
insilmaril@408
|
14 |
FrameObj::FrameObj(QGraphicsScene *s) :MapObj(s)
|
insilmaril@0
|
15 |
{
|
insilmaril@0
|
16 |
// cout << "Const FrameObj\n";
|
insilmaril@0
|
17 |
init ();
|
insilmaril@0
|
18 |
}
|
insilmaril@0
|
19 |
|
insilmaril@0
|
20 |
FrameObj::~FrameObj()
|
insilmaril@0
|
21 |
{
|
insilmaril@0
|
22 |
clear();
|
insilmaril@0
|
23 |
}
|
insilmaril@0
|
24 |
|
insilmaril@0
|
25 |
void FrameObj::init()
|
insilmaril@0
|
26 |
{
|
insilmaril@0
|
27 |
type=NoFrame;
|
insilmaril@0
|
28 |
border=0;
|
insilmaril@0
|
29 |
}
|
insilmaril@0
|
30 |
|
insilmaril@0
|
31 |
void FrameObj::clear()
|
insilmaril@0
|
32 |
{
|
insilmaril@0
|
33 |
switch (type)
|
insilmaril@0
|
34 |
{
|
insilmaril@0
|
35 |
case NoFrame:
|
insilmaril@0
|
36 |
break;
|
insilmaril@0
|
37 |
case Rectangle:
|
insilmaril@0
|
38 |
delete rectFrame;
|
insilmaril@0
|
39 |
break;
|
insilmaril@0
|
40 |
}
|
insilmaril@0
|
41 |
type=NoFrame;
|
insilmaril@0
|
42 |
border=0;
|
insilmaril@0
|
43 |
}
|
insilmaril@0
|
44 |
|
insilmaril@0
|
45 |
void FrameObj::move(double x, double y)
|
insilmaril@0
|
46 |
{
|
insilmaril@0
|
47 |
switch (type)
|
insilmaril@0
|
48 |
{
|
insilmaril@0
|
49 |
case NoFrame:
|
insilmaril@0
|
50 |
break;
|
insilmaril@0
|
51 |
case Rectangle:
|
insilmaril@408
|
52 |
rectFrame->setPos (x,y);
|
insilmaril@0
|
53 |
break;
|
insilmaril@0
|
54 |
}
|
insilmaril@0
|
55 |
}
|
insilmaril@0
|
56 |
|
insilmaril@0
|
57 |
void FrameObj::moveBy(double x, double y)
|
insilmaril@0
|
58 |
{
|
insilmaril@0
|
59 |
MapObj::moveBy (x,y);
|
insilmaril@0
|
60 |
}
|
insilmaril@0
|
61 |
|
insilmaril@0
|
62 |
void FrameObj::positionBBox()
|
insilmaril@0
|
63 |
{
|
insilmaril@0
|
64 |
}
|
insilmaril@0
|
65 |
|
insilmaril@0
|
66 |
void FrameObj::calcBBoxSize()
|
insilmaril@0
|
67 |
{
|
insilmaril@0
|
68 |
}
|
insilmaril@0
|
69 |
|
insilmaril@408
|
70 |
void FrameObj::setRect(const QRectF &r)
|
insilmaril@0
|
71 |
{
|
insilmaril@0
|
72 |
bbox=r;
|
insilmaril@0
|
73 |
switch (type)
|
insilmaril@0
|
74 |
{
|
insilmaril@0
|
75 |
case NoFrame:
|
insilmaril@0
|
76 |
break;
|
insilmaril@0
|
77 |
case Rectangle:
|
insilmaril@408
|
78 |
rectFrame->setRect (QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ));
|
insilmaril@0
|
79 |
break;
|
insilmaril@0
|
80 |
}
|
insilmaril@0
|
81 |
}
|
insilmaril@0
|
82 |
|
insilmaril@0
|
83 |
int FrameObj::getBorder()
|
insilmaril@0
|
84 |
{
|
insilmaril@0
|
85 |
return border;
|
insilmaril@0
|
86 |
}
|
insilmaril@0
|
87 |
|
insilmaril@0
|
88 |
FrameType FrameObj::getFrameType()
|
insilmaril@0
|
89 |
{
|
insilmaril@0
|
90 |
return type;
|
insilmaril@0
|
91 |
}
|
insilmaril@0
|
92 |
|
insilmaril@0
|
93 |
QString FrameObj::getFrameTypeName()
|
insilmaril@0
|
94 |
{
|
insilmaril@0
|
95 |
switch (type)
|
insilmaril@0
|
96 |
{
|
insilmaril@0
|
97 |
case Rectangle:
|
insilmaril@0
|
98 |
return "Rectangle";
|
insilmaril@0
|
99 |
break;
|
insilmaril@0
|
100 |
default:
|
insilmaril@0
|
101 |
return "NoFrame";
|
insilmaril@0
|
102 |
}
|
insilmaril@0
|
103 |
}
|
insilmaril@0
|
104 |
|
insilmaril@0
|
105 |
void FrameObj::setFrameType(const FrameType &t)
|
insilmaril@0
|
106 |
{
|
insilmaril@0
|
107 |
if (t!=type)
|
insilmaril@0
|
108 |
{
|
insilmaril@0
|
109 |
clear();
|
insilmaril@0
|
110 |
type=t;
|
insilmaril@0
|
111 |
switch (type)
|
insilmaril@0
|
112 |
{
|
insilmaril@0
|
113 |
case NoFrame:
|
insilmaril@0
|
114 |
border=0;
|
insilmaril@0
|
115 |
break;
|
insilmaril@0
|
116 |
case Rectangle:
|
insilmaril@0
|
117 |
border=10;
|
insilmaril@408
|
118 |
rectFrame = scene->addRect(QRectF(0,0,0,0), QPen(QColor("black") ), QColor("white"));
|
insilmaril@408
|
119 |
rectFrame->setZValue(Z_FRAME);
|
insilmaril@408
|
120 |
|
insilmaril@0
|
121 |
break;
|
insilmaril@0
|
122 |
}
|
insilmaril@140
|
123 |
setVisibility (visible);
|
insilmaril@0
|
124 |
}
|
insilmaril@0
|
125 |
}
|
insilmaril@0
|
126 |
|
insilmaril@0
|
127 |
void FrameObj::setFrameType(const QString &t)
|
insilmaril@0
|
128 |
{
|
insilmaril@0
|
129 |
if (t=="Rectangle")
|
insilmaril@0
|
130 |
FrameObj::setFrameType (Rectangle);
|
insilmaril@0
|
131 |
else
|
insilmaril@0
|
132 |
FrameObj::setFrameType (NoFrame);
|
insilmaril@0
|
133 |
}
|
insilmaril@0
|
134 |
|
insilmaril@0
|
135 |
void FrameObj::setVisibility (bool v)
|
insilmaril@0
|
136 |
{
|
insilmaril@0
|
137 |
MapObj::setVisibility(v);
|
insilmaril@140
|
138 |
switch (type)
|
insilmaril@140
|
139 |
{
|
insilmaril@140
|
140 |
case NoFrame:
|
insilmaril@140
|
141 |
break;
|
insilmaril@140
|
142 |
case Rectangle:
|
insilmaril@140
|
143 |
if (visible)
|
insilmaril@140
|
144 |
rectFrame->show();
|
insilmaril@140
|
145 |
else
|
insilmaril@140
|
146 |
rectFrame->hide();
|
insilmaril@140
|
147 |
break;
|
insilmaril@140
|
148 |
}
|
insilmaril@0
|
149 |
}
|
insilmaril@0
|
150 |
|