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

Last change on this file since 9 was 9, checked in by Sanahuja Guillaume, 5 years ago

gcs

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