Browse Source

Updated visuals

QGC4.4
Don Gagne 6 years ago
parent
commit
e58ddc00af
  1. 215
      src/PlanView/FWLandingPatternMapVisual.qml

215
src/PlanView/FWLandingPatternMapVisual.qml

@ -26,17 +26,17 @@ Item {
signal clicked(int sequenceNumber) signal clicked(int sequenceNumber)
property var _missionItem: object readonly property real _landingWidthMeters: 15
property var _itemVisuals: [ ] readonly property real _landingLengthMeters: 100
property var _mouseArea
property var _dragAreas: [ ] property var _missionItem: object
property var _flightPath property var _itemVisuals: [ ]
property var _mouseArea
readonly property int _flightPathIndex: 0 property var _dragAreas: [ ]
readonly property int _loiterPointIndex: 1 property var _flightPath
readonly property int _loiterRadiusIndex: 2 property real _landingAreaBearing: _missionItem.landingCoordinate.azimuthTo(_missionItem.loiterTangentCoordinate)
readonly property int _landingAreaIndex: 3 property var _loiterPointObject
readonly property int _landPointIndex: 4 property var _landingPointObject
function hideItemVisuals() { function hideItemVisuals() {
for (var i=0; i<_itemVisuals.length; i++) { for (var i=0; i<_itemVisuals.length; i++) {
@ -46,22 +46,23 @@ Item {
} }
function showItemVisuals() { function showItemVisuals() {
if (_itemVisuals.length === 0) { if (_itemVisuals.length === 0) {
var itemVisual = flightPathComponent.createObject(map) var itemVisual = loiterPointComponent.createObject(map)
map.addMapItem(itemVisual) map.addMapItem(itemVisual)
_itemVisuals[_flightPathIndex] =itemVisual _itemVisuals.push(itemVisual)
itemVisual = loiterPointComponent.createObject(map) _loiterPointObject = itemVisual
map.addMapItem(itemVisual)
_itemVisuals[_loiterPointIndex] = itemVisual itemVisual = landingPointComponent.createObject(map)
itemVisual = loiterRadiusComponent.createObject(map)
map.addMapItem(itemVisual)
_itemVisuals[_loiterRadiusIndex] = itemVisual
itemVisual = landingAreaComponent.createObject(map)
map.addMapItem(itemVisual)
_itemVisuals[_landingAreaIndex] = itemVisual
itemVisual = landPointComponent.createObject(map)
map.addMapItem(itemVisual) map.addMapItem(itemVisual)
_itemVisuals[_landPointIndex] = itemVisual _itemVisuals.push(itemVisual)
_landingPointObject = itemVisual
var rgComponents = [ flightPathComponent, loiterRadiusComponent, landingAreaComponent, landingAreaLabelComponent, glideSlopeComponent, glideSlopeLabelComponent ]
for (var i=0; i<rgComponents.length; i++) {
var obj = rgComponents[i].createObject(map)
_itemVisuals.push(obj)
map.addMapItem(obj)
}
} }
} }
@ -177,7 +178,7 @@ Item {
MissionItemIndicatorDrag { MissionItemIndicatorDrag {
mapControl: _root.map mapControl: _root.map
itemIndicator: _itemVisuals[_loiterPointIndex] itemIndicator: _loiterPointObject
itemCoordinate: _missionItem.loiterCoordinate itemCoordinate: _missionItem.loiterCoordinate
onItemCoordinateChanged: _missionItem.loiterCoordinate = itemCoordinate onItemCoordinateChanged: _missionItem.loiterCoordinate = itemCoordinate
@ -190,7 +191,7 @@ Item {
MissionItemIndicatorDrag { MissionItemIndicatorDrag {
mapControl: _root.map mapControl: _root.map
itemIndicator: _itemVisuals[_landPointIndex] itemIndicator: _landingPointObject
itemCoordinate: _missionItem.landingCoordinate itemCoordinate: _missionItem.landingCoordinate
onItemCoordinateChanged: _missionItem.landingCoordinate = itemCoordinate onItemCoordinateChanged: _missionItem.landingCoordinate = itemCoordinate
@ -230,6 +231,26 @@ Item {
} }
} }
// Landing point
Component {
id: landingPointComponent
MapQuickItem {
anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.anchorPointY
z: QGroundControl.zOrderMapItems
coordinate: _missionItem.landingCoordinate
sourceItem:
MissionItemIndexLabel {
index: _missionItem.sequenceNumber
checked: _missionItem.isCurrentItem
onClicked: _root.clicked(_missionItem.sequenceNumber)
}
}
}
Component { Component {
id: loiterRadiusComponent id: loiterRadiusComponent
@ -244,21 +265,88 @@ Item {
} }
Component { Component {
id: landPointComponent id: landingAreaLabelComponent
MapQuickItem { MapQuickItem {
anchorPoint.x: sourceItem.anchorPointX anchorPoint.x: sourceItem.contentWidth / 2
anchorPoint.y: sourceItem.anchorPointY anchorPoint.y: sourceItem.contentHeight / 2
z: QGroundControl.zOrderMapItems z: QGroundControl.zOrderMapItems
coordinate: _missionItem.landingCoordinate coordinate: _missionItem.landingCoordinate
visible: _missionItem.isCurrentItem
sourceItem: QGCLabel {
id: landingAreaLabel
text: qsTr("Landing Area")
color: "white"
property real _rawBearing: _landingAreaBearing
property real _adjustedBearing
on_RawBearingChanged: {
_adjustedBearing = _rawBearing
if (_adjustedBearing > 180) {
_adjustedBearing -= 180
}
_adjustedBearing -= 90
if (_adjustedBearing < 0) {
_adjustedBearing += 360
}
}
sourceItem: transform: Rotation {
MissionItemIndexLabel { origin.x: landingAreaLabel.width / 2
index: _missionItem.lastSequenceNumber origin.y: landingAreaLabel.height / 2
label: "Land" angle: landingAreaLabel._adjustedBearing
checked: _missionItem.isCurrentItem }
}
}
}
onClicked: _root.clicked(_missionItem.sequenceNumber) Component {
id: glideSlopeLabelComponent
MapQuickItem {
anchorPoint.x: 0
anchorPoint.y: sourceItem.contentHeight / 2
z: QGroundControl.zOrderMapItems
visible: _missionItem.isCurrentItem
sourceItem: QGCLabel {
id: glideSlopeLabel
text: qsTr("Glide Slope")
color: "white"
property real _rawBearing: _landingAreaBearing
property real _adjustedBearing
on_RawBearingChanged: {
_adjustedBearing = _rawBearing
if (_adjustedBearing > 180) {
_adjustedBearing -= 180
}
_adjustedBearing -= 90
if (_adjustedBearing < 0) {
_adjustedBearing += 360
}
}
transform: Rotation {
origin.x: 0
origin.y: glideSlopeLabel.contentHeight / 2
angle: glideSlopeLabel._adjustedBearing
}
}
function recalc() {
coordinate = _missionItem.landingCoordinate.atDistanceAndAzimuth(_landingLengthMeters / 2 + 2, _landingAreaBearing)
}
Component.onCompleted: recalc()
Connections {
target: _missionItem
onLandingCoordinateChanged: recalc()
onLoiterTangentCoordinateChanged: recalc()
} }
} }
} }
@ -273,28 +361,55 @@ Item {
color: "green" color: "green"
opacity: 0.5 opacity: 0.5
readonly property real landingWidth: 15 readonly property real angleRadians: Math.atan((_landingWidthMeters / 2) / (_landingLengthMeters / 2))
readonly property real landingLength: 100
readonly property real angleRadians: Math.atan((landingWidth / 2) / (landingLength / 2))
readonly property real angleDegrees: (angleRadians * (180 / Math.PI)) readonly property real angleDegrees: (angleRadians * (180 / Math.PI))
readonly property real hypotenuse: (landingWidth / 2) / Math.sin(angleRadians) readonly property real hypotenuse: (_landingWidthMeters / 2) / Math.sin(angleRadians)
function recalc() {
path = [ ]
addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, _landingAreaBearing - angleDegrees))
addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, _landingAreaBearing + angleDegrees))
addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, _landingAreaBearing + (180 - angleDegrees)))
addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, _landingAreaBearing - (180 - angleDegrees)))
}
Component.onCompleted: recalc()
Connections {
target: _missionItem
onLandingCoordinateChanged: recalc()
onLoiterTangentCoordinateChanged: recalc()
}
}
}
Component {
id: glideSlopeComponent
MapPolygon {
z: QGroundControl.zOrderMapItems
border.width: 1
border.color: "black"
color: "orange"
opacity: 0.5
property real landingAreaAngle: _missionItem.landingCoordinate.azimuthTo(_missionItem.loiterTangentCoordinate) readonly property real angleRadians: Math.atan((_landingWidthMeters / 2) / (_landingLengthMeters / 2))
readonly property real angleDegrees: (angleRadians * (180 / Math.PI))
readonly property real hypotenuse: (_landingWidthMeters / 2) / Math.sin(angleRadians)
function calcPoly() { function recalc() {
path = [ ] path = [ ]
addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, landingAreaAngle - angleDegrees)) addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, _landingAreaBearing - angleDegrees))
addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, landingAreaAngle + angleDegrees)) addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, _landingAreaBearing + angleDegrees))
addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, landingAreaAngle + (180 - angleDegrees))) addCoordinate(_missionItem.loiterTangentCoordinate)
addCoordinate(_missionItem.landingCoordinate.atDistanceAndAzimuth(hypotenuse, landingAreaAngle - (180 - angleDegrees)))
} }
Component.onCompleted: calcPoly() Component.onCompleted: recalc()
Connections { Connections {
target: _missionItem target: _missionItem
onLandingCoordinateChanged: calcPoly() onLandingCoordinateChanged: recalc()
onLoiterTangentCoordinateChanged: calcPoly() onLoiterTangentCoordinateChanged: recalc()
} }
} }
} }

Loading…
Cancel
Save