diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 8e9e8fc779bc1bd68f8aeb06186d40bb819b27e3..b25a9fa69ed727be29273e5ca840fbf3d78849fd 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -41,6 +41,7 @@ src/VehicleSetup/PX4FlowSensor.qml src/AnalyzeView/AnalyzePage.qml src/QmlControls/AppMessages.qml + src/MissionEditor/ComplexMissionItem.qml src/QmlControls/ClickableColor.qml src/QmlControls/DropButton.qml src/QmlControls/ExclusiveGroupItem.qml @@ -92,6 +93,7 @@ src/ui/toolbar/SignalStrength.qml src/QmlControls/SliderSwitch.qml src/QmlControls/SubMenuButton.qml + src/MissionEditor/SurveyComplexItem.qml src/QmlControls/VehicleRotationCal.qml src/QmlControls/VehicleSummaryRow.qml src/QmlControls/ToolStrip.qml diff --git a/src/MissionEditor/ComplexMissionItem.qml b/src/MissionEditor/ComplexMissionItem.qml new file mode 100644 index 0000000000000000000000000000000000000000..5ee3527d3564f036f8f181b8dde19950b1c9130d --- /dev/null +++ b/src/MissionEditor/ComplexMissionItem.qml @@ -0,0 +1,43 @@ +/**************************************************************************** + * + * (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.2 +import QtQuick.Controls 1.2 +import QtLocation 5.3 +import QtPositioning 5.2 + +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 + + +/// Mission item edit control +Item { + id: _root + + property var map ///< Map control to place item in + + property var _complexItem + + Component.onCompleted: { + if (object.mapVisualQML) { + var component = Qt.createComponent(object.mapVisualQML) + if (component.status === Component.Error) { + console.log("Error loading Qml: ", object.mapVisualQML, component.errorString()) + } + _complexItem = component.createObject(map, { "map": _root.map }) + } + } + + Component.onDestruction: { + if (_complexItem) { + _complexItem.destroy() + } + } +} diff --git a/src/MissionEditor/MissionEditor.qml b/src/MissionEditor/MissionEditor.qml index a71ce19d61265d28eda225c878b7088146056547..2bcb265e43a1c9a3cc7b4eb104b3d0b766582a74 100644 --- a/src/MissionEditor/MissionEditor.qml +++ b/src/MissionEditor/MissionEditor.qml @@ -445,25 +445,12 @@ QGCView { } } - // Add the complex mission item polygon to the map - MapItemView { - model: missionController.complexVisualItems - - delegate: MapPolygon { - color: 'green' - path: object.polygonPath - opacity: 0.5 - } - } - - // Add the complex mission item grid to the map - MapItemView { + // Add the complex mission item to the map + Repeater { model: missionController.complexVisualItems - delegate: MapPolyline { - line.color: "white" - line.width: 2 - path: object.gridPoints + delegate: ComplexMissionItem { + map: editorMap } } diff --git a/src/MissionEditor/SurveyComplexItem.qml b/src/MissionEditor/SurveyComplexItem.qml new file mode 100644 index 0000000000000000000000000000000000000000..d3a2382cb43773dea9fdee0e9ab95f5af88ef08e --- /dev/null +++ b/src/MissionEditor/SurveyComplexItem.qml @@ -0,0 +1,59 @@ +/**************************************************************************** + * + * (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.2 +import QtQuick.Controls 1.2 +import QtLocation 5.3 +import QtPositioning 5.2 + +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 + +/// Survey Complex Mission Item visuals +Item { + property var map ///< Map control to place item in + + property var _polygon + property var _grid + + Component.onCompleted: { + _polygon = polygonComponent.createObject(map) + _grid = gridComponent.createObject(map) + map.addMapItem(_polygon) + map.addMapItem(_grid) + } + + Component.onDestruction: { + _polygon.destroy() + _grid.destroy() + } + + // Survey area polygon + Component { + id: polygonComponent + + MapPolygon { + color: "green" + opacity: 0.5 + path: object.polygonPath + } + } + + // Survey grid lines + Component { + id: gridComponent + + MapPolyline { + line.color: "white" + line.width: 2 + path: object.gridPoints + } + } +} diff --git a/src/MissionManager/ComplexMissionItem.h b/src/MissionManager/ComplexMissionItem.h index ad512e6eed13b4aa119a2f69bd5d76668b35b337..5aa8b072da6c258c252ff5b3c485130f973c42eb 100644 --- a/src/MissionManager/ComplexMissionItem.h +++ b/src/MissionManager/ComplexMissionItem.h @@ -21,6 +21,7 @@ public: const ComplexMissionItem& operator=(const ComplexMissionItem& other); + Q_PROPERTY(QString mapVisualQML READ mapVisualQML CONSTANT) Q_PROPERTY(int lastSequenceNumber READ lastSequenceNumber NOTIFY lastSequenceNumberChanged) Q_PROPERTY(double complexDistance READ complexDistance NOTIFY complexDistanceChanged) @@ -52,6 +53,9 @@ public: /// This mission item attribute specifies the type of the complex item. static const char* jsonComplexItemTypeKey; + /// @return The QML resource file which contains the control which visualizes the item on the map. + virtual QString mapVisualQML(void) const = 0; + signals: void lastSequenceNumberChanged (int lastSequenceNumber); void complexDistanceChanged (double complexDistance); diff --git a/src/MissionManager/FixedWingLandingComplexItem.h b/src/MissionManager/FixedWingLandingComplexItem.h index 0c9f76b43ccbf61004f31eb3989696062b151add..26a5c47664e246faa1ff83607954511a3f07c7df 100644 --- a/src/MissionManager/FixedWingLandingComplexItem.h +++ b/src/MissionManager/FixedWingLandingComplexItem.h @@ -32,6 +32,7 @@ public: bool load (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) final; double greatestDistanceTo (const QGeoCoordinate &other) const final; void setCruiseSpeed (double cruiseSpeed) final; + QString mapVisualQML (void) const final { return QString(); } // Overrides from VisualMissionItem diff --git a/src/MissionManager/SurveyMissionItem.h b/src/MissionManager/SurveyMissionItem.h index 7f46a28ca01deee7b533164c5651615379a65800..6ad612d57eccef3417f2d68863c11650f546add8 100644 --- a/src/MissionManager/SurveyMissionItem.h +++ b/src/MissionManager/SurveyMissionItem.h @@ -83,6 +83,7 @@ public: bool load (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) final; double greatestDistanceTo (const QGeoCoordinate &other) const final; void setCruiseSpeed (double cruiseSpeed) final; + QString mapVisualQML (void) const final { return QStringLiteral("SurveyComplexItem.qml"); } // Overrides from VisualMissionItem diff --git a/src/QmlControls/QGroundControl.Controls.qmldir b/src/QmlControls/QGroundControl.Controls.qmldir index eed1fdc475d98f89546f56c0af12483f07a7bb38..2040fedc4f5122c61cb5620c78edbfe0a4a97e74 100644 --- a/src/QmlControls/QGroundControl.Controls.qmldir +++ b/src/QmlControls/QGroundControl.Controls.qmldir @@ -3,6 +3,7 @@ Module QGroundControl.Controls AnalyzePage 1.0 AnalyzePage.qml AppMessages 1.0 AppMessages.qml ClickableColor 1.0 ClickableColor.qml +ComplexMissionItem 1.0 ComplexMissionItem.qml DropButton 1.0 DropButton.qml DropPanel 1.0 DropPanel.qml ExclusiveGroupItem 1.0 ExclusiveGroupItem.qml @@ -50,6 +51,7 @@ SetupPage 1.0 SetupPage.qml SignalStrength 1.0 SignalStrength.qml SliderSwitch 1.0 SliderSwitch.qml SubMenuButton 1.0 SubMenuButton.qml +SurveyComplexItem 1.0 SurveyComplexItem.qml ToolStrip 1.0 ToolStrip.qml VehicleRotationCal 1.0 VehicleRotationCal.qml VehicleSummaryRow 1.0 VehicleSummaryRow.qml