-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEarthView.h
More file actions
141 lines (118 loc) · 4.84 KB
/
Copy pathEarthView.h
File metadata and controls
141 lines (118 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#pragma once
#include <QImage>
#include <QPointer>
#include <QQuickItem>
#include <QSGTexture>
#include <QVariantList>
#include <QVector>
#include <QString>
#include <QColor>
#include <limits>
#include <QtQml/qqmlregistration.h>
// Copyright (c) 2026 Andy Armitage
// This source is distributed under the Mozilla Public License 2.0; see LICENSE.txt.
class QSGNode;
class QSGTransformNode;
class QSGClipNode;
class QSGSimpleTextureNode;
class QSGGeometryNode;
class EarthView : public QQuickItem
{
Q_OBJECT
QML_ELEMENT
public:
Q_PROPERTY(double centerLongitude READ centerLongitude WRITE setCenterLongitude NOTIFY centerLongitudeChanged)
Q_PROPERTY(bool fitWorld READ fitWorld WRITE setFitWorld NOTIFY fitWorldChanged)
Q_PROPERTY(QColor accentColor READ accentColor WRITE setAccentColor NOTIFY accentColorChanged)
Q_PROPERTY(QVariantList groundStations READ groundStations WRITE setGroundStations NOTIFY groundStationsChanged)
Q_PROPERTY(QVariantList satellites READ satellites WRITE setSatellites NOTIFY satellitesChanged)
Q_PROPERTY(QVariantList activeContacts READ activeContacts WRITE setActiveContacts NOTIFY activeContactsChanged)
explicit EarthView(QQuickItem *parent = nullptr);
double centerLongitude() const { return m_centerLongitude; }
void setCenterLongitude(double lon);
bool fitWorld() const { return m_fitWorld; }
void setFitWorld(bool fit);
QColor accentColor() const { return m_accentColor; }
void setAccentColor(const QColor &color);
QVariantList groundStations() const { return {}; }
void setGroundStations(const QVariantList &stations);
QVariantList satellites() const { return {}; }
void setSatellites(const QVariantList &sats);
QVariantList activeContacts() const { return m_activeContacts; }
void setActiveContacts(const QVariantList &contacts);
Q_INVOKABLE QVariantMap satelliteAtPoint(qreal x, qreal y) const;
Q_INVOKABLE QVariantMap groundStationAtPoint(qreal x, qreal y) const;
protected:
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
void releaseResources() override;
void timerEvent(QTimerEvent *event) override;
void hoverMoveEvent(QHoverEvent *event) override;
void hoverLeaveEvent(QHoverEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
void touchEvent(QTouchEvent *event) override;
signals:
void centerLongitudeChanged();
void fitWorldChanged();
void accentColorChanged();
void groundStationsChanged();
void satellitesChanged();
void activeContactsChanged();
void satelliteHovered(const QVariantMap &satelliteInfo);
void groundStationHovered(const QVariantMap &groundStationInfo);
void itemTapped(const QVariantMap &satelliteInfo, const QVariantMap &groundStationInfo);
private:
void ensureTexture();
void clearSceneGraphPointers();
QVariantMap satelliteAt(const QPointF &pt) const;
QVariantMap groundStationAt(const QPointF &pt) const;
QRectF viewRect(bool &rotated) const;
QImage m_backgroundImage;
QPointer<QSGTexture> m_texture;
QPointer<QQuickWindow> m_lastWindow;
double m_centerLongitude {0.0};
bool m_fitWorld {true};
QColor m_accentColor {QColor(90, 210, 255)}; // default pale/electric blue
QVariantList m_activeContacts;
struct GeoPoint {
double lat {0.0};
double lon {0.0};
};
struct GroundStation {
double lat {0.0};
double lon {0.0};
double radiusKm {0.0};
bool available {true};
QString id;
QVector<GeoPoint> mask;
};
QVector<GroundStation> m_groundStationData;
struct Satellite {
double lat {0.0};
double lon {0.0};
double latPast {std::numeric_limits<double>::quiet_NaN()};
double lonPast {std::numeric_limits<double>::quiet_NaN()};
double latFuture {std::numeric_limits<double>::quiet_NaN()};
double lonFuture {std::numeric_limits<double>::quiet_NaN()};
QString id;
bool alert {false};
};
QVector<Satellite> m_satelliteData;
bool m_lastHoverHadSat {false};
bool m_lastHoverHadGroundStation {false};
QSGNode *m_rootNode {nullptr};
QSGTransformNode *m_transformNode {nullptr};
QSGClipNode *m_clipNode {nullptr};
QSGNode *m_contentRoot {nullptr};
QSGSimpleTextureNode *m_textureNodeA {nullptr};
QSGSimpleTextureNode *m_textureNodeB {nullptr};
QSGGeometryNode *m_gsFootNode {nullptr};
QSGGeometryNode *m_gsDotOnlineNode {nullptr};
QSGGeometryNode *m_gsDotOfflineNode {nullptr};
QSGGeometryNode *m_satNode {nullptr};
QSGGeometryNode *m_satAlertNode {nullptr};
QSGGeometryNode *m_satPastNode {nullptr};
QSGGeometryNode *m_satFutureNode {nullptr};
QSGGeometryNode *m_contactNode {nullptr};
};