Commit 3992e5bd authored by DonLakeFlyer's avatar DonLakeFlyer

Draggable radius adjustment for Orbit

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