Unverified Commit d03cdffa authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #7748 from DonLakeFlyer/SurveyVisuals

Survey visuals
parents bb3a192a 73c468f1
...@@ -185,6 +185,7 @@ ...@@ -185,6 +185,7 @@
<file alias="QGroundControl/FlightMap/FlightMap.qml">src/FlightMap/FlightMap.qml</file> <file alias="QGroundControl/FlightMap/FlightMap.qml">src/FlightMap/FlightMap.qml</file>
<file alias="QGroundControl/FlightMap/InstrumentSwipeView.qml">src/FlightMap/Widgets/InstrumentSwipeView.qml</file> <file alias="QGroundControl/FlightMap/InstrumentSwipeView.qml">src/FlightMap/Widgets/InstrumentSwipeView.qml</file>
<file alias="QGroundControl/FlightMap/MapFitFunctions.qml">src/FlightMap/Widgets/MapFitFunctions.qml</file> <file alias="QGroundControl/FlightMap/MapFitFunctions.qml">src/FlightMap/Widgets/MapFitFunctions.qml</file>
<file alias="QGroundControl/FlightMap/MapLineArrow.qml">src/MissionManager/MapLineArrow.qml</file>
<file alias="QGroundControl/FlightMap/MapScale.qml">src/FlightMap/MapScale.qml</file> <file alias="QGroundControl/FlightMap/MapScale.qml">src/FlightMap/MapScale.qml</file>
<file alias="QGroundControl/FlightMap/MissionItemIndicator.qml">src/FlightMap/MapItems/MissionItemIndicator.qml</file> <file alias="QGroundControl/FlightMap/MissionItemIndicator.qml">src/FlightMap/MapItems/MissionItemIndicator.qml</file>
<file alias="QGroundControl/FlightMap/MissionItemIndicatorDrag.qml">src/FlightMap/MapItems/MissionItemIndicatorDrag.qml</file> <file alias="QGroundControl/FlightMap/MissionItemIndicatorDrag.qml">src/FlightMap/MapItems/MissionItemIndicatorDrag.qml</file>
......
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtLocation 5.3
import QtPositioning 5.3
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FlightMap 1.0
MapQuickItem {
property color arrowColor: "white"
property var fromCoord: QtPositioning.coordinate()
property var toCoord: QtPositioning.coordinate()
property bool exitPosition: false
property var _map: parent
property real _arrowSize: 20
property real _arrowHeading: 0
function _updateArrowDetails() {
if (fromCoord && fromCoord.isValid && toCoord && toCoord.isValid) {
_arrowHeading = fromCoord.azimuthTo(toCoord)
var lineDistanceQuarter = fromCoord.distanceTo(toCoord) / 4
coordinate = fromCoord.atDistanceAndAzimuth(lineDistanceQuarter * (exitPosition ? 3 : 1), _arrowHeading)
} else {
coordinate = QtPositioning.coordinate()
_arrowHeading = 0
}
}
onFromCoordChanged: _updateArrowDetails()
onToCoordChanged: _updateArrowDetails()
sourceItem: Canvas {
x: -_arrowSize
y: 0
width: _arrowSize * 2
height: _arrowSize
onPaint: {
var ctx = getContext("2d");
ctx.lineWidth = 2
ctx.strokeStyle = arrowColor
ctx.beginPath();
ctx.moveTo(_arrowSize, 0);
ctx.lineTo(_arrowSize * 2, _arrowSize)
ctx.stroke();
ctx.beginPath();
ctx.moveTo(_arrowSize, 0);
ctx.lineTo(0, _arrowSize)
ctx.stroke();
}
transform: Rotation {
origin.x: width / 2
origin.y: 0
angle: _arrowHeading
}
}
}
...@@ -28,35 +28,35 @@ Item { ...@@ -28,35 +28,35 @@ Item {
property var _mapPolygon: object.surveyAreaPolygon property var _mapPolygon: object.surveyAreaPolygon
property bool _currentItem: object.isCurrentItem property bool _currentItem: object.isCurrentItem
property var _transectPoints: _missionItem.visualTransectPoints property var _transectPoints: _missionItem.visualTransectPoints
property bool _showPartialEntryExit: !_currentItem && _missionItem.turnAroundDistance.rawValue !== 0 &&_transectPoints.length >= 2 property int _transectCount: _transectPoints.length / (_hasTurnaround ? 4 : 2)
property bool _hasTurnaround: _missionItem.turnAroundDistance.rawValue !== 0
property int _firstTrueTransectIndex: _hasTurnaround ? 1 : 0
property int _lastTrueTransectIndex: _transectPoints.length - (_hasTurnaround ? 2 : 1)
property int _lastPointIndex: _transectPoints.length - 1
property bool _showPartialEntryExit: !_currentItem && _hasTurnaround &&_transectPoints.length >= 2
property var _fullTransectsComponent: null property var _fullTransectsComponent: null
property var _entryTransectsComponent: null property var _entryTransectsComponent: null
property var _exitTransectsComponent: null property var _exitTransectsComponent: null
property var _entryCoordinate property var _entryCoordinate
property var _exitCoordinate property var _exitCoordinate
property var _dynamicComponents: [ ]
signal clicked(int sequenceNumber) signal clicked(int sequenceNumber)
function _addVisualElements() { function _addVisualElements() {
_fullTransectsComponent = fullTransectsComponent.createObject(map) var toAdd = [ fullTransectsComponent, entryTransectComponent, exitTransectComponent, entryPointComponent, exitPointComponent,
_entryTransectsComponent = entryTransectComponent.createObject(map) entryArrow1Component, entryArrow2Component, exitArrow1Component, exitArrow2Component ]
_exitTransectsComponent = exitTransectComponent.createObject(map) for (var i=0; i<toAdd.length; i++) {
_entryCoordinate = entryPointComponent.createObject(map) _dynamicComponents.push(toAdd[i].createObject(map))
_exitCoordinate = exitPointComponent.createObject(map) map.addMapItem(_dynamicComponents[_dynamicComponents.length -1])
}
map.addMapItem(_fullTransectsComponent)
map.addMapItem(_entryTransectsComponent)
map.addMapItem(_exitTransectsComponent)
map.addMapItem(_entryCoordinate)
map.addMapItem(_exitCoordinate)
} }
function _destroyVisualElements() { function _destroyVisualElements() {
_fullTransectsComponent.destroy() for (var i=0; i<_dynamicComponents.length; i++) {
_entryTransectsComponent.destroy() _dynamicComponents[i].destroy()
_exitTransectsComponent.destroy() }
_entryCoordinate.destroy() _dynamicComponents = [ ]
_exitCoordinate.destroy()
} }
Component.onCompleted: { Component.onCompleted: {
...@@ -108,10 +108,8 @@ Item { ...@@ -108,10 +108,8 @@ Item {
MapPolyline { MapPolyline {
line.color: "white" line.color: "white"
line.width: 2 line.width: 2
path: _showPartialEntryExit ? [ _transectPoints[lastPointIndex - 1], _transectPoints[lastPointIndex] ] : [] path: _showPartialEntryExit ? [ _transectPoints[_lastPointIndex - 1], _transectPoints[_lastPointIndex] ] : []
visible: _showPartialEntryExit visible: _showPartialEntryExit
property int lastPointIndex: _transectPoints.length - 1
} }
} }
...@@ -128,13 +126,60 @@ Item { ...@@ -128,13 +126,60 @@ Item {
sourceItem: MissionItemIndexLabel { sourceItem: MissionItemIndexLabel {
index: _missionItem.sequenceNumber index: _missionItem.sequenceNumber
label: qsTr("Entry")
checked: _missionItem.isCurrentItem checked: _missionItem.isCurrentItem
onClicked: _root.clicked(_missionItem.sequenceNumber) onClicked: _root.clicked(_missionItem.sequenceNumber)
} }
} }
} }
Component {
id: entryArrow1Component
MapLineArrow {
fromCoord: _transectPoints[_firstTrueTransectIndex]
toCoord: _transectPoints[_firstTrueTransectIndex + 1]
exitPosition: false
visible: _currentItem
}
}
Component {
id: entryArrow2Component
MapLineArrow {
fromCoord: _transectPoints[nextTrueTransectIndex]
toCoord: _transectPoints[nextTrueTransectIndex + 1]
exitPosition: false
visible: _currentItem && _transectCount > 3
property int nextTrueTransectIndex: _firstTrueTransectIndex + (_hasTurnaround ? 4 : 2)
}
}
Component {
id: exitArrow1Component
MapLineArrow {
fromCoord: _transectPoints[_lastTrueTransectIndex - 1]
toCoord: _transectPoints[_lastTrueTransectIndex]
exitPosition: true
visible: _currentItem
}
}
Component {
id: exitArrow2Component
MapLineArrow {
fromCoord: _transectPoints[prevTrueTransectIndex - 1]
toCoord: _transectPoints[prevTrueTransectIndex]
exitPosition: true
visible: _currentItem && _transectCount > 3
property int prevTrueTransectIndex: _lastTrueTransectIndex - (_hasTurnaround ? 4 : 2)
}
}
// Exit point // Exit point
Component { Component {
id: exitPointComponent id: exitPointComponent
...@@ -148,7 +193,6 @@ Item { ...@@ -148,7 +193,6 @@ Item {
sourceItem: MissionItemIndexLabel { sourceItem: MissionItemIndexLabel {
index: _missionItem.lastSequenceNumber index: _missionItem.lastSequenceNumber
label: qsTr("Exit")
checked: _missionItem.isCurrentItem checked: _missionItem.isCurrentItem
onClicked: _root.clicked(_missionItem.sequenceNumber) onClicked: _root.clicked(_missionItem.sequenceNumber)
} }
......
...@@ -10,6 +10,7 @@ CenterMapDropPanel 1.0 CenterMapDropPanel.qml ...@@ -10,6 +10,7 @@ CenterMapDropPanel 1.0 CenterMapDropPanel.qml
CompassRing 1.0 CompassRing.qml CompassRing 1.0 CompassRing.qml
InstrumentSwipeView 1.0 InstrumentSwipeView.qml InstrumentSwipeView 1.0 InstrumentSwipeView.qml
MapFitFunctions 1.0 MapFitFunctions.qml MapFitFunctions 1.0 MapFitFunctions.qml
MapLineArrow 1.0 MapLineArrow.qml
MapScale 1.0 MapScale.qml MapScale 1.0 MapScale.qml
QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml
QGCAttitudeHUD 1.0 QGCAttitudeHUD.qml QGCAttitudeHUD 1.0 QGCAttitudeHUD.qml
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment