Marble

Maneuver.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2011 Dennis Nienhüser <nienhueser@kde.org>
4//
5
6#include "Maneuver.h"
7#include "MarbleDirs.h"
8
9#include <QHash>
10
11namespace Marble
12{
13
14static QHash<Maneuver::Direction, QString> createTurnTypePixmapMap()
15{
17
18 turnTypePixmaps.insert(Maneuver::Unknown, QStringLiteral(":/data/bitmaps/routing_step.png"));
19 turnTypePixmaps.insert(Maneuver::Straight, QStringLiteral(":/data/bitmaps/turn-continue.png"));
20 turnTypePixmaps.insert(Maneuver::Continue, QStringLiteral(":/data/bitmaps/turn-continue.png"));
21 turnTypePixmaps.insert(Maneuver::Merge, QStringLiteral(":/data/bitmaps/turn-merge.png"));
22 turnTypePixmaps.insert(Maneuver::SlightRight, QStringLiteral(":/data/bitmaps/turn-slight-right.png"));
23 turnTypePixmaps.insert(Maneuver::Right, QStringLiteral(":/data/bitmaps/turn-right.png"));
24 turnTypePixmaps.insert(Maneuver::SharpRight, QStringLiteral(":/data/bitmaps/turn-sharp-right.png"));
25 turnTypePixmaps.insert(Maneuver::TurnAround, QStringLiteral(":/data/bitmaps/turn-around.png"));
26 turnTypePixmaps.insert(Maneuver::SharpLeft, QStringLiteral(":/data/bitmaps/turn-sharp-left.png"));
27 turnTypePixmaps.insert(Maneuver::Left, QStringLiteral(":/data/bitmaps/turn-left.png"));
28 turnTypePixmaps.insert(Maneuver::SlightLeft, QStringLiteral(":/data/bitmaps/turn-slight-left.png"));
29 turnTypePixmaps.insert(Maneuver::RoundaboutFirstExit, QStringLiteral(":/data/bitmaps/turn-roundabout-ccw-first.png"));
30 turnTypePixmaps.insert(Maneuver::RoundaboutSecondExit, QStringLiteral(":/data/bitmaps/turn-roundabout-ccw-second.png"));
31 turnTypePixmaps.insert(Maneuver::RoundaboutThirdExit, QStringLiteral(":/data/bitmaps/turn-roundabout-ccw-third.png"));
32 turnTypePixmaps.insert(Maneuver::RoundaboutExit, QStringLiteral(":/data/bitmaps/turn-roundabout-ccw-far.png"));
33 turnTypePixmaps.insert(Maneuver::ExitLeft, QStringLiteral(":/data/bitmaps/turn-exit-left.png"));
34 turnTypePixmaps.insert(Maneuver::ExitRight, QStringLiteral(":/data/bitmaps/turn-exit-right.png"));
35
36 return turnTypePixmaps;
37}
38
39
40Maneuver::Maneuver() :
41 m_direction( Unknown ),
42 m_waypointIndex( -1 )
43{
44}
45
46Maneuver::Direction Maneuver::direction() const
47{
48 return m_direction;
49}
50
51QString Maneuver::directionPixmap() const
52{
53 static const QHash<Maneuver::Direction, QString> turnTypePixmaps = createTurnTypePixmapMap();
54
55 return turnTypePixmaps.value(direction());
56}
57
58bool Maneuver::operator ==(const Maneuver &other) const
59{
60 return m_direction == other.m_direction &&
61 m_waypointIndex == other.m_waypointIndex &&
62 m_position == other.m_position &&
63 m_waypoint == other.m_waypoint &&
64 m_instructionText == other.m_instructionText;
65}
66
67bool Maneuver::operator !=(const Maneuver &other) const
68{
69 return !(other == *this);
70}
71
72void Maneuver::setDirection( Direction direction )
73{
74 m_direction = direction;
75}
76
77GeoDataCoordinates Maneuver::position() const
78{
79 return m_position;
80}
81
82void Maneuver::setPosition( const GeoDataCoordinates &position )
83{
84 m_position = position;
85}
86
87GeoDataCoordinates Maneuver::waypoint() const
88{
89 return m_waypoint;
90}
91
92bool Maneuver::hasWaypoint() const
93{
94 return m_waypointIndex >= 0;
95}
96
97void Maneuver::setWaypoint( const GeoDataCoordinates &waypoint, int index )
98{
99 m_waypoint = waypoint;
100 m_waypointIndex = index;
101}
102
103int Maneuver::waypointIndex() const
104{
105 return m_waypointIndex;
106}
107
108QString Maneuver::instructionText() const
109{
110 return m_instructionText;
111}
112
113void Maneuver::setInstructionText( const QString &text )
114{
115 m_instructionText = text;
116}
117
118QString Maneuver::roadName() const
119{
120 return m_roadName;
121}
122
123void Maneuver::setRoadName(const QString &roadName)
124{
125 m_roadName = roadName;
126}
127
128}
Binds a QML item to a specific geodetic location in screen coordinates.
iterator insert(const Key &key, const T &value)
T value(const Key &key) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 12:00:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.