diff --git a/UnitTest.qrc b/UnitTest.qrc
index 674df436d8cbed62e6df101948efe6fd1c0a47ab..803d5e79a275e7e60babb22cc6a5b32a53652750 100644
--- a/UnitTest.qrc
+++ b/UnitTest.qrc
@@ -15,7 +15,5 @@
src/MissionManager/UnitTest/PolygonBadXml.kml
src/MissionManager/UnitTest/PolygonBadCoordinatesNode.kml
-
- src/WimaView/FlyAreaMapVisual.qml
-
+
diff --git a/WimaGlobalMeasurementPolygonMapVisual.qml b/WimaGlobalMeasurementPolygonMapVisual.qml
new file mode 100644
index 0000000000000000000000000000000000000000..5a7cd107e23b2a4089fd22cd54dc17192a7ab72a
--- /dev/null
+++ b/WimaGlobalMeasurementPolygonMapVisual.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+ *
+ * (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
+
+/// Wima Global Measurement Area visuals
+Item {
+ id: _root
+
+ property var map ///< Map control to place item in
+ property var qgcView ///< QGCView to use for popping dialogs
+
+ property var _missionItem: object
+ property var _polygon: object.polygon
+
+ signal clicked(int sequenceNumber)
+
+ /// Add an initial 4 sided polygon if there is none
+ function _addInitialPolygon() {
+ if (_polygon.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)
+
+ _polygon.appendVertex(topLeftCoord)
+ _polygon.appendVertex(topRightCoord)
+ _polygon.appendVertex(bottomRightCoord)
+ _polygon.appendVertex(bottomLeftCoord)
+ }
+ }
+
+ Component.onCompleted: {
+ _addInitialPolygon()
+ }
+
+ Component.onDestruction: {
+ }
+
+ QGCMapPolygonVisuals {
+ qgcView: _root.qgcView
+ mapControl: map
+ mapPolygon: _polygon
+ interactive: _missionItem.isCurrentItem
+ borderWidth: 1
+ borderColor: "black"
+ interiorColor: "green"
+ interiorOpacity: 0.25
+ }
+
+
+
+
+}
diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro
index 35d6265a2462632817e1f717f0b1692bcdf620a4..af91b5f8626db55da810a58ea9e0f6ff1d399f87 100644
--- a/qgroundcontrol.pro
+++ b/qgroundcontrol.pro
@@ -413,7 +413,6 @@ HEADERS += \
src/MissionManager/WimaVehicleCorridor.h \
src/MissionManager/WimaVehicleMeasurementPolygon.h \
src/MissionManager/WimaGlobalMeasurementPolygon.h \
- src/MissionManager/WimaPolygonContainer.h \
src/MissionManager/WimaVehicle.h
SOURCES += \
@@ -423,13 +422,11 @@ SOURCES += \
src/api/QmlComponentInfo.cc \
src/comm/MavlinkMessagesTimer.cc \
src/MissionManager/WimaController.cc \
- src/MissionManager/WimaFlyArea.cc \
src/MissionManager/WimaPolygon.cc \
src/MissionManager/WimaServicePolygon.cc \
src/MissionManager/WimaVehicleCorridor.cc \
src/MissionManager/WimaVehicleMeasurementPolygon.cc \
src/MissionManager/WimaGlobalMeasurementPolygon.cc \
- src/MissionManager/WimaPolygonContainer.cc \
src/MissionManager/WimaVehicle.cc
#
diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index 7c317e544563cadc27678fbf7cda42abd5c055c9..8cc6201ca8007c71aee3da0781c5b7dcf92b8d51 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -210,9 +210,10 @@
src/FlightDisplay/VirtualJoystick.qml
src/WimaView/WimaToolBar.qml
src/WimaView/WimaView.qml
- src/WimaView/FlyAreaPolygonMapVisual.qml
- src/WimaView/FlyAreaEditor.qml
- src/WimaView/FlyAreaItemEditor.qml
+ src/WimaView/WimaMapVisual.qml
+ src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml
+ src/WimaView/WimaServicePolygonMapVisual.qml
+ src/WimaView/WimaItemEditor.qml
src/Settings/APMMavlinkStreamRate.SettingsGroup.json
diff --git a/src/MissionManager/WimaController.cc b/src/MissionManager/WimaController.cc
index b0f30da0a9b9caff36bee27da54d51a2d861df1e..bd3435aa75e822f71264f039438f75f9fa24a7ee 100644
--- a/src/MissionManager/WimaController.cc
+++ b/src/MissionManager/WimaController.cc
@@ -2,11 +2,11 @@
#include "MissionController.h"
WimaController::WimaController(QObject *parent) :
- QObject(parent)
- ,_planView(true)
-
+ QObject (parent)
+ ,_planView (true)
+ ,_visualItems (new QmlObjectListModel(parent))
{
-
+ connect(this, &WimaController::currentPolygonIndexChanged, this, &WimaController::recalcPolygonInteractivity);
}
void WimaController::setMasterController(PlanMasterController *masterC)
@@ -21,18 +21,30 @@ void WimaController::setMissionController(MissionController *missionC)
emit missionControllerChanged();
}
+void WimaController::setCurrentPolygonIndex(int index)
+{
+ if(index > 0 && index < _visualItems->count() && index != _currentPolygonIndex){
+ _currentPolygonIndex = index;
+
+ emit currentPolygonIndexChanged(index);
+ }
+}
+
void WimaController::addGlobalMeasurementArea()
{
- WimaGlobalMeasurementPolygon* poly = new WimaGlobalMeasurementPolygon(this);
- _visualItems.append(poly);
+ WimaGlobalMeasurementPolygon* newPoly = new WimaGlobalMeasurementPolygon(this);
+ _visualItems->append(newPoly);
+ int newIndex = _visualItems->count()-1;
+ _currentPolygonIndex = newIndex;
+ emit currentPolygonIndexChanged(newIndex);
emit visualItemsChanged();
}
void WimaController::removeArea(int index)
{
- if(index > 0 && index < _visualItems.size()){
- _visualItems.removeAt(index);
+ if(index > 0 && index < _visualItems->count()){
+ _visualItems->removeAt(index);
emit visualItemsChanged();
}else{
@@ -43,16 +55,74 @@ void WimaController::removeArea(int index)
void WimaController::addServiceArea()
{
- WimaServicePolygon* poly = new WimaServicePolygon(this);
- _visualItems.append(poly);
+ resetAllIsCurrentPolygon();
+ WimaServicePolygon* newPoly = new WimaServicePolygon(this);
+ newPoly->setIsCurrentPolygon(true);
+ _visualItems->append(newPoly);
emit visualItemsChanged();
}
+void WimaController::startMission()
+{
+
+}
+
+void WimaController::abortMission()
+{
+
+}
+
+void WimaController::pauseMission()
+{
+
+}
+
+void WimaController::resumeMission()
+{
+
+}
+
+void WimaController::saveMission()
+{
+
+}
+
+void WimaController::loadMission()
+{
+
+}
+
void WimaController::recalcVehicleCorridor()
{
}
+void WimaController::recalcVehicleMeasurementAreas()
+{
+
+}
+
+void WimaController::recalcAll()
+{
+
+}
+
+void WimaController::recalcPolygonInteractivity(int index)
+{
+ resetAllIsCurrentPolygon();
+ WimaPolygon* interactivePoly = qobject_cast(_visualItems->get(index));
+ interactivePoly->setIsCurrentPolygon(true);
+}
+
+void WimaController::resetAllIsCurrentPolygon()
+{
+ int itemCount = _visualItems->count();
+ for (int i = 0; i < itemCount; i++) {
+ WimaPolygon* iteratorPoly = qobject_cast(_visualItems->get(i));
+ iteratorPoly->setIsCurrentPolygon(false);
+ }
+}
+
diff --git a/src/MissionManager/WimaController.h b/src/MissionManager/WimaController.h
index 52b5e75fc69578aef27bf28267884003da9ec010..6f2bb0d2855762d83c660d75bbba5c3c130ba4d4 100644
--- a/src/MissionManager/WimaController.h
+++ b/src/MissionManager/WimaController.h
@@ -1,12 +1,12 @@
-#ifndef WIMACONTROLLER_H
-#define WIMACONTROLLER_H
+#pragma once
#include
#include "QGCMapPolygon.h"
+#include "QmlObjectListModel.h"
+
#include "WimaPolygon.h"
#include "WimaGlobalMeasurementPolygon.h"
#include "WimaServicePolygon.h"
-#include "WimaPolygonContainer.h"
#include "PlanMasterController.h"
#include "MissionController.h"
@@ -21,13 +21,15 @@ public:
Q_PROPERTY(PlanMasterController* masterController READ masterController WRITE setMasterController NOTIFY masterControllerChanged)
Q_PROPERTY(MissionController* missionController READ missionController WRITE setMissionController NOTIFY missionControllerChanged)
- Q_PROPERTY(QList& visualItems READ visualItems NOTIFY visualItemsChanged)
- Q_PROPERTY(QList& editorItems READ editorItems NOTIFY visualItemsChanged)
+ Q_PROPERTY(QmlObjectListModel* visualItems READ visualItems NOTIFY visualItemsChanged)
+ Q_PROPERTY(int currentPolygonIndex READ currentPolygonIndex WRITE setCurrentPolygonIndex NOTIFY currentPolygonIndexChanged)
+
// Property accessors
PlanMasterController* masterController (void) const { return _masterController;}
MissionController* missionController (void) const { return _missionController;}
- QList& visualItems (void) { return _visualItemsContainer.returnFlatList(); }
+ QmlObjectListModel* visualItems (void) { return _visualItems; }
+ int currentPolygonIndex (void) const { return _currentPolygonIndex; }
@@ -35,6 +37,7 @@ public:
// Property setters
void setMasterController (PlanMasterController* masterController);
void setMissionController (MissionController* missionController);
+ void setCurrentPolygonIndex (int index);
Q_INVOKABLE void addGlobalMeasurementArea();
Q_INVOKABLE void removeArea(int index);
@@ -48,25 +51,28 @@ public:
Q_INVOKABLE void saveMission();
Q_INVOKABLE void loadMission();
+ Q_INVOKABLE void resetAllIsCurrentPolygon(void);
+
signals:
void masterControllerChanged (void);
void missionControllerChanged (void);
void visualItemsChanged (void);
+ void currentPolygonIndexChanged (int index);
private slots:
void recalcVehicleCorridor();
void recalcVehicleMeasurementAreas();
void recalcAll();
+ void recalcPolygonInteractivity(int index);
private:
bool _planView;
- QList _visualItems;
+ QmlObjectListModel* _visualItems;
PlanMasterController* _masterController;
MissionController* _missionController;
+ int _currentPolygonIndex;
};
-
-#endif // WIMACONTROLLER_H
diff --git a/src/MissionManager/WimaFlyArea.cc b/src/MissionManager/WimaFlyArea.cc
deleted file mode 100644
index f912ad69125a9192ceebd66aa8dc789c7140f1af..0000000000000000000000000000000000000000
--- a/src/MissionManager/WimaFlyArea.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-#include "WimaFlyArea.h"
-
-WimaFlyArea::WimaFlyArea(QObject *parent) : QObject(parent)
- , _polygons (nullptr)
-{
-
-}
-
-WimaFlyArea::WimaFlyArea(const WimaFlyArea &other, QObject *parent): QObject(parent)
-{
- *this = other;
-}
-
-const WimaFlyArea& WimaFlyArea::operator=(const WimaFlyArea& other)
-{
- this->_polygons = other._polygons;
- return *this;
-}
-
-void WimaFlyArea::_init()
-{
- _polygons = new QmlObjectListModel(this);
-}
-
-
-
-void WimaFlyArea::appendFlyAreaPolygon()
-{
- QGCMapPolygon *newPolygon = new QGCMapPolygon();
-
- _polygons->append(newPolygon);
- int index = _polygons->count()-1;
- selectCurrentPolygon(index);
-
- emit polygonsChanged();
-}
-
-void WimaFlyArea::removeFlyAreaPolygon(int index)
-{
- if(index >= 0 && index < _polygons->count()) {
- _polygons->removeAt(index);
-
- emit polygonsChanged();
- }
-}
-
-void WimaFlyArea::selectCurrentPolygon(int index)
-{
- if(index >= 0 && index < _polygons->count()) {
-
- disselectAllPolygons();
-
- _currentPolygonIndex = index;
- _currentPolygonItem = qobject_cast(_polygons->get(index));
- _currentPolygonItem->setInteractive(true);
-
- if(index != _currentPolygonIndex){
- emit currentPolygonItemChanged(_currentPolygonItem);
- emit currentPolygonIndexChanged(index);
- }
-
- }
-}
-
-void WimaFlyArea::disselectAllPolygons()
-{
- for (int i = 0; i < _polygons->count(); i++) {
- QGCMapPolygon* polygon = qobject_cast(_polygons->get(i));
- polygon->setInteractive(false);
- }
-}
-
-/*void WimaFlyArea::setBottomLayerAltitude(double alt)
-{
- if(_bottomLayerAltitude != alt){
- _bottomLayerAltitude = alt;
- emit bottomLayerAltitudeChanged(_bottomLayerAltitude);
- }
-
-}*/
-
diff --git a/src/MissionManager/WimaFlyArea.h b/src/MissionManager/WimaFlyArea.h
deleted file mode 100644
index 7da903ce26e48775ffbae4ea620ea8a7cdb22483..0000000000000000000000000000000000000000
--- a/src/MissionManager/WimaFlyArea.h
+++ /dev/null
@@ -1,74 +0,0 @@
-#ifndef WIMAFLYAREA_H
-#define WIMAFLYAREA_H
-
-#include
-#include "QGCMapPolygon.h"
-#include "QmlObjectListModel.h"
-
-class WimaFlyArea : public QObject
-{
- Q_OBJECT
-public:
- WimaFlyArea(QObject *parent = nullptr);
- WimaFlyArea(const WimaFlyArea& other, QObject *parent = nullptr);
-
- const WimaFlyArea& operator=(const WimaFlyArea& other);
-
-
-
- Q_PROPERTY(QmlObjectListModel* polygons READ polygons NOTIFY polygonsChanged)
- Q_PROPERTY(QGCMapPolygon* currentPolygonItem READ currentPolygonItem NOTIFY currentPolygonItemChanged)
- Q_PROPERTY(int currentPolygonIndex READ currentPolygonIndex NOTIFY currentPolygonIndexChanged)
- //Q_PROPERTY(QList* bottomLayerAltitude READ bottomLayerAltitude WRITE setBottomLayerAltitude NOTIFY bottomLayerAltitudeChanged)
- //Q_PROPERTY(QList* layerNumber READ layerNumber WRITE setLayerNumber NOTIFY layerNumberChanged)
- //Q_PROPERTY(QList* layerDistance READ layerDistance WRITE setLayerDistance NOTIFY layerDistanceChanged)
-
- Q_INVOKABLE void appendFlyAreaPolygon();
- Q_INVOKABLE void removeFlyAreaPolygon(int index);
- Q_INVOKABLE void selectCurrentPolygon(int index);
- Q_INVOKABLE void disselectAllPolygons();
-
- // Property Accessors
- QmlObjectListModel * polygons (void) { return _polygons;}
- QGCMapPolygon * currentPolygonItem (void) { return _currentPolygonItem;}
- int currentPolygonIndex (void) { return _currentPolygonIndex;}
- //QList* bottomLayerAltitude (void) { return _bottomLayerAltitude;}
- //QList* layerNumber (void) { return _layerNumber;}
- //QList* layerDistance (void) { return _layerDistance;}
-
- // Property Writers
- //void setBottomLayerAltitude(double alt);
- //void setLayerNumber(int layerNumber);
- //void setLayerDistance(double dist);
-
-
- // Methodes
- void _init(void);
-
-signals:
- void polygonsChanged(void);
- void currentPolygonItemChanged(QGCMapPolygon * polygon);
- void currentPolygonIndexChanged(int index);
- void bottomLayerAltitudeChanged(double alt);
- void layerNumberChanged(int alt);
- void layerDistanceChanged(double dist);
-
-
-public slots:
-
-private:
-
-
-
- QmlObjectListModel* _polygons;
- QGCMapPolygon* _currentPolygonItem;
- int _currentPolygonIndex;
- bool _visible;
- //QList* _bottomLayerAltitude;
- //QList* _layerNumber;
- //QList* _layerDistance;
-
-
-};
-
-#endif // WIMAFLYAREA_H
diff --git a/src/MissionManager/WimaGlobalMeasurementPolygon.cc b/src/MissionManager/WimaGlobalMeasurementPolygon.cc
index c08ec4f379c390a3c0c12fc2e19ed827031fc4de..84f23553a326ee9902c7a1df611e866273efedce 100644
--- a/src/MissionManager/WimaGlobalMeasurementPolygon.cc
+++ b/src/MissionManager/WimaGlobalMeasurementPolygon.cc
@@ -17,25 +17,30 @@ WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QGCMapPolygon *other,
void WimaGlobalMeasurementPolygon::addVehicle(Vehicle *vehicle)
{
if(vehicle != nullptr){
- _vehicleList.append(vehicle);
- emit vehicleListChanged(_vehicleList);
+ _vehicleList->append(vehicle);
+ emit vehicleListChanged();
}
}
void WimaGlobalMeasurementPolygon::removeVehicle(int vehicleIndex)
{
- if(vehicleIndex >= 0 && vehicleIndex < _vehicleList.count()){
- _vehicleList.removeAt(vehicleIndex);
- emit vehicleListChanged(_vehicleList);
+ if(vehicleIndex >= 0 && vehicleIndex < _vehicleList->count()){
+ _vehicleList->removeAt(vehicleIndex);
+ emit vehicleListChanged();
}
}
void WimaGlobalMeasurementPolygon::recalculatesubPolygons()
{
int vehicleCount = _vehicleList->count();
- WimaVehicleMeasurementPolygon* newPolygon = new WimaVehicleMeasurementPolygon(this);
+ QScopedPointer> listQGCPoly(this->splitPolygonArea(vehicleCount));
- _subPolygons = this->splitPolygonArea(vehicleCount);
+ int polyCount = listQGCPoly->size();
+ _subPolygons->clear();
+ for(int i = 0; i < polyCount; i++){
+ WimaVehicleMeasurementPolygon* subPoly = new WimaVehicleMeasurementPolygon(listQGCPoly->takeAt(i), this);
+ _subPolygons->append(subPoly);
+ }
}
void WimaGlobalMeasurementPolygon::removeAllVehicles()
@@ -47,14 +52,14 @@ void WimaGlobalMeasurementPolygon::removeAllVehicles()
counter--;
}
- emit vehicleListChanged(_vehicleList);
+ emit vehicleListChanged();
}
void WimaGlobalMeasurementPolygon::setBottomLayerAltitude(double altitude)
{
if(altitude > 0 && altitude != _bottomLayerAltitude){
_bottomLayerAltitude = altitude;
- emit bottomLayerAltitudeChanged(altitude);
+ emit bottomLayerAltitudeChanged();
}
}
@@ -62,7 +67,7 @@ void WimaGlobalMeasurementPolygon::setNumberOfLayers(int numberOfLayers)
{
if(numberOfLayers > 0 && _numberOfLayers != numberOfLayers){
_numberOfLayers = numberOfLayers;
- emit numberOfLayersChanged(numberOfLayers);
+ emit numberOfLayersChanged();
}
}
@@ -70,6 +75,6 @@ void WimaGlobalMeasurementPolygon::setLayerDistance(double distance)
{
if(distance > 0 && distance != _layerDistance){
_layerDistance = distance;
- emit layerDistanceChanged(distance);
+ emit layerDistanceChanged();
}
}
diff --git a/src/MissionManager/WimaGlobalMeasurementPolygon.h b/src/MissionManager/WimaGlobalMeasurementPolygon.h
index 5df1622fe6d09f6bca1ed06546a83e583401c228..d5578fdf1200868ba18b6a11b898f37673af342a 100644
--- a/src/MissionManager/WimaGlobalMeasurementPolygon.h
+++ b/src/MissionManager/WimaGlobalMeasurementPolygon.h
@@ -1,5 +1,4 @@
-#ifndef WIMAGLOBALMEASUREMENTPOLYGON_H
-#define WIMAGLOBALMEASUREMENTPOLYGON_H
+#pragma once
#include
#include "WimaPolygon.h"
@@ -7,6 +6,8 @@
#include "QGCMapPolygon.h"
#include "WimaVehicleMeasurementPolygon.h"
+#include "QScopedPointer"
+
class WimaGlobalMeasurementPolygon : public WimaPolygon
{
Q_OBJECT
@@ -17,9 +18,8 @@ public:
Q_PROPERTY(double bottomLayerAltitude READ bottomLayerAltitude WRITE setBottomLayerAltitude NOTIFY bottomLayerAltitudeChanged)
Q_PROPERTY(int numberOfLayers READ numberOfLayers WRITE setNumberOfLayers NOTIFY numberOfLayersChanged)
Q_PROPERTY(double layerDistance READ layerDistance WRITE setLayerDistance NOTIFY layerDistanceChanged)
- Q_PROPERTY(QList vehicleList READ vehicleList NOTIFY vehicleListChanged)
+ Q_PROPERTY(QmlObjectListModel* vehicleList READ vehicleList NOTIFY vehicleListChanged)
Q_PROPERTY(QGCMapPolyline* entryPolyline READ entryPolyline NOTIFY entryPolylineChanged)
- Q_PROPERTY( QList subPolygons READ subPolygons NOTIFY subPolygonsChanged)
Q_INVOKABLE void addVehicle(Vehicle *vehicle);
Q_INVOKABLE void removeVehicle(int vehicleIndex);
@@ -28,14 +28,14 @@ public:
// Overrides from WimaPolygon
- QString mapVisualQML (void) const { return "WimaGlobalMeasurementPolygonMapVisal.qml";}
+ QString mapVisualQML (void) const { return "WimaGlobalMeasurementPolygonMapVisual.qml";}
QString editorQML (void) const { return "WimaGlobalMeasurementPolygonEditor.qml";}
// Property accessors
double bottomLayerAltitude (void) const { return _bottomLayerAltitude;}
int numberOfLayers (void) const { return _numberOfLayers;}
double layerDistance (void) const { return _layerDistance;}
- QList vehicleList (void) const { return _vehicleList;}
+ QmlObjectListModel* vehicleList (void) const { return _vehicleList;}
QGCMapPolyline* entryPolyline (void) const { return _entryPolyline;}
// Property setters
@@ -45,21 +45,20 @@ public:
void setLayerDistance (double distance);
signals:
- void bottomLayerAltitudeChanged (double altitude);
- void numberOfLayersChanged (int numberOfLayers);
- void layerDistanceChanged (double distance);
- void vehicleListChanged (QList vehicleList);
- void entryPolylineChanged (QGCMapPolyline* polyline);
- void subPolygonsChanged (QList subPolygons);
+ void bottomLayerAltitudeChanged (void);
+ void numberOfLayersChanged (void);
+ void layerDistanceChanged (void);
+ void vehicleListChanged (void);
+ void entryPolylineChanged (void);
+ void subPolygonsChanged (void);
private:
double _bottomLayerAltitude;
int _numberOfLayers;
double _layerDistance;
- QList _vehicleList;
+ QmlObjectListModel* _vehicleList;
QGCMapPolyline* _entryPolyline;
};
-#endif // WIMAGLOBALMEASUREMENTPOLYGON_H
diff --git a/src/MissionManager/WimaPolygon.cc b/src/MissionManager/WimaPolygon.cc
index 946ea7f45db7a0ae396370c3e92a8134f135e80b..412398cf8517008675e20bbd90fe0a7f575c0980 100644
--- a/src/MissionManager/WimaPolygon.cc
+++ b/src/MissionManager/WimaPolygon.cc
@@ -3,15 +3,16 @@
WimaPolygon::WimaPolygon(QObject *parent) :
QObject (parent)
,_maxAltitude (30)
- ,_vehicle (nullptr)
+ ,_vehicle (parent)
,_polygon (new QGCMapPolygon(this))
+ ,_subPolygons (new QmlObjectListModel(this))
+ ,_subPolylines (new QmlObjectListModel(this))
{
}
WimaPolygon::WimaPolygon(QGCMapPolygon *other, QObject *parent):
WimaPolygon(parent)
{
- delete _polygon;
*_polygon = *other;
}
@@ -27,17 +28,25 @@ void WimaPolygon::setMaxAltitude(double alt)
void WimaPolygon::setVehicle(Vehicle *vehicle)
{
- if(_vehicle != vehicle){
- _vehicle = vehicle;
+ if(_vehicle.vehicle() != vehicle){
+ _vehicle.setVehicle(vehicle);
emit vehicleChanged();
}
}
-QGCMapPolygon* WimaPolygon::splitPolygonArea(int numberOfFractions)
+void WimaPolygon::setIsCurrentPolygon(bool isCurrentPolygon)
+{
+ _isCurrentPolygon = isCurrentPolygon;
+ emit isCurrentPolygonChanged();
+}
+
+QList* WimaPolygon::splitPolygonArea(int numberOfFractions)
{
if(numberOfFractions > 0){
QGCMapPolygon* poly = new QGCMapPolygon(this->polygon(), this);
- return poly;
+ QList* list = new QList();
+ list->append(poly);
+ return list;
}
return nullptr;
}
diff --git a/src/MissionManager/WimaPolygon.h b/src/MissionManager/WimaPolygon.h
index 33c3b844ce7d6281ec46c5726e0c95d3ee586453..723fc903b72146c2ef5ea543b8883de1a508907e 100644
--- a/src/MissionManager/WimaPolygon.h
+++ b/src/MissionManager/WimaPolygon.h
@@ -1,10 +1,13 @@
-#ifndef WIMAPOLYGON_H
-#define WIMAPOLYGON_H
+#pragma once
+
#include "QGCMapPolygon.h"
#include "QGCMapPolyline.h"
#include "Vehicle.h"
#include "qobject.h"
+#include "WimaVehicle.h"
+
+
@@ -22,15 +25,17 @@ public:
Q_PROPERTY(QString editorQML READ editorQML CONSTANT)
Q_PROPERTY(Vehicle* vehicle READ vehicle WRITE setVehicle NOTIFY vehicleChanged)
Q_PROPERTY(QGCMapPolygon* polygon READ polygon NOTIFY polygonChanged)
- Q_PROPERTY(QList subPolygons READ subPolygons NOTIFY subPolygonsChanged)
- Q_PROPERTY(QList subPolylines READ subPolylines NOTIFY subPolylinesChanged)
+ Q_PROPERTY(QmlObjectListModel* subPolygons READ subPolygons NOTIFY subPolygonsChanged)
+ Q_PROPERTY(QmlObjectListModel* subPolylines READ subPolylines NOTIFY subPolylinesChanged)
+ Q_PROPERTY(bool isCurrentPolygon READ isCurrentPolygon WRITE setIsCurrentPolygon NOTIFY isCurrentPolygonChanged)
//Property accessors
double maxAltitude (void) const { return _maxAltitude;}
- Vehicle* vehicle (void) const { return _vehicle;}
+ Vehicle* vehicle (void) const { return _vehicle.vehicle();}
QGCMapPolygon* polygon (void) const { return _polygon;}
- QList subPolygons (void) const { return _subPolygons;}
- QList subPolylines (void) const { return _subPolylines;}
+ QmlObjectListModel* subPolygons (void) const { return _subPolygons;}
+ QmlObjectListModel* subPolylines (void) const { return _subPolylines;}
+ bool isCurrentPolygon (void) const { return _isCurrentPolygon;}
virtual QString mapVisualQML (void) const = 0;
virtual QString editorQML (void) const = 0;
@@ -39,25 +44,28 @@ public:
void setMaxAltitude (double alt);
void setName (QString name);
void setVehicle (Vehicle* vehicle);
+ void setIsCurrentPolygon(bool isCurrentPolygon);
- QGCMapPolygon* splitPolygonArea(int numberOfFractions);
+ QList* splitPolygonArea(int numberOfFractions); // use QScopedPointer to store return value
signals:
void maxAltitudeChanged (void);
void vehicleChanged (void);
- void subPolygons (void);
-
-
-private:
+ void polygonChanged (void);
+ void subPolygonsChanged (void);
+ void subPolylinesChanged (void);
+ void isCurrentPolygonChanged (void);
+protected:
double _maxAltitude;
- Vehicle* _vehicle;
+ WimaVehicle _vehicle;
QGCMapPolygon* _polygon;
- QList _subPolygons;
- QList _subPolylines;
+ QmlObjectListModel* _subPolygons;
+ QmlObjectListModel* _subPolylines;
+ bool _isCurrentPolygon;
};
-#endif // WIMAPOLYGON_H
+
diff --git a/src/MissionManager/WimaServicePolygon.cc b/src/MissionManager/WimaServicePolygon.cc
index 14753ce29044cd54eed0688e320d668a5e0074eb..3be47f6279059acc10aed536f4bb15fb4eed581c 100644
--- a/src/MissionManager/WimaServicePolygon.cc
+++ b/src/MissionManager/WimaServicePolygon.cc
@@ -12,26 +12,19 @@ WimaServicePolygon::WimaServicePolygon(QGCMapPolygon *other, QObject *parent):
}
-void WimaServicePolygon::setTakeOffPosition(QGeoCoordinate coordinate)
+void WimaServicePolygon::setTakeOffPosition(QGeoCoordinate* coordinate)
{
- if(_takeOffPosition != coordinate){
- _takeOffPosition = coordinate;
- emit takeOffPositionChanged(coordinate);
+ if(_takeOffPosition != *coordinate){
+ _takeOffPosition = *coordinate;
+ emit takeOffPositionChanged();
}
}
-void WimaServicePolygon::setLandPosition(QGeoCoordinate coordinate)
+void WimaServicePolygon::setLandPosition(QGeoCoordinate* coordinate)
{
- if(_landPosition != coordinate){
- _landPosition = coordinate;
- emit landPositionChanged(coordinate);
+ if(_landPosition != *coordinate){
+ _landPosition = *coordinate;
+ emit landPositionChanged();
}
}
-void WimaServicePolygon::setVehicle(Vehicle *vehicle)
-{
- if(_vehicle != vehicle){
- _vehicle = vehicle;
- emit vehicleChanged(vehicle);
- }
-}
diff --git a/src/MissionManager/WimaServicePolygon.h b/src/MissionManager/WimaServicePolygon.h
index 22a93cdeb5cdf74fe5d44a9aa6111676be455541..f4dc3713492e50b202b38c5ac9ec24085afa5789 100644
--- a/src/MissionManager/WimaServicePolygon.h
+++ b/src/MissionManager/WimaServicePolygon.h
@@ -1,7 +1,6 @@
-#ifndef WIMASERVICEPOLYGON_H
-#define WIMASERVICEPOLYGON_H
+#pragma once
-#include "QObject"
+#include
#include "WimaPolygon.h"
class WimaServicePolygon : public WimaPolygon
@@ -11,33 +10,26 @@ public:
WimaServicePolygon(QObject* parent = nullptr);
WimaServicePolygon(QGCMapPolygon* other, QObject* parent = nullptr);
- Q_PROPERTY(QGeoCoordiante takeOffPosition READ takeOffPosition WRITE setTakeOffPosition NOTIFY takeOffPositionChanged)
- Q_PROPERTY(QGeoCoordinate landPosition READ landPosition WRITE setLandPosition NOTIFY landPositionChanged)
- Q_PROPERTY(Vehicle* vehicle READ vehicle WRITE setVehicle NOTIFY vehicleChanged)
+ Q_PROPERTY(QGeoCoordinate* takeOffPosition READ takeOffPosition WRITE setTakeOffPosition NOTIFY takeOffPositionChanged)
+ Q_PROPERTY(QGeoCoordinate* landPosition READ landPosition WRITE setLandPosition NOTIFY landPositionChanged)
// Overrides from WimaPolygon
- QString mapVisualQML (void) const { return "WimaServicePolygonMapVisal.qml";}
+ QString mapVisualQML (void) const { return "WimaServicePolygonMapVisual.qml";}
QString editorQML (void) const { return "WimaServicePolygonEditor.qml";}
// Property acessors
- QGeoCoordinate takeOffPosition (void) const { return _takeOffPosition;}
- QGeoCoordinate landPosition (void) const { return _landPosition;}
- Vehicle* vehicle (void) const { return _vehicle;}
+ QGeoCoordinate* takeOffPosition (void) { return &_takeOffPosition;}
+ QGeoCoordinate* landPosition (void) { return &_landPosition;}
// Property setters
- void setTakeOffPosition (QGeoCoordinate coordinate);
- void setLandPosition (QGeoCoordinate coordinate);
- void setVehicle (Vehicle* vehicle);
+ void setTakeOffPosition (QGeoCoordinate* coordinate);
+ void setLandPosition (QGeoCoordinate* coordinate);
signals:
- void takeOffPositionChanged (QGeoCoordinate takeOffPos);
- void landPositionChanged (QGeoCoordinate landPos);
- void vehicleChanged (Vehicle* vehicle);
-
+ void takeOffPositionChanged (void);
+ void landPositionChanged (void);
private:
QGeoCoordinate _takeOffPosition;
QGeoCoordinate _landPosition;
- Vehicle* _vehicle;
};
-#endif // WIMASERVICEPOLYGON_H
diff --git a/src/MissionManager/WimaVehicle.cc b/src/MissionManager/WimaVehicle.cc
index ef495f2ea79f806f8cdd8f4330eae75d8c8340d3..06f0eaddd16cfec4a7685fec852ddb3041c16706 100644
--- a/src/MissionManager/WimaVehicle.cc
+++ b/src/MissionManager/WimaVehicle.cc
@@ -3,7 +3,47 @@
WimaVehicle::WimaVehicle(QObject *parent):
- Vehicle (parent)
+ QObject (parent)
+ ,_vehicle (nullptr)
+ ,_servicePolygon (nullptr)
+ ,_vehicleCorridor (nullptr)
+ ,_measurementPolygon (nullptr)
{
}
+
+void WimaVehicle::setVehicle(Vehicle *vehicle)
+{
+ if(vehicle != nullptr){
+ _vehicle = vehicle;
+ }else {
+ qWarning("Not a valid vehicle!");
+ }
+}
+
+void WimaVehicle::setServicePolygon(WimaServicePolygon *servicePolygon)
+{
+ if(servicePolygon != nullptr){
+ _servicePolygon = servicePolygon;
+ }else{
+ qWarning("Not a valid service Polygon!");
+ }
+}
+
+void WimaVehicle::setVehicleCorridor(WimaVehicleCorridor *vehicleCorridor)
+{
+ if(vehicleCorridor != nullptr){
+ _vehicleCorridor = vehicleCorridor;
+ }else{
+ qWarning("Not a valid vehicle Corridor!");
+ }
+}
+
+void WimaVehicle::setMeasurementPolygon(WimaVehicleMeasurementPolygon *measurementPolygon)
+{
+ if(measurementPolygon != nullptr){
+ _measurementPolygon = measurementPolygon;
+ }else{
+ qWarning("Not a valid measurementPolygon!");
+ }
+}
diff --git a/src/MissionManager/WimaVehicle.h b/src/MissionManager/WimaVehicle.h
index da22f0e83f1a48555d2767d4ca8d7b21072bc327..2a41f4ad6782f29bc66170d528bc0daa82cda53b 100644
--- a/src/MissionManager/WimaVehicle.h
+++ b/src/MissionManager/WimaVehicle.h
@@ -1,14 +1,34 @@
-#ifndef WIMAVEHICLE_H
-#define WIMAVEHICLE_H
+#pragma once
#include
#include "Vehicle.h"
-class WimaVehicle : public Vehicle
+class WimaServicePolygon;
+class WimaVehicleCorridor;
+class WimaVehicleMeasurementPolygon;
+
+class WimaVehicle : public QObject
{
Q_OBJECT
public:
WimaVehicle(QObject* parent);
+
+ Vehicle* vehicle (void) const { return _vehicle;}
+ WimaServicePolygon* servicePolygon (void) const { return _servicePolygon;}
+ WimaVehicleCorridor* vehicleCorridor (void) const { return _vehicleCorridor;}
+ WimaVehicleMeasurementPolygon* measurementPolygon (void) const { return _measurementPolygon;}
+
+ void setVehicle (Vehicle* vehicle);
+ void setServicePolygon (WimaServicePolygon* servicePolygon);
+ void setVehicleCorridor (WimaVehicleCorridor* vehicleCorridor);
+ void setMeasurementPolygon (WimaVehicleMeasurementPolygon* measurementPolygon);
+
+private:
+ Vehicle* _vehicle;
+ WimaServicePolygon* _servicePolygon;
+ WimaVehicleCorridor* _vehicleCorridor;
+ WimaVehicleMeasurementPolygon* _measurementPolygon;
+
};
-#endif // WIMAVEHICLE_H
+
diff --git a/src/MissionManager/WimaVehicleCorridor.h b/src/MissionManager/WimaVehicleCorridor.h
index 99596ecd0d29df9fc805198ec45b70139633e34b..2dc06b7649f9897206cf57be6328b839ee0e54b7 100644
--- a/src/MissionManager/WimaVehicleCorridor.h
+++ b/src/MissionManager/WimaVehicleCorridor.h
@@ -1,5 +1,4 @@
-#ifndef WIMAVEHICLECORRIDOR_H
-#define WIMAVEHICLECORRIDOR_H
+#pragma once
#include
#include "WimaPolygon.h"
@@ -12,8 +11,7 @@ public:
WimaVehicleCorridor(QGCMapPolygon* other, QObject* parent);
// Overrides from WimaPolygon
- QString mapVisualQML (void) const { return "WimaVehicleCorridorMapVisal.qml";}
+ QString mapVisualQML (void) const { return "WimaVehicleCorridorMapVisual.qml";}
QString editorQML (void) const { return "WimaVehicleCorridorEditor.qml";}
};
-#endif // WIMAVEHICLECORRIDOR_H
diff --git a/src/MissionManager/WimaVehicleMeasurementPolygon.h b/src/MissionManager/WimaVehicleMeasurementPolygon.h
index 44a5e0c7a7a5ee1370926fa8f0ff0f00298e8549..8aa63d6d10f4b35c2f4e2b83b301b1344508bcd9 100644
--- a/src/MissionManager/WimaVehicleMeasurementPolygon.h
+++ b/src/MissionManager/WimaVehicleMeasurementPolygon.h
@@ -1,5 +1,4 @@
-#ifndef WIMAVEHICLEMEASUREMENTPOLYGON_H
-#define WIMAVEHICLEMEASUREMENTPOLYGON_H
+#pragma once
#include
#include "WimaPolygon.h"
@@ -12,8 +11,8 @@ public:
WimaVehicleMeasurementPolygon(QGCMapPolygon* other, QObject* parent);
// Overrides from WimaPolygon
- QString mapVisualQML (void) const { return "WimaVehicleMeasurementPolygonMapVisal.qml";}
+ QString mapVisualQML (void) const { return "WimaVehicleMeasurementPolygonMapVisual.qml";}
QString editorQML (void) const { return "WimaVehicleMeasurementPolygonEditor.qml";}
};
-#endif // WIMAVEHICLEMEASUREMENTPOLYGON_H
+
diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc
index 1116e9ded6fff1b96eb4992bc81b539887a00637..71b76c4c84c83cb043fefafeb800b49c6c55fe40 100644
--- a/src/QGCApplication.cc
+++ b/src/QGCApplication.cc
@@ -68,7 +68,6 @@
#include "CoordinateVector.h"
#include "PlanMasterController.h"
#include "WimaController.h" //custom
-#include "WimaFlyArea.h" //custom
#include "VideoManager.h"
#include "VideoSurface.h"
#include "VideoReceiver.h"
@@ -466,7 +465,6 @@ void QGCApplication::_initCommon(void)
qmlRegisterType (kQGCControllers, 1, 0, "MavlinkConsoleController");
#endif
// Wima
- qmlRegisterUncreatableType ("Wima", 1, 0, "WimaFlyArea", kRefOnly); //custom
qmlRegisterType ("Wima", 1, 0, "WimaController"); //custom
diff --git a/src/QmlControls/QGroundControl.Controls.qmldir b/src/QmlControls/QGroundControl.Controls.qmldir
index 4043d987e6ed73eeba73310e3a1def27b5528d07..a24a43a873a4aa62b0717bf29ddebf34db97f7d2 100644
--- a/src/QmlControls/QGroundControl.Controls.qmldir
+++ b/src/QmlControls/QGroundControl.Controls.qmldir
@@ -83,5 +83,9 @@ 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
FlyAreaItemEditor 1.0 FlyAreaItemEditor.qml
+
+WimaMapVisual 1.0 WimaMapVisual.qml
+WimaGlobalMeasurementPolygonMapVisual 1.0 WimaGlobalMeasurementPolygonMapVisual.qml
+WimaServicePolygonMapVisual 1.0 WimaServicePolygonMapVisual.qml
+WimaItemEditor 1.0 WimaItemEditor.qml
diff --git a/src/WimaView/FlyAreaEditor.qml b/src/WimaView/FlyAreaEditor.qml
deleted file mode 100644
index 11168fa78772a6c082eacb16a4a8cad66661fb5d..0000000000000000000000000000000000000000
--- a/src/WimaView/FlyAreaEditor.qml
+++ /dev/null
@@ -1,47 +0,0 @@
-import QtQuick 2.3
-import QtQuick.Controls 1.2
-import QtQuick.Controls.Styles 1.4
-import QtQuick.Dialogs 1.2
-import QtQuick.Extras 1.4
-import QtQuick.Layouts 1.2
-
-import QGroundControl 1.0
-import QGroundControl.ScreenTools 1.0
-import QGroundControl.Vehicle 1.0
-import QGroundControl.Controls 1.0
-import QGroundControl.FactControls 1.0
-import QGroundControl.Palette 1.0
-import QGroundControl.FlightMap 1.0
-
-// Editor for Survery mission items
-Rectangle {
- id: _root
- height: visible ? (editorColumn.height + (_margin * 2)) : 0
- width: availableWidth
- color: qgcPal.windowShadeDark
- radius: _radius
-
- // The following properties must be available up the hierarchy chain
- //property real availableWidth ///< Width for control
-
- property real _margin: ScreenTools.defaultFontPixelWidth / 2
- property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5
- property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
-
-
-
-
- QGCPalette { id: qgcPal; colorGroupEnabled: true }
-
- Column {
- id: editorColumn
- anchors.margins: _margin
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.right: parent.right
- spacing: _margin
-
-
-
- } // Column
-} // Rectangle
diff --git a/src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml b/src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml
new file mode 100644
index 0000000000000000000000000000000000000000..056a9bfc87fdb9a06916deaa8f877835b8144c89
--- /dev/null
+++ b/src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+ *
+ * (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
+
+/// Wima Global Measurement Area visuals
+Item {
+ id: _root
+
+ property var map ///< Map control to place item in
+ property var qgcView ///< QGCView to use for popping dialogs
+
+ property var _missionItem: object
+ property var _polygon: object.polygon
+
+ signal clicked(int sequenceNumber)
+
+ /// Add an initial 4 sided polygon if there is none
+ function _addInitialPolygon() {
+ if (_polygon.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)
+
+ _polygon.appendVertex(topLeftCoord)
+ _polygon.appendVertex(topRightCoord)
+ _polygon.appendVertex(bottomRightCoord)
+ _polygon.appendVertex(bottomLeftCoord)
+ }
+ }
+
+ Component.onCompleted: {
+ _addInitialPolygon()
+ }
+
+ Component.onDestruction: {
+ }
+
+ QGCMapPolygonVisuals {
+ qgcView: _root.qgcView
+ mapControl: map
+ mapPolygon: _polygon
+ interactive: _missionItem.isCurrentPolygon
+ borderWidth: 1
+ borderColor: "black"
+ interiorColor: "green"
+ interiorOpacity: 0.25
+ }
+
+
+
+
+}
diff --git a/src/WimaView/FlyAreaItemEditor.qml b/src/WimaView/WimaItemEditor.qml
similarity index 100%
rename from src/WimaView/FlyAreaItemEditor.qml
rename to src/WimaView/WimaItemEditor.qml
diff --git a/src/WimaView/WimaItemEditor_old.qml b/src/WimaView/WimaItemEditor_old.qml
new file mode 100644
index 0000000000000000000000000000000000000000..796dcf87418f8c7e1930201137ccfd3809400ed3
--- /dev/null
+++ b/src/WimaView/WimaItemEditor_old.qml
@@ -0,0 +1,142 @@
+import QtQuick 2.3
+import QtQuick.Controls 1.2
+import QtQuick.Controls.Styles 1.4
+import QtQuick.Dialogs 1.2
+import QtQml 2.2
+
+import QGroundControl 1.0
+import QGroundControl.ScreenTools 1.0
+import QGroundControl.Vehicle 1.0
+import QGroundControl.Controls 1.0
+import QGroundControl.FactControls 1.0
+import QGroundControl.Palette 1.0
+
+
+/// Fly Area Item edit control
+Rectangle {
+ id: _root
+ height: editorLoader.visible ? (editorLoader.y + editorLoader.height + (_margin * 2)) : (descriptionLabel.y + descriptionLabel.height + _margin / 2)
+ color: _currentItem ? qgcPal.missionItemEditor : qgcPal.windowShade
+ radius: _radius
+
+ property var map ///< Map control
+ property var flyArea
+ property var masterController
+ property var polygon ///< MissionItem associated with this editor
+ property bool readOnly ///< true: read only view, false: full editing view
+ property var rootQgcView
+ property int _index
+
+ signal clicked
+ signal remove
+
+ property var _masterController: masterController
+ property var _missionController: _masterController.missionController
+ property bool _currentItem: polygon.interactive
+ property color _outerTextColor: _currentItem ? qgcPal.primaryButtonText : qgcPal.text
+ property bool _noMissionItemsAdded: ListView.view.model.count === 1
+ property real _sectionSpacer: ScreenTools.defaultFontPixelWidth / 2 // spacing between section headings
+
+ readonly property real _editFieldWidth: Math.min(width - _margin * 2, ScreenTools.defaultFontPixelWidth * 12)
+ readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2
+ readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2
+ readonly property real _hamburgerSize: descriptionLabel.height * 0.75
+ readonly property bool _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly
+
+ QGCPalette {
+ id: qgcPal
+ colorGroupEnabled: enabled
+ }
+
+ FocusScope {
+ id: currentItemScope
+ anchors.fill: parent
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ currentItemScope.focus = true
+ _root.clicked()
+ }
+ }
+ }
+
+
+ QGCLabel {
+ id: label
+ anchors.verticalCenter: descriptionLabel.verticalCenter
+ anchors.leftMargin: _margin
+ anchors.left: parent.left
+ text: index
+ color: _outerTextColor
+ }
+
+ QGCColoredImage {
+ id: hamburger
+ anchors.rightMargin: ScreenTools.defaultFontPixelWidth
+ anchors.right: parent.right
+ anchors.verticalCenter: descriptionLabel.verticalCenter
+ width: _hamburgerSize
+ height: _hamburgerSize
+ sourceSize.height: _hamburgerSize
+ source: "qrc:/qmlimages/Hamburger.svg"
+ visible: _currentItem
+ color: qgcPal.text
+ }
+
+ QGCMouseArea {
+ fillItem: hamburger
+ visible: hamburger.visible
+ onClicked: {
+ currentItemScope.focus = true
+ hamburgerMenu.popup()
+ }
+
+ Menu {
+ id: hamburgerMenu
+
+ MenuItem {
+ text: qsTr("Insert Fly Area")
+ onTriggered: flyArea.appendFlyAreaPolygon()
+ }
+
+ MenuItem {
+ text: qsTr("Delete")
+ onTriggered: remove()
+ }
+ MenuItem {
+ text: qsTr("Copy Fly Area")
+ //onTriggered: //To Do
+ }
+
+
+ }
+ }
+
+ QGCLabel {
+ id: descriptionLabel
+ anchors.topMargin: _margin / 2
+ anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
+ anchors.rightMargin: ScreenTools.defaultFontPixelWidth
+ anchors.left: label.right
+ anchors.top: parent.top
+ text: "Fly Area"
+ verticalAlignment: Text.AlignVCenter
+ color: _outerTextColor
+ }
+
+
+ Loader {
+ id: editorLoader
+ anchors.leftMargin: _margin
+ anchors.topMargin: _margin
+ anchors.left: parent.left
+ anchors.top: descriptionLabel.bottom
+ source: "FlyAreaEditor.qml"
+ visible: _currentItem
+
+ property var masterController: _masterController
+ property real availableWidth: _root.width - (_margin * 2) ///< How wide the editor should be
+ property var editorRoot: _root
+ }
+} // Rectangle
diff --git a/src/WimaView/WimaMapVisual.qml b/src/WimaView/WimaMapVisual.qml
new file mode 100644
index 0000000000000000000000000000000000000000..33e90ee2750ea4d4ee0ff9202eeec69692a40d4b
--- /dev/null
+++ b/src/WimaView/WimaMapVisual.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+ *
+ * (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.ScreenTools 1.0
+import QGroundControl.Palette 1.0
+import QGroundControl.Controls 1.0
+
+
+/// Wima map visual
+Item {
+ id: _root
+
+ property var map ///< Map control to place item in
+ property var qgcView ///< QGCView to use for popping dialogs
+
+ signal clicked(int sequenceNumber)
+
+ property var _visualItem
+
+ 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())
+ }
+ _visualItem = component.createObject(map, { "map": _root.map, "qgcView": _root.qgcView })
+ _visualItem.clicked.connect(_root.clicked)
+ }
+ }
+
+ Component.onDestruction: {
+ if (_visualItem) {
+ _visualItem.destroy()
+ }
+ }
+}
diff --git a/src/WimaView/WimaServicePolygonMapVisual.qml b/src/WimaView/WimaServicePolygonMapVisual.qml
new file mode 100644
index 0000000000000000000000000000000000000000..8fec7f55af9a07f780fc95aebd1392600b9cc1df
--- /dev/null
+++ b/src/WimaView/WimaServicePolygonMapVisual.qml
@@ -0,0 +1,86 @@
+/****************************************************************************
+ *
+ * (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
+
+/// Wima Global Measurement Area visuals
+Item {
+ id: _root
+
+ property var map ///< Map control to place item in
+ property var qgcView ///< QGCView to use for popping dialogs
+
+ property var _missionItem: object
+ property var _polygon: object.polygon
+
+ signal clicked(int sequenceNumber)
+
+ /// Add an initial 4 sided polygon if there is none
+ function _addInitialPolygon() {
+ if (_polygon.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.25
+ rect.height *= 0.25
+
+ 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)
+
+ _polygon.appendVertex(topLeftCoord)
+ _polygon.appendVertex(topRightCoord)
+ _polygon.appendVertex(bottomRightCoord)
+ _polygon.appendVertex(bottomLeftCoord)
+ }
+ }
+
+ Component.onCompleted: {
+ _addInitialPolygon()
+ }
+
+ Component.onDestruction: {
+ }
+
+ QGCMapPolygonVisuals {
+ qgcView: _root.qgcView
+ mapControl: map
+ mapPolygon: _polygon
+ interactive: _missionItem.isCurrentPolygon
+ borderWidth: 1
+ borderColor: "black"
+ interiorColor: "yellow"
+ interiorOpacity: 0.25
+ }
+
+
+
+
+}
diff --git a/src/WimaView/WimaView.qml b/src/WimaView/WimaView.qml
index 9e9e76db046fafda75121a544f46eee15a78da89..727916d6cf6b219f8454408b69f62b47d48b536f 100644
--- a/src/WimaView/WimaView.qml
+++ b/src/WimaView/WimaView.qml
@@ -68,7 +68,7 @@ QGCView {
property var _appSettings: QGroundControl.settingsManager.appSettings
readonly property int _layerMission: 1
- readonly property int _layerFlyArea: 2
+ readonly property int _layerWima: 2
readonly property string _armedVehicleUploadPrompt: qsTr("Vehicle is currently armed. Do you want to upload the mission to the vehicle?")
Component.onCompleted: {
@@ -155,7 +155,7 @@ QGCView {
}
}
}
- }
+ }_layerWimaPlan
Connections {
target: QGroundControl.airspaceManager
@@ -174,7 +174,8 @@ QGCView {
id:wimaController
Component.onCompleted: {
- wimaController.start()
+ wimaController.masterController = Qt.binding(function () { return masterController})
+ wimaController.missionController = Qt.binding(function () { return masterController.missionController})
}
}
@@ -256,7 +257,7 @@ QGCView {
}
Connections {
- target: _missionController
+ target: _missionController_layerWimaPlan
onNewItemsFromVehicle: {
if (_visualItems && _visualItems.count != 1) {
@@ -375,7 +376,7 @@ QGCView {
toIndex = 1
}
_missionController.moveMissionItem(_moveDialogMissionItemIndex, toIndex)
- hideDialog()
+ hideDialog()_layerWimaPlan
}
Column {
@@ -433,7 +434,7 @@ QGCView {
QGCMapPalette { id: mapPal; lightColors: editorMap.isSatelliteMap }
onZoomLevelChanged: updateAirspace(false)
- onCenterChanged: updateAirspace(false)
+ onCenterChanged: updateAirspace(false)_layerWimaPlan
MouseArea {
//-- It's a whole lot faster to just fill parent and deal with top offset below
@@ -484,13 +485,13 @@ QGCView {
model: _editingLayer == _layerMission ? _missionController.waypointLines : undefined
}
- //Add fly area
+ //Add Wima Visuals
Repeater {
- model: _flyArea.polygons
- delegate: FlyAreaPolygonMapVisual {
+ model: wimaController.visualItems
+ delegate: WimaMapVisual {
map: editorMap ///< Map control to place item in
qgcView: _qgcView ///< QGCView to use for popping dialogs
- _flyAreaPolygon: object
+ visible: true
}
onItemAdded: {
@@ -575,11 +576,11 @@ QGCView {
dropPanelComponent: syncDropPanel
},
{
- name: qsTr("Fly Area"),
+ name: qsTr("Global Area"),
iconSource: "/qmlimages/Target.svg"
},
{
- name: qsTr("No Fly"),
+ name: qsTr("Service Area"),
iconSource: "/qmlimages/noFlyArea.svg"
},
{
@@ -609,15 +610,13 @@ QGCView {
onClicked: {
switch (index) {
case 1:
- _flyArea.appendFlyAreaPolygon();
- console.log("polygon count: ", _flyArea.polygons.count)
+ wimaController.addGlobalMeasurementArea();
//addComplexItem(_missionController.complexMissionItemNames[2])
/*_addWaypointOnClick = checked
_addROIOnClick = false*/
break
case 2:
-
- /*
+ wimaController.addServiceArea(); /*
_addROIOnClick = checked
_addWaypointOnClick = false*/
break
@@ -625,7 +624,7 @@ QGCView {
/*if (_singleComplexItem) {
addComplexItem(_missionController.complexMissionItemNames[0])
- }*/
+ }*/FlyArea
break
case 5:
editorMap.zoomLevel += 0.5
@@ -757,16 +756,16 @@ QGCView {
case planElementMission:
_editingLayer = _layerMission
break
- case planElementFlyArea:
- _editingLayer = _layerFlyArea
+ case planElementWima:
+ _editingLayer = _layerWima
break
}
}
}
QGCRadioButton {
- id: planElementFlyArea
+ id: planElementWima
exclusiveGroup: planElementSelectorGroup
- text: qsTr("Fly Area")
+ text: qsTr("Wima")
checked: true
visible: QGroundControl.corePlugin.options.enablePlanViewSelector
anchors.verticalCenter: parent.verticalCenter
@@ -784,7 +783,7 @@ QGCView {
}
}
//-------------------------------------------------------
- // Fly Area Item Editor
+ // Wima Item Editor
Item {
id: flyAreaItemEditor
anchors.left: parent.left
@@ -793,20 +792,20 @@ QGCView {
anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.5
anchors.bottom: parent.bottom
anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * 0.25
- visible: _editingLayer == _layerFlyArea && !planControlColapsed
+ visible: _editingLayer == _layerWima && !planControlColapsed
QGCListView {
id: flyAreaItemEditorListView
anchors.fill: parent
spacing: ScreenTools.defaultFontPixelHeight / 4
orientation: ListView.Vertical
- model: _flyArea.polygons
+ model: wimaController.visualItems
cacheBuffer: Math.max(height * 2, 0)
clip: true
- currentIndex: _flyArea.currentPolygonIndex
+ currentIndex: wimaController.currentPolygonIndex
highlightMoveDuration: 250
- visible: _editingLayer == _layerFlyArea && !planControlColapsed
+ visible: _editingLayer == _layerWima && !planControlColapsed
//-- List Elements
- delegate: FlyAreaItemEditor {
+ delegate: WimaItemEditor {
map: editorMap
masterController: _planMasterController
flyArea: _flyArea