Commit e7ee7d09 authored by Valentin Platzgummer's avatar Valentin Platzgummer

before editing QGCMapPolygonVisuals.qml

parent 1b6d3ca9
...@@ -210,7 +210,7 @@ ...@@ -210,7 +210,7 @@
<file alias="VirtualJoystick.qml">src/FlightDisplay/VirtualJoystick.qml</file> <file alias="VirtualJoystick.qml">src/FlightDisplay/VirtualJoystick.qml</file>
<file alias="QGroundControl/Controls/WimaToolBar.qml">src/WimaView/WimaToolBar.qml</file> <file alias="QGroundControl/Controls/WimaToolBar.qml">src/WimaView/WimaToolBar.qml</file>
<file alias="WimaView.qml">src/WimaView/WimaView.qml</file> <file alias="WimaView.qml">src/WimaView/WimaView.qml</file>
<file alias="QGroundControl/Controls/FlyAreaMapVisual.qml">src/WimaView/FlyAreaMapVisual.qml</file> <file alias="QGroundControl/FlightMap/FlyAreaMapVisual.qml">src/WimaView/FlyAreaMapVisual.qml</file>
</qresource> </qresource>
<qresource prefix="/json"> <qresource prefix="/json">
<file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file> <file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file>
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
WimaController::WimaController(QObject *parent) : QObject(parent) WimaController::WimaController(QObject *parent) : QObject(parent)
{ {
this->_flyArea = WimaFlyArea(parent); this->_flyArea = new WimaFlyArea(parent);
} }
void WimaController::start()
void WimaController::initWimaFlyArea()
{ {
this->_flyArea.setReady(); _flyArea->_init();
return;
} }
...@@ -15,17 +15,14 @@ public: ...@@ -15,17 +15,14 @@ public:
Q_PROPERTY(WimaFlyArea *flyArea READ flyArea CONSTANT) Q_PROPERTY(WimaFlyArea *flyArea READ flyArea CONSTANT)
//Q_PROPERTY(QmlObjectListModel* visualItems READ visualItems NOTIFY visualItemsChanged) //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 //Property Accessors
WimaFlyArea *flyArea (void) { return &_flyArea; } WimaFlyArea *flyArea (void) { return _flyArea; }
//QmlObjectListModel* visualItems (void) { return _visualItems; } //QmlObjectListModel* visualItems (void) { return _visualItems; }
Q_INVOKABLE void start(void);
signals: signals:
...@@ -33,7 +30,7 @@ public slots: ...@@ -33,7 +30,7 @@ public slots:
private: private:
//QmlObjectListModel* _visualItems; //QmlObjectListModel* _visualItems;
WimaFlyArea _flyArea; WimaFlyArea * _flyArea;
}; };
#endif // WIMACONTROLLER_H #endif // WIMACONTROLLER_H
#include "WimaFlyArea.h" #include "WimaFlyArea.h"
WimaFlyArea::WimaFlyArea(QObject *parent) : QObject(parent) WimaFlyArea::WimaFlyArea(QObject *parent) : QObject(parent)
, _polygons (nullptr)
{ {
this->_isReady = false;
} }
WimaFlyArea::WimaFlyArea(const WimaFlyArea &other, QObject *parent): QObject(parent) WimaFlyArea::WimaFlyArea(const WimaFlyArea &other, QObject *parent): QObject(parent)
...@@ -12,14 +13,23 @@ WimaFlyArea::WimaFlyArea(const WimaFlyArea &other, QObject *parent): QObject(par ...@@ -12,14 +13,23 @@ WimaFlyArea::WimaFlyArea(const WimaFlyArea &other, QObject *parent): QObject(par
const WimaFlyArea& WimaFlyArea::operator=(const WimaFlyArea& other) const WimaFlyArea& WimaFlyArea::operator=(const WimaFlyArea& other)
{ {
this->_flyAreaPolygon = other._flyAreaPolygon; this->_polygons = other._polygons;
this->_isReady = other._isReady;
return *this; return *this;
} }
void WimaFlyArea::setReady() void WimaFlyArea::_init()
{
_polygons = new QmlObjectListModel(this);
}
void WimaFlyArea::append_WimaFlyArea()
{ {
this->_isReady = true; QGCMapPolygon *newPolygon = new QGCMapPolygon();
emit readyStateChanged();
_polygons->append(newPolygon);
emit polygonsChanged();
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <QObject> #include <QObject>
#include "QGCMapPolygon.h" #include "QGCMapPolygon.h"
#include "QmlObjectListModel.h"
class WimaFlyArea : public QObject class WimaFlyArea : public QObject
{ {
...@@ -15,28 +16,27 @@ public: ...@@ -15,28 +16,27 @@ public:
Q_PROPERTY(QString mapVisualQML READ mapVisualQML CONSTANT) Q_PROPERTY(QmlObjectListModel *polygons READ polygons NOTIFY polygonsChanged)
Q_PROPERTY(bool isReady READ isReady NOTIFY readyStateChanged)
Q_PROPERTY(QGCMapPolygon flyAreaPolygon READ flyAreaPolygon CONSTANT) Q_INVOKABLE void append_WimaFlyArea();
// Property Accessors // Property Accessors
QString mapVisualQML (void) const { return QStringLiteral("FlyAreaMapVisual.qml"); } QmlObjectListModel * polygons (void) { return _polygons;}
bool isReady (void) { return _isReady;}
QGCMapPolygon flyAreaPolygon (void) { return _flyAreaPolygon;}
// Methodes // Methodes
void setReady(); void _init(void);
signals: signals:
void readyStateChanged(void); void polygonsChanged(void);
public slots: public slots:
private: private:
QGCMapPolygon _flyAreaPolygon; QmlObjectListModel *_polygons;
bool _isReady;
}; };
#endif // WIMAFLYAREA_H #endif // WIMAFLYAREA_H
...@@ -438,7 +438,7 @@ void QGCApplication::_initCommon(void) ...@@ -438,7 +438,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterUncreatableType<FactValueSliderListModel>("QGroundControl.FactControls", 1, 0, "FactValueSliderListModel", kRefOnly); qmlRegisterUncreatableType<FactValueSliderListModel>("QGroundControl.FactControls", 1, 0, "FactValueSliderListModel", kRefOnly);
qmlRegisterUncreatableType<QGCMapPolygon> ("QGroundControl.FlightMap", 1, 0, "QGCMapPolygon", kRefOnly); qmlRegisterUncreatableType<QGCMapPolygon> ("QGroundControl.FlightMap", 1, 0, "QGCMapPolygon", kRefOnly);
qmlRegisterUncreatableType<WimaFlyArea> ("QGroundControl.FlightMap", 1, 0, "WimaFlyArea", kRefOnly); //custom
qmlRegisterUncreatableType<QGCGeoBoundingCube> ("QGroundControl.FlightMap", 1, 0, "QGCGeoBoundingCube", kRefOnly); qmlRegisterUncreatableType<QGCGeoBoundingCube> ("QGroundControl.FlightMap", 1, 0, "QGCGeoBoundingCube", kRefOnly);
qmlRegisterType<QGCMapCircle> ("QGroundControl.FlightMap", 1, 0, "QGCMapCircle"); qmlRegisterType<QGCMapCircle> ("QGroundControl.FlightMap", 1, 0, "QGCMapCircle");
...@@ -465,6 +465,10 @@ void QGCApplication::_initCommon(void) ...@@ -465,6 +465,10 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<GeoTagController> (kQGCControllers, 1, 0, "GeoTagController"); qmlRegisterType<GeoTagController> (kQGCControllers, 1, 0, "GeoTagController");
qmlRegisterType<MavlinkConsoleController> (kQGCControllers, 1, 0, "MavlinkConsoleController"); qmlRegisterType<MavlinkConsoleController> (kQGCControllers, 1, 0, "MavlinkConsoleController");
#endif #endif
// Wima
qmlRegisterUncreatableType<WimaFlyArea> ("Wima", 1, 0, "WimaFlyArea", kRefOnly); //custom
qmlRegisterType<WimaController> ("Wima", 1, 0, "WimaController"); //custom
// Register Qml Singletons // Register Qml Singletons
qmlRegisterSingletonType<QGroundControlQmlGlobal> ("QGroundControl", 1, 0, "QGroundControl", qgroundcontrolQmlGlobalSingletonFactory); qmlRegisterSingletonType<QGroundControlQmlGlobal> ("QGroundControl", 1, 0, "QGroundControl", qgroundcontrolQmlGlobalSingletonFactory);
......
...@@ -28,6 +28,8 @@ import QGroundControl.ShapeFileHelper 1.0 ...@@ -28,6 +28,8 @@ import QGroundControl.ShapeFileHelper 1.0
import QGroundControl.Airspace 1.0 import QGroundControl.Airspace 1.0
import QGroundControl.Airmap 1.0 import QGroundControl.Airmap 1.0
import Wima 1.0
/// Mission Editor /// Mission Editor
QGCView { QGCView {
...@@ -110,6 +112,8 @@ QGCView { ...@@ -110,6 +112,8 @@ QGCView {
property bool _firstRallyLoadComplete: false property bool _firstRallyLoadComplete: false
property bool _firstLoadComplete: false property bool _firstLoadComplete: false
MapFitFunctions { MapFitFunctions {
id: mapFitFunctions // The name for this id cannot be changed without breaking references outside of this code. Beware! id: mapFitFunctions // The name for this id cannot be changed without breaking references outside of this code. Beware!
map: editorMap map: editorMap
...@@ -201,6 +205,10 @@ QGCView { ...@@ -201,6 +205,10 @@ QGCView {
} }
WimaController { WimaController {
id:wimaController id:wimaController
Component.onCompleted: {
wimaController.start()
}
} }
PlanMasterController { PlanMasterController {
...@@ -530,12 +538,26 @@ QGCView { ...@@ -530,12 +538,26 @@ QGCView {
} }
//Add fly area //Add fly area
FlyAreaMapVisual { Repeater {
map: editorMap model: _flyArea.polygons
qgcView: _qgcView delegate: QGCMapPolygonVisuals {
_flyAreaPolygon: _flyArea.flyAreaPolygon 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 // Add the vehicles to the map
MapItemView { MapItemView {
...@@ -617,7 +639,7 @@ QGCView { ...@@ -617,7 +639,7 @@ QGCView {
iconSource: "/qmlimages/Target.svg", iconSource: "/qmlimages/Target.svg",
toggle: true toggle: true
}, },
{ {
name: qsTr("No Fly"), name: qsTr("No Fly"),
iconSource: "/qmlimages/noFlyArea.svg", iconSource: "/qmlimages/noFlyArea.svg",
toggle: true toggle: true
...@@ -650,7 +672,8 @@ QGCView { ...@@ -650,7 +672,8 @@ QGCView {
onClicked: { onClicked: {
switch (index) { switch (index) {
case 1: case 1:
wimaController.initWimaFlyArea(); _flyArea.append_WimaFlyArea();
console.log("polygon count: ", _flyArea.polygons.count)
//addComplexItem(_missionController.complexMissionItemNames[2]) //addComplexItem(_missionController.complexMissionItemNames[2])
/*_addWaypointOnClick = checked /*_addWaypointOnClick = checked
_addROIOnClick = false*/ _addROIOnClick = false*/
...@@ -1175,4 +1198,38 @@ QGCView { ...@@ -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 } // QGCVIew
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment