7#include "MarbleQuickItem.h"
23bool GeoItem::moveToScreenCoordinates(qreal x, qreal y)
25 bool valid = m_map->screenCoordinatesToGeoDataCoordinates(
QPoint(x, y), m_coordinate);
27 updateScreenPosition();
28 Q_EMIT longitudeChanged();
29 Q_EMIT latitudeChanged();
34qreal GeoItem::longitude()
const
36 return m_coordinate.longitude(GeoDataCoordinates::Degree);
39void GeoItem::setLongitude(qreal lon)
41 if (m_coordinate.longitude(GeoDataCoordinates::Degree) != lon) {
42 m_coordinate.setLongitude(lon, GeoDataCoordinates::Degree);
43 updateScreenPosition();
44 Q_EMIT longitudeChanged();
48qreal GeoItem::latitude()
const
50 return m_coordinate.latitude(GeoDataCoordinates::Degree);
53void GeoItem::setLatitude(qreal lat)
55 if (m_coordinate.latitude(GeoDataCoordinates::Degree) != lat) {
56 m_coordinate.setLatitude(lat, GeoDataCoordinates::Degree);
57 updateScreenPosition();
58 Q_EMIT latitudeChanged();
62qreal GeoItem::altitude()
const
64 return m_coordinate.altitude();
67void GeoItem::setAltitude(qreal alt)
69 if (m_coordinate.altitude() != alt) {
70 m_coordinate.setAltitude(alt);
71 updateScreenPosition();
72 Q_EMIT altitudeChanged();
83 if (m_coordinate != coordinates) {
84 m_coordinate = coordinates;
85 updateScreenPosition();
89MarbleQuickItem *GeoItem::map()
const
94void GeoItem::setMap(MarbleQuickItem *map)
101 connect(m_map, &MarbleQuickItem::geoItemUpdateRequested,
this, &GeoItem::updateScreenPosition);
102 Q_EMIT mapChanged(m_map);
105void GeoItem::updateScreenPosition()
108 QPointF relativePoint = m_map->screenCoordinatesFromGeoDataCoordinates(m_coordinate);
109 bool observable = !relativePoint.
isNull();
110 if (observable != m_observable) {
111 m_observable = observable;
112 Q_EMIT observableChanged(m_observable);
114 if (!m_coordinate.isValid()) {
115 setPosition(
QPointF(-childrenRect().width(), -childrenRect().height()));
116 }
else if (observable) {
117 setPosition(
QPointF(0.0, 0.0));
118 QPointF screenPoint = mapFromItem(m_map, relativePoint);
119 screenPoint -=
QPointF(width() / 2.0, height() / 2.0);
120 setPosition(screenPoint);
121 Q_EMIT readonlyXChanged(readonlyX());
122 Q_EMIT readonlyYChanged(readonlyY());
128void GeoItem::setMapToParentOnInit()
130 auto visualParent = qobject_cast<MarbleQuickItem *>(parentItem());
133 setMap(visualParent);
137bool GeoItem::observable()
const
142bool GeoItem::visObservable()
const
147void GeoItem::setVisObservable(
bool visible)
149 if (m_visible == visible)
154 Q_EMIT visObservableChanged(m_visible);
158#include "moc_GeoItem.cpp"
A 3d point representation.
Binds a QML item to a specific geodetic location in screen coordinates.
bool isNull() const const
void parentChanged(QQuickItem *)
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)