Commit 3992e5bd authored by DonLakeFlyer's avatar DonLakeFlyer

Draggable radius adjustment for Orbit

parent beff8561
...@@ -49,7 +49,6 @@ FlightMap { ...@@ -49,7 +49,6 @@ FlightMap {
property var _rallyPointController: _planMasterController.rallyPointController property var _rallyPointController: _planMasterController.rallyPointController
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property var _activeVehicleCoordinate: _activeVehicle ? _activeVehicle.coordinate : QtPositioning.coordinate() property var _activeVehicleCoordinate: _activeVehicle ? _activeVehicle.coordinate : QtPositioning.coordinate()
property var _guidedLocationCoordinate: QtPositioning.coordinate()
property real _toolButtonTopMargin: parent.height - ScreenTools.availableHeight + (ScreenTools.defaultFontPixelHeight / 2) property real _toolButtonTopMargin: parent.height - ScreenTools.availableHeight + (ScreenTools.defaultFontPixelHeight / 2)
property bool _disableVehicleTracking: false property bool _disableVehicleTracking: false
...@@ -274,23 +273,58 @@ FlightMap { ...@@ -274,23 +273,58 @@ FlightMap {
} }
} }
// Guided action location
MapQuickItem { MapQuickItem {
id: guidedLocationItem id: gotoLocationItem
coordinate: _guidedLocationCoordinate visible: false
visible: _activeVehicle && _activeVehicle.guidedModeSupported && _guidedLocationCoordinate.isValid
z: QGroundControl.zOrderMapItems z: QGroundControl.zOrderMapItems
anchorPoint.x: sourceItem.anchorPointX anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.anchorPointY anchorPoint.y: sourceItem.anchorPointY
property bool gotoLocation: true ///< true: Used for go to location, false: used for orbit
sourceItem: MissionItemIndexLabel { sourceItem: MissionItemIndexLabel {
checked: true checked: true
index: -1 index: -1
label: guidedLocationItem.gotoLocation ? qsTr("Goto here", "Goto here waypoint") : qsTr("Orbit here", "Orbit here waypoint") label: qsTr("Goto here", "Goto here waypoint")
}
function show(coord) {
gotoLocationItem.coordinate = coord
gotoLocationItem.visible = true
}
function hide() {
gotoLocationItem.visible = false
}
}
QGCMapCircleVisuals {
id: orbitMapCircle
mapControl: parent
mapCircle: _mapCircle
visible: false
property alias center: _mapCircle.center
property real radius: defaultRadius
readonly property real defaultRadius: 30
function show(coord) {
orbitMapCircle.radius = defaultRadius
orbitMapCircle.center = coord
orbitMapCircle.visible = true
}
function hide() {
orbitMapCircle.visible = false
}
Component.onCompleted: guidedActionsController.orbitMapCircle = orbitMapCircle
QGCMapCircle {
id: _mapCircle
interactive: true
radius.rawValue: orbitMapCircle.radius
} }
} }
// Handle guided mode clicks // Handle guided mode clicks
MouseArea { MouseArea {
...@@ -299,22 +333,27 @@ FlightMap { ...@@ -299,22 +333,27 @@ FlightMap {
Menu { Menu {
id: clickMenu id: clickMenu
property var coord
MenuItem { MenuItem {
text: qsTr("Go to location") text: qsTr("Go to location")
visible: guidedActionsController.showGotoLocation visible: guidedActionsController.showGotoLocation
onTriggered: { onTriggered: {
guidedLocationItem.gotoLocation = true gotoLocationItem.show(clickMenu.coord)
guidedActionsController.confirmAction(guidedActionsController.actionGoto, _guidedLocationCoordinate) orbitMapCircle.hide()
guidedActionsController.confirmAction(guidedActionsController.actionGoto, clickMenu.coord)
} }
} }
MenuItem { MenuItem {
text: qsTr("Orbit at location") text: qsTr("Orbit at location")
visible: guidedActionsController.showOrbit visible: guidedActionsController.showOrbit
onTriggered: { onTriggered: {
guidedLocationItem.gotoLocation = false orbitMapCircle.show(clickMenu.coord)
guidedActionsController.confirmAction(guidedActionsController.actionOrbit, _guidedLocationCoordinate) gotoLocationItem.hide()
guidedActionsController.confirmAction(guidedActionsController.actionOrbit, clickMenu.coord)
} }
} }
} }
...@@ -322,16 +361,19 @@ FlightMap { ...@@ -322,16 +361,19 @@ FlightMap {
onClicked: { onClicked: {
if (guidedActionsController.guidedUIVisible || (!guidedActionsController.showGotoLocation && !guidedActionsController.showOrbit)) { if (guidedActionsController.guidedUIVisible || (!guidedActionsController.showGotoLocation && !guidedActionsController.showOrbit)) {
return return
} }
_guidedLocationCoordinate = flightMap.toCoordinate(Qt.point(mouse.x, mouse.y), false /* clipToViewPort */) orbitMapCircle.hide()
gotoLocationItem.hide()
var clickCoord = flightMap.toCoordinate(Qt.point(mouse.x, mouse.y), false /* clipToViewPort */)
if (guidedActionsController.showGotoLocation && guidedActionsController.showOrbit) { if (guidedActionsController.showGotoLocation && guidedActionsController.showOrbit) {
clickMenu.coord = clickCoord
clickMenu.popup() clickMenu.popup()
} else if (guidedActionsController.showGotoLocation) { } else if (guidedActionsController.showGotoLocation) {
guidedLocationItem.gotoLocation = true _guidedLocationCoordinate = clickCoord
guidedActionsController.confirmAction(guidedActionsController.actionGoto, _guidedLocationCoordinate) guidedActionsController.confirmAction(guidedActionsController.actionGoto, clickCoord)
} else if (guidedActionsController.showOrbit) { } else if (guidedActionsController.showOrbit) {
guidedLocationItem.gotoLocation = false orbitMapCircle.show(clickCoord)
guidedActionsController.confirmAction(guidedActionsController.actionOrbit, _guidedLocationCoordinate) guidedActionsController.confirmAction(guidedActionsController.actionOrbit, clickCoord)
} }
} }
} }
......
...@@ -31,6 +31,7 @@ Item { ...@@ -31,6 +31,7 @@ Item {
property var confirmDialog property var confirmDialog
property var actionList property var actionList
property var altitudeSlider property var altitudeSlider
property var orbitMapCircle
readonly property string emergencyStopTitle: qsTr("EMERGENCY STOP") readonly property string emergencyStopTitle: qsTr("EMERGENCY STOP")
readonly property string armTitle: qsTr("Arm") readonly property string armTitle: qsTr("Arm")
...@@ -388,7 +389,8 @@ Item { ...@@ -388,7 +389,8 @@ Item {
_activeVehicle.setCurrentMissionSequence(actionData) _activeVehicle.setCurrentMissionSequence(actionData)
break break
case actionOrbit: case actionOrbit:
_activeVehicle.guidedModeOrbit(actionData, 10 /* Hacked fixed radius */, _activeVehicle.altitudeAMSL + actionAltitudeChange) _activeVehicle.guidedModeOrbit(orbitMapCircle.center, orbitMapCircle.radius, _activeVehicle.altitudeAMSL + actionAltitudeChange)
orbitMapCircle.hide()
break break
case actionLandAbort: case actionLandAbort:
_activeVehicle.abortLanding(50) // hardcoded value for climbOutAltitude that is currently ignored _activeVehicle.abortLanding(50) // hardcoded value for climbOutAltitude that is currently ignored
......
...@@ -25,6 +25,7 @@ Rectangle { ...@@ -25,6 +25,7 @@ Rectangle {
z: QGroundControl.zOrderMapItems + 1 // Above item icons z: QGroundControl.zOrderMapItems + 1 // Above item icons
// Properties which must be specific by consumer // Properties which must be specific by consumer
property var mapControl ///< Map control which contains this item
property var itemIndicator ///< The mission item indicator to drag around property var itemIndicator ///< The mission item indicator to drag around
property var itemCoordinate ///< Coordinate we are updating during drag property var itemCoordinate ///< Coordinate we are updating during drag
...@@ -51,7 +52,7 @@ Rectangle { ...@@ -51,7 +52,7 @@ Rectangle {
function liveDrag() { function liveDrag() {
if (!itemDragger._preventCoordinateBindingLoop && itemDrag.drag.active) { if (!itemDragger._preventCoordinateBindingLoop && itemDrag.drag.active) {
var point = Qt.point(itemDragger.x + _touchMarginHorizontal + itemIndicator.anchorPoint.x, itemDragger.y + _touchMarginVertical + itemIndicator.anchorPoint.y) var point = Qt.point(itemDragger.x + _touchMarginHorizontal + itemIndicator.anchorPoint.x, itemDragger.y + _touchMarginVertical + itemIndicator.anchorPoint.y)
var coordinate = map.toCoordinate(point, false /* clipToViewPort */) var coordinate = mapControl.toCoordinate(point, false /* clipToViewPort */)
itemDragger._preventCoordinateBindingLoop = true itemDragger._preventCoordinateBindingLoop = true
coordinate.altitude = itemCoordinate.altitude coordinate.altitude = itemCoordinate.altitude
itemCoordinate = coordinate itemCoordinate = coordinate
......
...@@ -27,52 +27,60 @@ Item { ...@@ -27,52 +27,60 @@ Item {
property bool interactive: mapCircle.interactive /// true: user can manipulate polygon property bool interactive: mapCircle.interactive /// true: user can manipulate polygon
property color interiorColor: "transparent" property color interiorColor: "transparent"
property real interiorOpacity: 1 property real interiorOpacity: 1
property int borderWidth: 0 property int borderWidth: 2
property color borderColor: "black" property color borderColor: "orange"
property var _circleComponent property var _circleComponent
property var _centerDragHandleComponent property var _dragHandlesComponent
function addVisuals() { function addVisuals() {
_circleComponent = circleComponent.createObject(mapControl) if (!_circleComponent) {
mapControl.addMapItem(_circleComponent) _circleComponent = circleComponent.createObject(mapControl)
mapControl.addMapItem(_circleComponent)
}
} }
function removeVisuals() { function removeVisuals() {
_circleComponent.destroy() if (_circleComponent) {
_circleComponent.destroy()
_circleComponent = undefined
}
} }
function addHandles() { function addDragHandles() {
if (!_centerDragHandleComponent) { if (!_dragHandlesComponent) {
_centerDragHandleComponent = centerDragHandleComponent.createObject(mapControl) _dragHandlesComponent = dragHandlesComponent.createObject(mapControl)
} }
} }
function removeHandles() { function removeDragHandles() {
if (_centerDragHandleComponent) { if (_dragHandlesComponent) {
_centerDragHandleComponent.destroy() _dragHandlesComponent.destroy()
_centerDragHandleComponent = undefined _dragHandlesComponent = undefined
} }
} }
onInteractiveChanged: { function updateInternalComponents() {
if (interactive) { if (visible) {
addHandles() addVisuals()
if (interactive) {
addDragHandles()
} else {
removeDragHandles()
}
} else { } else {
removeHandles() removeVisuals()
removeDragHandles()
} }
} }
Component.onCompleted: { Component.onCompleted: updateInternalComponents()
addVisuals() onInteractiveChanged: updateInternalComponents()
if (interactive) { onVisibleChanged: updateInternalComponents()
addHandles()
}
}
Component.onDestruction: { Component.onDestruction: {
removeVisuals() removeVisuals()
removeHandles() removeDragHandles()
} }
Component { Component {
...@@ -112,6 +120,8 @@ Item { ...@@ -112,6 +120,8 @@ Item {
id: centerDragAreaComponent id: centerDragAreaComponent
MissionItemIndicatorDrag { MissionItemIndicatorDrag {
mapControl: _root.mapControl
onItemCoordinateChanged: mapCircle.center = itemCoordinate onItemCoordinateChanged: mapCircle.center = itemCoordinate
} }
} }
...@@ -120,12 +130,14 @@ Item { ...@@ -120,12 +130,14 @@ Item {
id: radiusDragAreaComponent id: radiusDragAreaComponent
MissionItemIndicatorDrag { MissionItemIndicatorDrag {
mapControl: _root.mapControl
onItemCoordinateChanged: mapCircle.radius.rawValue = mapCircle.center.distanceTo(itemCoordinate) onItemCoordinateChanged: mapCircle.radius.rawValue = mapCircle.center.distanceTo(itemCoordinate)
} }
} }
Component { Component {
id: centerDragHandleComponent id: dragHandlesComponent
Item { Item {
property var centerDragHandle property var centerDragHandle
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
#include "FollowMe.h" #include "FollowMe.h"
#include "MissionCommandTree.h" #include "MissionCommandTree.h"
#include "QGCMapPolygon.h" #include "QGCMapPolygon.h"
#include "QGCMapCircle.h"
#include "ParameterManager.h" #include "ParameterManager.h"
#include "SettingsManager.h" #include "SettingsManager.h"
#include "QGCCorePlugin.h" #include "QGCCorePlugin.h"
...@@ -389,6 +390,7 @@ void QGCApplication::_initCommon(void) ...@@ -389,6 +390,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<LogDownloadController> ("QGroundControl.Controllers", 1, 0, "LogDownloadController"); qmlRegisterType<LogDownloadController> ("QGroundControl.Controllers", 1, 0, "LogDownloadController");
qmlRegisterType<SyslinkComponentController> ("QGroundControl.Controllers", 1, 0, "SyslinkComponentController"); qmlRegisterType<SyslinkComponentController> ("QGroundControl.Controllers", 1, 0, "SyslinkComponentController");
qmlRegisterType<EditPositionDialogController> ("QGroundControl.Controllers", 1, 0, "EditPositionDialogController"); qmlRegisterType<EditPositionDialogController> ("QGroundControl.Controllers", 1, 0, "EditPositionDialogController");
qmlRegisterType<QGCMapCircle> ("QGroundControl.FlightMap", 1, 0, "QGCMapCircle");
#ifndef __mobile__ #ifndef __mobile__
qmlRegisterType<ViewWidgetController> ("QGroundControl.Controllers", 1, 0, "ViewWidgetController"); qmlRegisterType<ViewWidgetController> ("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType<CustomCommandWidgetController> ("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController"); qmlRegisterType<CustomCommandWidgetController> ("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController");
......
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