1
#include "mapitem.h"
2
3
#include "linkablemapobj.h"
4
#include "ornamentedobj.h"
5
6
#include <iostream>
7
using namespace std;
8
9
MapItem::MapItem()
10
{
11
lmo=NULL;
12
posMode=Unused;
13
}
14
15
void MapItem::setRelPos (const QPointF &p)
16
17
posMode=Relative;
18
pos=p;
19
if (lmo)
20
21
((OrnamentedObj*)lmo)->setUseRelPos (true);
22
((OrnamentedObj*)lmo)->move2RelPos(p);
23
24
25
26
void MapItem::setAbsPos (const QPointF &p)
27
28
posMode=Absolute;
29
30
if (lmo) lmo->move (p);
31
32
33
LinkableMapObj* MapItem::getLMO()
34
35
return lmo;
36
37
38
void MapItem::setLMO(LinkableMapObj *l)
39
40
lmo=l;
41
42
43
void MapItem::initLMO()
44
45
if (!lmo) return;
46
switch (posMode)
47
48
case Relative:
49
lmo->setRelPos (pos);
50
break;
51
case Absolute:
52
lmo->move (pos);
53
54
default:
55
56
57
58
59
QString MapItem::getAttr()
60
61
62
63
64
if (lmo) pos=lmo->getRelPos();
65
return
66
attribut("relPosX",QString().setNum(pos.x())) +
67
attribut("relPosY",QString().setNum(pos.y()));
68
69
70
if (lmo) pos=lmo->getAbsPos();
71
72
attribut("absPosX",QString().setNum(pos.x())) +
73
attribut("absPosY",QString().setNum(pos.y()));
74
75
76
return QString();
77
78
79
80