2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Sami Rämö - sami.ramo@ixonos.com
6 Henri Lampela - henri.lampela@ixonos.com
8 Situare is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 Situare is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Situare; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
25 #include "coordinates/geocoordinate.h"
26 #include "coordinates/scenecoordinate.h"
27 #include "map/mapcommon.h"
28 #include "routing/route.h"
30 #include "maprouteitem.h"
32 MapRouteItem::MapRouteItem(QGraphicsItem *parent)
33 : QGraphicsItemGroup(parent)
35 qDebug() << __PRETTY_FUNCTION__;
37 setZValue(RouteItemZValue);
40 MapRouteItem::MapRouteItem(Route *route, QGraphicsItem *parent)
41 : QGraphicsItemGroup(parent)
43 qDebug() << __PRETTY_FUNCTION__;
45 setZValue(RouteItemZValue);
49 void MapRouteItem::clear()
51 qDebug() << __PRETTY_FUNCTION__;
53 foreach(QGraphicsItem *item, childItems()) {
54 removeFromGroup(item);
59 void MapRouteItem::setRoute(Route *route)
61 qDebug() << __PRETTY_FUNCTION__;
63 const int LINE_WIDTH = 5;
64 const QColor LINE_COLOR = Qt::red;
69 pen.setWidth(LINE_WIDTH);
70 pen.setColor(LINE_COLOR);
71 pen.setCosmetic(true);
73 QList<GeoCoordinate> points = route->geometryPoints();
74 for (int i = 1; i < points.count(); i++) {
75 SceneCoordinate begin = SceneCoordinate(points.at(i - 1));
76 SceneCoordinate end = SceneCoordinate(points.at(i));
77 QGraphicsLineItem *line = new QGraphicsLineItem(QLineF(begin.toPointF(),