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

Merge pull request #6609 from DonLakeFlyer/CircleRadiusDrag

QGCMapCircle: Support for dragging to change radius
parents 38a2246e 920969bb
...@@ -116,23 +116,50 @@ Item { ...@@ -116,23 +116,50 @@ Item {
} }
} }
Component {
id: radiusDragAreaComponent
MissionItemIndicatorDrag {
onItemCoordinateChanged: mapCircle.radius.rawValue = mapCircle.center.distanceTo(itemCoordinate)
}
}
Component { Component {
id: centerDragHandleComponent id: centerDragHandleComponent
Item { Item {
property var dragHandle property var centerDragHandle
property var dragArea property var centerDragArea
property var radiusDragHandle
property var radiusDragArea
property var radiusDragCoord: QtPositioning.coordinate()
property var circleCenterCoord: mapCircle.center
property real circleRadius: mapCircle.radius.rawValue
function calcRadiusDragCoord() {
radiusDragCoord = mapCircle.center.atDistanceAndAzimuth(circleRadius, 90)
}
onCircleCenterCoordChanged: calcRadiusDragCoord()
onCircleRadiusChanged: calcRadiusDragCoord()
Component.onCompleted: { Component.onCompleted: {
dragHandle = dragHandleComponent.createObject(mapControl) calcRadiusDragCoord()
dragHandle.coordinate = Qt.binding(function() { return mapCircle.center }) radiusDragHandle = dragHandleComponent.createObject(mapControl)
mapControl.addMapItem(dragHandle) radiusDragHandle.coordinate = Qt.binding(function() { return radiusDragCoord })
dragArea = centerDragAreaComponent.createObject(mapControl, { "itemIndicator": dragHandle, "itemCoordinate": mapCircle.center }) mapControl.addMapItem(radiusDragHandle)
radiusDragArea = radiusDragAreaComponent.createObject(mapControl, { "itemIndicator": radiusDragHandle, "itemCoordinate": radiusDragCoord })
centerDragHandle = dragHandleComponent.createObject(mapControl)
centerDragHandle.coordinate = Qt.binding(function() { return circleCenterCoord })
mapControl.addMapItem(centerDragHandle)
centerDragArea = centerDragAreaComponent.createObject(mapControl, { "itemIndicator": centerDragHandle, "itemCoordinate": circleCenterCoord })
} }
Component.onDestruction: { Component.onDestruction: {
dragHandle.destroy() centerDragHandle.destroy()
dragArea.destroy() centerDragArea.destroy()
radiusDragHandle.destroy()
radiusDragArea.destroy()
} }
} }
} }
......
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