Marble

MarbleQuickItem.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2014 Adam Dabrowski <adabrowski@piap.pl, adamdbrw@gmail.com>
4//
5
6#ifndef MARBLEQUICKITEM_H
7#define MARBLEQUICKITEM_H
8
9#include "Coordinate.h"
10#include "GeoDataAccuracy.h"
11#include "GeoDataCoordinates.h"
12#include "GeoDataLineString.h"
13#include "MapTheme.h"
14#include "MarbleGlobal.h"
15#include "MarbleMap.h"
16#include "Placemark.h"
17#include "PositionProviderPluginInterface.h"
18
19#include <QPolygonF>
20#include <QQuickPaintedItem>
21#include <QSharedPointer>
22#include <qqmlregistration.h>
23
24namespace Marble
25{
26class GeoDataLatLonBox;
27class GeoDataPlacemark;
28class MarbleModel;
29class MarbleInputHandler;
30class MarbleQuickItemPrivate;
31
32// Class is still being developed
33class MarbleQuickItem : public QQuickPaintedItem
34{
36 QML_NAMED_ELEMENT(MarbleItem)
37
38 Q_ENUM(Projection)
39
40 Q_PROPERTY(int mapWidth READ mapWidth WRITE setMapWidth NOTIFY mapWidthChanged)
41 Q_PROPERTY(int mapHeight READ mapHeight WRITE setMapHeight NOTIFY mapHeightChanged)
42 Q_PROPERTY(int zoom READ zoom WRITE setZoom NOTIFY zoomChanged)
43 Q_PROPERTY(int minimumZoom READ minimumZoom NOTIFY minimumZoomChanged)
44 Q_PROPERTY(int maximumZoom READ maximumZoom NOTIFY maximumZoomChanged)
45 Q_PROPERTY(int radius READ radius WRITE setRadius NOTIFY radiusChanged)
46 Q_PROPERTY(qreal heading READ heading WRITE setHeading NOTIFY headingChanged)
47
48 Q_PROPERTY(bool showFrameRate READ showFrameRate WRITE setShowFrameRate NOTIFY showFrameRateChanged)
49 Q_PROPERTY(Projection projection READ projection WRITE setProjection NOTIFY projectionChanged)
50
51 Q_PROPERTY(Marble::MapTheme *mapTheme READ mapTheme NOTIFY mapThemeChanged)
52 Q_PROPERTY(QString mapThemeId READ mapThemeId WRITE setMapThemeId NOTIFY mapThemeIdChanged)
53 Q_PROPERTY(bool showAtmosphere READ showAtmosphere WRITE setShowAtmosphere NOTIFY showAtmosphereChanged)
54 Q_PROPERTY(bool showCompass READ showCompass WRITE setShowCompass NOTIFY showCompassChanged)
55 Q_PROPERTY(bool showClouds READ showClouds WRITE setShowClouds NOTIFY showCloudsChanged)
56 Q_PROPERTY(bool showCrosshairs READ showCrosshairs WRITE setShowCrosshairs NOTIFY showCrosshairsChanged)
57 Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid NOTIFY showGridChanged)
58 Q_PROPERTY(bool showOverviewMap READ showOverviewMap WRITE setShowOverviewMap NOTIFY showOverviewMapChanged)
59 Q_PROPERTY(bool showOtherPlaces READ showOtherPlaces WRITE setShowOtherPlaces NOTIFY showOtherPlacesChanged)
60 Q_PROPERTY(bool showScaleBar READ showScaleBar WRITE setShowScaleBar NOTIFY showScaleBarChanged)
61 Q_PROPERTY(bool showBackground READ showBackground WRITE setShowBackground NOTIFY showBackgroundChanged)
62 Q_PROPERTY(bool showPositionMarker READ showPositionMarker WRITE setShowPositionMarker NOTIFY showPositionMarkerChanged)
63 Q_PROPERTY(bool showPublicTransport READ showPublicTransport WRITE setShowPublicTransport NOTIFY showPublicTransportChanged)
64 Q_PROPERTY(bool showOutdoorActivities READ showOutdoorActivities WRITE setShowOutdoorActivities NOTIFY showOutdoorActivitiesChanged)
65 Q_PROPERTY(QString positionProvider READ positionProvider WRITE setPositionProvider NOTIFY positionProviderChanged)
66 Q_PROPERTY(bool positionAvailable READ positionAvailable NOTIFY positionAvailableChanged)
67 Q_PROPERTY(bool positionVisible READ positionVisible NOTIFY positionVisibleChanged)
68 Q_PROPERTY(MarbleMap *marbleMap READ map NOTIFY marbleMapChanged)
69 Q_PROPERTY(Placemark *currentPosition READ currentPosition NOTIFY currentPositionChanged)
70 Q_PROPERTY(qreal speed READ speed NOTIFY speedChanged)
71 Q_PROPERTY(qreal angle READ angle NOTIFY angleChanged)
72 Q_PROPERTY(bool inertialGlobeRotation READ inertialGlobeRotation WRITE setInertialGlobeRotation NOTIFY inertialGlobeRotationChanged)
73 Q_PROPERTY(bool animationViewContext READ animationViewContext WRITE setAnimationViewContext NOTIFY animationViewContextChanged)
74 Q_PROPERTY(bool animationsEnabled READ animationsEnabled WRITE setAnimationsEnabled NOTIFY animationsEnabledChanged)
75 Q_PROPERTY(QQmlComponent *placemarkDelegate READ placemarkDelegate WRITE setPlacemarkDelegate NOTIFY placemarkDelegateChanged)
76 Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
77 Q_PROPERTY(bool invertColorEnabled READ invertColorEnabled WRITE setInvertColorEnabled NOTIFY invertColorEnabledChanged)
78 Q_PROPERTY(bool workOffline READ workOffline WRITE setWorkOffline NOTIFY workOfflineChanged)
79
80public:
81 explicit MarbleQuickItem(QQuickItem *parent = nullptr);
82
83 enum Projection {
84 Spherical = Marble::Spherical,
85 Equirectangular = Marble::Equirectangular,
86 Mercator = Marble::Mercator,
87 Gnomonic = Marble::Gnomonic,
88 Stereographic = Marble::Stereographic,
89 LambertAzimuthal = Marble::LambertAzimuthal,
90 AzimuthalEquidistant = Marble::AzimuthalEquidistant,
91 VerticalPerspective = Marble::VerticalPerspective
92 };
93
94 MarbleInputHandler *inputHandler();
95 int zoom() const;
96 int radius() const;
97
98public Q_SLOTS:
99 void goHome();
100 void setZoom(int zoom, FlyToMode mode = Instant);
101 Q_INVOKABLE void setZoomToMaximumLevel();
102 void setRadius(int radius);
103 void centerOn(const GeoDataPlacemark &placemark, bool animated = false);
104 void centerOn(const GeoDataLatLonBox &box, bool animated = false);
105 void centerOn(const GeoDataCoordinates &coordinate);
106 void centerOn(qreal longitude, qreal latitude);
107 Q_INVOKABLE void centerOnCoordinates(qreal longitude, qreal latitude);
108 Q_INVOKABLE void centerOnCurrentPosition();
109 Q_INVOKABLE void selectPlacemarkAt(int x, int y);
110
111 void zoomIn(FlyToMode mode = Automatic);
112 void zoomOut(FlyToMode mode = Automatic);
113
114 Q_INVOKABLE void handlePinchStarted(const QPointF &point);
115 Q_INVOKABLE void handlePinchFinished(const QPointF &point);
116 Q_INVOKABLE void handlePinchUpdated(const QPointF &point, qreal scale);
117
118 void setMapWidth(int mapWidth);
119 void setMapHeight(int mapHeight);
120 void setShowFrameRate(bool showFrameRate);
121 void setProjection(Projection projection);
122 void setMapThemeId(const QString &mapThemeId);
123 void setShowAtmosphere(bool showAtmosphere);
124 void setShowCompass(bool showCompass);
125 void setShowClouds(bool showClouds);
126 void setShowCrosshairs(bool showCrosshairs);
127 void setShowGrid(bool showGrid);
128 void setShowOverviewMap(bool showOverviewMap);
129 void setShowOtherPlaces(bool showOtherPlaces);
130 void setShowScaleBar(bool showScaleBar);
131 void setShowBackground(bool showBackground);
132 void setShowPositionMarker(bool showPositionMarker);
133 void setShowPublicTransport(bool showPublicTransport);
134 void setShowOutdoorActivities(bool showOutdoorActivities);
135 void setPositionProvider(const QString &positionProvider);
136
137 void setInertialGlobeRotation(bool inertialGlobeRotation);
138 void setAnimationViewContext(bool animationViewContext);
139 void setAnimationsEnabled(bool animationsEnabled);
140
141 void setPluginSetting(const QString &plugin, const QString &key, const QString &value);
142
143 void setPropertyEnabled(const QString &property, bool enabled);
144 bool isPropertyEnabled(const QString &property) const;
145
146 void setWorkOffline(bool enabled);
147
148 Q_INVOKABLE void setInvertColorEnabled(bool enabled, const QString &blending = QStringLiteral("InvertColorBlending"));
149
150 Q_INVOKABLE void setShowRuntimeTrace(bool showRuntimeTrace);
151 Q_INVOKABLE void setShowDebugPolygons(bool showDebugPolygons);
152 Q_INVOKABLE void setShowDebugPlacemarks(bool showDebugPlacemarks);
153 Q_INVOKABLE void setShowDebugBatches(bool showDebugBatches);
154
155 void setPlacemarkDelegate(QQmlComponent *placemarkDelegate);
156
157 Q_INVOKABLE void loadSettings();
158 Q_INVOKABLE void writeSettings();
159
160 Q_INVOKABLE void reloadTiles();
161 Q_INVOKABLE void highlightRouteRelation(qint64 osmId, bool enabled);
162 Q_INVOKABLE void setRelationTypeVisible(const QString &relationType, bool visible);
163 Q_INVOKABLE bool isRelationTypeVisible(const QString &relationType) const;
164
165 void setHeading(qreal heading);
166 void setHoverEnabled(bool hoverEnabled);
167 qreal centerLongitude() const;
168 qreal centerLatitude() const;
169
170public:
171 void paint(QPainter *painter) override;
172
173 // QQmlParserStatus interface
174public:
175 void classBegin() override;
176 void componentComplete() override;
177
178 void hoverMoveEvent(QHoverEvent *event) override;
179
180public:
181 virtual bool layersEventFilter(QObject *o, QEvent *e);
182
183 int mapWidth() const;
184 int mapHeight() const;
185 qreal heading() const;
186
187 bool showFrameRate() const;
188 Projection projection() const;
189 QString mapThemeId() const;
190 Marble::MapTheme *mapTheme() const;
191 bool showAtmosphere() const;
192 bool showCompass() const;
193 bool showClouds() const;
194 bool showCrosshairs() const;
195 bool showGrid() const;
196 bool showOverviewMap() const;
197 bool showOtherPlaces() const;
198 bool showScaleBar() const;
199 bool showBackground() const;
200 bool showPositionMarker() const;
201 bool showPublicTransport() const;
202 bool showOutdoorActivities() const;
203 QString positionProvider() const;
204 bool positionAvailable() const;
205 bool positionVisible() const;
206 Q_INVOKABLE qreal distanceFromPointToCurrentLocation(const QPoint &position) const;
207 Q_INVOKABLE qreal angleFromPointToCurrentLocation(const QPoint &position) const;
208 Placemark *currentPosition() const;
209 Q_INVOKABLE QPointF screenCoordinatesFromCoordinate(Coordinate *coordinate) const;
210 Q_INVOKABLE QPointF screenCoordinatesFromGeoDataCoordinates(const GeoDataCoordinates &coordinates) const;
211 bool screenCoordinatesFromGeoDataLineString(const GeoDataLineString &lineString, QList<QPolygonF *> &polygons) const;
212
213 bool screenCoordinatesToGeoDataCoordinates(const QPoint &point, GeoDataCoordinates &coordinates);
214 Q_INVOKABLE bool screenCoordinatesToCoordinate(const QPoint &point, Coordinate *coordinate);
215 qreal speed() const;
216 qreal angle() const;
217
218 MarbleModel *model();
219 const MarbleModel *model() const;
220
221 MarbleMap *map();
222 const MarbleMap *map() const;
223
224 bool inertialGlobeRotation() const;
225 bool animationViewContext() const;
226 bool animationsEnabled() const;
227
228 QQmlComponent *placemarkDelegate() const;
229 void reverseGeocoding(const QPoint &point);
230
231 bool hoverEnabled() const;
232 Q_INVOKABLE bool invertColorEnabled();
233 bool workOffline();
234
235 Q_INVOKABLE void moveUp();
236 Q_INVOKABLE void moveDown();
237 Q_INVOKABLE void moveLeft();
238 Q_INVOKABLE void moveRight();
239
240 int minimumZoom() const;
241
242 int maximumZoom() const;
243
245 void mapWidthChanged(int mapWidth);
246 void mapHeightChanged(int mapHeight);
247 void showFrameRateChanged(bool showFrameRate);
248 void projectionChanged(Projection projection);
249 void mapThemeIdChanged(const QString &mapThemeId);
250 void mapThemeChanged();
251 void showAtmosphereChanged(bool showAtmosphere);
252 void showCompassChanged(bool showCompass);
253 void showCloudsChanged(bool showClouds);
254 void showCrosshairsChanged(bool showCrosshairs);
255 void showGridChanged(bool showGrid);
256 void showOverviewMapChanged(bool showOverviewMap);
257 void showOtherPlacesChanged(bool showOtherPlaces);
258 void showScaleBarChanged(bool showScaleBar);
259 void showBackgroundChanged(bool showBackground);
260 void showPositionMarkerChanged(bool showPositionMarker);
261 void showPublicTransportChanged(bool showPublicTransport);
262 void showOutdoorActivitiesChanged(bool showOutdoorActivities);
263 void positionProviderChanged(const QString &positionProvider);
264 void positionAvailableChanged(bool positionAvailable);
265 void positionVisibleChanged(bool positionVisible);
266 void marbleMapChanged();
267 void visibleLatLonAltBoxChanged();
268 void currentPositionChanged(Placemark *currentPosition);
269 void angleChanged();
270 void speedChanged();
271 void headingChanged(qreal heading);
272 void zoomChanged();
273 void radiusChanged(int radius);
274 void inertialGlobeRotationChanged(bool inertialGlobeRotation);
275 void animationViewContextChanged(bool animationViewContext);
276 void placemarkDelegateChanged(QQmlComponent *placemarkDelegate);
277
278 void animationsEnabledChanged(bool animationsEnabled);
279
280 void hoverEnabledChanged(bool hoverEnabled);
281
282 void lmbMenuRequested(const QPoint &point);
283 void rmbMenuRequested(const QPoint &point);
284 void hoverPositionChanged(const QPoint &point);
285
286 void minimumZoomChanged(int minimumZoom);
287 void maximumZoomChanged(int maximumZoom);
288
289 void invertColorEnabledChanged(bool enabled);
290 void workOfflineChanged();
291
292 void geoItemUpdateRequested();
293
294protected:
295 QObject *getEventFilter() const;
296 void pinch(const QPointF &center, qreal scale, Qt::GestureState state);
297
298private Q_SLOTS:
299 void resizeMap();
300 void positionDataStatusChanged(PositionProviderStatus status);
301 void positionChanged(const GeoDataCoordinates &, GeoDataAccuracy);
302 void updatePositionVisibility();
303 void updateCurrentPosition(const GeoDataCoordinates &coordinates);
304 void updatePlacemarks();
305 void handleReverseGeocoding(const GeoDataCoordinates &coordinates, const GeoDataPlacemark &placemark);
306 void handleVisibleLatLonAltBoxChanged(const GeoDataLatLonAltBox &latLonAltBox);
307
308private:
309 using MarbleQuickItemPrivatePtr = QSharedPointer<MarbleQuickItemPrivate>;
310 MarbleQuickItemPrivatePtr d;
311 friend class MarbleQuickItemPrivate;
312};
313}
314
315#endif // MARBLEQUICKITEM_H
This file contains the headers for MarbleMap.
Represents a coordinate with the properties of a name and coordinates.
Definition Coordinate.h:19
Q_SCRIPTABLE CaptureState status()
Binds a QML item to a specific geodetic location in screen coordinates.
@ Automatic
A sane value is chosen automatically depending on animation settings and the action.
@ Instant
Change camera position immediately (no interpolation)
@ Mercator
Mercator projection.
@ VerticalPerspective
Vertical perspective projection.
@ AzimuthalEquidistant
Azimuthal Equidistant projection.
@ Gnomonic
Gnomonic projection.
@ LambertAzimuthal
Lambert Azimuthal Equal-Area projection.
@ Equirectangular
Flat projection ("plate carree")
@ Spherical
Spherical projection ("Orthographic")
@ Stereographic
Stereographic projection.
Q_ENUM(...)
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QVariant property(const char *name) const const
virtual bool event(QEvent *ev) override
GestureState
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.