Commit c878bb8a authored by Valentin Platzgummer's avatar Valentin Platzgummer

WimaController renamed to WimaPlaner, WimaController is now responsible for...

WimaController renamed to WimaPlaner, WimaController is now responsible for coordination purposes in flyView
parent 81769297
......@@ -414,7 +414,9 @@ HEADERS += \
src/Wima/WimaTrackerPolyline.h \
src/Wima/WimaController.h \
src/Wima/WimaVehicle.h \
src/Wima/WimaDataContainer.h
src/Wima/WimaDataContainer.h \
src/Wima/WimaPlaner.h \
src/Wima/WimaPlaner.h
SOURCES += \
src/api/QGCCorePlugin.cc \
src/api/QGCOptions.cc \
......@@ -428,7 +430,8 @@ SOURCES += \
src/Wima/WimaTrackerPolyline.cc \
src/Wima/WimaController.cc \
src/Wima/WimaVehicle.cc \
src/Wima/WimaDataContainer.cc
src/Wima/WimaDataContainer.cc \
src/Wima/WimaPlaner.cc
#
# Unit Test specific configuration goes here (requires full debug build with all plugins)
......
......@@ -234,6 +234,8 @@ QList<QGeoCoordinate> QGCMapPolygon::coordinateList(void) const
void QGCMapPolygon::splitPolygonSegment(int vertexIndex)
{
int nextIndex = vertexIndex + 1;
if (nextIndex > _polygonPath.length() - 1) {
nextIndex = 0;
}
......@@ -367,6 +369,11 @@ void QGCMapPolygon::setInteractive(bool interactive)
}
}
void QGCMapPolygon::update(const QGCMapPolygon &poly)
{
this->setPath(poly.path());
}
void print(const QGCMapPolygon &poly)
{
QString message;
......@@ -391,19 +398,6 @@ void print(const QGCMapPolygon &poly, QString &outputString)
outputString.append(QString("Interactive: %s\n").arg(QVariant(poly._interactive).toString()));
}
void swap(QGCMapPolygon &poly1, QGCMapPolygon &poly2)
{
using std::swap;
poly1._polygonPath.swap(poly2._polygonPath);
swap(poly1._polygonModel, poly2._polygonModel);
swap(poly1._dirty, poly2._dirty);
swap(poly1._center, poly2._center);
swap(poly1._centerDrag, poly2._centerDrag);
swap(poly1._ignoreCenterUpdates, poly2._ignoreCenterUpdates);
swap(poly1._interactive, poly2._interactive);
}
QGeoCoordinate QGCMapPolygon::vertexCoordinate(int vertex) const
{
if (vertex >= 0 && vertex < _polygonPath.count()) {
......
/****************************************************************************
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
......@@ -99,14 +99,10 @@ public:
QmlObjectListModel* qmlPathModel(void) { return &_polygonModel; }
QmlObjectListModel& pathModel (void) { return _polygonModel; }
void setPath (const QList<QGeoCoordinate>& path);
void setPath (const QVariantList& path);
void setCenter (QGeoCoordinate newCenter);
void setCenterDrag (bool centerDrag);
void setInteractive (bool interactive);
/// Updates this with data from poly
void update(const QGCMapPolygon &poly);
// Friends
friend void swap(QGCMapPolygon& poly1, QGCMapPolygon& poly2);
friend void print(const QGCMapPolygon& poly, QString& outputString);
friend void print(const QGCMapPolygon& poly);
......@@ -122,10 +118,17 @@ signals:
void centerDragChanged (bool centerDrag);
void interactiveChanged (bool interactive);
public slots:
void setPath (const QList<QGeoCoordinate>& path);
void setPath (const QVariantList& path);
void setCenter (QGeoCoordinate newCenter);
void setCenterDrag (bool centerDrag);
void setInteractive (bool interactive);
private slots:
void _polygonModelCountChanged(int count);
void _polygonModelDirtyChanged(bool dirty);
void _updateCenter(void);
void _polygonModelCountChanged (int count);
void _polygonModelDirtyChanged (bool dirty);
void _updateCenter (void);
private:
void _init(void);
......
......@@ -26,42 +26,14 @@ WimaArea::WimaArea(const WimaArea &other, QObject *parent)
_maxAltitude = other.maxAltitude();
}
WimaArea &WimaArea::operator=(WimaArea other)
{
swap(*this, other); // copy-swap-idiom
return *this;
}
void WimaArea::setMaxAltitude(double alt)
{
if(alt > 0 && alt != _maxAltitude){
if ( alt > 0 && qFuzzyCompare(alt, _maxAltitude) ) {
_maxAltitude = alt;
emit maxAltitudeChanged();
}
}
/*QList<WimaArea *>* WimaArea::splitArea<T>(WimaArea *polygonToSplitt, int numberOfFractions)
{
if(numberOfFractions > 0 && polygonToSplitt != nullptr){
WimaArea* poly;
if(p)
= new WimaArea(polygonToSplitt, this);
QList<WimaArea*>* list = new QList<WimaArea*>();
list->append(poly);
return list;
}
return nullptr;
}
QList<QGCMapPolygon*>* WimaArea::splitArea(int numberOfFractions)
{
return splitPolygonArea(this, numberOfFractions);
}*/
int WimaArea::getClosestVertexIndex(const QGeoCoordinate &coordinate) const
{
if (this->count() == 0) {
......@@ -327,32 +299,39 @@ bool WimaArea::intersects(const QGCMapPolyline &line1, const QGCMapPolyline &lin
}
}
bool WimaArea::intersects(const QGCMapPolyline& line, const WimaArea& poly, QList<QGeoCoordinate>& intersectionList, QList<QPair<int, int> >& neighbourlist)
bool WimaArea::intersects(const QGCMapPolyline &line,
const WimaArea &poly,
QList<QGeoCoordinate> &intersectionList,
QList<QPair<int, int> > &neighbourList)
{
neighbourlist.clear();
// ================ Brief Explanation ================
// This function checks whether line intersects with the border line of poly
// Returns true if at least one intersection occurs, false else.
// Stores the intersection points inside intersectionList.
// Stores the indices of the cloest two polygon vetices for each of coorespoinding intersection points in neighbourList
intersectionList.clear();
neighbourList.clear();
if (line.count() == 2 && poly.count() >= 3) {
for (int i = 0; i < poly.count(); i++) {
QGCMapPolyline polySegment;
QGeoCoordinate currentVertex = poly.vertexCoordinate(i);
QGeoCoordinate nextVertex = poly.vertexCoordinate(poly.nextVertexIndex(i));
polySegment.appendVertex(currentVertex);
polySegment.appendVertex(nextVertex);
if (line.count() == 2 && poly.count() >= 3) { // are line a proper line and poly a proper poly?
QGeoCoordinate intersectionPoint;
//bool retVal2 = intersects(line, line, &intersectionPoint);
bool retVal = intersects(line, polySegment, intersectionPoint);
// Asseble a line form each tow consecutive polygon vertices and check whether it intersects with line
for (int i = 0; i < poly.count(); i++) {
QGCMapPolyline interatorLine;
QGeoCoordinate currentVertex = poly.vertexCoordinate(i);
QGeoCoordinate nextVertex = poly.vertexCoordinate(poly.nextVertexIndex(i));
interatorLine.appendVertex(currentVertex);
interatorLine.appendVertex(nextVertex);
if (retVal != false){
QGeoCoordinate intersectionPoint;
if ( intersects(line, interatorLine, intersectionPoint) ){
intersectionList.append(intersectionPoint);
QPair<int, int> neighbours;
neighbours.first = i;
neighbours.second = poly.nextVertexIndex(i);
neighbourlist.append(neighbours);
neighbourList.append(neighbours);
}
}
......@@ -390,42 +369,54 @@ double WimaArea::distInsidePoly(const QGeoCoordinate &c1, const QGeoCoordinate &
}
}
bool WimaArea::dijkstraPath(const QGeoCoordinate &start, const QGeoCoordinate &end, const WimaArea &poly, QList<QGeoCoordinate> &dijkstraPath)
bool WimaArea::dijkstraPath(const QGeoCoordinate &start,
const QGeoCoordinate &end,
const WimaArea &poly,
QList<QGeoCoordinate> &dijkstraPath)
{
// ================ Brief Explanation ================
// This function calculates the shortes Path between two GeoCoordinates (start, end) using the Dijkstra Algorithm.
// The path will be inside the polygon poly if possible.
// Stores the result inside dijkstraPath
// Returns true if a valid path was found.
if ( isSelfIntersecting(poly) ) {
return false;
}
// Each QGeoCoordinate gets stuff into a Node
/// @param distance is the distance between the Node and it's predecessor
struct Node{
QGeoCoordinate coordinate;
double distance = std::numeric_limits<qreal>::infinity();
Node* predecessorNode = nullptr;
};
// The list with all Nodes (start, end + poly.path())
QList<Node> nodeList;
// This list will be initalized with (pointer to) all elements of nodeList.
// Elements will be successively remove during the execution of the Dijkstra Algorithm.
QList<Node*> workingSet;
// initialize
// start
// initialize nodeList
// start cooridnate
Node startNode;
startNode.coordinate = start;
startNode.distance = 0;
nodeList.append(startNode);
//poly
//poly cooridnates
for (int i = 0; i < poly.count(); i++) {
Node node;
node.coordinate = poly.vertexCoordinate(i);
nodeList.append(node);
}
//end
//end coordinate
Node endNode;
endNode.coordinate = end;
nodeList.append(endNode);
// working set
// initialize working set
for (int i = 0; i < nodeList.size(); i++) {
Node* nodePtr = &nodeList[i];
workingSet.append(nodePtr);
......@@ -453,8 +444,9 @@ bool WimaArea::dijkstraPath(const QGeoCoordinate &start, const QGeoCoordinate &e
for (int i = 0; i < workingSet.size(); i++) {
Node* v = workingSet[i];
// is neighbour?
// is neighbour? dist == infinity if no neihbour
double dist = distInsidePoly(u->coordinate, v->coordinate, poly);
// is ther a alternative path which is shorter?
double alternative = u->distance + dist;
if (alternative < v->distance) {
v->distance = alternative;
......@@ -463,14 +455,17 @@ bool WimaArea::dijkstraPath(const QGeoCoordinate &start, const QGeoCoordinate &e
}
}
// end Djikstra Algorithm
// create path
// check it the Algorithm was sucessful
Node* Node = &nodeList.last();
if (Node->predecessorNode == nullptr) {
qWarning("WimaArea::dijkstraPath(): Error, no path found!");
return false;
}
// assemble path
while (1) {
dijkstraPath.prepend(Node->coordinate);
......@@ -540,6 +535,12 @@ bool WimaArea::loadFromJson(const QJsonObject &json, QString& errorString)
}
}
void WimaArea::update(const WimaArea &area)
{
this->QGCMapPolygon::update(area);
this->setMaxAltitude(area.maxAltitude());
}
void WimaArea::init()
{
this->setObjectName(wimaAreaName);
......@@ -554,16 +555,8 @@ void print(const WimaArea &area)
void print(const WimaArea &area, QString &outputString)
{
outputString.append(QString("Type: %s").arg(area.objectName()));
outputString.append(QString("Type: %1").arg(area.objectName()));
print(static_cast<const QGCMapPolygon&>(area), outputString);
outputString.append(QString("Maximum Altitude: %.3f").arg(area._maxAltitude));
}
void swap(WimaArea &area1, WimaArea &area2)
{
using std::swap;
swap(static_cast<QGCMapPolygon&>(area1), static_cast<QGCMapPolygon&>(area2));
swap(area1._maxAltitude, area2._maxAltitude);
outputString.append(QString("Maximum Altitude: %1").arg(area._maxAltitude));
}
......@@ -17,72 +17,73 @@ class WimaArea : public QGCMapPolygon //abstract base class for all WimaAreas
public:
WimaArea(QObject* parent = nullptr);
WimaArea(const WimaArea& other, QObject* parent = nullptr);
WimaArea& operator=(WimaArea other);
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(double maxAltitude READ maxAltitude WRITE setMaxAltitude NOTIFY maxAltitudeChanged)
Q_PROPERTY(QString mapVisualQML READ mapVisualQML CONSTANT)
Q_PROPERTY(QString editorQML READ editorQML CONSTANT)
//Property accessors
double maxAltitude (void) const { return _maxAltitude;}
double maxAltitude (void) const { return _maxAltitude;}
// overrides from WimaArea
virtual QString mapVisualQML (void) const { return "WimaAreaMapVisual.qml";}
virtual QString editorQML (void) const { return "WimaAreaEditor.qml";}
//Property setters
void setMaxAltitude (double alt);
void setVehicle (WimaVehicle* vehicle);
// Member Methodes
//iterates over all vertices in _polygon and returns the index of that one closest to coordinate
int getClosestVertexIndex (const QGeoCoordinate& coordinate) const;
int getClosestVertexIndex (const QGeoCoordinate& coordinate) const;
//iterates over all vertices in _polygon and returns that one closest to coordinate
QGeoCoordinate getClosestVertex (const QGeoCoordinate& coordinate) const;
static QGCMapPolygon toQGCPolygon (const WimaArea& poly);
QGCMapPolygon toQGCPolygon () const;
static void join (QList<WimaArea*>* polyList, WimaArea* joinedPoly);// change to & notation
/// joins the poly1 and poly2 if possible, joins the polygons to form a simple polygon (no holes)
/// see https://en.wikipedia.org/wiki/Simple_polygon
/// @return true if polygons have been joined, false else
static bool join (WimaArea &poly1, WimaArea &poly2, WimaArea& joinedPoly);
bool join (WimaArea &poly);
bool isDisjunct (QList<WimaArea*>* polyList);// change to & notation, if necessary
bool isDisjunct (WimaArea* poly1, WimaArea* poly2);// change to & notation, if necessary
QGeoCoordinate getClosestVertex (const QGeoCoordinate& coordinate) const;
QGCMapPolygon toQGCPolygon () const;
void join (QList<WimaArea*>* polyList, WimaArea* joinedPoly);// change to & notation
bool join (WimaArea &poly);
bool isDisjunct (QList<WimaArea*>* polyList);// change to & notation, if necessary
bool isDisjunct (WimaArea* poly1, WimaArea* poly2);// change to & notation, if necessary
/// calculates the next polygon vertex index
/// @return index + 1 if index < poly->count()-1 && index >= 0, or 0 if index == poly->count()-1, -1 else
int nextVertexIndex (int index) const;
int nextVertexIndex (int index) const;
/// calculates the previous polygon vertex index
/// @return index - 1 if index < poly->count() && index > 0, or poly->count()-1 if index == 0, -1 else
int previousVertexIndex (int index) const;
int previousVertexIndex (int index) const;
void saveToJson (QJsonObject& jsonObject);
bool loadFromJson (const QJsonObject &jsonObject, QString& errorString);
// static Methodes
static QGCMapPolygon toQGCPolygon (const WimaArea& poly);
/// joins the poly1 and poly2 if possible, joins the polygons to form a simple polygon (no holes)
/// see https://en.wikipedia.org/wiki/Simple_polygon
/// @return true if polygons have been joined, false else
static bool join (WimaArea &poly1, WimaArea &poly2, WimaArea& joinedPoly);
/// checks if line1 and line2 intersect with each other, takes latitude and longitute into account only (height neglected)
/// @param line1 line containing two coordinates, height not taken into account
/// @param line2 line containing two coordinates, height not taken into account
/// @param intersectionPt Coordinate item to store intersection pt. in.
/// @return false on error or no intersection, true else
static bool intersects(const QGCMapPolyline& line1, const QGCMapPolyline& line2, QGeoCoordinate& intersectionPt);
static bool intersects (const QGCMapPolyline& line1, const QGCMapPolyline& line2,
QGeoCoordinate& intersectionPt);
/// checks if line1 and poly intersect with each other, takes latitude and longitute into account only (height neglected)
/// @param line line containing two coordinates, height not taken into account
/// @param intersectionList Empty list to store intersection points in.
/// @param neighbourList Empty list to store the indices of the neighbours (the two Vertices of poly with the smallest distance to the intersection pt.)
/// @return false on error or no intersection, true else
static bool intersects(const QGCMapPolyline& line, const WimaArea& poly, QList<QGeoCoordinate>& intersectionList, QList<QPair<int, int>>& neighbourlist);
static bool intersects (const QGCMapPolyline& line, const WimaArea& poly,
QList<QGeoCoordinate>& intersectionList,
QList<QPair<int, int>>& neighbourList);
/// calculates the distance between to geo coordinates, returns the distance if the path lies within the polygon and inf. else.
/// @return the distance if the path lies within the polygon and inf. else.
static double distInsidePoly(const QGeoCoordinate& c1, const QGeoCoordinate& c2, WimaArea poly);
static double distInsidePoly (const QGeoCoordinate& c1, const QGeoCoordinate& c2, WimaArea poly);
/// calculates the shortes path between two geo coordinates inside a polygon using the Dijkstra Algorithm
/// @return true if path was found, false else
static bool dijkstraPath(const QGeoCoordinate& c1, const QGeoCoordinate& c2, const WimaArea& poly, QList<QGeoCoordinate>& dijkstraPath);
static bool dijkstraPath (const QGeoCoordinate& c1, const QGeoCoordinate& c2,
const WimaArea& poly, QList<QGeoCoordinate>& dijkstraPath);
/// @return true if the polygon is self intersecting
static bool isSelfIntersecting(const WimaArea& poly);
bool isSelfIntersecting();
void saveToJson(QJsonObject& jsonObject);
bool loadFromJson(const QJsonObject &jsonObject, QString& errorString);
static bool isSelfIntersecting (const WimaArea& poly);
bool isSelfIntersecting ();
// Friends
friend void swap(WimaArea& area1, WimaArea& area2);
/// prints the member values of area to the outputString
friend void print(const WimaArea& area, QString& outputString);
/// prints the member values of area to the console
......@@ -99,8 +100,12 @@ signals:
void maxAltitudeChanged (void);
void vehicleChanged (void);
public slots:
void setMaxAltitude (double alt);
/// Updates this with data from area
void update(const WimaArea& area);
protected:
private:
double _maxAltitude;
private:
......
This diff is collapsed.
......@@ -29,25 +29,25 @@ 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(const QmlObjectListModel*visualItems READ visualItems NOTIFY visualItemsChanged)
Q_PROPERTY(int currentPolygonIndex READ currentPolygonIndex WRITE setCurrentPolygonIndex NOTIFY currentPolygonIndexChanged)
Q_PROPERTY(QString currentFile READ currentFile NOTIFY currentFileChanged)
Q_PROPERTY(QStringList loadNameFilters READ loadNameFilters CONSTANT)
Q_PROPERTY(QStringList saveNameFilters READ saveNameFilters CONSTANT)
Q_PROPERTY(QString fileExtension READ fileExtension CONSTANT)
Q_PROPERTY(QGeoCoordinate joinedAreaCenter READ joinedAreaCenter CONSTANT)
Q_PROPERTY(WimaArea joinedArea READ joinedArea NOTIFY joinedAreaChanged)
Q_PROPERTY(bool flyView READ flyView CONSTANT)
Q_PROPERTY(WimaDataContainer* dataContainer READ dataContainer WRITE setDataContainer NOTIFY dataContainerChanged)
Q_PROPERTY(bool readyForSaveSend READ readyForSaveSend NOTIFY readyForSaveSendChanged)
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)
Q_PROPERTY(QString currentFile READ currentFile NOTIFY currentFileChanged)
Q_PROPERTY(QStringList loadNameFilters READ loadNameFilters CONSTANT)
Q_PROPERTY(QStringList saveNameFilters READ saveNameFilters CONSTANT)
Q_PROPERTY(QString fileExtension READ fileExtension CONSTANT)
Q_PROPERTY(QGeoCoordinate joinedAreaCenter READ joinedAreaCenter CONSTANT)
Q_PROPERTY(WimaArea joinedArea READ joinedArea NOTIFY joinedAreaChanged)
Q_PROPERTY(bool flyView READ flyView CONSTANT)
Q_PROPERTY(WimaDataContainer* dataContainer WRITE setDataContainer NOTIFY dataContainerChanged)
Q_PROPERTY(bool readyForSaveSend READ readyForSaveSend NOTIFY readyForSaveSendChanged)
// Property accessors
PlanMasterController* masterController (void) const { return _masterController; }
MissionController* missionController (void) const { return _missionController; }
const QmlObjectListModel* visualItems (void) const;
QmlObjectListModel* visualItems (void) ;
int currentPolygonIndex (void) const { return _currentPolygonIndex; }
QString currentFile (void) const { return _currentFile; }
QStringList loadNameFilters (void) const;
......@@ -55,8 +55,6 @@ public:
QString fileExtension (void) const { return wimaFileExtension; }
QGeoCoordinate joinedAreaCenter (void) const;
WimaArea joinedArea (void) const;
WimaDataContainer* dataContainer (void) const { return _container; }
bool flyView (void) const { return _flyView; }
bool readyForSaveSend (void) const { return _readyForSaveSend; }
......@@ -76,6 +74,7 @@ public:
Q_INVOKABLE void removeArea(int index);
Q_INVOKABLE bool addServiceArea();
Q_INVOKABLE bool addVehicleCorridor();
/// Remove all areas from WimaController and all mission items from MissionController
Q_INVOKABLE void removeAll();
Q_INVOKABLE void startMission();
......@@ -115,23 +114,17 @@ signals:
private slots:
void recalcPolygonInteractivity (int index);
bool updateJoinedArea ();
void updateContainer ();
void downloadFromContainer ();
void setOpArea (const WimaGOperationArea& area);
void setSerArea (const WimaServiceArea& area);
void setCorridor (const WimaVCorridor& area);
void setJoinedArea (const WimaArea& area);
bool recalcJoinedArea ();
void updateContainer ();// only executed if flyView == false
void downloadFromContainer ();// only executed if flyView == true
private:
bool _flyView;
bool _readyForSaveSend;
PlanMasterController* _masterController;
MissionController* _missionController;
PlanMasterController *_masterController;
MissionController *_missionController;
int _currentPolygonIndex;
QString _currentFile;
WimaDataContainer* _container;
WimaDataContainer *_container;
QmlObjectListModel _visualItems;
WimaArea _joinedArea;
WimaGOperationArea _opArea;
......
......@@ -2,44 +2,44 @@
WimaDataContainer::WimaDataContainer(QObject *parent)
: QObject (parent)
, _joinedArea (this)
, _opArea (this)
, _serArea (this)
, _corridor (this)
, _joinedArea (nullptr)
, _opArea (nullptr)
, _serArea (nullptr)
, _corridor (nullptr)
{
}
void WimaDataContainer::setJoinedArea(const WimaArea &joinedArea)
void WimaDataContainer::setJoinedArea(const WimaArea *joinedArea)
{
if (_joinedArea.path() != joinedArea.path()) {
if (_joinedArea != joinedArea) {
_joinedArea = joinedArea;
emit joinedAreaChanged(_joinedArea);
}
}
void WimaDataContainer::setOpArea(const WimaGOperationArea &opArea)
void WimaDataContainer::setOpArea(const WimaGOperationArea *opArea)
{
if (_opArea.path() != opArea.path()) {
if (_opArea != opArea) {
_opArea = opArea;
emit opAreaChanged(_opArea);
}
}
void WimaDataContainer::setSerArea(const WimaServiceArea &serArea)
void WimaDataContainer::setSerArea(const WimaServiceArea *serArea)
{
if (_serArea.path() != serArea.path()) {
if (_serArea != serArea) {
_serArea = serArea;
emit serAreaChanged(_serArea);
}
}
void WimaDataContainer::setCorridor(const WimaVCorridor &corridor)
void WimaDataContainer::setCorridor(const WimaVCorridor *corridor)
{
if (_corridor.path() != corridor.path()) {
if (_corridor != corridor) {
_corridor = corridor;
emit corridorChanged(_corridor);
......
#ifndef WIMADATACONTAINER_H
#define WIMADATACONTAINER_H
#pragma once
#include <QObject>
......@@ -15,30 +14,30 @@ class WimaDataContainer : public QObject
Q_OBJECT
public:
explicit WimaDataContainer(QObject *parent = nullptr);
WimaDataContainer(WimaDataContainer &other, QObject *parent = nullptr) = delete;
WimaDataContainer(WimaDataContainer &other) = delete;
WimaArea joinedArea (void) { return _joinedArea; }
WimaGOperationArea opArea (void) { return _opArea; }
WimaServiceArea serArea (void) { return _serArea; }
WimaVCorridor corridor (void) { return _corridor; }
void setJoinedArea (const WimaArea& joinedArea);
void setOpArea (const WimaGOperationArea& opArea);
void setSerArea (const WimaServiceArea& serArea);
void setCorridor (const WimaVCorridor& corridor);
const WimaArea * joinedArea (void) { return _joinedArea; }
const WimaGOperationArea * opArea (void) { return _opArea; }
const WimaServiceArea * serArea (void) { return _serArea; }
const WimaVCorridor * corridor (void) { return _corridor; }
signals:
void joinedAreaChanged (const WimaArea& area);
void opAreaChanged (const WimaGOperationArea& area);
void serAreaChanged (const WimaServiceArea& area);
void corridorChanged (const WimaVCorridor& area);
void joinedAreaChanged (const WimaArea *area);
void opAreaChanged (const WimaGOperationArea *area);
void serAreaChanged (const WimaServiceArea *area);
void corridorChanged (const WimaVCorridor *area);
public slots:
void setJoinedArea (const WimaArea *joinedArea);
void setOpArea (const WimaGOperationArea *opArea);
void setSerArea (const WimaServiceArea *serArea);
void setCorridor (const WimaVCorridor *corridor);
private:
WimaArea _joinedArea;
WimaGOperationArea _opArea;
WimaServiceArea _serArea;
WimaVCorridor _corridor;
const WimaArea *_joinedArea;
const WimaGOperationArea *_opArea;
const WimaServiceArea *_serArea;
const WimaVCorridor *_corridor;
};
#endif // WIMADATACONTAINER_H
......@@ -21,13 +21,6 @@ WimaGOperationArea::WimaGOperationArea(const WimaGOperationArea &other, QObject
init();
}
WimaGOperationArea &WimaGOperationArea::operator=(WimaGOperationArea other)
{
swap(*this, other);
return *this;
}
void WimaGOperationArea::saveToJson(QJsonObject &json)
{
this->WimaArea::saveToJson(json);
......@@ -77,6 +70,23 @@ bool WimaGOperationArea::loadFromJson(const QJsonObject &json, QString& errorStr
}
}
void WimaGOperationArea::update(const WimaGOperationArea &area)
{
this->WimaArea::update(area);
this->setBottomLayerAltitude(area.bottomLayerAltitude());
this->setNumberOfLayers(area.numberOfLayers());
this->setLayerDistance(area.layerDistance());
this->setBorderPolygonOffset(area.borderPolygonOffset());
recalcBorderPolygon();
}
void WimaGOperationArea::setBottomLayerAltitude(double altitude)
{
}
void print(const WimaGOperationArea &area)
{
QString message;
......@@ -87,30 +97,18 @@ void print(const WimaGOperationArea &area)
void print(const WimaGOperationArea &area, QString outputStr)
{
print(static_cast<const WimaArea&>(area), outputStr);
outputStr.append(QString("Bottom Layer Altitude: %.3f\n").arg(area._bottomLayerAltitude.rawValue().toDouble()));
outputStr.append(QString("Number of Layers: %i\n").arg(area._numberOfLayers.rawValue().toInt()));
outputStr.append(QString("Layer Distance: %.3f\n").arg(area._layerDistance.rawValue().toDouble()));
outputStr.append(QString("Border Polygon Offset: %.3f\n").arg(area._borderPolygonOffset.rawValue().toDouble()));
outputStr.append(QString("Bottom Layer Altitude: %1\n").arg(area._bottomLayerAltitude.rawValue().toDouble()));
outputStr.append(QString("Number of Layers: %1\n").arg(area._numberOfLayers.rawValue().toInt()));
outputStr.append(QString("Layer Distance: %1\n").arg(area._layerDistance.rawValue().toDouble()));
outputStr.append(QString("Border Polygon Offset: %1\n").arg(area._borderPolygonOffset.rawValue().toDouble()));
outputStr.append(QString("Border Polygon Coordinates\n").arg(area._borderPolygonOffset.rawValue().toDouble()));
for (int i = 0; i < area._borderPolygon.count(); i++) {
QGeoCoordinate coordinate = area._borderPolygon.vertexCoordinate(i);
outputStr.append(QString("%s\n").arg(coordinate.toString(QGeoCoordinate::Degrees)));
outputStr.append(QString("%1\n").arg(coordinate.toString(QGeoCoordinate::Degrees)));
}
}
void swap(WimaGOperationArea &area1, WimaGOperationArea &area2)
{
using std::swap;
swap(area1._metaDataMap, area2._metaDataMap);
swap(area1._bottomLayerAltitude, area2._bottomLayerAltitude);
swap(area1._numberOfLayers, area2._numberOfLayers);
swap(area1._layerDistance, area2._layerDistance);
swap(area1._borderPolygonOffset, area2._borderPolygonOffset);
swap(area1._borderPolygon, area2._borderPolygon);
}
void WimaGOperationArea::recalcBorderPolygon()
{
//qWarning("WimaGOperationArea::recalcBorderPolygon() %f", _borderPolygonOffset.rawValue().toDouble());
......
......@@ -13,35 +13,34 @@ class WimaGOperationArea : public WimaArea
Q_OBJECT
public:
WimaGOperationArea(QObject* parent = nullptr);
WimaGOperationArea(const WimaGOperationArea& other, QObject* parent = nullptr);
WimaGOperationArea& operator=(WimaGOperationArea other);
WimaGOperationArea(const WimaGOperationArea &other, QObject *parent = nullptr);
Q_PROPERTY(Fact* bottomLayerAltitude READ bottomLayerAltitude CONSTANT)
Q_PROPERTY(Fact* numberOfLayers READ numberOfLayers CONSTANT)
Q_PROPERTY(Fact* layerDistance READ layerDistance CONSTANT)
Q_PROPERTY(Fact* borderPolygonOffset READ borderPolygonOffset CONSTANT)
Q_PROPERTY(QGCMapPolygon* borderPolygon READ borderPolygon NOTIFY borderPolygonChanged)
void setVehicleCorridor (WimaVCorridor* corridor);
Q_PROPERTY(Fact* bottomLayerAltitude READ bottomLayerAltitudeFact CONSTANT)
Q_PROPERTY(Fact* numberOfLayers READ numberOfLayersFact CONSTANT)
Q_PROPERTY(Fact* layerDistance READ layerDistanceFact CONSTANT)
Q_PROPERTY(Fact* borderPolygonOffset READ borderPolygonOffsetFact CONSTANT)
Q_PROPERTY(QGCMapPolygon borderPolygon READ borderPolygon NOTIFY borderPolygonChanged)
// Overrides from WimaPolygon
QString mapVisualQML (void) const { return "WimaGOperationAreaMapVisual.qml";}
QString editorQML (void) const { return "WimaGOperationAreaEditor.qml";}
// Property accessors
Fact* bottomLayerAltitude (void) { return &_bottomLayerAltitude;}
Fact* numberOfLayers (void) { return &_numberOfLayers;}
Fact* layerDistance (void) { return &_layerDistance;}
Fact* borderPolygonOffset (void) { return &_borderPolygonOffset;}
QGCMapPolygon* borderPolygon (void) { return &_borderPolygon;}
Fact* bottomLayerAltitudeFact (void) { return &_bottomLayerAltitude;}
Fact* numberOfLayersFact (void) { return &_numberOfLayers;}
Fact* layerDistanceFact (void) { return &_layerDistance;}
Fact* borderPolygonOffsetFact (void) { return &_borderPolygonOffset;}
double bottomLayerAltitude (void) const { return _bottomLayerAltitude.rawValue().toDouble();}
int numberOfLayers (void) const { return _numberOfLayers.rawValue().toInt();}
double layerDistance (void) const { return _layerDistance.rawValue().toDouble();}
double borderPolygonOffset (void) const { return _borderPolygonOffset.rawValue().toDouble();}
QGCMapPolygon borderPolygon (void) const { return _borderPolygon;}
// Member Methodes
void saveToJson(QJsonObject& json);
bool loadFromJson(const QJsonObject& json, QString &errorString);
// Friends
friend void swap(WimaGOperationArea& area1, WimaGOperationArea& area2);
friend void print(const WimaGOperationArea& area, QString outputStr);
friend void print(const WimaGOperationArea& area);
......@@ -53,21 +52,23 @@ public:
static const char* borderPolygonOffsetName;
static const char* wimaGOperationAreaName;
signals:
void bottomLayerAltitudeChanged (void);
void numberOfLayersChanged (void);
void layerDistanceChanged (void);
//void vehicleListChanged (void);
void polylineChanged (void);
//void vehiclePolygonsChanged (void);
void vehicleCorridorChanged (WimaVCorridor* corridor);
void borderPolygonChanged (void);
public slots:
/// Updates this with data from area
void update(const WimaGOperationArea &area);
void setBottomLayerAltitude (double altitude);
void setNumberOfLayers (double numLayers);
void setLayerDistance (double layerDistance);
void setBorderPolygonOffset (double offset);
private slots:
void recalcBorderPolygon (void);
private:
// Member Methodes
void init();
......
#include "WimaPlaner.h"
WimaPlaner::WimaPlaner()
{
}
#ifndef WIMAPLANER_H
#define WIMAPLANER_H
class WimaPlaner
{
public:
WimaPlaner();
};
#endif // WIMAPLANER_H
\ No newline at end of file
......@@ -16,13 +16,6 @@ WimaServiceArea::WimaServiceArea(const WimaServiceArea &other, QObject *parent)
init();
}
WimaServiceArea &WimaServiceArea::operator=(WimaServiceArea other)
{
swap(*this, other);
return *this;
}
void WimaServiceArea::setTakeOffPosition(const QGeoCoordinate &coordinate)
{
if(_takeOffPosition != coordinate){
......@@ -57,6 +50,13 @@ bool WimaServiceArea::loadFromJson(const QJsonObject &json, QString &errorString
}
}
void WimaServiceArea::update(const WimaServiceArea &area)
{
this->WimaArea::update(area);
this->setTakeOffPosition(area.takeOffPosition());
this->setLandPosition(area.landPosition());
}
void print(const WimaServiceArea &area)
{
QString message;
......@@ -71,14 +71,6 @@ void print(const WimaServiceArea &area, QString &outputStr)
outputStr.append(QString("Land Position: %s\n").arg(area._landPosition.toString(QGeoCoordinate::Degrees)));
}
void swap(WimaServiceArea &area1, WimaServiceArea &area2)
{
using std::swap;
swap(area1._takeOffPosition, area2._takeOffPosition);
swap(area1._landPosition, area2._landPosition);
}
void WimaServiceArea::init()
{
this->setObjectName(wimaServiceAreaName);
......
......@@ -10,12 +10,10 @@ class WimaServiceArea : public WimaArea
public:
WimaServiceArea(QObject* parent = nullptr);
WimaServiceArea(const WimaServiceArea& other, QObject* parent);
WimaServiceArea& operator=(WimaServiceArea other);
Q_PROPERTY(const QGeoCoordinate& takeOffPosition READ takeOffPosition WRITE setTakeOffPosition NOTIFY takeOffPositionChanged)
Q_PROPERTY(const QGeoCoordinate& landPosition READ landPosition WRITE setLandPosition NOTIFY landPositionChanged)
// Overrides from WimaPolygon
QString mapVisualQML (void) const { return "WimaServiceAreaMapVisual.qml";}
QString editorQML (void) const { return "WimaServiceAreaEditor.qml";}
......@@ -24,27 +22,29 @@ public:
const QGeoCoordinate& takeOffPosition (void) const { return _takeOffPosition;}
const QGeoCoordinate& landPosition (void) const { return _landPosition;}
// Property setters
void setTakeOffPosition (const QGeoCoordinate& coordinate);
void setLandPosition (const QGeoCoordinate& coordinate);
// Member Methodes
void saveToJson(QJsonObject& json);
bool loadFromJson(const QJsonObject& json, QString& errorString);
// static Members
static const char* wimaServiceAreaName;
// Friends
friend void swap(WimaServiceArea& area1, WimaServiceArea& area2);
friend void print(const WimaServiceArea& area, QString& outputStr);
friend void print(const WimaServiceArea& area);
// static Members
static const char* wimaServiceAreaName;
signals:
void takeOffPositionChanged (void);
void landPositionChanged (void);
void vehicleCorridorChanged (WimaVCorridor& corridor);
public slots:
void setTakeOffPosition (const QGeoCoordinate& coordinate);
void setLandPosition (const QGeoCoordinate& coordinate);
/// Updates this with data from area
void update(const WimaServiceArea &area);
private:
// Member Methodes
void init();
......
......@@ -16,13 +16,6 @@ WimaVCorridor::WimaVCorridor(const WimaVCorridor &other, QObject *parent)
init();
}
WimaVCorridor &WimaVCorridor::operator=(WimaVCorridor other)
{
swap(*this, other);
return *this;
}
void WimaVCorridor::saveToJson(QJsonObject &json)
{
this->WimaArea::saveToJson(json);
......@@ -41,6 +34,11 @@ bool WimaVCorridor::loadFromJson(const QJsonObject &json, QString &errorString)
}
}
void WimaVCorridor::update(const WimaVCorridor &area)
{
this->WimaArea::update(area);
}
void WimaVCorridor::init()
{
this->setObjectName(wimaVCorridorName);
......@@ -57,10 +55,3 @@ void print(const WimaVCorridor &area, QString &outputString)
{
print(static_cast<const WimaArea&>(area), outputString);
}
void swap(WimaVCorridor &area1, WimaVCorridor &area2)
{
using std::swap;
swap(static_cast<WimaArea&>(area1), static_cast<WimaArea&>(area2));
}
......@@ -11,7 +11,6 @@ class WimaVCorridor : public WimaArea
public:
WimaVCorridor(QObject* parent = nullptr);
WimaVCorridor(const WimaVCorridor& other, QObject* parent = nullptr);
WimaVCorridor& operator=(WimaVCorridor other);
// Overrides from WimaPolygon
QString mapVisualQML (void) const { return "WimaVCorridorMapVisual.qml";}
......@@ -25,7 +24,6 @@ public:
static const char* wimaVCorridorName;
// Friends
friend void swap(WimaVCorridor& area1, WimaVCorridor& area2);
friend void print(const WimaVCorridor& area, QString& outputString);
friend void print(const WimaVCorridor& area);
......@@ -33,6 +31,10 @@ signals:
void serviceAreaChanged (WimaServiceArea* serviceArea);
void opAreaChanged (WimaGOperationArea* opArea);
public slots:
/// Updates this with data from area
void update(const WimaVCorridor& area);
private:
void init();
......
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