source: flair-src/trunk/tools/FlairGCS/src/Landmark.cpp@ 13

Last change on this file since 13 was 10, checked in by Sanahuja Guillaume, 8 years ago

lic

File size: 1.7 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5#include "Landmark.h"
6#include <QPen>
7#include <QGeoMapTextObject>
8#include <QGeoMapPixmapObject>
9#include <QGraphicsGeoMap>
10
11using namespace QtMobility;
12
13Landmark::Landmark(QGraphicsGeoMap *geoMap, const QGeoCoordinate &coordinate,QString name,QString type)
14{
15 geoMap->addMapObject(this);
16 this->geoMap=geoMap;
17 pixmap = new QGeoMapPixmapObject();
18 pixmap->setCoordinate(coordinate);
19
20 if(type=="cross")
21 {
22 pixmap->setOffset(QPoint(-16, -16));
23 pixmap->setPixmap(QPixmap(":cross.png"));
24 }
25 else
26 {
27 pixmap->setOffset(QPoint(-2, -30));
28 pixmap->setPixmap(QPixmap(":landmark.png"));
29 }
30 addChildObject(pixmap);
31
32 QFont font;
33 font.setWeight(QFont::Bold);
34 text = new QGeoMapTextObject(coordinate,name, font, QPoint(0, 10));
35 text->setPen(QPen(Qt::NoPen));
36 text->setBrush(QBrush(Qt::red));
37 addChildObject(text);
38}
39
40Landmark::~Landmark()
41{
42 geoMap->removeMapObject(this);
43 clearChildObjects();
44}
45
46void Landmark::setText(QString string)
47{
48 text->setText(string);
49}
50
51void Landmark::setColor(Qt::GlobalColor color)
52{
53 text->setBrush(QBrush(color));
54}
55
56void Landmark::setCoordinate(const QGeoCoordinate &coordinate)
57{
58 pixmap->setCoordinate(coordinate);
59 text->setCoordinate(coordinate);
60}
61
62QGeoCoordinate Landmark::coordinate(void)
63{
64 return pixmap->coordinate();
65}
66
67void Landmark::RemoveLandmark(void)
68{
69 geoMap->removeMapObject(this);
70}
71
72void Landmark::AddLandmark(QGraphicsGeoMap *geoMap)
73{
74 geoMap->addMapObject(this);
75 this->geoMap=geoMap;
76}
Note: See TracBrowser for help on using the repository browser.