QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GeoMapMissionArrow.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
11
12/// Direction-indicator chevron for complex item visuals, positioned and
13/// rotated in screen space (not anchored via GeoMapItem): GeoMap's 2D camera
14/// heading is user-rotatable, so a geographic azimuth (as used by
15/// src/FlightMap/MapItems/MapLineArrow.qml) would point the wrong way on
16/// screen once the map is rotated. Callers derive screenPoint/heading from
17/// already-projected GeoMapProjectedPath.screenPoints (see
18/// GeoMapSegmentArrow.qml), avoiding a second projector per arrow.
19Canvas {
20 id: root
21
22 property point screenPoint: Qt.point(0, 0)
23 property real heading: 0 ///< degrees, 0 = up, clockwise
24
25 readonly property real _arrowSize: 15
26
27 x: screenPoint.x - width / 2
28 y: screenPoint.y
29 width: _arrowSize * 2
30 height: _arrowSize
31 rotation: heading
32 transformOrigin: Item.Top
33
34 onPaint: {
35 const ctx = getContext("2d")
36 ctx.clearRect(0, 0, width, height)
37 ctx.lineWidth = 2
38 ctx.strokeStyle = "white"
39 ctx.beginPath()
40 ctx.moveTo(_arrowSize, 0)
41 ctx.lineTo(_arrowSize * 2, _arrowSize)
42 ctx.stroke()
43 ctx.beginPath()
44 ctx.moveTo(_arrowSize, 0)
45 ctx.lineTo(0, _arrowSize)
46 ctx.stroke()
47 }
48
49 Component.onCompleted: requestPaint()
50}