Marble

RoutingLayer.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2010 Dennis Nienhüser <[email protected]>
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 
17 class QModelIndex;
18 
19 namespace Marble
20 {
21 
22 class MarbleWidget;
23 class MarblePlacemarkModel;
24 class RoutingLayerPrivate;
25 
26 /**
27  * @brief A paint layer that serves as a view on a route model
28  */
29 class RoutingLayer: public QObject, public LayerInterface
30 {
31  Q_OBJECT
32 
33 public:
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 
88 Q_SIGNALS:
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 
97 public:
98  /** Overriding QWidget, used to make the layer interactive */
99  bool eventFilter( QObject *obj, QEvent *event ) override;
100 
101 private 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 
119 private:
120  RoutingLayerPrivate *const d;
121  friend class RoutingLayerPrivate;
122 
123 };
124 
125 } // namespace Marble
126 
127 #endif
Q_OBJECTQ_OBJECT
ViewContext
This enum is used to choose context in which map quality gets used.
Definition: MarbleGlobal.h:66
Q_SLOTSQ_SLOTS
bool render(GeoPainter *painter, ViewportParams *viewport, const QString &renderPos="NONE", GeoSceneLayer *layer=nullptr) override
Reimplemented from LayerInterface.
A widget class that displays a view of the earth.
Definition: MarbleWidget.h:98
QStringList renderPosition() const override
Reimplemented from LayerInterface.
Layer of a GeoScene document.
Definition: GeoSceneLayer.h:28
void setPlacemarkModel(MarblePlacemarkModel *model)
Set the placemark model to use.
virtual bool event(QEvent *e)
A public class that controls what is visible in the viewport of a Marble map.
void synchronizeWith(QItemSelectionModel *selection)
Set the proxy model another QAbstractItemView uses that should share its selection model with us.
void setInteractive(bool interactive)
Determine whether the route can be edited by the user (via points added, route cleared)
Binds a QML item to a specific geodetic location in screen coordinates.
bool eventFilter(QObject *obj, QEvent *event) override
Overriding QWidget, used to make the layer interactive.
A painter that allows to draw geometric primitives on the map.
Definition: GeoPainter.h:88
Q_SIGNALSQ_SIGNALS
void placemarkSelected(const QModelIndex &index)
A placemark was selected (clicked) by the user.
void setViewContext(ViewContext viewContext)
Set the view context to determine whether the map is used interactively.
RoutingLayer(MarbleWidget *widget, QWidget *parent=nullptr)
Constructor.
qreal zValue() const override
Reimplemented from LayerInterface.
~RoutingLayer() override
Destructor.
A paint layer that serves as a view on a route model.
Definition: RoutingLayer.h:29
This class represents a model of all place marks which are currently available through a given Placem...
QObject * parent() const const
bool isInteractive() const
Returns whether the route is interactive (true by default if not changed by setInteractive)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:12:28 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.