Marble

GeoItem.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2019 Torsten Rahn <rahn@kde.org>
4//
5
6#ifndef MARBLE_DECLARATIVE_GEOITEM_H
7#define MARBLE_DECLARATIVE_GEOITEM_H
8
9#include "GeoDataCoordinates.h"
10#include <QObject>
11#include <QQuickItem>
12#include <QtQml>
13
14/**
15 * Binds a QML item to a specific geodetic location in screen coordinates.
16 *
17 */
18namespace Marble
19{
20class MarbleQuickItem;
21
22class GeoItem : public QQuickItem
23{
25
26 Q_PROPERTY(Marble::MarbleQuickItem *map READ map WRITE setMap NOTIFY mapChanged)
27
28 Q_PROPERTY(qreal longitude READ longitude WRITE setLongitude NOTIFY longitudeChanged)
29 Q_PROPERTY(qreal latitude READ latitude WRITE setLatitude NOTIFY latitudeChanged)
30 Q_PROPERTY(qreal altitude READ altitude WRITE setAltitude NOTIFY altitudeChanged)
31 // Determines whether the item is on the visible side of the globe
32 Q_PROPERTY(bool observable READ observable NOTIFY observableChanged)
33 // We shadow QQuickItem's visible property in order to take the observable into account
34 Q_PROPERTY(bool visible READ visObservable WRITE setVisObservable NOTIFY visObservableChanged)
35
36 Q_PROPERTY(qreal x READ readonlyX NOTIFY readonlyXChanged)
37 Q_PROPERTY(qreal y READ readonlyY NOTIFY readonlyYChanged)
38
39public:
40 /** Constructor */
41 explicit GeoItem(QQuickItem *parent = nullptr);
42
43 Q_INVOKABLE bool moveToScreenCoordinates(qreal x, qreal y);
44
45 /** Provides access to the longitude (degree) of the coordinate */
46 qreal longitude() const;
47
48 /** Change the longitude of the coordinate */
49 void setLongitude(qreal lon);
50
51 /** Provides access to the latitude (degree) of the coordinate */
52 qreal latitude() const;
53
54 /** Change the latitude of the coordinate */
55 void setLatitude(qreal lat);
56
57 /** Provides access to the altitude (meters) of the coordinate */
58 qreal altitude() const;
59
60 /** Change the altitude of the coordinate */
61 void setAltitude(qreal alt);
62
63 /** Return all coordinates at once */
64 Marble::GeoDataCoordinates coordinates() const;
65
66 /** Change all coordinates at once */
67 void setCoordinates(const Marble::GeoDataCoordinates &coordinates);
68
69 /** Query the Marble map backend that this item uses for screen position determination */
70 MarbleQuickItem *map() const;
71
72 /** Hook up the GeoItem with Marble's map backend */
73 void setMap(MarbleQuickItem *map);
74
75 /** Return whether the item is visible or hidden on the backside of the globe. */
76 bool observable() const;
77
78 /** "Shadowed" version for the visible property to take observable into account. */
79 bool visObservable() const;
80 /** "Shadowed" version for the visible() property to take observable into account. */
81 void setVisObservable(bool visible);
82
83 /** "Shadowed" version for the x property to disable writing to the property. */
84 qreal readonlyX() const
85 {
86 return x();
87 }
88
89 /** "Shadowed" version for the y property to disable writing to the property. */
90 qreal readonlyY() const
91 {
92 return y();
93 }
94
96 void longitudeChanged();
97 void latitudeChanged();
98 void altitudeChanged();
99
100 void mapChanged(MarbleQuickItem *map);
101
102 void observableChanged(bool observable);
103
104 void visObservableChanged(bool visible);
105
106 void readonlyXChanged(qreal x);
107 void readonlyYChanged(qreal y);
108
109private:
110 Marble::GeoDataCoordinates m_coordinate;
111 MarbleQuickItem *m_map = nullptr;
112 bool m_observable;
113 bool m_visible;
114 qreal m_x;
115 qreal m_y;
116
117 void updateScreenPosition();
118 void setMapToParentOnInit();
119};
120}
121
122#endif // MARBLE_DECLARATIVE_GEOITEM_H
A 3d point representation.
Binds a QML item to a specific geodetic location in screen coordinates.
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:37:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.