source: flair-src/branches/mavlink/tools/FlairGCS/src/Landmark.cpp@ 70

Last change on this file since 70 was 15, checked in by Bayard Gildas, 9 years ago

sources reformatted with flair-format-dir script

File size: 1.6 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,
14 QString name, QString type) {
15 geoMap->addMapObject(this);
16 this->geoMap = geoMap;
17 pixmap = new QGeoMapPixmapObject();
18 pixmap->setCoordinate(coordinate);
19
20 if (type == "cross") {
21 pixmap->setOffset(QPoint(-16, -16));
22 pixmap->setPixmap(QPixmap(":cross.png"));
23 } else {
24 pixmap->setOffset(QPoint(-2, -30));
25 pixmap->setPixmap(QPixmap(":landmark.png"));
26 }
27 addChildObject(pixmap);
28
29 QFont font;
30 font.setWeight(QFont::Bold);
31 text = new QGeoMapTextObject(coordinate, name, font, QPoint(0, 10));
32 text->setPen(QPen(Qt::NoPen));
33 text->setBrush(QBrush(Qt::red));
34 addChildObject(text);
35}
36
37Landmark::~Landmark() {
38 geoMap->removeMapObject(this);
39 clearChildObjects();
40}
41
42void Landmark::setText(QString string) { text->setText(string); }
43
44void Landmark::setColor(Qt::GlobalColor color) {
45 text->setBrush(QBrush(color));
46}
47
48void Landmark::setCoordinate(const QGeoCoordinate &coordinate) {
49 pixmap->setCoordinate(coordinate);
50 text->setCoordinate(coordinate);
51}
52
53QGeoCoordinate Landmark::coordinate(void) { return pixmap->coordinate(); }
54
55void Landmark::RemoveLandmark(void) { geoMap->removeMapObject(this); }
56
57void Landmark::AddLandmark(QGraphicsGeoMap *geoMap) {
58 geoMap->addMapObject(this);
59 this->geoMap = geoMap;
60}
Note: See TracBrowser for help on using the repository browser.