QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GeoMapSegmentArrow.qml
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
10import QtQuick
11import QtPositioning
12
13import QGroundControl.GeoMap
14
15/// Direction-indicator chevron positioned along a single fromCoord->toCoord
16/// segment, at fraction of the way between them (screen-space, see
17/// GeoMapMissionArrow). Self-contained (owns its own GeoMapProjectedPath)
18/// for one-off segments.
19Item {
20 id: root
21
22 property var scene
23 property var surfaceModel
24 property var fromCoord: QtPositioning.coordinate()
25 property var toCoord: QtPositioning.coordinate()
26 property real fraction: 0.75 ///< 0..1 along fromCoord -> toCoord
27
28 GeoMapProjectedPath {
29 id: segmentPath
30 scene: root.scene
31 surfaceModel: root.surfaceModel
32 altitudeMode: GeoMapItem.Absolute
33 coordinates: [root.fromCoord, root.toCoord]
34 }
35
36 readonly property bool _ready: segmentPath.projected && segmentPath.screenPoints.length > 1
37
38 GeoMapMissionArrow {
39 visible: root._ready
40 screenPoint: root._ready
41 ? Qt.point(segmentPath.screenPoints[0].x + (segmentPath.screenPoints[1].x - segmentPath.screenPoints[0].x) * root.fraction,
42 segmentPath.screenPoints[0].y + (segmentPath.screenPoints[1].y - segmentPath.screenPoints[0].y) * root.fraction)
43 : Qt.point(0, 0)
44 heading: root._ready
45 ? Math.atan2(segmentPath.screenPoints[1].x - segmentPath.screenPoints[0].x,
46 -(segmentPath.screenPoints[1].y - segmentPath.screenPoints[0].y)) * 180 / Math.PI
47 : 0
48 }
49}