Commit 6c9cee43 authored by Valentin Platzgummer's avatar Valentin Platzgummer

polyline not beeing displayed

parent d60a1318
......@@ -25,3 +25,7 @@ DISTFILES += \
$$PWD/android/build.gradle \
$$PWD/android/gradle/wrapper/gradle-wrapper.properties \
$$PWD/android/gradlew.bat
HEADERS += \
SOURCES += \
......@@ -407,29 +407,26 @@ HEADERS += \
src/api/QmlComponentInfo.h \
src/comm/MavlinkMessagesTimer.h \
src/GPS/Drivers/src/base_station.h \
src/MissionManager/WimaController.h \
src/MissionManager/WimaPolygon.h \
src/MissionManager/WimaServicePolygon.h \
src/MissionManager/WimaVehicleCorridor.h \
src/MissionManager/WimaVehicleMeasurementPolygon.h \
src/MissionManager/WimaGlobalMeasurementPolygon.h \
src/MissionManager/WimaVehicle.h \
src/MissionManager/WimaPolyline.h
src/Wima/WimaArea.h \
src/Wima/WimaGOperationArea.h \
src/Wima/WimaServiceArea.h \
src/Wima/WimaVCorridor.h \
src/Wima/WimaTrackerPolyline.h \
src/Wima/WimaController.h \
src/Wima/WimaVehicle.h
SOURCES += \
src/api/QGCCorePlugin.cc \
src/api/QGCOptions.cc \
src/api/QGCSettings.cc \
src/api/QmlComponentInfo.cc \
src/comm/MavlinkMessagesTimer.cc \
src/MissionManager/WimaController.cc \
src/MissionManager/WimaPolygon.cc \
src/MissionManager/WimaServicePolygon.cc \
src/MissionManager/WimaVehicleCorridor.cc \
src/MissionManager/WimaVehicleMeasurementPolygon.cc \
src/MissionManager/WimaGlobalMeasurementPolygon.cc \
src/MissionManager/WimaVehicle.cc \
src/MissionManager/WimaPolyline.cc
src/Wima/WimaArea.cc \
src/Wima/WimaGOperationArea.cc \
src/Wima/WimaServiceArea.cc \
src/Wima/WimaVCorridor.cc \
src/Wima/WimaTrackerPolyline.cc \
src/Wima/WimaController.cc \
src/Wima/WimaVehicle.cc
#
# Unit Test specific configuration goes here (requires full debug build with all plugins)
......@@ -1311,4 +1308,4 @@ contains (CONFIG, QGC_DISABLE_INSTALLER_SETUP) {
}
DISTFILES += \
src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json
src/Wima/WimaGOperationArea.SettingsGroup.json
......@@ -211,10 +211,13 @@
<file alias="QGroundControl/Controls/WimaToolBar.qml">src/WimaView/WimaToolBar.qml</file>
<file alias="WimaView.qml">src/WimaView/WimaView.qml</file>
<file alias="QGroundControl/Controls/WimaMapVisual.qml">src/WimaView/WimaMapVisual.qml</file>
<file alias="QGroundControl/Controls/WimaGlobalMeasurementPolygonMapVisual.qml">src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml</file>
<file alias="QGroundControl/Controls/WimaServicePolygonMapVisual.qml">src/WimaView/WimaServicePolygonMapVisual.qml</file>
<file alias="QGroundControl/Controls/WimaItemEditor.qml">src/WimaView/WimaItemEditor.qml</file>
<file alias="QGroundControl/Controls/WimaGlobalMeasurementPolygonEditor.qml">WimaGlobalMeasurementPolygonEditor.qml</file>
<file alias="QGroundControl/Controls/WimaMapPolylineVisuals.qml">src/WimaView/WimaMapPolylineVisuals.qml</file>
<file alias="QGroundControl/Controls/WimaMapPolygonVisuals.qml">src/WimaView/WimaMapPolygonVisuals.qml</file>
<file alias="QGroundControl/Controls/WimaGOperationAreaMapVisual.qml">src/WimaView/WimaGOperationAreaMapVisual.qml</file>
<file alias="QGroundControl/Controls/WimaServiceAreaMapVisual.qml">src/WimaView/WimaServiceAreaMapVisual.qml</file>
<file alias="QGroundControl/Controls/WimaGOperationAreaEditor.qml">src/WimaView/WimaGOperationAreaEditor.qml</file>
</qresource>
<qresource prefix="/json">
<file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file>
......@@ -259,7 +262,7 @@
<file alias="Vehicle/VibrationFact.json">src/Vehicle/VibrationFact.json</file>
<file alias="Vehicle/WindFact.json">src/Vehicle/WindFact.json</file>
<file alias="Video.SettingsGroup.json">src/Settings/Video.SettingsGroup.json</file>
<file alias="WimaGlobalMeasurementPolygon.SettingsGroup.json">src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json</file>
<file alias="WimaGOperationArea.SettingsGroup.json">src/Wima/WimaGOperationArea.SettingsGroup.json</file>
</qresource>
<qresource prefix="/MockLink">
<file alias="APMArduCopterMockLink.params">src/comm/APMArduCopterMockLink.params</file>
......
#pragma once
#include <QObject>
#include "QGCMapPolygon.h"
#include "QmlObjectListModel.h"
#include "WimaPolygon.h"
#include "WimaGlobalMeasurementPolygon.h"
#include "WimaServicePolygon.h"
#include "PlanMasterController.h"
#include "MissionController.h"
class WimaController : public QObject
{
Q_OBJECT
public:
WimaController(QObject *parent = nullptr);
Q_PROPERTY(PlanMasterController* masterController READ masterController WRITE setMasterController NOTIFY masterControllerChanged)
Q_PROPERTY(MissionController* missionController READ missionController WRITE setMissionController NOTIFY missionControllerChanged)
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;}
QmlObjectListModel* visualItems (void) { return _visualItems; }
int currentPolygonIndex (void) const { return _currentPolygonIndex; }
// Property setters
void setMasterController (PlanMasterController* masterController);
void setMissionController (MissionController* missionController);
void setCurrentPolygonIndex (int index);
Q_INVOKABLE void addGlobalMeasurementArea();
Q_INVOKABLE void removeArea(int index);
Q_INVOKABLE void addServiceArea();
Q_INVOKABLE void startMission();
Q_INVOKABLE void abortMission();
Q_INVOKABLE void pauseMission();
Q_INVOKABLE void resumeMission();
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;
QmlObjectListModel* _visualItems;
PlanMasterController* _masterController;
MissionController* _missionController;
int _currentPolygonIndex;
};
[
{
"name": "BottomLayerAltitude",
"shortDescription": "Altitude of the bottom layer.",
"type": "double",
"units": "m",
"min": 1,
"decimalPlaces": 2,
"defaultValue": 5
},
{
"name": "NumberOfLayers",
"shortDescription": "The number of layers",
"type": "uint32",
"min": 1,
"defaultValue": 1
},
{
"name": "LayerDistance",
"shortDescription": "The distance between to adjacent layers.",
"type": "double",
"units": "m",
"min": 0,
"decimalPlaces": 2,
"defaultValue": 1
}
]
#pragma once
#include <QObject>
#include "WimaPolygon.h"
#include "QGCMapPolyline.h"
#include "QGCMapPolygon.h"
#include "WimaVehicleMeasurementPolygon.h"
#include "SettingsFact.h"
#include "QScopedPointer"
class WimaGlobalMeasurementPolygon : public WimaPolygon
{
Q_OBJECT
public:
WimaGlobalMeasurementPolygon(QObject* parent);
WimaGlobalMeasurementPolygon(QGCMapPolygon* other, QObject* parent);
Q_PROPERTY(Fact* bottomLayerAltitude READ bottomLayerAltitude CONSTANT)
Q_PROPERTY(Fact* numberOfLayers READ numberOfLayers CONSTANT)
Q_PROPERTY(Fact* layerDistance READ layerDistance CONSTANT)
Q_PROPERTY(QmlObjectListModel* vehicleList READ vehicleList NOTIFY vehicleListChanged)
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 addVehiclePolygon ();
Q_INVOKABLE void removeVehiclePolygon (int polygonIndex);
Q_INVOKABLE void removeVehiclePolygon (WimaVehicleMeasurementPolygon *wimaPolygon);
// Overrides from WimaPolygon
QString mapVisualQML (void) const { return "WimaGlobalMeasurementPolygonMapVisual.qml";}
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;}
QmlObjectListModel* vehiclePolygons (void) const { return _vehiclePolygons;}
WimaPolyline* polyline (void) { return &_polyline;}
static const char* settingsGroup;
static const char* bottomLayerAltitudeName;
static const char* numberOfLayersName;
static const char* layerDistanceName;
signals:
void bottomLayerAltitudeChanged (void);
void numberOfLayersChanged (void);
void layerDistanceChanged (void);
void vehicleListChanged (void);
void gatewayPolylinesChanged (void);
void vehiclePolygonsChanged (void);
private:
QMap<QString, FactMetaData*> _metaDataMap;
SettingsFact _bottomLayerAltitude;
SettingsFact _numberOfLayers;
SettingsFact _layerDistance;
QmlObjectListModel* _vehicleList;
QmlObjectListModel* _vehiclePolygons;
WimaPolyline _polyline;
};
#include "WimaPolygon.h"
WimaPolygon::WimaPolygon(QObject *parent) :
QObject (parent)
,_maxAltitude (30)
,_vehicle (parent)
,_polygon (new QGCMapPolygon(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()
{
}
void WimaPolygon::setMaxAltitude(double alt)
{
if(alt > 0 && alt != _maxAltitude){
_maxAltitude = alt;
emit maxAltitudeChanged();
}
}
void WimaPolygon::setVehicle(Vehicle *vehicle)
{
if(_vehicle.vehicle() != vehicle){
_vehicle.setVehicle(vehicle);
emit vehicleChanged();
}
}
void WimaPolygon::setInteractive(bool interactive)
{
_polygon->setInteractive(interactive);
}
QList<QGCMapPolygon *> *WimaPolygon::splitPolygonArea(QGCMapPolygon *polygonToSplitt, int numberOfFractions)
{
if(numberOfFractions > 0 && polygonToSplitt != nullptr){
QGCMapPolygon* poly = new QGCMapPolygon(polygonToSplitt, this);
QList<QGCMapPolygon*>* list = new QList<QGCMapPolygon*>();
list->append(poly);
return list;
}
return nullptr;
}
QList<QGCMapPolygon*>* WimaPolygon::splitPolygonArea(int numberOfFractions)
{
return splitPolygonArea(_polygon, numberOfFractions);
}
#pragma once
#include "QGCMapPolygon.h"
#include "QGCMapPolyline.h"
#include "Vehicle.h"
#include "qobject.h"
#include "WimaVehicle.h"
#include "WimaPolyline.h"
class WimaPolygon : public QObject //abstract base class for all WimaPolygons
{
Q_OBJECT
public:
WimaPolygon(QObject* parent = nullptr);
WimaPolygon(QGCMapPolygon* other, QObject* parent = nullptr);
~WimaPolygon();
Q_PROPERTY(double maxAltitude READ maxAltitude WRITE setMaxAltitude NOTIFY maxAltitudeChanged)
Q_PROPERTY(QString mapVisualQML READ mapVisualQML CONSTANT)
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(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;}
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 setInteractive (bool interactive);
// Member Methodes
QList<QGCMapPolygon*>* splitPolygonArea(QGCMapPolygon *polygonToSplitt, int numberOfFractions); // use QScopedPointer to store return value
QList<QGCMapPolygon*>* splitPolygonArea(int numberOfFractions); // use QScopedPointer to store return value
signals:
void maxAltitudeChanged (void);
void vehicleChanged (void);
void polygonChanged (void);
void interactiveChanged (void);
void polylineChanged (void);
void countChanged (void);
protected:
double _maxAltitude;
WimaVehicle _vehicle;
QGCMapPolygon* _polygon;
};
#include "WimaPolygonContainer.h"
WimaPolygonContainer::WimaPolygonContainer(QObject *parent) :
QObject (parent)
,_flatListDirty (true)
{
connect(this, &WimaPolygonContainer::itemListChanged, this, &WimaPolygonContainer::setFlatListDirty);
}
QList<WimaPolygon *> &WimaPolygonContainer::returnItems()
{
return _itemList;
}
void WimaPolygonContainer::addItem(WimaPolygon *polygon)
{
if(polygon != nullptr){
_itemList.append(polygon);
emit itemListChanged();
}
else {
qWarning("Not a valid WimaPolygon!");
}
}
void WimaPolygonContainer::removeItem(int itemIndex)
{
if(itemIndex >= 0 && itemIndex < _itemList.count()){
_itemList.removeAt(itemIndex);
emit itemListChanged();
}else {
qWarning("Invalid item Index. Index must be in 0..%i.", _itemList.count()-1);
}
}
void WimaPolygonContainer::removeItem(WimaPolygon *polygon)
{
if(polygon != nullptr){
_itemList.removeOne(polygon);
emit itemListChanged();
}
else {
qWarning("Not a valid WimaPolygon!");
}
}
QList<WimaPolygon*>& WimaPolygonContainer::returnFlatList()
{
if(_flatListDirty){
_flatList.clear();
int count = _itemList.count();
for(int i = 0; i < count; i++){
WimaPolygon* poly = _itemList.takeAt(i);
_flatList.append(poly);
_flatList.append(poly->subPolygons()); // returns an emptey list, if no sub polygons exist
}
_flatListDirty = false;
}
return _flatList;
}
int WimaPolygonContainer::count()
{
return _itemList.size();
}
void WimaPolygonContainer::setFlatListDirty(void)
{
_flatListDirty = true;
}
#ifndef WIMAPOLYGONCONTAINER_H
#define WIMAPOLYGONCONTAINER_H
#include <QObject>
#include "WimaPolygon.h"
class WimaPolygonContainer : public QObject
{
Q_OBJECT
public:
WimaPolygonContainer(QObject *parent = nullptr);
QList<WimaPolygon*>& returnItems();
void addItem(WimaPolygon* polygon);
void removeItem(int itemIndex);
void removeItem(WimaPolygon* polygon);
QList<WimaPolygon*>& returnFlatList();
int count(void);
signals:
void itemListChanged(void);
private slots:
void setFlatListDirty(void);
private:
QList<WimaPolygon*> _itemList;
QList<WimaPolygon*> _flatList;
bool _flatListDirty;
};
#endif // WIMAPOLYGONCONTAINER_H
#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!");
}
}
#ifndef WIMAPOLYLINE_H
#define WIMAPOLYLINE_H
#include <QObject>
#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
#include "WimaServicePolygon.h"
WimaServicePolygon::WimaServicePolygon(QObject *parent):
WimaPolygon (parent)
{
this->setObjectName("Service Area");
}
WimaServicePolygon::WimaServicePolygon(QGCMapPolygon *other, QObject *parent):
WimaPolygon (other, parent)
{
}
void WimaServicePolygon::setTakeOffPosition(QGeoCoordinate* coordinate)
{
if(_takeOffPosition != *coordinate){