insilmaril@0
|
1 |
#include "mapobj.h"
|
insilmaril@129
|
2 |
#include "misc.h"
|
insilmaril@0
|
3 |
|
insilmaril@0
|
4 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
5 |
// MapObj
|
insilmaril@0
|
6 |
/////////////////////////////////////////////////////////////////
|
insilmaril@0
|
7 |
MapObj::MapObj ()
|
insilmaril@0
|
8 |
{
|
insilmaril@408
|
9 |
//qWarning ( "Const MapObj (): Please set scene somehow!!!");
|
insilmaril@408
|
10 |
scene=NULL;
|
insilmaril@0
|
11 |
init ();
|
insilmaril@0
|
12 |
}
|
insilmaril@0
|
13 |
|
insilmaril@408
|
14 |
MapObj::MapObj (QGraphicsScene *s)
|
insilmaril@0
|
15 |
{
|
insilmaril@0
|
16 |
// cout << "Const MapObj\n";
|
insilmaril@408
|
17 |
scene=s;
|
insilmaril@0
|
18 |
init ();
|
insilmaril@0
|
19 |
}
|
insilmaril@0
|
20 |
|
insilmaril@0
|
21 |
|
insilmaril@0
|
22 |
MapObj::MapObj (MapObj* mo)
|
insilmaril@0
|
23 |
{
|
insilmaril@0
|
24 |
// cout << "CopyConst MapObj\n";
|
insilmaril@0
|
25 |
copy (mo);
|
insilmaril@0
|
26 |
}
|
insilmaril@0
|
27 |
|
insilmaril@0
|
28 |
MapObj::~MapObj ()
|
insilmaril@0
|
29 |
{
|
insilmaril@0
|
30 |
// cout << "Destr MapObj\n";
|
insilmaril@0
|
31 |
}
|
insilmaril@0
|
32 |
|
insilmaril@0
|
33 |
void MapObj::init ()
|
insilmaril@0
|
34 |
{
|
insilmaril@408
|
35 |
absPos=QPointF(0,0);
|
insilmaril@0
|
36 |
visible=true;
|
insilmaril@0
|
37 |
}
|
insilmaril@0
|
38 |
|
insilmaril@0
|
39 |
void MapObj::copy(MapObj* other)
|
insilmaril@0
|
40 |
{
|
insilmaril@408
|
41 |
// scene=other->scene; // already set in constr. of child, use that one...
|
insilmaril@0
|
42 |
absPos=other->absPos;
|
insilmaril@0
|
43 |
bbox.setX (other->bbox.x() );
|
insilmaril@0
|
44 |
bbox.setY (other->bbox.y() );
|
insilmaril@408
|
45 |
bbox.setSize (QSizeF(other->bbox.width(), other->bbox.height() ) );
|
insilmaril@0
|
46 |
}
|
insilmaril@0
|
47 |
|
insilmaril@408
|
48 |
QGraphicsScene* MapObj::getScene()
|
insilmaril@0
|
49 |
{
|
insilmaril@408
|
50 |
return scene;
|
insilmaril@0
|
51 |
}
|
insilmaril@0
|
52 |
|
insilmaril@408
|
53 |
qreal MapObj::x()
|
insilmaril@0
|
54 |
{
|
insilmaril@0
|
55 |
return absPos.x();
|
insilmaril@0
|
56 |
}
|
insilmaril@0
|
57 |
|
insilmaril@408
|
58 |
qreal MapObj::y()
|
insilmaril@0
|
59 |
{
|
insilmaril@0
|
60 |
return absPos.y();
|
insilmaril@0
|
61 |
}
|
insilmaril@0
|
62 |
|
insilmaril@408
|
63 |
qreal MapObj::width()
|
insilmaril@0
|
64 |
{
|
insilmaril@0
|
65 |
return bbox.width();
|
insilmaril@0
|
66 |
}
|
insilmaril@0
|
67 |
|
insilmaril@408
|
68 |
qreal MapObj::height()
|
insilmaril@0
|
69 |
{
|
insilmaril@0
|
70 |
return bbox.height();
|
insilmaril@0
|
71 |
}
|
insilmaril@0
|
72 |
|
insilmaril@408
|
73 |
QPointF MapObj::getAbsPos()
|
insilmaril@227
|
74 |
{
|
insilmaril@227
|
75 |
return absPos;
|
insilmaril@227
|
76 |
}
|
insilmaril@227
|
77 |
|
insilmaril@129
|
78 |
QString MapObj::getPos()
|
insilmaril@129
|
79 |
{
|
insilmaril@408
|
80 |
return qpointfToString(absPos);
|
insilmaril@129
|
81 |
}
|
insilmaril@129
|
82 |
|
insilmaril@0
|
83 |
void MapObj::move (double x, double y)
|
insilmaril@0
|
84 |
{
|
insilmaril@408
|
85 |
absPos.setX( x);
|
insilmaril@408
|
86 |
absPos.setY( y);
|
insilmaril@408
|
87 |
bbox.moveTo(QPointF(x,y));
|
insilmaril@408
|
88 |
clickBox.moveTo(QPointF(x,y));
|
insilmaril@408
|
89 |
}
|
insilmaril@408
|
90 |
|
insilmaril@408
|
91 |
void MapObj::move (QPointF p)
|
insilmaril@408
|
92 |
{
|
insilmaril@408
|
93 |
absPos=p;
|
insilmaril@408
|
94 |
bbox.moveTo (p);
|
insilmaril@408
|
95 |
clickBox.moveTo (p);
|
insilmaril@0
|
96 |
}
|
insilmaril@0
|
97 |
|
insilmaril@0
|
98 |
void MapObj::moveBy (double x, double y)
|
insilmaril@0
|
99 |
{
|
insilmaril@336
|
100 |
MapObj::move (x+absPos.x(),y+absPos.y() );
|
insilmaril@408
|
101 |
bbox.moveTo (bbox.x()+x,bbox.y()+y);
|
insilmaril@408
|
102 |
clickBox.moveTo (clickBox.x()+x,clickBox.y()+y);
|
insilmaril@0
|
103 |
}
|
insilmaril@0
|
104 |
|
insilmaril@408
|
105 |
QRectF MapObj::getBBox()
|
insilmaril@0
|
106 |
{
|
insilmaril@0
|
107 |
return bbox;
|
insilmaril@0
|
108 |
}
|
insilmaril@0
|
109 |
|
insilmaril@645
|
110 |
QRectF MapObj::getClickBox()
|
insilmaril@645
|
111 |
{
|
insilmaril@645
|
112 |
return clickBox;
|
insilmaril@645
|
113 |
}
|
insilmaril@175
|
114 |
|
insilmaril@0
|
115 |
|
insilmaril@408
|
116 |
QSizeF MapObj::getSize()
|
insilmaril@0
|
117 |
{
|
insilmaril@0
|
118 |
return bbox.size();
|
insilmaril@0
|
119 |
}
|
insilmaril@0
|
120 |
|
insilmaril@0
|
121 |
|
insilmaril@0
|
122 |
bool MapObj::isVisibleObj()
|
insilmaril@0
|
123 |
{
|
insilmaril@0
|
124 |
return visible;
|
insilmaril@0
|
125 |
}
|
insilmaril@0
|
126 |
|
insilmaril@0
|
127 |
void MapObj::setVisibility(bool v)
|
insilmaril@0
|
128 |
{
|
insilmaril@0
|
129 |
visible=v;
|
insilmaril@0
|
130 |
}
|
insilmaril@93
|
131 |
|
insilmaril@474
|
132 |
void MapObj::animate()
|
insilmaril@474
|
133 |
{
|
insilmaril@474
|
134 |
}
|