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

KDE's Doxygen guidelines are available online.