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,
53 const QString &renderPos = "NONE", GeoSceneLayer *layer = nullptr ) override;
54
55 RenderState renderState() const override;
56
57 /**
58 * Set the proxy model another QAbstractItemView uses that should share
59 * its selection model with us. Needed because this class uses an unfiltered
60 * model which has different indices than a filtered one.
61 */
62 void synchronizeWith( QItemSelectionModel *selection );
63
64 /**
65 * Set the placemark model to use. Implicitly removes the routing model.
66 */
68
69 /**
70 * Set the view context to determine whether the map is used interactively
71 */
72 void setViewContext( ViewContext viewContext );
73
74 /**
75 * Determine whether the route can be edited by the user (via points added,
76 * route cleared)
77 */
78 void setInteractive( bool interactive );
79
80 /**
81 * Returns whether the route is interactive (true by default if not changed
82 * by setInteractive)
83 */
84 bool isInteractive() const;
85
86 QString runtimeTrace() const override;
87
89 /**
90 * A placemark was selected (clicked) by the user. The index belongs to
91 * the model set via setModel
92 */
93 void placemarkSelected( const QModelIndex &index );
94
95 void repaintNeeded( const QRect &rect = QRect() );
96
97public:
98 /** Overriding QWidget, used to make the layer interactive */
99 bool eventFilter( QObject *obj, QEvent *event ) override;
100
101private Q_SLOTS:
102 void removeViaPoint();
103
104 void showAlternativeRoutes();
105
106 /** Export route to a file */
107 void exportRoute();
108
109 /**
110 * Paint a dashed route when downloading a new route, a solid one otherwise.
111 */
112 void updateRouteState();
113
114 /**
115 * The viewport has changed, recalculate positions accordingly
116 */
117 void setViewportChanged();
118
119private:
120 RoutingLayerPrivate *const d;
121 friend class RoutingLayerPrivate;
122
123};
124
125} // namespace Marble
126
127#endif
A painter that allows to draw geometric primitives on the map.
Definition GeoPainter.h:89
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="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
T qobject_cast(QObject *object)
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.