Marble

RoutingLayer.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2010 Dennis Nienhüser <nienhueser@kde.org>
4//
5
6#ifndef MARBLE_ROUTINGLAYER_H
7#define MARBLE_ROUTINGLAYER_H
8
9#include "LayerInterface.h"
10
11#include "MarbleGlobal.h"
12
13#include <QObject>
14#include <QRect>
15
17class QModelIndex;
18
19namespace Marble
20{
21
22class MarbleWidget;
23class MarblePlacemarkModel;
24class RoutingLayerPrivate;
25
26/**
27 * @brief A paint layer that serves as a view on a route model
28 */
29class RoutingLayer : public QObject, public LayerInterface
30{
32
33public:
34 /**
35 * @brief Constructor
36 * @param widget The marble widget used for geopos <-> screenpos transformations
37 * and repainting of (small) areas. Must not be null
38 * @param parent Optional parent widget
39 */
40 explicit RoutingLayer(MarbleWidget *widget, QWidget *parent = nullptr);
41
42 /** Destructor */
43 ~RoutingLayer() override;
44
45 /** Reimplemented from LayerInterface. We'll hover above the surface */
46 QStringList renderPosition() const override;
47
48 /** Reimplemented from LayerInterface. */
49 qreal zValue() const override;
50
51 /** Reimplemented from LayerInterface. Paints route items and placemarks */
52 bool render(GeoPainter *painter, ViewportParams *viewport, const QString &renderPos = QStringLiteral("NONE"), GeoSceneLayer *layer = nullptr) override;
53
54 RenderState renderState() const override;
55
56 /**
57 * Set the proxy model another QAbstractItemView uses that should share
58 * its selection model with us. Needed because this class uses an unfiltered
59 * model which has different indices than a filtered one.
60 */
61 void synchronizeWith(QItemSelectionModel *selection);
62
63 /**
64 * Set the placemark model to use. Implicitly removes the routing model.
65 */
67
68 /**
69 * Set the view context to determine whether the map is used interactively
70 */
71 void setViewContext(ViewContext viewContext);
72
73 /**
74 * Determine whether the route can be edited by the user (via points added,
75 * route cleared)
76 */
77 void setInteractive(bool interactive);
78
79 /**
80 * Returns whether the route is interactive (true by default if not changed
81 * by setInteractive)
82 */
83 bool isInteractive() const;
84
85 QString runtimeTrace() const override;
86
88 /**
89 * A placemark was selected (clicked) by the user. The index belongs to
90 * the model set via setModel
91 */
92 void placemarkSelected(const QModelIndex &index);
93
94 void repaintNeeded(const QRect &rect = QRect());
95
96public:
97 /** Overriding QWidget, used to make the layer interactive */
98 bool eventFilter(QObject *obj, QEvent *event) override;
99
100private Q_SLOTS:
101 void removeViaPoint();
102
103 void showAlternativeRoutes();
104
105 /** Export route to a file */
106 void exportRoute();
107
108 /**
109 * Paint a dashed route when downloading a new route, a solid one otherwise.
110 */
111 void updateRouteState();
112
113 /**
114 * The viewport has changed, recalculate positions accordingly
115 */
116 void setViewportChanged();
117
118private:
119 RoutingLayerPrivate *const d;
120 friend class RoutingLayerPrivate;
121};
122
123} // namespace Marble
124
125#endif
A painter that allows to draw geometric primitives on the map.
Definition GeoPainter.h:86
Layer of a GeoScene document.
This class represents a model of all place marks which are currently available through a given Placem...
A widget class that displays a view of the earth.
A paint layer that serves as a view on a route model.
bool isInteractive() const
Returns whether the route is interactive (true by default if not changed by setInteractive)
qreal zValue() const override
Reimplemented from LayerInterface.
~RoutingLayer() override
Destructor.
RoutingLayer(MarbleWidget *widget, QWidget *parent=nullptr)
Constructor.
void setViewContext(ViewContext viewContext)
Set the view context to determine whether the map is used interactively.
bool render(GeoPainter *painter, ViewportParams *viewport, const QString &renderPos=QStringLiteral("NONE"), GeoSceneLayer *layer=nullptr) override
Reimplemented from LayerInterface.
QStringList renderPosition() const override
Reimplemented from LayerInterface.
bool eventFilter(QObject *obj, QEvent *event) override
Overriding QWidget, used to make the layer interactive.
void setInteractive(bool interactive)
Determine whether the route can be edited by the user (via points added, route cleared)
void synchronizeWith(QItemSelectionModel *selection)
Set the proxy model another QAbstractItemView uses that should share its selection model with us.
void setPlacemarkModel(MarblePlacemarkModel *model)
Set the placemark model to use.
void placemarkSelected(const QModelIndex &index)
A placemark was selected (clicked) by the user.
A public class that controls what is visible in the viewport of a Marble map.
Binds a QML item to a specific geodetic location in screen coordinates.
ViewContext
This enum is used to choose context in which map quality gets used.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
virtual bool event(QEvent *e)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.