Commit 03cf8047 authored by Valentin Platzgummer's avatar Valentin Platzgummer

new classes edited

parent 6bde4d9c
......@@ -413,7 +413,8 @@ HEADERS += \
src/MissionManager/WimaServicePolygon.h \
src/MissionManager/WimaVehicleCorridor.h \
src/MissionManager/WimaVehicleMeasurementPolygon.h \
src/MissionManager/WimaGlobalMeasurementPolygon.h
src/MissionManager/WimaGlobalMeasurementPolygon.h \
src/MissionManager/WimaPolygonContainer.h
SOURCES += \
src/api/QGCCorePlugin.cc \
......@@ -427,7 +428,8 @@ SOURCES += \
src/MissionManager/WimaServicePolygon.cc \
src/MissionManager/WimaVehicleCorridor.cc \
src/MissionManager/WimaVehicleMeasurementPolygon.cc \
src/MissionManager/WimaGlobalMeasurementPolygon.cc
src/MissionManager/WimaGlobalMeasurementPolygon.cc \
src/MissionManager/WimaPolygonContainer.cc
#
# Unit Test specific configuration goes here (requires full debug build with all plugins)
......
......@@ -45,6 +45,7 @@ public:
typedef struct _MissionFlightStatus_t {
double maxTelemetryDistance;
void dirtyChanged();
double totalDistance;
double totalTime;
double hoverDistance;
......
#include "WimaController.h"
#include "MissionController.h"
WimaController::WimaController(QObject *parent) : QObject(parent)
{
this->_flyArea = new WimaFlyArea(parent);
}
WimaController::WimaController(QObject *parent) :
QObject(parent)
,_planView(true)
void WimaController::start()
{
_flyArea->_init();
}
void WimaController::recalcMission()
{
}
void WimaController::setMasterController(PlanMasterController *masterC)
{
_masterController = masterC;
emit masterControllerChanged(_masterController);
emit masterControllerChanged();
}
void WimaController::setMissionController(MissionController *missionC)
{
_missionController = missionC;
emit missionControllerChanged(_missionController);
emit missionControllerChanged();
}
void WimaController::addGlobalMeasurementArea()
{
WimaGlobalMeasurementPolygon* poly = new WimaGlobalMeasurementPolygon(this);
}
......
......@@ -3,48 +3,68 @@
#include <QObject>
#include "QGCMapPolygon.h"
#include "QmlObjectListModel.h"
#include "WimaFlyArea.h"
#include "WimaPolygon.h"
#include "WimaGlobalMeasurementPolygon.h"
#include "WimaServicePolygon.h"
#include "WimaPolygonContainer.h"
#include "PlanMasterController.h"
#include "MissionController.h"
class WimaController : public QObject
{
Q_OBJECT
public:
explicit WimaController(QObject *parent = nullptr);
WimaController(QObject *parent = nullptr);
Q_PROPERTY(WimaFlyArea* flyArea READ flyArea CONSTANT)
Q_PROPERTY(PlanMasterController* masterController READ masterController WRITE setMasterController NOTIFY masterControllerChanged)
Q_PROPERTY(MissionController* missionController READ missionController WRITE setMissionController NOTIFY missionControllerChanged)
Q_PROPERTY(PlanMasterController* masterController READ masterController WRITE setMasterController NOTIFY masterControllerChanged)
Q_PROPERTY(MissionController* missionController READ missionController WRITE setMissionController NOTIFY missionControllerChanged)
Q_PROPERTY(QList<WimaPolygon*> visualItems READ visualItems NOTIFY visualItemsChanged)
// Property accessors
PlanMasterController* masterController (void) const { return _masterController;}
MissionController* missionController (void) const { return _missionController;}
QList<WimaPolygon*>& visualItems (void) const { return }
//Property Accessors
WimaFlyArea *flyArea (void) { return _flyArea; }
PlanMasterController* masterController (void) { return _masterController; }
MissionController* missionController (void) { return _missionController; }
Q_INVOKABLE void start(void);
Q_INVOKABLE void recalcMission();
// Property setters
void setMasterController (PlanMasterController* masterController);
void setMissionController (MissionController* missionController);
void setMasterController(PlanMasterController* masterC);
void setMissionController(MissionController* missionC);
Q_INVOKABLE void addGlobalMeasurementArea();
Q_INVOKABLE void removeGlobalMeasurementArea(int index);
Q_INVOKABLE void addServiceArea();
Q_INVOKABLE void removeServiceArea(int index);
signals:
void masterControllerChanged(PlanMasterController* masterController);
void missionControllerChanged(MissionController* missionController);
Q_INVOKABLE void recalcVehicleCorridor();
Q_INVOKABLE void recalcVehicleMeasurementArea();
Q_INVOKABLE void startMission();
Q_INVOKABLE void abortMission();
Q_INVOKABLE void pauseMission();
Q_INVOKABLE void resumeMission();
Q_INVOKABLE void saveMission();
Q_INVOKABLE void loadMission();
public slots:
signals:
void masterControllerChanged (void);
void missionControllerChanged (void);
void visualItemsChanged (void);
private:
//QmlObjectListModel* _visualItems;
WimaFlyArea * _flyArea;
bool _planView;
WimaPolygonContainer _visualItemsContainer;
PlanMasterController* _masterController;
MissionController* _missionController;
};
#endif // WIMACONTROLLER_H
......@@ -8,28 +8,34 @@ WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QObject *parent):
}
WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QGCMapPolygon *other, QObject *parent):
WimaPolygon (other, parent)
{
}
void WimaGlobalMeasurementPolygon::addVehicle(Vehicle *vehicle)
{
if(vehicle != nullptr){
_vehicleList->append(vehicle);
_vehicleList.append(vehicle);
emit vehicleListChanged(_vehicleList);
}
}
void WimaGlobalMeasurementPolygon::removeVehicle(int vehicleIndex)
{
if(vehicleIndex >= 0 && vehicleIndex < _vehicleList->count()){
_vehicleList->removeAt(vehicleIndex);
if(vehicleIndex >= 0 && vehicleIndex < _vehicleList.count()){
_vehicleList.removeAt(vehicleIndex);
emit vehicleListChanged(_vehicleList);
}
}
void WimaGlobalMeasurementPolygon::recalculateVehiclePolygons()
void WimaGlobalMeasurementPolygon::recalculatesubPolygons()
{
int vehicleCount = _vehicleList->count();
WimaVehicleMeasurementPolygon* newPolygon = new WimaVehicleMeasurementPolygon(this);
_vehiclePolygons = this->splitPolygonArea(vehicleCount);
_subPolygons = this->splitPolygonArea(vehicleCount);
}
void WimaGlobalMeasurementPolygon::removeAllVehicles()
......
......@@ -4,6 +4,7 @@
#include <QObject>
#include "WimaPolygon.h"
#include "QGCMapPolyline.h"
#include "QGCMapPolygon.h"
#include "WimaVehicleMeasurementPolygon.h"
class WimaGlobalMeasurementPolygon : public WimaPolygon
......@@ -11,17 +12,18 @@ class WimaGlobalMeasurementPolygon : public WimaPolygon
Q_OBJECT
public:
WimaGlobalMeasurementPolygon(QObject* parent);
WimaGlobalMeasurementPolygon(QGCMapPolygon* other, QObject* parent);
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(QmlObjectListModel* vehicleList READ vehicleList NOTIFY vehicleListChanged)
Q_PROPERTY(QList<Vehicle*> vehicleList READ vehicleList NOTIFY vehicleListChanged)
Q_PROPERTY(QGCMapPolyline* entryPolyline READ entryPolyline NOTIFY entryPolylineChanged)
Q_PROPERTY(QmlObjectListModel* vehiclePolygons READ vehiclePolygons NOTIFY vehiclePolygonsChanged)
Q_PROPERTY( QList<WimaPolygon*> subPolygons READ subPolygons NOTIFY subPolygonsChanged)
Q_INVOKABLE void addVehicle(Vehicle *vehicle);
Q_INVOKABLE void removeVehicle(int vehicleIndex);
Q_INVOKABLE void recalculateVehiclePolygons();
Q_INVOKABLE void recalculatesubPolygons();
Q_INVOKABLE void removeAllVehicles();
......@@ -30,35 +32,33 @@ public:
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;}
QmlObjectListModel* vehicleList (void) const { return _vehicleList;}
QGCMapPolyline* entryPolyline (void) const { return _entryPolyline;}
QmlObjectListModel* vehiclePolygons (void) const { return _vehiclePolygons;}
double bottomLayerAltitude (void) const { return _bottomLayerAltitude;}
int numberOfLayers (void) const { return _numberOfLayers;}
double layerDistance (void) const { return _layerDistance;}
QList<Vehicle*> vehicleList (void) const { return _vehicleList;}
QGCMapPolyline* entryPolyline (void) const { return _entryPolyline;}
// Property setters
void setBottomLayerAltitude(double altitude);
void setNumberOfLayers(int numberOfLayers);
void setLayerDistance(double distance);
void setBottomLayerAltitude (double altitude);
void setNumberOfLayers (int numberOfLayers);
void setLayerDistance (double distance);
signals:
void bottomLayerAltitudeChanged(double altitude);
void numberOfLayersChanged(int numberOfLayers);
void layerDistanceChanged(double distance);
void vehicleListChanged(QmlObjectListModel* vehicleList);
void entryPolylineChanged(QGCMapPolyline* polyline);
void vehiclePolygonsChanged(QmlObjectListModel* vehiclePolygons);
void bottomLayerAltitudeChanged (double altitude);
void numberOfLayersChanged (int numberOfLayers);
void layerDistanceChanged (double distance);
void vehicleListChanged (QList<Vehicle*> vehicleList);
void entryPolylineChanged (QGCMapPolyline* polyline);
void subPolygonsChanged (QList<WimaPolygon*> subPolygons);
private:
double _bottomLayerAltitude;
int _numberOfLayers;
int _numberOfLayers;
double _layerDistance;
QmlObjectListModel* _vehicleList;
QList<Vehicle*> _vehicleList;
QGCMapPolyline* _entryPolyline;
QmlObjectListModel* _vehiclePolygons;
};
......
#include "WimaPolygon.h"
WimaPolygon::WimaPolygon(QObject *parent) :
QGCMapPolygon (parent)
QObject (parent)
,_maxAltitude (30)
,_vehicle (nullptr)
,_polygonFractions (new QmlObjectListModel(this))
,_polygon (new QGCMapPolygon(this))
{
}
WimaPolygon::WimaPolygon(QGCMapPolygon *other, QObject *parent):
WimaPolygon(parent)
{
*_polygon = *other;
}
void WimaPolygon::setMaxAltitude(double alt)
{
if(alt > 0 && alt != _maxAltitude){
......@@ -36,8 +43,4 @@ QmlObjectListModel* WimaPolygon::splitPolygonArea(int numberOfFractions)
return nullptr;
}
QGCMapPolygon *WimaPolygon::extractQGCPolygon()
{
QGCMapPolygon* newPolygon = new QGCMapPolygon(this->parent());
}
......@@ -3,14 +3,16 @@
#include "QGCMapPolygon.h"
#include "Vehicle.h"
#include "qobject.h"
class WimaPolygon : public QGCMapPolygon //abstract base class for all WimaPolygons
class WimaPolygon : public QObject //abstract base class for all WimaPolygons
{
Q_OBJECT
public:
WimaPolygon(QObject* parent = nullptr);
WimaPolygon(QGCMapPolygon* other, QObject* parent = nullptr);
......@@ -18,14 +20,17 @@ public:
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(QmlObjectListModel* polygonFractions READ polygonFractions NOTIFY polygonFractionsChanged)
Q_PROPERTY(QGCMapPolygon* polygon READ polygon NOTIFY polygonChanged)
//Property accessors
double maxAltitude (void) const { return _maxAltitude;}
Vehicle* vehicle (void) const { return _vehicle;}
double maxAltitude (void) const { return _maxAltitude;}
Vehicle* vehicle (void) const { return _vehicle;}
QGCMapPolygon* polygon (void) const { return _polygon;}
virtual QString mapVisualQML (void) const = 0;
virtual QString editorQML (void) const = 0;
virtual QString mapVisualQML (void) const = 0;
virtual QString editorQML (void) const = 0;
virtual QList<WimaPolygon*>& subPolygons (void) { return _subPolygons;}
//Property setters
void setMaxAltitude (double alt);
......@@ -38,11 +43,9 @@ public:
Q_INVOKABLE QmlObjectListModel* splitPolygonArea(int numberOfFractions);
signals:
void maxAltitudeChanged (double alt);
void vehicleChanged (Vehicle* vehicle);
void polygonFractionsChanged (QmlObjectListModel* pfrac);
protected:
QGCMapPolygon* extractQGCPolygon(void);
......@@ -52,7 +55,8 @@ private:
double _maxAltitude;
Vehicle* _vehicle;
QmlObjectListModel* _polygonFractions;
QGCMapPolygon* _polygon;
QList<WimaPolygon*> _subPolygons;
};
#endif // WIMAPOLYGON_H
#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;
}
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();
signals:
void itemListChanged(void);
private slots:
void setFlatListDirty(void);
private:
QList<WimaPolygon*> _itemList;
QList<WimaPolygon*> _flatList;
bool _flatListDirty;
};
#endif // WIMAPOLYGONCONTAINER_H
......@@ -6,6 +6,12 @@ WimaServicePolygon::WimaServicePolygon(QObject *parent):
}
WimaServicePolygon::WimaServicePolygon(QGCMapPolygon *other, QObject *parent):
WimaPolygon (other, parent)
{
}
void WimaServicePolygon::setTakeOffPosition(QGeoCoordinate coordinate)
{
if(_takeOffPosition != coordinate){
......
......@@ -8,7 +8,9 @@ class WimaServicePolygon : public WimaPolygon
{
Q_OBJECT
public:
WimaServicePolygon(QObject* parent);
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)
......
......@@ -5,3 +5,9 @@ WimaVehicleCorridor::WimaVehicleCorridor(QObject *parent):
{
}
WimaVehicleCorridor::WimaVehicleCorridor(QGCMapPolygon *other, QObject *parent):
WimaPolygon (other, parent)
{
}
......@@ -9,6 +9,7 @@ class WimaVehicleCorridor : public WimaPolygon
Q_OBJECT
public:
WimaVehicleCorridor(QObject* parent);
WimaVehicleCorridor(QGCMapPolygon* other, QObject* parent);
// Overrides from WimaPolygon
QString mapVisualQML (void) const { return "WimaVehicleCorridorMapVisal.qml";}
......
......@@ -6,3 +6,9 @@ WimaVehicleMeasurementPolygon::WimaVehicleMeasurementPolygon(QObject *parent):
{
}
WimaVehicleMeasurementPolygon::WimaVehicleMeasurementPolygon(QGCMapPolygon *other, QObject *parent):
WimaPolygon (other, parent)
{
}
......@@ -9,6 +9,8 @@ class WimaVehicleMeasurementPolygon : public WimaPolygon
Q_OBJECT
public:
WimaVehicleMeasurementPolygon(QObject* parent);
WimaVehicleMeasurementPolygon(QGCMapPolygon* other, QObject* parent);
// Overrides from WimaPolygon
QString mapVisualQML (void) const { return "WimaVehicleMeasurementPolygonMapVisal.qml";}
QString editorQML (void) const { return "WimaVehicleMeasurementPolygonEditor.qml";}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment