Browse Source

Merge pull request #6609 from DonLakeFlyer/CircleRadiusDrag

QGCMapCircle: Support for dragging to change radius
QGC4.4
Don Gagne 7 years ago committed by GitHub
parent
commit
beff8561d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 43
      src/MissionManager/QGCMapCircleVisuals.qml

43
src/MissionManager/QGCMapCircleVisuals.qml

@ -117,22 +117,49 @@ Item {
} }
Component { Component {
id: radiusDragAreaComponent
MissionItemIndicatorDrag {
onItemCoordinateChanged: mapCircle.radius.rawValue = mapCircle.center.distanceTo(itemCoordinate)
}
}
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()
} }
} }
} }

Loading…
Cancel
Save