Commit e7ee7d09 authored by Valentin Platzgummer's avatar Valentin Platzgummer

before editing QGCMapPolygonVisuals.qml

parent 1b6d3ca9
......@@ -210,7 +210,7 @@
<file alias="VirtualJoystick.qml">src/FlightDisplay/VirtualJoystick.qml</file>
<file alias="QGroundControl/Controls/WimaToolBar.qml">src/WimaView/WimaToolBar.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 prefix="/json">
<file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file>
......
......@@ -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();
}
......@@ -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
#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();
}
......@@ -3,6 +3,7 @@
#include <QObject>
#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
......@@ -438,7 +438,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterUncreatableType<FactValueSliderListModel>("QGroundControl.FactControls", 1, 0, "FactValueSliderListModel", 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);
qmlRegisterType<QGCMapCircle> ("QGroundControl.FlightMap", 1, 0, "QGCMapCircle");
......@@ -465,6 +465,10 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<GeoTagController> (kQGCControllers, 1, 0, "GeoTagController");
qmlRegisterType<MavlinkConsoleController> (kQGCControllers, 1, 0, "MavlinkConsoleController");
#endif
// Wima
qmlRegisterUncreatableType<WimaFlyArea> ("Wima", 1, 0, "WimaFlyArea", kRefOnly); //custom
qmlRegisterType<WimaController> ("Wima", 1, 0, "WimaController"); //custom
// Register Qml Singletons
qmlRegisterSingletonType<QGroundControlQmlGlobal> ("QGroundControl", 1, 0, "QGroundControl", qgroundcontrolQmlGlobalSingletonFactory);
......
......@@ -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
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