|
|
|
@ -31,13 +31,22 @@ Item {
@@ -31,13 +31,22 @@ Item {
|
|
|
|
|
property color borderColor: "orange" |
|
|
|
|
|
|
|
|
|
property var _circleComponent |
|
|
|
|
property var _topRotationIndicatorComponent |
|
|
|
|
property var _bottomRotationIndicatorComponent |
|
|
|
|
property var _dragHandlesComponent |
|
|
|
|
property real _radius: mapCircle.radius.rawValue |
|
|
|
|
|
|
|
|
|
function addVisuals() { |
|
|
|
|
if (!_circleComponent) { |
|
|
|
|
_circleComponent = circleComponent.createObject(mapControl) |
|
|
|
|
mapControl.addMapItem(_circleComponent) |
|
|
|
|
} |
|
|
|
|
if (!_topRotationIndicatorComponent) { |
|
|
|
|
_topRotationIndicatorComponent = rotationIndicatorComponent.createObject(mapControl, { "topIndicator": true }) |
|
|
|
|
_bottomRotationIndicatorComponent = rotationIndicatorComponent.createObject(mapControl, { "topIndicator": false }) |
|
|
|
|
mapControl.addMapItem(_topRotationIndicatorComponent) |
|
|
|
|
mapControl.addMapItem(_bottomRotationIndicatorComponent) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function removeVisuals() { |
|
|
|
@ -45,6 +54,12 @@ Item {
@@ -45,6 +54,12 @@ Item {
|
|
|
|
|
_circleComponent.destroy() |
|
|
|
|
_circleComponent = undefined |
|
|
|
|
} |
|
|
|
|
if (_topRotationIndicatorComponent) { |
|
|
|
|
_topRotationIndicatorComponent.destroy() |
|
|
|
|
_bottomRotationIndicatorComponent.destroy() |
|
|
|
|
_topRotationIndicatorComponent = undefined |
|
|
|
|
_bottomRotationIndicatorComponent = undefined |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function addDragHandles() { |
|
|
|
@ -74,15 +89,64 @@ Item {
@@ -74,15 +89,64 @@ Item {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Component.onCompleted: updateInternalComponents() |
|
|
|
|
onInteractiveChanged: updateInternalComponents() |
|
|
|
|
onVisibleChanged: updateInternalComponents() |
|
|
|
|
Component.onCompleted: { |
|
|
|
|
updateInternalComponents() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Component.onDestruction: { |
|
|
|
|
removeVisuals() |
|
|
|
|
removeDragHandles() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onInteractiveChanged: updateInternalComponents() |
|
|
|
|
onVisibleChanged: updateInternalComponents() |
|
|
|
|
|
|
|
|
|
Component { |
|
|
|
|
id: rotationIndicatorComponent |
|
|
|
|
|
|
|
|
|
MapQuickItem { |
|
|
|
|
z: QGroundControl.zOrderMapItems + 2 |
|
|
|
|
visible: mapCircle.showRotation |
|
|
|
|
|
|
|
|
|
property bool topIndicator: true |
|
|
|
|
|
|
|
|
|
property real _rotationRadius: _radius |
|
|
|
|
|
|
|
|
|
function updateCoordinate() { |
|
|
|
|
coordinate = mapCircle.center.atDistanceAndAzimuth(_radius, topIndicator ? 0 : 180) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Component.onCompleted: updateCoordinate() |
|
|
|
|
|
|
|
|
|
on_RotationRadiusChanged: updateCoordinate() |
|
|
|
|
|
|
|
|
|
Connections { |
|
|
|
|
target: mapCircle |
|
|
|
|
onCenterChanged: updateCoordinate() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sourceItem: QGCColoredImage { |
|
|
|
|
anchors.centerIn: parent |
|
|
|
|
width: ScreenTools.defaultFontPixelHeight / 2 |
|
|
|
|
height: ScreenTools.defaultFontPixelHeight |
|
|
|
|
source: "/qmlimages/arrow-down.png" |
|
|
|
|
color: borderColor |
|
|
|
|
|
|
|
|
|
transform: Rotation { |
|
|
|
|
origin.x: width / 2 |
|
|
|
|
origin.y: height / 2 |
|
|
|
|
angle: (mapCircle.clockwiseRotation ? 1 : -1) * (topIndicator ? -90 : 90) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QGCMouseArea { |
|
|
|
|
fillItem: parent |
|
|
|
|
onClicked: mapCircle.clockwiseRotation = !mapCircle.clockwiseRotation |
|
|
|
|
visible: mapCircle.interactive |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Component { |
|
|
|
|
id: circleComponent |
|
|
|
|
|
|
|
|
@ -92,7 +156,7 @@ Item {
@@ -92,7 +156,7 @@ Item {
|
|
|
|
|
border.color: borderColor |
|
|
|
|
border.width: borderWidth |
|
|
|
|
center: mapCircle.center |
|
|
|
|
radius: mapCircle.radius.rawValue |
|
|
|
|
radius: _radius |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -146,7 +210,7 @@ Item {
@@ -146,7 +210,7 @@ Item {
|
|
|
|
|
property var radiusDragArea |
|
|
|
|
property var radiusDragCoord: QtPositioning.coordinate() |
|
|
|
|
property var circleCenterCoord: mapCircle.center |
|
|
|
|
property real circleRadius: mapCircle.radius.rawValue |
|
|
|
|
property real circleRadius: _radius |
|
|
|
|
|
|
|
|
|
function calcRadiusDragCoord() { |
|
|
|
|
radiusDragCoord = mapCircle.center.atDistanceAndAzimuth(circleRadius, 90) |
|
|
|
|