Skip to content

Commit b9557c5

Browse files
committed
fix(FlightMap): hide arrows on short legs
Direction arrows could become larger on screen than their underlying mission legs, obscuring rather than clarifying the route. They now hide whenever a leg's projected length is shorter than the 30-pixel width of the arrow canvas.
1 parent de6c8cd commit b9557c5

4 files changed

Lines changed: 33 additions & 1 deletion

File tree

src/FlightMap/MapItems/MapLineArrow.qml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ import QGroundControl.Controls
88
import QGroundControl.FlightMap
99

1010
MapQuickItem {
11+
id: root
12+
13+
required property FlightMap mapControl
14+
1115
property color arrowColor: "white"
1216
property var fromCoord: QtPositioning.coordinate()
1317
property var toCoord: QtPositioning.coordinate()
1418
property int arrowPosition: 1 ///< 1: first quarter, 2: halfway, 3: last quarter
1519

16-
property var _map: parent
1720
property real _arrowSize: 15
1821
property real _arrowHeading: 0
22+
property real _screenLegLength: 0
1923

2024
function _updateArrowDetails() {
2125
if (fromCoord && fromCoord.isValid && toCoord && toCoord.isValid) {
@@ -26,16 +30,38 @@ MapQuickItem {
2630
coordinate = QtPositioning.coordinate()
2731
_arrowHeading = 0
2832
}
33+
_updateScreenLegLength()
34+
}
35+
36+
function _updateScreenLegLength() {
37+
if (mapControl && fromCoord && fromCoord.isValid && toCoord && toCoord.isValid) {
38+
const fromPoint = mapControl.fromCoordinate(fromCoord, false)
39+
const toPoint = mapControl.fromCoordinate(toCoord, false)
40+
_screenLegLength = Math.hypot(toPoint.x - fromPoint.x, toPoint.y - fromPoint.y)
41+
} else {
42+
_screenLegLength = 0
43+
}
2944
}
3045

3146
onFromCoordChanged: _updateArrowDetails()
3247
onToCoordChanged: _updateArrowDetails()
48+
onMapControlChanged: _updateScreenLegLength()
49+
50+
Component.onCompleted: _updateArrowDetails()
51+
52+
Connections {
53+
target: root.mapControl
54+
55+
function onCenterChanged() { root._updateScreenLegLength() }
56+
function onZoomLevelChanged() { root._updateScreenLegLength() }
57+
}
3358

3459
sourceItem: Canvas {
3560
x: -_arrowSize
3661
y: 0
3762
width: _arrowSize * 2
3863
height: _arrowSize
64+
visible: root._screenLegLength >= width
3965

4066
onPaint: {
4167
var ctx = getContext("2d");

src/FlightMap/MapItems/PlanMapItems.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Item {
7979
fromCoord: object ? object.coordinate1 : undefined
8080
toCoord: object ? object.coordinate2 : undefined
8181
arrowPosition: 3
82+
mapControl: _root.map
8283
z: QGroundControl.zOrderWaypointLines + 1
8384
}
8485
}

src/PlanView/PlanView.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ Item {
349349
fromCoord: object ? object.coordinate1 : undefined
350350
toCoord: object ? object.coordinate2 : undefined
351351
arrowPosition: 3
352+
mapControl: editorMap
352353
z: QGroundControl.zOrderWaypointLines + 1
353354
}
354355
}

src/PlanView/TransectStyleMapVisuals.qml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ Item {
136136
fromCoord: _transectPoints[_firstTrueTransectIndex]
137137
toCoord: _transectPoints[_firstTrueTransectIndex + 1]
138138
arrowPosition: 1
139+
mapControl: _root.map
139140
visible: _currentItem && !_vertexDrag
140141
opacity: _root.opacity
141142
}
@@ -148,6 +149,7 @@ Item {
148149
fromCoord: _transectPoints[nextTrueTransectIndex]
149150
toCoord: _transectPoints[nextTrueTransectIndex + 1]
150151
arrowPosition: 1
152+
mapControl: _root.map
151153
visible: _currentItem && _transectCount > 3 && !_vertexDrag
152154
opacity: _root.opacity
153155

@@ -162,6 +164,7 @@ Item {
162164
fromCoord: _transectPoints[_lastTrueTransectIndex - 1]
163165
toCoord: _transectPoints[_lastTrueTransectIndex]
164166
arrowPosition: 3
167+
mapControl: _root.map
165168
visible: _currentItem && !_vertexDrag
166169
opacity: _root.opacity
167170
}
@@ -174,6 +177,7 @@ Item {
174177
fromCoord: _transectPoints[prevTrueTransectIndex - 1]
175178
toCoord: _transectPoints[prevTrueTransectIndex]
176179
arrowPosition: 13
180+
mapControl: _root.map
177181
visible: _currentItem && _transectCount > 3 && !_vertexDrag
178182
opacity: _root.opacity
179183

0 commit comments

Comments
 (0)