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.
22 required property var geoMap
24 spacing: ScreenTools.defaultFontPixelWidth / 2
26 readonly property var _camera: root.geoMap ? root.geoMap.camera : null
27 readonly property real _diameter: ScreenTools.defaultFontPixelHeight * 2.25
29 QGCPalette { id: qgcPal; colorGroupEnabled: true }
32 objectName: "flyViewGeoMapModeButton"
34 // Shows the mode a click switches to (UI tests read this too)
35 property string text: root._camera && root._camera.mode === GeoMapCamera.Mode2D ? qsTr("3D") : qsTr("2D")
38 height: root._diameter
39 radius: root._diameter / 2
40 color: modeMouseArea.pressed ? qgcPal.buttonHighlight : qgcPal.button
43 anchors.centerIn: parent
46 color: modeMouseArea.pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
54 root._camera.mode = (root._camera.mode === GeoMapCamera.Mode2D)
55 ? GeoMapCamera.Mode3D : GeoMapCamera.Mode2D
62 objectName: "flyViewGeoMapCompassButton"
64 height: root._diameter
65 radius: root._diameter / 2
66 color: compassMouseArea.pressed ? qgcPal.buttonHighlight : qgcPal.button
68 // The face tilts with the camera like Google Earth, foreshortening
69 // the needle as the view moves off top-down
74 origin.x: compassFace.width / 2
75 origin.y: compassFace.height / 2
76 axis { x: 1; y: 0; z: 0 }
77 angle: root._camera ? root._camera.tilt : 0
80 // Nested so the in-plane heading rotation applies before the tilt
84 rotation: root._camera ? -root._camera.heading : 0
88 preferredRendererType: Shape.CurveRenderer
90 // North half: conventional red needle tip
93 strokeColor: "#80404040"
95 startX: needle.width / 2
96 startY: needle.height * 0.14
97 PathLine { x: needle.width * 0.32; y: needle.height / 2 }
98 PathLine { x: needle.width * 0.68; y: needle.height / 2 }
99 PathLine { x: needle.width / 2; y: needle.height * 0.14 }
105 strokeColor: "#80404040"
107 startX: needle.width / 2
108 startY: needle.height * 0.86
109 PathLine { x: needle.width * 0.32; y: needle.height / 2 }
110 PathLine { x: needle.width * 0.68; y: needle.height / 2 }
111 PathLine { x: needle.width / 2; y: needle.height * 0.86 }
122 root.geoMap.animateHeadingToNorth()