diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index aa12868160521e4eed4c32d2b527de7426bbec1b..79c89f87dc1c4dacc345d636da507f8ee079aef1 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -210,7 +210,7 @@ src/FlightDisplay/VirtualJoystick.qml src/WimaView/WimaToolBar.qml src/WimaView/WimaView.qml - src/WimaView/FlyAreaMapVisual.qml + src/WimaView/FlyAreaPolygonMapVisual.qml src/Settings/APMMavlinkStreamRate.SettingsGroup.json diff --git a/src/MissionManager/QGCMapPolygonVisuals.qml b/src/MissionManager/QGCMapPolygonVisuals.qml index 8c9a093fb6bf20cc6ed38f7c22ca368f642b1e3c..ae559317d27701a14a5d34915a8170926a35253d 100644 --- a/src/MissionManager/QGCMapPolygonVisuals.qml +++ b/src/MissionManager/QGCMapPolygonVisuals.qml @@ -32,6 +32,7 @@ Item { property real interiorOpacity: 1 property int borderWidth: 0 property color borderColor: "black" + property bool initPolygon: false property var _polygonComponent property var _dragHandlesComponent @@ -80,17 +81,17 @@ Item { /// Calculate the default/initial 4 sided polygon function defaultPolygonVertices() { // Initial polygon is inset to take 2/3rds space - var rect = Qt.rect(map.centerViewport.x, map.centerViewport.y, map.centerViewport.width, map.centerViewport.height) + var rect = Qt.rect(mapControl.centerViewport.x, mapControl.centerViewport.y, mapControl.centerViewport.width, mapControl.centerViewport.height) rect.x += (rect.width * 0.25) / 2 rect.y += (rect.height * 0.25) / 2 rect.width *= 0.75 rect.height *= 0.75 - var centerCoord = map.toCoordinate(Qt.point(rect.x + (rect.width / 2), rect.y + (rect.height / 2)), false /* clipToViewPort */) - var topLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */) - var topRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y), false /* clipToViewPort */) - var bottomLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y + rect.height), false /* clipToViewPort */) - var bottomRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */) + var centerCoord = mapControl.toCoordinate(Qt.point(rect.x + (rect.width / 2), rect.y + (rect.height / 2)), false /* clipToViewPort */) + var topLeftCoord = mapControl.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */) + var topRightCoord = mapControl.toCoordinate(Qt.point(rect.x + rect.width, rect.y), false /* clipToViewPort */) + var bottomLeftCoord = mapControl.toCoordinate(Qt.point(rect.x, rect.y + rect.height), false /* clipToViewPort */) + var bottomRightCoord = mapControl.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */) // Initial polygon has max width and height of 3000 meters var halfWidthMeters = Math.min(topLeftCoord.distanceTo(topRightCoord), 3000) / 2 @@ -106,7 +107,7 @@ Item { /// Add an initial 4 sided polygon function addInitialPolygon() { if (mapPolygon.count < 3) { - initialVertices = defaultPolygonVertices() + var initialVertices = defaultPolygonVertices() mapPolygon.appendVertex(initialVertices[0]) mapPolygon.appendVertex(initialVertices[1]) mapPolygon.appendVertex(initialVertices[2]) @@ -158,6 +159,10 @@ Item { } Component.onCompleted: { + if(initPolygon){ + addInitialPolygon() + } + addVisuals() if (interactive) { addHandles() diff --git a/src/MissionManager/WimaController.h b/src/MissionManager/WimaController.h index 0b404d307bf98183114bd2f385a562857aa32d16..59d42be77572e912932aebc62d8372363f9d5974 100644 --- a/src/MissionManager/WimaController.h +++ b/src/MissionManager/WimaController.h @@ -20,6 +20,7 @@ public: //Property Accessors WimaFlyArea *flyArea (void) { return _flyArea; } //QmlObjectListModel* visualItems (void) { return _visualItems; } + QString QMLView Q_INVOKABLE void start(void); diff --git a/src/QmlControls/QGroundControl.Controls.qmldir b/src/QmlControls/QGroundControl.Controls.qmldir index d937f7b0f3cb3bb80b9c9ab67a966a25be4e1efb..d3fe378e159c96cde12a73a3ef0ff2776de48346 100644 --- a/src/QmlControls/QGroundControl.Controls.qmldir +++ b/src/QmlControls/QGroundControl.Controls.qmldir @@ -83,3 +83,4 @@ ToolStrip 1.0 ToolStrip.qml VehicleRotationCal 1.0 VehicleRotationCal.qml VehicleSummaryRow 1.0 VehicleSummaryRow.qml ViewWidget 1.0 ViewWidget.qml +FlyAreaPolygonMapVisual 1.0 FlyAreaPolygonMapVisual.qml diff --git a/src/WimaView/FlyAreaMapVisual.qml b/src/WimaView/FlyAreaMapVisual.qml deleted file mode 100644 index e32b8c68863c03323825c41bc5d2edae4e42d557..0000000000000000000000000000000000000000 --- a/src/WimaView/FlyAreaMapVisual.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2016 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtLocation 5.3 -import QtPositioning 5.3 - -import QGroundControl 1.0 -import QGroundControl.ScreenTools 1.0 -import QGroundControl.Palette 1.0 -import QGroundControl.Controls 1.0 -import QGroundControl.FlightMap 1.0 - -/// Fly Area Map visuals -Item { - id: _root - - property var map ///< Map control to place item in - property var qgcView ///< QGCView to use for popping dialogs - property var _flyAreaPolygon - - - - - /// Add an initial 4 sided polygon if there is none - function _addInitialPolygon() { - if (_flyAreaPolygon.count < 3) { - // Initial polygon is inset to take 2/3rds space - var rect = Qt.rect(map.centerViewport.x, map.centerViewport.y, map.centerViewport.width, map.centerViewport.height) - rect.x += (rect.width * 0.25) / 2 - rect.y += (rect.height * 0.25) / 2 - rect.width *= 0.75 - rect.height *= 0.75 - - var centerCoord = map.toCoordinate(Qt.point(rect.x + (rect.width / 2), rect.y + (rect.height / 2)), false /* clipToViewPort */) - var topLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */) - var topRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y), false /* clipToViewPort */) - var bottomLeftCoord = map.toCoordinate(Qt.point(rect.x, rect.y + rect.height), false /* clipToViewPort */) - var bottomRightCoord = map.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */) - - // Adjust polygon to max size - var maxSize = 100 - var halfWidthMeters = Math.min(topLeftCoord.distanceTo(topRightCoord), maxSize) / 2 - var halfHeightMeters = Math.min(topLeftCoord.distanceTo(bottomLeftCoord), maxSize) / 2 - topLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 0) - topRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 0) - bottomLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 180) - bottomRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 180) - - _flyAreaPolygon.appendVertex(topLeftCoord) - _flyAreaPolygon.appendVertex(topRightCoord) - _flyAreaPolygon.appendVertex(bottomRightCoord) - _flyAreaPolygon.appendVertex(bottomLeftCoord) - } - } - - Component.onCompleted: { - _addInitialPolygon() - } - - QGCMapPolygonVisuals { - qgcView: _root.qgcView - mapControl: map - mapPolygon: _flyAreaPolygon - interactive: true - borderWidth: 1 - borderColor: "black" - interiorColor: "green" - interiorOpacity: 0.25 - } - -} diff --git a/src/WimaView/FlyAreaPolygonMapVisual.qml b/src/WimaView/FlyAreaPolygonMapVisual.qml index 4c751114f4293908787d7ec4f7023677229c158b..5eabc85a9741c4e0f3f8ae5b8bb6458289fc77a2 100644 --- a/src/WimaView/FlyAreaPolygonMapVisual.qml +++ b/src/WimaView/FlyAreaPolygonMapVisual.qml @@ -18,7 +18,7 @@ import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 import QGroundControl.FlightMap 1.0 -/// Survey Complex Mission Item visuals +/// Fly Area visuals Item { id: _root @@ -31,7 +31,7 @@ Item { /// Add an initial 4 sided polygon if there is none function _addInitialPolygon() { - if (_structurePolygon.count < 3) { + if (_flyAreaPolygon.count < 3) { // Initial polygon is inset to take 2/3rds space var rect = Qt.rect(map.centerViewport.x, map.centerViewport.y, map.centerViewport.width, map.centerViewport.height) rect.x += (rect.width * 0.25) / 2 @@ -54,10 +54,10 @@ Item { bottomLeftCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, -90).atDistanceAndAzimuth(halfHeightMeters, 180) bottomRightCoord = centerCoord.atDistanceAndAzimuth(halfWidthMeters, 90).atDistanceAndAzimuth(halfHeightMeters, 180) - _structurePolygon.appendVertex(topLeftCoord) - _structurePolygon.appendVertex(topRightCoord) - _structurePolygon.appendVertex(bottomRightCoord) - _structurePolygon.appendVertex(bottomLeftCoord) + _flyAreaPolygon.appendVertex(topLeftCoord) + _flyAreaPolygon.appendVertex(topRightCoord) + _flyAreaPolygon.appendVertex(bottomRightCoord) + _flyAreaPolygon.appendVertex(bottomLeftCoord) } } diff --git a/src/WimaView/WimaView.qml b/src/WimaView/WimaView.qml index 086dd127acbf3004c29a7676c0970b263239cd7c..91db40d78dc9722830f920c7d195e40da8347835 100644 --- a/src/WimaView/WimaView.qml +++ b/src/WimaView/WimaView.qml @@ -539,19 +539,11 @@ QGCView { //Add fly area Repeater { - model: _flyArea.polygons - delegate: QGCMapPolygonVisuals { - qgcView: _qgcView ///< QGCView for popping dialogs - mapControl: editorMap ///< Map control to place item in - mapPolygon: object - interiorColor: "green" - interiorOpacity: 1 - borderWidth: 1 - borderColor: "white" - - Component.onCompleted: { - addInitialPolygon() - } + model: _flyArea.polygons + delegate: FlyAreaPolygonMapVisual { + map: editorMap ///< Map control to place item in + qgcView: _qgcView ///< QGCView to use for popping dialogs + _flyAreaPolygon: object } onItemAdded: {