1/****************************************************************************
3 * (c) 2009-2024 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
5 * QGroundControl is licensed according to the terms in the file
6 * COPYING.md in the root of the source code directory.
8 ****************************************************************************/
14import QGroundControl.Controls
15import QGroundControl.GeoMap
17/// Google Earth-style GeoMap camera controls: round 2D/3D mode toggle plus a
18/// compass whose needle tracks the camera heading and tilts with the camera.
19/// Used by every view that hosts a GeoMap; the host decides where it goes.
23 required property var geoMap
25 spacing: ScreenTools.defaultFontPixelWidth / 2
27 readonly property var _camera: root.geoMap ? root.geoMap.camera : null
28 readonly property real _diameter: ScreenTools.defaultFontPixelHeight * 2.25
30 QGCPalette { id: qgcPal; colorGroupEnabled: true }
33 objectName: "geoMapModeButton"
35 // Shows the mode a click switches to (UI tests read this too)
36 property string text: root._camera && root._camera.mode === GeoMapCamera.Mode2D ? qsTr("3D") : qsTr("2D")
39 height: root._diameter
40 radius: root._diameter / 2
41 color: modeMouseArea.pressed ? qgcPal.accent : qgcPal.windowCard
44 anchors.centerIn: parent
47 color: modeMouseArea.pressed ? qgcPal.accentText : qgcPal.textPrimary
55 root._camera.mode = (root._camera.mode === GeoMapCamera.Mode2D)
56 ? GeoMapCamera.Mode3D : GeoMapCamera.Mode2D
63 objectName: "geoMapCompassButton"
65 height: root._diameter
66 radius: root._diameter / 2
67 color: compassMouseArea.pressed ? qgcPal.accent : qgcPal.windowCard
69 // The face tilts with the camera like Google Earth, foreshortening
70 // the needle as the view moves off top-down
75 origin.x: compassFace.width / 2
76 origin.y: compassFace.height / 2
77 axis { x: 1; y: 0; z: 0 }
78 angle: root._camera ? root._camera.tilt : 0
81 // Nested so the in-plane heading rotation applies before the tilt
85 rotation: root._camera ? -root._camera.heading : 0
89 preferredRendererType: Shape.CurveRenderer
91 // North half: conventional red needle tip
94 strokeColor: "#80404040"
96 startX: needle.width / 2
97 startY: needle.height * 0.14
98 PathLine { x: needle.width * 0.32; y: needle.height / 2 }
99 PathLine { x: needle.width * 0.68; y: needle.height / 2 }
100 PathLine { x: needle.width / 2; y: needle.height * 0.14 }
106 strokeColor: "#80404040"
108 startX: needle.width / 2
109 startY: needle.height * 0.86
110 PathLine { x: needle.width * 0.32; y: needle.height / 2 }
111 PathLine { x: needle.width * 0.68; y: needle.height / 2 }
112 PathLine { x: needle.width / 2; y: needle.height * 0.86 }
123 root.geoMap.animateHeadingToNorth()