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 <QQuickItem>
11#include <QObject>
12#include <QtQml>
13
14/**
15 * Binds a QML item to a specific geodetic location in screen coordinates.
16 *
17 */
18namespace Marble
19{
20 class MarbleQuickItem;
21
22 class 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
39 public:
40 /** Constructor */
41 explicit GeoItem( QQuickItem *parent = nullptr );
42
43
44 Q_INVOKABLE bool moveToScreenCoordinates(qreal x, qreal y);
45
46 /** Provides access to the longitude (degree) of the coordinate */
47 qreal longitude() const;
48
49 /** Change the longitude of the coordinate */
50 void setLongitude( qreal lon );
51
52 /** Provides access to the latitude (degree) of the coordinate */
53 qreal latitude() const;
54
55 /** Change the latitude of the coordinate */
56 void setLatitude( qreal lat );
57
58 /** Provides access to the altitude (meters) of the coordinate */
59 qreal altitude() const;
60
61 /** Change the altitude of the coordinate */
62 void setAltitude( qreal alt );
63
64 /** Return all coordinates at once */
65 Marble::GeoDataCoordinates coordinates() const;
66
67 /** Change all coordinates at once */
68 void setCoordinates( const Marble::GeoDataCoordinates &coordinates );
69
70 /** Query the Marble map backend that this item uses for screen position determination */
71 MarbleQuickItem* map() const;
72
73 /** Hook up the GeoItem with Marble's map backend */
74 void setMap(MarbleQuickItem* map);
75
76 /** Return whether the item is visible or hidden on the backside of the globe. */
77 bool observable() const;
78
79 /** "Shadowed" version for the visible property to take observable into account. */
80 bool visObservable() const;
81 /** "Shadowed" version for the visible() property to take observable into account. */
82 void setVisObservable(bool visible);
83
84 /** "Shadowed" version for the x property to disable writing to the property. */
85 qreal readonlyX() const
86 {
87 return x();
88 }
89
90 /** "Shadowed" version for the y property to disable writing to the property. */
91 qreal readonlyY() const
92 {
93 return y();
94 }
95
97 void longitudeChanged();
98 void latitudeChanged();
99 void altitudeChanged();
100
101 void mapChanged(MarbleQuickItem* map);
102
103 void observableChanged(bool observable);
104
105 void visObservableChanged(bool visible);
106
107 void readonlyXChanged(qreal x);
108 void readonlyYChanged(qreal y);
109
110 private:
111 Marble::GeoDataCoordinates m_coordinate;
112 MarbleQuickItem* m_map;
113 bool m_observable;
114 bool m_visible;
115 qreal m_x;
116 qreal m_y;
117
118 void updateScreenPosition();
119 void setMapToParentOnInit();
120 };
121}
122
123#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
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:06 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.