diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index 31732409586935e7a2173c4977d7dcf0553aa0d8..aa12868160521e4eed4c32d2b527de7426bbec1b 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/FlyAreaMapVisual.qml
src/Settings/APMMavlinkStreamRate.SettingsGroup.json
diff --git a/src/MissionManager/WimaController.cc b/src/MissionManager/WimaController.cc
index c507d748ef10b7010663673c90814600bcca033b..3ed4ac8648a7a063e1d7915d3fbf0636261fa8d1 100644
--- a/src/MissionManager/WimaController.cc
+++ b/src/MissionManager/WimaController.cc
@@ -3,13 +3,13 @@
WimaController::WimaController(QObject *parent) : QObject(parent)
{
- this->_flyArea = WimaFlyArea(parent);
+ this->_flyArea = new WimaFlyArea(parent);
}
-
-void WimaController::initWimaFlyArea()
+void WimaController::start()
{
- this->_flyArea.setReady();
- return;
+ _flyArea->_init();
}
+
+
diff --git a/src/MissionManager/WimaController.h b/src/MissionManager/WimaController.h
index e5266fa21a269c126e242d97bea60451c8cfa181..0b404d307bf98183114bd2f385a562857aa32d16 100644
--- a/src/MissionManager/WimaController.h
+++ b/src/MissionManager/WimaController.h
@@ -15,17 +15,14 @@ public:
Q_PROPERTY(WimaFlyArea *flyArea READ flyArea CONSTANT)
//Q_PROPERTY(QmlObjectListModel* visualItems READ visualItems NOTIFY visualItemsChanged)
- /// Add a fly area to the list
- /// @param itemName: Name of complex item to create (from complexMissionItemNames)
- /// @param mapCenterCoordinate: coordinate for current center of map
- /// @param i: index to insert at
- /// @return Sequence number for new item
- Q_INVOKABLE void initWimaFlyArea();
+
//Property Accessors
- WimaFlyArea *flyArea (void) { return &_flyArea; }
+ WimaFlyArea *flyArea (void) { return _flyArea; }
//QmlObjectListModel* visualItems (void) { return _visualItems; }
+ Q_INVOKABLE void start(void);
+
signals:
@@ -33,7 +30,7 @@ public slots:
private:
//QmlObjectListModel* _visualItems;
- WimaFlyArea _flyArea;
+ WimaFlyArea * _flyArea;
};
#endif // WIMACONTROLLER_H
diff --git a/src/MissionManager/WimaFlyArea.cc b/src/MissionManager/WimaFlyArea.cc
index 90953cd1a2e3c414d2c96bda11c1aa7fb6d5135f..92d1d3a74189c74808ffac1d6ccb942baa43b587 100644
--- a/src/MissionManager/WimaFlyArea.cc
+++ b/src/MissionManager/WimaFlyArea.cc
@@ -1,8 +1,9 @@
#include "WimaFlyArea.h"
WimaFlyArea::WimaFlyArea(QObject *parent) : QObject(parent)
+ , _polygons (nullptr)
{
- this->_isReady = false;
+
}
WimaFlyArea::WimaFlyArea(const WimaFlyArea &other, QObject *parent): QObject(parent)
@@ -12,14 +13,23 @@ WimaFlyArea::WimaFlyArea(const WimaFlyArea &other, QObject *parent): QObject(par
const WimaFlyArea& WimaFlyArea::operator=(const WimaFlyArea& other)
{
- this->_flyAreaPolygon = other._flyAreaPolygon;
- this->_isReady = other._isReady;
-
+ this->_polygons = other._polygons;
return *this;
}
-void WimaFlyArea::setReady()
+void WimaFlyArea::_init()
+{
+ _polygons = new QmlObjectListModel(this);
+}
+
+void WimaFlyArea::append_WimaFlyArea()
{
- this->_isReady = true;
- emit readyStateChanged();
+ QGCMapPolygon *newPolygon = new QGCMapPolygon();
+
+ _polygons->append(newPolygon);
+
+ emit polygonsChanged();
}
+
+
+
diff --git a/src/MissionManager/WimaFlyArea.h b/src/MissionManager/WimaFlyArea.h
index 8d9de286631cdf79c06b27989a07709bab56921b..089b5d02db7f3b9d3845d99c32db321137992cd8 100644
--- a/src/MissionManager/WimaFlyArea.h
+++ b/src/MissionManager/WimaFlyArea.h
@@ -3,6 +3,7 @@
#include
#include "QGCMapPolygon.h"
+#include "QmlObjectListModel.h"
class WimaFlyArea : public QObject
{
@@ -15,28 +16,27 @@ public:
- Q_PROPERTY(QString mapVisualQML READ mapVisualQML CONSTANT)
- Q_PROPERTY(bool isReady READ isReady NOTIFY readyStateChanged)
- Q_PROPERTY(QGCMapPolygon flyAreaPolygon READ flyAreaPolygon CONSTANT)
+ Q_PROPERTY(QmlObjectListModel *polygons READ polygons NOTIFY polygonsChanged)
+
+ Q_INVOKABLE void append_WimaFlyArea();
// Property Accessors
- QString mapVisualQML (void) const { return QStringLiteral("FlyAreaMapVisual.qml"); }
- bool isReady (void) { return _isReady;}
- QGCMapPolygon flyAreaPolygon (void) { return _flyAreaPolygon;}
+ QmlObjectListModel * polygons (void) { return _polygons;}
// Methodes
- void setReady();
+ void _init(void);
signals:
- void readyStateChanged(void);
+ void polygonsChanged(void);
public slots:
private:
- QGCMapPolygon _flyAreaPolygon;
- bool _isReady;
+ QmlObjectListModel *_polygons;
+
+
};
#endif // WIMAFLYAREA_H
diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc
index 86c017cab1c4cadf593c1179e503a682e30f24a1..1116e9ded6fff1b96eb4992bc81b539887a00637 100644
--- a/src/QGCApplication.cc
+++ b/src/QGCApplication.cc
@@ -438,7 +438,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterUncreatableType("QGroundControl.FactControls", 1, 0, "FactValueSliderListModel", kRefOnly);
qmlRegisterUncreatableType ("QGroundControl.FlightMap", 1, 0, "QGCMapPolygon", kRefOnly);
- qmlRegisterUncreatableType ("QGroundControl.FlightMap", 1, 0, "WimaFlyArea", kRefOnly); //custom
+
qmlRegisterUncreatableType ("QGroundControl.FlightMap", 1, 0, "QGCGeoBoundingCube", kRefOnly);
qmlRegisterType ("QGroundControl.FlightMap", 1, 0, "QGCMapCircle");
@@ -465,6 +465,10 @@ void QGCApplication::_initCommon(void)
qmlRegisterType (kQGCControllers, 1, 0, "GeoTagController");
qmlRegisterType (kQGCControllers, 1, 0, "MavlinkConsoleController");
#endif
+ // Wima
+ qmlRegisterUncreatableType ("Wima", 1, 0, "WimaFlyArea", kRefOnly); //custom
+ qmlRegisterType ("Wima", 1, 0, "WimaController"); //custom
+
// Register Qml Singletons
qmlRegisterSingletonType ("QGroundControl", 1, 0, "QGroundControl", qgroundcontrolQmlGlobalSingletonFactory);
diff --git a/src/WimaView/WimaView.qml b/src/WimaView/WimaView.qml
index 8f038a33b3c236616104f936f36e8c85e75cb0e0..086dd127acbf3004c29a7676c0970b263239cd7c 100644
--- a/src/WimaView/WimaView.qml
+++ b/src/WimaView/WimaView.qml
@@ -28,6 +28,8 @@ import QGroundControl.ShapeFileHelper 1.0
import QGroundControl.Airspace 1.0
import QGroundControl.Airmap 1.0
+import Wima 1.0
+
/// Mission Editor
QGCView {
@@ -110,6 +112,8 @@ QGCView {
property bool _firstRallyLoadComplete: false
property bool _firstLoadComplete: false
+
+
MapFitFunctions {
id: mapFitFunctions // The name for this id cannot be changed without breaking references outside of this code. Beware!
map: editorMap
@@ -201,6 +205,10 @@ QGCView {
}
WimaController {
id:wimaController
+
+ Component.onCompleted: {
+ wimaController.start()
+ }
}
PlanMasterController {
@@ -530,12 +538,26 @@ QGCView {
}
//Add fly area
- FlyAreaMapVisual {
- map: editorMap
- qgcView: _qgcView
- _flyAreaPolygon: _flyArea.flyAreaPolygon
- }
+ 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()
+ }
+ }
+ onItemAdded: {
+ console.log("Item added")
+ }
+ }
// Add the vehicles to the map
MapItemView {
@@ -617,7 +639,7 @@ QGCView {
iconSource: "/qmlimages/Target.svg",
toggle: true
},
- {
+ {
name: qsTr("No Fly"),
iconSource: "/qmlimages/noFlyArea.svg",
toggle: true
@@ -650,7 +672,8 @@ QGCView {
onClicked: {
switch (index) {
case 1:
- wimaController.initWimaFlyArea();
+ _flyArea.append_WimaFlyArea();
+ console.log("polygon count: ", _flyArea.polygons.count)
//addComplexItem(_missionController.complexMissionItemNames[2])
/*_addWaypointOnClick = checked
_addROIOnClick = false*/
@@ -1175,4 +1198,38 @@ QGCView {
}
}
}
+
+
+
+ Rectangle {
+ id: debugMessageWindow
+ anchors.bottom: parent.bottom
+ width: parent.width*0.7
+ x: (parent.width-width)/2
+ height: 150
+ radius: 10
+ border.color: "black"
+ border.width: 3
+
+ color: "green"
+ z:100
+
+ Text {
+ id: debugTextTitle
+ anchors.top: parent.top
+ x: (parent.width - width)/2
+ text: qsTr("Debug Messages")
+ }
+
+ Text {
+ id: debugText
+ anchors.bottom: parent.bottom
+ x: (parent.width - width)/2
+ width: parent.width*0.95
+ height: parent.height-debugTextTitle.height
+ text: "Polygon count: " + wimaController.flyArea.polygons.dirty;
+
+ }
+ }
+
} // QGCVIew