diff --git a/WimaGlobalMeasurementPolygonEditor.qml b/WimaGlobalMeasurementPolygonEditor.qml
index 3fb34fa108d7e19e1dfc3101525b72d785cc4b0b..a49b242519b0f8147409351a06cc05be74f9fff4 100644
--- a/WimaGlobalMeasurementPolygonEditor.qml
+++ b/WimaGlobalMeasurementPolygonEditor.qml
@@ -23,10 +23,18 @@ Rectangle {
// The following properties must be available up the hierarchy chain
//property real availableWidth ///< Width for control
- //property var missionItem ///< Mission Item for editor
+ //property var areaItem ///< Mission Item for editor
property real _margin: ScreenTools.defaultFontPixelWidth / 2
property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5
+ property var polyline: areaItem.polyline
+ property var operatingPolygon: areaItem.polygon
+ property bool initNecesarry: true
+
+ function editPolyline(){
+ polyline.setInteractive(true);
+ }
+
@@ -42,7 +50,7 @@ Rectangle {
SectionHeader {
id: scanHeader
- text: qsTr("Scan")
+ text: qsTr("Settings")
}
Column {
@@ -58,55 +66,48 @@ Rectangle {
rowSpacing: _margin
columns: 2
- FactComboBox {
- fact: missionItem.startFromTop
- indexModel: true
- model: [ qsTr("Start Scan From Bottom"), qsTr("Start Scan From Top") ]
- Layout.columnSpan: 2
- Layout.fillWidth: true
- }
-
QGCLabel {
- text: qsTr("Structure Height")
+ text: qsTr("Bottom Layer Altitude")
}
FactTextField {
- fact: missionItem.structureHeight
+ fact: areaItem.bottomLayerAltitude
Layout.fillWidth: true
}
- QGCLabel { text: qsTr("Scan Bottom Alt") }
+ QGCLabel { text: qsTr("Number of Layers") }
FactTextField {
- fact: missionItem.scanBottomAlt
+ fact: areaItem.numberOfLayers
Layout.fillWidth: true
}
- QGCLabel { text: qsTr("Entrance/Exit Alt") }
+ QGCLabel { text: qsTr("Layer Distance") }
FactTextField {
- fact: missionItem.entranceAlt
- LayoWimaGlobalMeasurementPolygonEditor.qmlut.fillWidth: true
- }
-
- QGCLabel {
- text: qsTr("Gimbal Pitch")
- visible: missionItem.cameraCalc.isManualCamera
- }
- FactTextField {
- fact: missionItem.gimbalPitch
+ fact: areaItem.layerDistance
Layout.fillWidth: true
- visible: missionItem.cameraCalc.isManualCamera
}
+
+
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: 1
}
-
- QGCButton {
- text: qsTr("Rotate entry point")
- onClicked: missionItem.rotateEntryPoint()
- }
} // Column - Scan
+ SectionHeader {
+ id: polylineHeader
+ text: qsTr("Gateway Poly Line")
+ }
+
+ QGCButton {
+ id: polylineEditor
+ anchors.topMargin: _margin / 2
+ anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
+ anchors.rightMargin: ScreenTools.defaultFontPixelWidth
+ text: "Edit Polyline"
+
+ onClicked: editPolyline()
+ }
SectionHeader {
id: statsHeader
@@ -118,26 +119,9 @@ Rectangle {
columnSpacing: ScreenTools.defaultFontPixelWidth
visible: statsHeader.checked
- QGCLabel { text: qsTr("Layers") }
- QGCLabel { text: missionItem.layers.valueString }
-
- QGCLabel { text: qsTr("Layer Height") }
- QGCLabel { text: missionItem.cameraCalc.adjustedFootprintFrontal.valueString + " " + QGroundControl.appSettingsDistanceUnitsString }
+ /*QGCLabel { text: qsTr("Layers") }
+ QGCLabel { text: areaItem.layers.valueString }*/
- QGCLabel { text: qsTr("Top Layer Alt") }
- QGCLabel { text: QGroundControl.metersToAppSettingsDistanceUnits(missionItem.topFlightAlt).toFixed(1) + " " + QGroundControl.appSettingsDistanceUnitsString }
-
- QGCLabel { text: qsTr("Bottom Layer Alt") }
- QGCLabel { text: QGroundControl.metersToAppSettingsDistanceUnits(missionItem.bottomFlightAlt).toFixed(1) + " " + QGroundControl.appSettingsDistanceUnitsString }
-
- QGCLabel { text: qsTr("Photo Count") }
- QGCLabel { text: missionItem.cameraShots }
-
- QGCLabel { text: qsTr("Photo Interval") }
- QGCLabel { text: missionItem.timeBetweenShots.toFixed(1) + " " + qsTr("secs") }
-
- QGCLabel { text: qsTr("Trigger Distance") }
- QGCLabel { text: missionItem.cameraCalc.adjustedFootprintSide.valueString + " " + QGroundControl.appSettingsDistanceUnitsString }
- }
+ }
} // Column
} // Rectangle
diff --git a/WimaGlobalMeasurementPolygonMapVisual.qml b/WimaGlobalMeasurementPolygonMapVisual.qml
index 5a7cd107e23b2a4089fd22cd54dc17192a7ab72a..f7552276e9cd1ea729da393877baa3168aa06ad1 100644
--- a/WimaGlobalMeasurementPolygonMapVisual.qml
+++ b/WimaGlobalMeasurementPolygonMapVisual.qml
@@ -27,6 +27,7 @@ Item {
property var _missionItem: object
property var _polygon: object.polygon
+ property var _polyline: object.polyline
signal clicked(int sequenceNumber)
@@ -77,9 +78,19 @@ Item {
borderWidth: 1
borderColor: "black"
interiorColor: "green"
- interiorOpacity: 0.25
+ interiorOpacity: 1
+ }
+ 1
+
+ QGCMapPolylineVisuals {
+ id: mapPolylineVisuals
+ qgcView: _root.qgcView
+ mapControl: map
+ mapPolyline: _polyline
+ interactive: true
+ lineWidth: 3
+ lineColor: "blue"
}
-
diff --git a/issues.txt b/issues.txt
new file mode 100644
index 0000000000000000000000000000000000000000..3242bc26f731420233afdf907369416074e1b53d
--- /dev/null
+++ b/issues.txt
@@ -0,0 +1,2 @@
+if polygon vertex clicked: remove circle option
+can't switch between polygons on first insert
diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro
index 4f471cb5c7f3e39c254819c684c3d25cd01be220..c3978a241e37e04e41888be8ae7916180db067a1 100644
--- a/qgroundcontrol.pro
+++ b/qgroundcontrol.pro
@@ -413,7 +413,8 @@ HEADERS += \
src/MissionManager/WimaVehicleCorridor.h \
src/MissionManager/WimaVehicleMeasurementPolygon.h \
src/MissionManager/WimaGlobalMeasurementPolygon.h \
- src/MissionManager/WimaVehicle.h
+ src/MissionManager/WimaVehicle.h \
+ src/MissionManager/WimaPolyline.h
SOURCES += \
src/api/QGCCorePlugin.cc \
@@ -427,7 +428,8 @@ SOURCES += \
src/MissionManager/WimaVehicleCorridor.cc \
src/MissionManager/WimaVehicleMeasurementPolygon.cc \
src/MissionManager/WimaGlobalMeasurementPolygon.cc \
- src/MissionManager/WimaVehicle.cc
+ src/MissionManager/WimaVehicle.cc \
+ src/MissionManager/WimaPolyline.cc
#
# Unit Test specific configuration goes here (requires full debug build with all plugins)
diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index 8711bce221e75c1a3950ca05ce6808e3d502ba1b..40a4efee8677e8323abda2234b7e30d1b8e123f3 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -259,7 +259,7 @@
src/Vehicle/VibrationFact.json
src/Vehicle/WindFact.json
src/Settings/Video.SettingsGroup.json
- src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json
+ src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json
src/comm/APMArduCopterMockLink.params
diff --git a/src/MissionManager/WimaController.cc b/src/MissionManager/WimaController.cc
index 18ee92dc0f064a0172f673581e17ff935376719d..60e782af5a5688f14ac0afa45bd143ac4aa3565b 100644
--- a/src/MissionManager/WimaController.cc
+++ b/src/MissionManager/WimaController.cc
@@ -43,7 +43,7 @@ void WimaController::addGlobalMeasurementArea()
void WimaController::removeArea(int index)
{
- if(index > 0 && index < _visualItems->count()){
+ if(index >= 0 && index < _visualItems->count()){
_visualItems->removeAt(index);
emit visualItemsChanged();
@@ -63,7 +63,7 @@ void WimaController::addServiceArea()
{
resetAllIsCurrentPolygon();
WimaServicePolygon* newPoly = new WimaServicePolygon(this);
- newPoly->setIsCurrentPolygon(true);
+ newPoly->setInteractive(true);
_visualItems->append(newPoly);
emit visualItemsChanged();
@@ -118,7 +118,7 @@ void WimaController::recalcPolygonInteractivity(int index)
{
resetAllIsCurrentPolygon();
WimaPolygon* interactivePoly = qobject_cast(_visualItems->get(index));
- interactivePoly->setIsCurrentPolygon(true);
+ interactivePoly->setInteractive(true);
}
void WimaController::resetAllIsCurrentPolygon()
@@ -126,7 +126,7 @@ void WimaController::resetAllIsCurrentPolygon()
int itemCount = _visualItems->count();
for (int i = 0; i < itemCount; i++) {
WimaPolygon* iteratorPoly = qobject_cast(_visualItems->get(i));
- iteratorPoly->setIsCurrentPolygon(false);
+ iteratorPoly->setInteractive(false);
}
}
diff --git a/src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json b/src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json
index b5fcb0b7f466d7eba312f24fb007081b42bac856..b6f5d25f3ee58e94c47a93c79d1c1ed03af2ab08 100644
--- a/src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json
+++ b/src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json
@@ -11,7 +11,7 @@
{
"name": "NumberOfLayers",
"shortDescription": "The number of layers",
- "type": "unint32",
+ "type": "uint32",
"min": 1,
"defaultValue": 1
},
diff --git a/src/MissionManager/WimaGlobalMeasurementPolygon.cc b/src/MissionManager/WimaGlobalMeasurementPolygon.cc
index 5b4d1d83a93321c503baf1fad00b5af840070ae8..ae28848abd9a3dd48077450e19750ba3f653517d 100644
--- a/src/MissionManager/WimaGlobalMeasurementPolygon.cc
+++ b/src/MissionManager/WimaGlobalMeasurementPolygon.cc
@@ -1,7 +1,7 @@
#include "WimaGlobalMeasurementPolygon.h"
-const char* WimaGlobalMeasurementPolygon::settingsGroup = "OperatingArea";
+const char* WimaGlobalMeasurementPolygon::settingsGroup = "OperatingArea";
const char* WimaGlobalMeasurementPolygon::bottomLayerAltitudeName = "BottomLayerAltitude";
const char* WimaGlobalMeasurementPolygon::numberOfLayersName = "NumberOfLayers";
const char* WimaGlobalMeasurementPolygon::layerDistanceName = "LayerDistance";
@@ -12,14 +12,24 @@ WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QObject *parent)
, _bottomLayerAltitude (settingsGroup, _metaDataMap[bottomLayerAltitudeName])
, _numberOfLayers (settingsGroup, _metaDataMap[numberOfLayersName])
, _layerDistance (settingsGroup, _metaDataMap[layerDistanceName])
+ , _vehicleList (new QmlObjectListModel(this))
+ , _vehiclePolygons (new QmlObjectListModel(this))
{
this->setObjectName("Operating Area");
+ _polyline.bindPolygon(this->polygon());
}
-WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QGCMapPolygon *other, QObject *parent):
- WimaPolygon (other, parent)
+WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QGCMapPolygon *other, QObject *parent)
+ : WimaPolygon (other, parent)
+ , _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/WimaGlobalMeasurementPolygon.SettingsGroup.json"), this /* QObject parent */))
+ , _bottomLayerAltitude (settingsGroup, _metaDataMap[bottomLayerAltitudeName])
+ , _numberOfLayers (settingsGroup, _metaDataMap[numberOfLayersName])
+ , _layerDistance (settingsGroup, _metaDataMap[layerDistanceName])
+ , _vehicleList (new QmlObjectListModel(this))
+ , _vehiclePolygons (new QmlObjectListModel(this))
{
-
+ this->setObjectName("Operating Area");
+ _polyline.bindPolygon(this->polygon());
}
void WimaGlobalMeasurementPolygon::addVehicle(Vehicle *vehicle)
@@ -44,23 +54,60 @@ void WimaGlobalMeasurementPolygon::recalculatesubPolygons()
QScopedPointer> listQGCPoly(this->splitPolygonArea(vehicleCount));
int polyCount = listQGCPoly->size();
- _subPolygons->clear();
+ _vehiclePolygons->clear();
for(int i = 0; i < polyCount; i++){
WimaVehicleMeasurementPolygon* subPoly = new WimaVehicleMeasurementPolygon(listQGCPoly->takeAt(i), this);
- _subPolygons->append(subPoly);
+ _vehiclePolygons->append(subPoly);
}
}
void WimaGlobalMeasurementPolygon::removeAllVehicles()
{
- int counter = _vehicleList->count()-1;
+ int count = _vehicleList->count();
- while(counter >= 0){
- _vehicleList->removeAt(0);
- counter--;
+ if(count > 0){
+ do{
+ _vehicleList->removeAt(0);
+ count--;
+ }while(count > 0);
+
+ emit vehicleListChanged();
}
- emit vehicleListChanged();
}
+void WimaGlobalMeasurementPolygon::addVehiclePolygon()
+{
+ _vehiclePolygons->append(new WimaVehicleMeasurementPolygon(this));
+
+ emit vehiclePolygonsChanged();
+}
+
+void WimaGlobalMeasurementPolygon::removeVehiclePolygon(int polygonIndex)
+{
+ if(polygonIndex >= 0 && polygonIndex < _vehiclePolygons->count()){
+ _vehiclePolygons->removeAt(polygonIndex);
+
+ emit vehiclePolygonsChanged();
+ }else {
+ qWarning("Index out of bounds!");
+ }
+}
+
+void WimaGlobalMeasurementPolygon::removeVehiclePolygon(WimaVehicleMeasurementPolygon *wimaPolygon)
+{
+ if(wimaPolygon != nullptr){
+ QObject* removedPolygon = _vehiclePolygons->removeOne(wimaPolygon);
+ if(removedPolygon){
+ emit vehiclePolygonsChanged();
+ }else {
+ qWarning("Polygon not inside polygon list.");
+ }
+ }else {
+ qWarning("Not a valid Polygon.");
+ }
+}
+
+
+
diff --git a/src/MissionManager/WimaGlobalMeasurementPolygon.h b/src/MissionManager/WimaGlobalMeasurementPolygon.h
index d15cba81ab3818df0849ad531e8f2e142db54817..dcf372362d9b1c9d79c4962ef0f7ea5575a3aa6b 100644
--- a/src/MissionManager/WimaGlobalMeasurementPolygon.h
+++ b/src/MissionManager/WimaGlobalMeasurementPolygon.h
@@ -1,4 +1,4 @@
-#pragma once
+#pragma once
#include
#include "WimaPolygon.h"
@@ -20,12 +20,17 @@ public:
Q_PROPERTY(Fact* numberOfLayers READ numberOfLayers CONSTANT)
Q_PROPERTY(Fact* layerDistance READ layerDistance CONSTANT)
Q_PROPERTY(QmlObjectListModel* vehicleList READ vehicleList NOTIFY vehicleListChanged)
- Q_PROPERTY(QGCMapPolyline* entryPolyline READ entryPolyline NOTIFY entryPolylineChanged)
+ Q_PROPERTY(QmlObjectListModel* vehiclePolygons READ vehiclePolygons NOTIFY vehiclePolygonsChanged)
+ Q_PROPERTY(WimaPolyline* polyline READ polyline NOTIFY polylineChanged)
- Q_INVOKABLE void addVehicle(Vehicle *vehicle);
- Q_INVOKABLE void removeVehicle(int vehicleIndex);
- Q_INVOKABLE void recalculatesubPolygons();
- Q_INVOKABLE void removeAllVehicles();
+
+ Q_INVOKABLE void addVehicle (Vehicle *vehicle);
+ Q_INVOKABLE void removeVehicle (int vehicleIndex);
+ Q_INVOKABLE void recalculatesubPolygons ();
+ Q_INVOKABLE void removeAllVehicles ();
+ Q_INVOKABLE void addVehiclePolygon ();
+ Q_INVOKABLE void removeVehiclePolygon (int polygonIndex);
+ Q_INVOKABLE void removeVehiclePolygon (WimaVehicleMeasurementPolygon *wimaPolygon);
// Overrides from WimaPolygon
@@ -33,11 +38,12 @@ public:
QString editorQML (void) const { return "WimaGlobalMeasurementPolygonEditor.qml";}
// Property accessors
- Fact* bottomLayerAltitude (void) { return &_bottomLayerAltitude;}
- Fact* numberOfLayers (void) { return &_numberOfLayers;}
- Fact* layerDistance (void) { return &_layerDistance;}
- QmlObjectListModel* vehicleList (void) const { return _vehicleList;}
- QGCMapPolyline* entryPolyline (void) const { return _entryPolyline;}
+ Fact* bottomLayerAltitude (void) { return &_bottomLayerAltitude;}
+ Fact* numberOfLayers (void) { return &_numberOfLayers;}
+ Fact* layerDistance (void) { return &_layerDistance;}
+ QmlObjectListModel* vehicleList (void) const { return _vehicleList;}
+ QmlObjectListModel* vehiclePolygons (void) const { return _vehiclePolygons;}
+ WimaPolyline* polyline (void) { return &_polyline;}
static const char* settingsGroup;
@@ -51,8 +57,8 @@ signals:
void numberOfLayersChanged (void);
void layerDistanceChanged (void);
void vehicleListChanged (void);
- void entryPolylineChanged (void);
- void subPolygonsChanged (void);
+ void gatewayPolylinesChanged (void);
+ void vehiclePolygonsChanged (void);
private:
@@ -64,8 +70,11 @@ private:
QmlObjectListModel* _vehicleList;
- QGCMapPolyline* _entryPolyline;
+ QmlObjectListModel* _vehiclePolygons;
+ WimaPolyline _polyline;
+
};
+
diff --git a/src/MissionManager/WimaPolygon.cc b/src/MissionManager/WimaPolygon.cc
index 927eeb12853ab7a7c1f17f86a3a71c0ab7893c3c..de3ebb22ce0433e9085524fae68d0d6e872d9b82 100644
--- a/src/MissionManager/WimaPolygon.cc
+++ b/src/MissionManager/WimaPolygon.cc
@@ -5,15 +5,22 @@ WimaPolygon::WimaPolygon(QObject *parent) :
,_maxAltitude (30)
,_vehicle (parent)
,_polygon (new QGCMapPolygon(this))
- ,_subPolygons (new QmlObjectListModel(this))
- ,_subPolylines (new QmlObjectListModel(this))
{
+ connect(_polygon, &QGCMapPolygon::interactiveChanged, this, &WimaPolygon::interactiveChanged);
+ connect(_polygon, &QGCMapPolygon::countChanged, this, &WimaPolygon::countChanged);
}
WimaPolygon::WimaPolygon(QGCMapPolygon *other, QObject *parent):
WimaPolygon(parent)
{
*_polygon = *other;
+ connect(_polygon, &QGCMapPolygon::interactiveChanged, this, &WimaPolygon::interactiveChanged);
+ connect(_polygon, &QGCMapPolygon::countChanged, this, &WimaPolygon::countChanged);
+}
+
+WimaPolygon::~WimaPolygon()
+{
+
}
@@ -34,19 +41,16 @@ void WimaPolygon::setVehicle(Vehicle *vehicle)
}
}
-void WimaPolygon::setIsCurrentPolygon(bool isCurrentPolygon)
-{
- if(_isCurrentPolygon != isCurrentPolygon){
- _isCurrentPolygon = isCurrentPolygon;
- emit isCurrentPolygonChanged();
- }
+void WimaPolygon::setInteractive(bool interactive)
+{
+ _polygon->setInteractive(interactive);
}
-QList* WimaPolygon::splitPolygonArea(int numberOfFractions)
+QList *WimaPolygon::splitPolygonArea(QGCMapPolygon *polygonToSplitt, int numberOfFractions)
{
- if(numberOfFractions > 0){
- QGCMapPolygon* poly = new QGCMapPolygon(this->polygon(), this);
+ if(numberOfFractions > 0 && polygonToSplitt != nullptr){
+ QGCMapPolygon* poly = new QGCMapPolygon(polygonToSplitt, this);
QList* list = new QList();
list->append(poly);
return list;
@@ -55,3 +59,9 @@ QList* WimaPolygon::splitPolygonArea(int numberOfFractions)
}
+QList* WimaPolygon::splitPolygonArea(int numberOfFractions)
+{
+ return splitPolygonArea(_polygon, numberOfFractions);
+}
+
+
diff --git a/src/MissionManager/WimaPolygon.h b/src/MissionManager/WimaPolygon.h
index f70f50cc71fbb14a6b92d549506d8fcf3f2370f6..a898122ae9a54b0b5e57e33dbc9bd67f4451efa8 100644
--- a/src/MissionManager/WimaPolygon.h
+++ b/src/MissionManager/WimaPolygon.h
@@ -6,6 +6,7 @@
#include "Vehicle.h"
#include "qobject.h"
#include "WimaVehicle.h"
+#include "WimaPolyline.h"
@@ -17,6 +18,7 @@ class WimaPolygon : public QObject //abstract base class for all WimaPolygons
public:
WimaPolygon(QObject* parent = nullptr);
WimaPolygon(QGCMapPolygon* other, QObject* parent = nullptr);
+ ~WimaPolygon();
@@ -25,46 +27,46 @@ 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(QmlObjectListModel* subPolygons READ subPolygons NOTIFY subPolygonsChanged)
- Q_PROPERTY(QmlObjectListModel* subPolylines READ subPolylines NOTIFY subPolylinesChanged)
- Q_PROPERTY(bool isCurrentPolygon READ isCurrentPolygon WRITE setIsCurrentPolygon NOTIFY isCurrentPolygonChanged)
+ Q_PROPERTY(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged)
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
//Property accessors
double maxAltitude (void) const { return _maxAltitude;}
Vehicle* vehicle (void) const { return _vehicle.vehicle();}
QGCMapPolygon* polygon (void) const { return _polygon;}
- QmlObjectListModel* subPolygons (void) const { return _subPolygons;}
- QmlObjectListModel* subPolylines (void) const { return _subPolylines;}
- bool isCurrentPolygon (void) const { return _isCurrentPolygon;}
+ bool interactive (void) const { return _polygon->interactive();}
+ int count (void) const { return _polygon->count();}
virtual QString mapVisualQML (void) const = 0;
virtual QString editorQML (void) const = 0;
+
//Property setters
void setMaxAltitude (double alt);
void setVehicle (Vehicle* vehicle);
- void setIsCurrentPolygon(bool isCurrentPolygon);
+ void setInteractive (bool interactive);
+ // Member Methodes
+ QList* splitPolygonArea(QGCMapPolygon *polygonToSplitt, int numberOfFractions); // use QScopedPointer to store return value
QList* splitPolygonArea(int numberOfFractions); // use QScopedPointer to store return value
+
+
signals:
void maxAltitudeChanged (void);
void vehicleChanged (void);
void polygonChanged (void);
- void subPolygonsChanged (void);
- void subPolylinesChanged (void);
- void isCurrentPolygonChanged (void);
+ void interactiveChanged (void);
+ void polylineChanged (void);
+ void countChanged (void);
protected:
double _maxAltitude;
WimaVehicle _vehicle;
QGCMapPolygon* _polygon;
- QmlObjectListModel* _subPolygons;
- QmlObjectListModel* _subPolylines;
- bool _isCurrentPolygon;
};
diff --git a/src/MissionManager/WimaPolyline.cc b/src/MissionManager/WimaPolyline.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8c09f8a80e2bd2d3311f56172dd358cfa29e7f2a
--- /dev/null
+++ b/src/MissionManager/WimaPolyline.cc
@@ -0,0 +1,97 @@
+#include "WimaPolyline.h"
+
+WimaPolyline::WimaPolyline(QObject *parent)
+ : QObject (parent)
+ , _boundPolygon (nullptr)
+ , _startVertexIndex(0)
+ , _endVertexIndex(1)
+{
+ connect(&_polyline, &QGCMapPolyline::interactiveChanged, this, &WimaPolyline::interactiveChanged);
+}
+
+WimaPolyline::WimaPolyline(QGCMapPolyline *polyline, QObject *parent)
+ :WimaPolyline(parent)
+{
+ _polyline = *polyline;
+}
+
+void WimaPolyline::bindPolygon(QGCMapPolygon *polygon)
+{
+ if(polygon != nullptr){
+ _boundPolygon = polygon;
+ connect(polygon, &QGCMapPolygon::pathChanged, this, &WimaPolyline::recalcPolyline);
+ }else{
+ qWarning("Invalid Object!");
+ }
+}
+
+void WimaPolyline::unbindPolygon()
+{
+ if(_boundPolygon != nullptr){
+ disconnect(_boundPolygon, &QGCMapPolygon::pathChanged, this, &WimaPolyline::recalcPolyline);
+ _boundPolygon = nullptr;
+ }else{
+ qWarning("No Object bound!");
+ }
+}
+
+void WimaPolyline::swapLimits()
+{
+ int storage = _startVertexIndex;
+ _startVertexIndex = _endVertexIndex;
+ _endVertexIndex = storage;
+}
+
+void WimaPolyline::setInteractive(bool interactive)
+{
+ _polyline.setInteractive(interactive);
+}
+void WimaPolyline::setStartVertexIndex(int PolygonVertexIndex)
+{
+ if(PolygonVertexIndex >= 0 && PolygonVertexIndex < _boundPolygon->count()){
+ _startVertexIndex = PolygonVertexIndex;
+ recalcPolyline();
+ }else{
+ qWarning("Index out of bounds!");
+ }
+}
+
+void WimaPolyline::setEndVertexIndex(int PolygonVertexIndex)
+{
+ if(PolygonVertexIndex >= 0 && PolygonVertexIndex < _boundPolygon->count()){
+ _endVertexIndex = PolygonVertexIndex;
+ recalcPolyline();
+ }else{
+ qWarning("Index out of bounds!");
+ }
+}
+
+void WimaPolyline::recalcPolyline()
+{
+ if (_boundPolygon != nullptr && _boundPolygon->count() > 0){
+ if (_startVertexIndex >= _boundPolygon->count()){
+ _startVertexIndex = 0;
+ }
+ if (_endVertexIndex >= _boundPolygon->count()){
+ _startVertexIndex = _boundPolygon->count()-1;
+ }
+
+ _polyline.clear();
+ int i = _startVertexIndex;
+ while(1){
+ _polyline.appendVertex(_boundPolygon->vertexCoordinate(i));
+ if (i == _boundPolygon->count()-1){
+ i = 0;
+ }else if (i == _endVertexIndex) {
+ break;
+ }
+ i++;
+ }
+
+ emit polylineChanged();
+ }else{
+ qWarning("No object bound!");
+ }
+}
+
+
diff --git a/src/MissionManager/WimaPolyline.h b/src/MissionManager/WimaPolyline.h
new file mode 100644
index 0000000000000000000000000000000000000000..819a99d20371277c210cb125f8f76dbc24563407
--- /dev/null
+++ b/src/MissionManager/WimaPolyline.h
@@ -0,0 +1,56 @@
+#ifndef WIMAPOLYLINE_H
+#define WIMAPOLYLINE_H
+
+#include
+#include "QGCMapPolyline.h"
+#include "QGCMapPolygon.h"
+
+class WimaPolyline : public QObject
+{
+ Q_OBJECT
+public:
+ WimaPolyline(QObject *parent = nullptr);
+ WimaPolyline(QGCMapPolyline *polyline, QObject *parent = nullptr);
+
+ Q_PROPERTY(QGCMapPolyline const* polyline READ polyline NOTIFY polylineChanged)
+ Q_PROPERTY(int startVertexIndex READ startVertexIndex WRITE setStartVertexIndex NOTIFY startVertexIndexChanged)
+ Q_PROPERTY(int endVertexIndex READ endVertexIndex WRITE setEndVertexIndex NOTIFY endVertexIndexChanged)
+ Q_PROPERTY(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged)
+
+ // Property accessors
+ QGCMapPolyline const* polyline (void) const { return &_polyline;}
+ int startVertexIndex (void) const { return _startVertexIndex;}
+ int endVertexIndex (void) const { return _endVertexIndex;}
+ bool interactive (void) const { return _polyline.interactive();}
+
+
+ //Property setters
+ Q_INVOKABLE void bindPolygon (QGCMapPolygon* polygon);
+ Q_INVOKABLE void unbindPolygon ();
+ Q_INVOKABLE void swapLimits ();
+ Q_INVOKABLE void setInteractive (bool interactive);
+ void setStartVertexIndex (int PolygonVertexIndex);
+ void setEndVertexIndex (int PolygonVertexIndex);
+
+
+
+
+
+signals:
+ void polylineChanged (void);
+ void startVertexIndexChanged (void);
+ void endVertexIndexChanged (void);
+ void interactiveChanged (void);
+
+public slots:
+ void recalcPolyline(void);
+
+private:
+ QGCMapPolyline _polyline;
+ QGCMapPolygon* _boundPolygon;
+ int _startVertexIndex;
+ int _endVertexIndex;
+
+};
+
+#endif // WIMAPOLYLINE_H
diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc
index 71b76c4c84c83cb043fefafeb800b49c6c55fe40..088426583514be0255801fd718dc1a48dbd18e82 100644
--- a/src/QGCApplication.cc
+++ b/src/QGCApplication.cc
@@ -327,7 +327,7 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
QGCLoggingCategoryRegister::instance()->setFilterRulesFromSettings(loggingOptions);
// Initialize Bluetooth
-#ifdef QGC_ENABLE_BLUETOOTH
+#ifdef QGC_ENABLE_BLUETOOTHsubPolylines
QBluetoothLocalDevice localDevice;
if (localDevice.isValid())
{
@@ -446,7 +446,6 @@ void QGCApplication::_initCommon(void)
qmlRegisterType (kQGCControllers, 1, 0, "ESP8266ComponentController");
qmlRegisterType (kQGCControllers, 1, 0, "ScreenToolsController");
qmlRegisterType (kQGCControllers, 1, 0, "PlanMasterController");
- qmlRegisterType (kQGCControllers, 1, 0, "WimaController"); //custom
qmlRegisterType (kQGCControllers, 1, 0, "ValuesWidgetController");
qmlRegisterType (kQGCControllers, 1, 0, "QGCFileDialogController");
qmlRegisterType (kQGCControllers, 1, 0, "RCChannelMonitorController");
diff --git a/src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml b/src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml
index 056a9bfc87fdb9a06916deaa8f877835b8144c89..c7ad14e6d654df8e94c695b1e4272a7b493b3626 100644
--- a/src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml
+++ b/src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml
@@ -25,8 +25,10 @@ Item {
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
+ property var areaItem: object
+ property var _polygon: areaItem.polygon
+ property var subPolylines: areaItem.subPolylines
+ property var subPolygons: areaItem.subPolygons
signal clicked(int sequenceNumber)
@@ -62,8 +64,19 @@ Item {
}
}
+ function _addInitialPolyline() {
+ if (subPolylines.count < 1) {
+ areaItem.addSubPolyline()
+ console.log("SubPolylines count: ", subPolylines.count)
+ var newPolyline = subPolylines.get(0)
+ newPolyline.appendVertex(_polygon.vertexCoordinate(0))
+ newPolyline.appendVertex(_polygon.vertexCoordinate(1))
+ }
+ }
+
Component.onCompleted: {
_addInitialPolygon()
+ _addInitialPolyline()// always call _addInitialPolyline() after _addInitialPolygon()
}
Component.onDestruction: {
@@ -73,13 +86,26 @@ Item {
qgcView: _root.qgcView
mapControl: map
mapPolygon: _polygon
- interactive: _missionItem.isCurrentPolygon
borderWidth: 1
borderColor: "black"
interiorColor: "green"
interiorOpacity: 0.25
}
+ Repeater {
+ model: subPolylines
+ delegate: QGCMapPolylineVisuals {
+ qgcView: _root.qgcView
+ mapControl: map
+ mapPolyline: object
+ lineWidth: 4
+ lineColor: interactive ? "yellow" : "white"
+ }
+ }
+
+
+
+
diff --git a/src/WimaView/WimaItemEditor.qml b/src/WimaView/WimaItemEditor.qml
index 9dfdbc04ba2eeb41ffc7c7b46731052cbf9b047a..050f2d63113adb290d46f7268061759741d7cbaf 100644
--- a/src/WimaView/WimaItemEditor.qml
+++ b/src/WimaView/WimaItemEditor.qml
@@ -12,11 +12,11 @@ import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
-/// Fly Area Item edit control
+/// Wima Item edit control
Rectangle {
id: _root
height: editorLoader.visible ? (editorLoader.y + editorLoader.height + (_margin * 2)) : (commandPicker.y + commandPicker.height + _margin / 2)
- color: _currentItem ? qgcPal.missionItemEditor : qgcPal.windowShade
+ color: interactive ? qgcPal.missionItemEditor : qgcPal.windowShade
radius: _radius
property var map ///< Map control
@@ -25,15 +25,16 @@ Rectangle {
property bool readOnly ///< true: read only view, false: full editing view
property var rootQgcView
property int _index
+ property var areaItem
signal clicked
signal remove
property var _masterController: masterController
property var _missionController: _masterController.missionController
- property var _polygon: object.polygon
- property bool _currentItem: object.isCurrentPolygon
- property color _outerTextColor: _currentItem ? qgcPal.primaryButtonText : qgcPal.text
+ property var _polygon: areaItem.polygon
+ property bool interactive: areaItem.interactive
+ property color _outerTextColor: interactive ? qgcPal.primaryButtonText : qgcPal.text
property real _sectionSpacer: ScreenTools.defaultFontPixelWidth / 2 // spacing between section headings
readonly property real _editFieldWidth: Math.min(width - _margin * 2, ScreenTools.defaultFontPixelWidth * 12)
@@ -78,7 +79,7 @@ Rectangle {
height: _hamburgerSize
sourceSize.height: _hamburgerSize
source: "qrc:/qmlimages/Hamburger.svg"
- visible: _currentItem
+ visible: interactive
color: qgcPal.text
}
@@ -124,14 +125,14 @@ Rectangle {
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.left: label.right
anchors.top: parent.top
- visible: _currentItem
- text: object.objectName;
+ visible: interactive
+ text: areaItem.objectName;
Component {
id: commandDialog
MissionCommandDialog {
- missionItem: object
+ missionItem: areaItem
}
}
@@ -141,9 +142,9 @@ Rectangle {
QGCLabel {
id: commandLabel
anchors.fill: commandPicker
- visible: !_currentItem
+ visible: !interactive
verticalAlignment: Text.AlignVCenter
- text: object.objectName;
+ text: areaItem.objectName;
color: _outerTextColor
}
@@ -153,8 +154,8 @@ Rectangle {
anchors.topMargin: _margin
anchors.left: parent.left
anchors.top: commandPicker.bottom
- source: object.editorQml
- visible: _currentItem
+ source: areaItem.editorQML
+ visible: interactive
property var masterController: _masterController
property real availableWidth: _root.width - (_margin * 2) ///< How wide the editor should be
diff --git a/src/WimaView/WimaView.qml b/src/WimaView/WimaView.qml
index 65d17705a88db7a7646ce3b2a8ff56ca1ab8ceac..1941577f97a487243d6f0ce82442c2b590375d58 100644
--- a/src/WimaView/WimaView.qml
+++ b/src/WimaView/WimaView.qml
@@ -413,7 +413,7 @@ QGCView {
planView: true
qgcView: _qgcView
- // This is the center rectangle of the map which is not_layerWimaPlan obscured by tools
+ // This is the center rectangle of the map which is not obscured by tools
property rect centerViewport: Qt.rect(_leftToolWidth, _toolbarHeight, editorMap.width - _leftToolWidth - _rightPanelWidth, editorMap.height - _statusHeight - _toolbarHeight)
property real _leftToolWidth: toolStrip.x + toolStrip.width
@@ -495,7 +495,7 @@ QGCView {
}
onItemAdded: {
- console.log("Item added")
+ //console.log("Item added")
}
}
@@ -810,6 +810,7 @@ QGCView {
masterController: _planMasterController
wimaController: _wimaController
_index: index
+ areaItem: object
width: parent.width
readOnly: false
rootQgcView: _qgcView
@@ -966,7 +967,7 @@ QGCView {
id: clearVehicleMissionDialog
QGCViewMessage {
message: qsTr("Are you sure you want to remove all mission items and clear the mission from the vehicle?")
- function accept() {_layerWimaPlan
+ function accept() {
masterController.removeAllFromVehicle()
hideDialog()
}
@@ -1061,7 +1062,7 @@ QGCView {
}
QGCButton {
- text: qsTr("Save Mission Waypoints As K_layerWimaPlanML...")
+ text: qsTr("Save Mission Waypoints As KML...")
Layout.columnSpan: 2
enabled: !masterController.syncInProgress && _visualItems.count > 1
onClicked: {
@@ -1153,7 +1154,7 @@ QGCView {
color: "lightsteelblue"
radius: 1
Text {
- text: object.isCurrentPolygon
+ text: "Hello World!"
}
}
}