QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GeoMapSpriteLayer.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * (c) 2009-2024 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 *
5 * QGroundControl is licensed according to the terms in the file
6 * COPYING.md in the root of the source code directory.
7 *
8 ****************************************************************************/
9
10#pragma once
11
12#include <QtCore/QPointF>
13#include <QtCore/QTimer>
14#include <QtPositioning/QGeoCoordinate>
15#include <QtQmlIntegration/QtQmlIntegration>
16#include <QtQuick/QQuickItem>
17
18#include <vector>
19
20class GeoMapCamera;
21class GeoScene;
22class QAbstractItemModel;
24
25Q_MOC_INCLUDE("GeoScene.h")
26Q_MOC_INCLUDE("SurfacePatchModel.h")
27Q_MOC_INCLUDE("QtCore/QAbstractItemModel")
28
40class GeoMapSpriteLayer : public QQuickItem
41{
42 Q_OBJECT
43 QML_ELEMENT
44 Q_PROPERTY(GeoScene* scene READ scene WRITE setScene NOTIFY sceneChanged)
45 Q_PROPERTY(SurfacePatchModel* surfaceModel READ surfaceModel WRITE setSurfaceModel NOTIFY surfaceModelChanged)
46 Q_PROPERTY(QAbstractItemModel* model READ model WRITE setModel NOTIFY modelChanged)
47 Q_PROPERTY(QVariantList coordinates READ coordinates WRITE setCoordinates NOTIFY coordinatesChanged)
48 Q_PROPERTY(QQuickItem* sprite READ sprite WRITE setSprite NOTIFY spriteChanged)
49 Q_PROPERTY(qreal spriteSize READ spriteSize WRITE setSpriteSize NOTIFY spriteSizeChanged)
50
51public:
52 explicit GeoMapSpriteLayer(QQuickItem* parent = nullptr);
53
54 GeoScene* scene() const { return _scene; }
55
56 void setScene(GeoScene* scene);
57
58 SurfacePatchModel* surfaceModel() const { return _surfaceModel; }
59
60 void setSurfaceModel(SurfacePatchModel* surfaceModel);
61
62 QAbstractItemModel* model() const { return _model; }
63
64 void setModel(QAbstractItemModel* model);
65
67 QVariantList coordinates() const { return _coordinates; }
68
69 void setCoordinates(const QVariantList& coordinates);
70
71 QQuickItem* sprite() const { return _sprite; }
72
73 void setSprite(QQuickItem* sprite);
74
76 qreal spriteSize() const { return _spriteSize; }
77
78 void setSpriteSize(qreal spriteSize);
79
80signals:
87
88protected:
89 QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* updatePaintNodeData) override;
90
91private slots:
92 void _markPointsDirty();
93 void _scheduleTerrainResample();
94
95private:
96 void _connectCamera();
97 void _rebuildPointCache();
98
99 struct CachedPoint
100 {
101 QGeoCoordinate coordinate;
102 QPointF world;
103 double terrainAlt{};
104 };
105
106 GeoScene* _scene = nullptr;
107 SurfacePatchModel* _surfaceModel = nullptr;
108 QAbstractItemModel* _model = nullptr;
109 QVariantList _coordinates;
110 QQuickItem* _sprite = nullptr;
111 GeoMapCamera* _connectedCamera = nullptr;
112 QTimer _terrainResampleTimer;
113 qreal _spriteSize = 24.0;
114 bool _pointsDirty = true;
115 bool _warnedNotProvider = false;
116 std::vector<CachedPoint> _points;
117};
void coordinatesChanged()
qreal spriteSize() const
On-screen sprite width/height in (logical) pixels.
void spriteSizeChanged()
QAbstractItemModel * model() const
QQuickItem * sprite() const
void surfaceModelChanged()
SurfacePatchModel * surfaceModel() const
GeoScene * scene() const
QVariantList coordinates() const
Coordinate list alternative to model (model takes precedence when set)
void setScene(GeoScene *scene)
GeoScene * scene() const