-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.qml
More file actions
154 lines (139 loc) · 4.85 KB
/
Copy pathMain.qml
File metadata and controls
154 lines (139 loc) · 4.85 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
142
143
144
145
146
147
148
149
150
151
152
153
154
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls.Material
import EarthView
// Copyright (c) 2026 Andy Armitage
// This source is distributed under the Mozilla Public License 2.0; see LICENSE.txt.
ApplicationWindow {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
// Follow desktop theme using Material style
Material.theme: Material.System
Material.accent: Material.DeepPurple
color: Material.background
readonly property color textColor: Material.foreground
readonly property color surfaceColor: Qt.rgba(Material.background.r, Material.background.g, Material.background.b, 0.95)
readonly property color borderColor: Material.dividerColor
property var hoveredSatellite: null
property var hoveredGroundStation: null
function formatSatellite(info) {
if (!info || Object.keys(info).length === 0)
return ""
let parts = []
const idVal = info.sat_id
if (idVal !== undefined)
parts.push("SAT " + idVal)
if (info.Lat !== undefined && info.Lon !== undefined)
parts.push("lat " + Number(info.Lat).toFixed(3) + " lon " + Number(info.Lon).toFixed(3))
if (info.Alt !== undefined)
parts.push("alt " + Number(info.Alt).toFixed(1) + " km")
if (info.LatPast !== undefined && info.LonPast !== undefined)
parts.push("past " + Number(info.LatPast).toFixed(2) + ", " + Number(info.LonPast).toFixed(2))
if (info.LatFuture !== undefined && info.LonFuture !== undefined)
parts.push("future " + Number(info.LatFuture).toFixed(2) + ", " + Number(info.LonFuture).toFixed(2))
return parts.join(" • ")
}
function formatGroundStation(info) {
if (!info || Object.keys(info).length === 0)
return ""
let parts = []
const idVal = info.gs_id
if (idVal !== undefined)
parts.push("GS " + idVal)
else
parts.push("Ground Station")
if (info.lat !== undefined && info.lon !== undefined)
parts.push("lat " + Number(info.lat).toFixed(3) + " lon " + Number(info.lon).toFixed(3))
const radius = info.radius_km
if (radius !== undefined)
parts.push("radius " + Number(radius).toFixed(1) + " km")
return parts.join(" • ")
}
function formatBadge() {
const satText = formatSatellite(hoveredSatellite)
if (satText.length > 0)
return satText
const gsText = formatGroundStation(hoveredGroundStation)
if (gsText.length > 0)
return gsText
return "Hover a satellite or ground station to see details"
}
EarthView {
id: earth
objectName: "earthView"
anchors.fill: parent
accentColor: Material.accent
onSatelliteHovered: function(satelliteInfo) { hoveredSatellite = satelliteInfo }
onGroundStationHovered: function(groundStationInfo) { hoveredGroundStation = groundStationInfo }
}
Rectangle {
id: hoverBadge
anchors.left: parent.left
anchors.top: parent.top
anchors.margins: 6
radius: 4
color: surfaceColor
opacity: 0.95
border.color: borderColor
border.width: 1
z: 2
width: hoverText.implicitWidth + 12
height: hoverText.implicitHeight + 10
Label {
id: hoverText
anchors.fill: parent
anchors.margins: 6
wrapMode: Text.NoWrap
text: formatBadge()
}
}
Rectangle {
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
margins: 2
}
height: 44
radius: 4
color: surfaceColor
opacity: 0.95
RowLayout {
anchors.fill: parent
anchors.margins: 2
spacing: 2
Label {
text: "Center"
}
Slider {
id: lonSlider
from: -180
to: 180
value: earth.centerLongitude
onValueChanged: earth.centerLongitude = value
Layout.fillWidth: true
}
TextField {
id: lonField
text: earth.centerLongitude.toFixed(1)
Layout.preferredWidth: 68
inputMethodHints: Qt.ImhFormattedNumbersOnly
onEditingFinished: {
const v = parseFloat(text)
if (!isNaN(v)) {
earth.centerLongitude = v
lonSlider.value = v
}
}
}
CheckBox {
id: fitWorld
text: "Fit"
checked: earth.fitWorld
onToggled: earth.fitWorld = checked
}
}
}
}