Commit dfceedc3 authored by Valentin Platzgummer's avatar Valentin Platzgummer

wima planer, plan data, wima controller edited

parent 47641f63
This diff is collapsed.
#pragma once
#include "QGCGeo.h"
#include "QGCMapPolygon.h"
#include "QGCMapPolyline.h"
#include "Vehicle.h"
#include "qobject.h"
#include <QLineF>
#include <QPointF>
#include "QGCGeo.h"
#include <QPair>
#include <QPointF>
#include "GeoUtilities.h"
#include "PolygonCalculus.h"
#include "PlanimetryCalculus.h"
#include "PolygonCalculus.h"
class WimaArea : public QGCMapPolygon //abstract base class for all WimaAreas
class WimaArea : public QGCMapPolygon // abstract base class for all WimaAreas
{
Q_OBJECT
Q_OBJECT
public:
WimaArea(QObject* parent = nullptr);
WimaArea(const WimaArea& other, QObject* parent = nullptr);
WimaArea &operator=(const 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(Fact* borderPolygonOffset READ borderPolygonOffsetFact CONSTANT)
Q_PROPERTY(QGCMapPolygon* borderPolygon READ borderPolygon NOTIFY borderPolygonChanged)
Q_PROPERTY(Fact* showBorderPolygon READ showBorderPolygon CONSTANT)
Q_PROPERTY(bool wimaAreaInteractive READ wimaAreaInteractive WRITE setWimaAreaInteractive NOTIFY wimaAreaInteractiveChanged)
//Property accessors
double maxAltitude (void) const { return _maxAltitude;}
Fact* borderPolygonOffsetFact (void) { return &_borderPolygonOffset;}
Fact* showBorderPolygon (void) { return &_showBorderPolygon;}
double borderPolygonOffset (void) const { return _borderPolygonOffset.rawValue().toDouble();}
QGCMapPolygon* borderPolygon (void) { return &_borderPolygon;}
bool wimaAreaInteractive (void) const { return _wimaAreaInteractive;}
void setWimaAreaInteractive (bool interactive);
// overrides from WimaArea
virtual QString mapVisualQML (void) const { return ""; }
virtual QString editorQML (void) const { return ""; }
// Member Methodes
int getClosestVertexIndex (const QGeoCoordinate& coordinate) const;
QGeoCoordinate getClosestVertex (const QGeoCoordinate& coordinate) const;
QGCMapPolygon toQGCPolygon () const;
bool join (WimaArea &area);
bool join (WimaArea &area, QString &errorString);
int nextVertexIndex (int index) const;
int previousVertexIndex (int index) const;
bool isSimplePolygon () const;
bool containsCoordinate (const QGeoCoordinate &coordinate) const;
void saveToJson (QJsonObject& jsonObject);
bool loadFromJson (const QJsonObject &jsonObject, QString& errorString);
// static Methodes
static QGCMapPolygon toQGCPolygon (const WimaArea& area);
static bool join (const WimaArea &area1, const WimaArea &area2, WimaArea& joinedArea, QString &errorString);
static bool join (const WimaArea &area1, const WimaArea &area2, WimaArea& joinedArea);
// Friends
friend void print(const WimaArea& area, QString& outputString);
friend void print(const WimaArea& area);
// static Members
// Accurracy used to compute isDisjunct
static const double epsilonMeter;
static const char* maxAltitudeName;
static const char* wimaAreaName;
static const char* areaTypeName;
static const char* borderPolygonOffsetName;
static const char* showBorderPolygonName;
static const char* settingsGroup;
WimaArea(QObject *parent = nullptr);
WimaArea(const WimaArea &other, QObject *parent = nullptr);
WimaArea &operator=(const 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(Fact *borderPolygonOffset READ borderPolygonOffsetFact CONSTANT)
Q_PROPERTY(QGCMapPolygon *borderPolygon READ borderPolygon NOTIFY
borderPolygonChanged)
Q_PROPERTY(Fact *showBorderPolygon READ showBorderPolygon CONSTANT)
Q_PROPERTY(bool wimaAreaInteractive READ wimaAreaInteractive WRITE
setWimaAreaInteractive NOTIFY wimaAreaInteractiveChanged)
// Property accessors
double maxAltitude(void) const { return _maxAltitude; }
Fact *borderPolygonOffsetFact(void) { return &_borderPolygonOffset; }
Fact *showBorderPolygon(void) { return &_showBorderPolygon; }
double borderPolygonOffset(void) const {
return _borderPolygonOffset.rawValue().toDouble();
}
QGCMapPolygon *borderPolygon(void) { return &_borderPolygon; }
bool wimaAreaInteractive(void) const { return _wimaAreaInteractive; }
void setWimaAreaInteractive(bool interactive);
// overrides from WimaArea
virtual QString mapVisualQML(void) const { return ""; }
virtual QString editorQML(void) const { return ""; }
// Member Methodes
int getClosestVertexIndex(const QGeoCoordinate &coordinate) const;
QGeoCoordinate getClosestVertex(const QGeoCoordinate &coordinate) const;
QGCMapPolygon toQGCPolygon() const;
bool join(WimaArea &area);
bool join(WimaArea &area, QString &errorString);
int nextVertexIndex(int index) const;
int previousVertexIndex(int index) const;
bool isSimplePolygon() const;
bool containsCoordinate(const QGeoCoordinate &coordinate) const;
void saveToJson(QJsonObject &jsonObject);
bool loadFromJson(const QJsonObject &jsonObject, QString &errorString);
// static Methodes
static QGCMapPolygon toQGCPolygon(const WimaArea &area);
static bool join(const WimaArea &area1, const WimaArea &area2,
WimaArea &joinedArea, QString &errorString);
static bool join(const WimaArea &area1, const WimaArea &area2,
WimaArea &joinedArea);
// Friends
friend void print(const WimaArea &area, QString &outputString);
friend void print(const WimaArea &area);
// static Members
// Accurracy used to compute isDisjunct
static const double epsilonMeter;
static const char *maxAltitudeName;
static const char *wimaAreaName;
static const char *areaTypeName;
static const char *borderPolygonOffsetName;
static const char *showBorderPolygonName;
static const char *settingsGroup;
signals:
void maxAltitudeChanged (void);
void borderPolygonChanged (void);
void borderPolygonOffsetChanged (void);
void wimaAreaInteractiveChanged (void);
void maxAltitudeChanged(void);
void borderPolygonChanged(void);
void borderPolygonOffsetChanged(void);
void wimaAreaInteractiveChanged(void);
public slots:
void setMaxAltitude (double altitude);
void setShowBorderPolygon (bool showBorderPolygon);
void setBorderPolygonOffset (double offset);
void setMaxAltitude(double altitude);
void setShowBorderPolygon(bool showBorderPolygon);
void setBorderPolygonOffset(double offset);
private slots:
void recalcPolygons (void);
void updatePolygonConnections (QVariant value);
void recalcInteractivity (void);
void recalcPolygons(void);
void updatePolygonConnections(QVariant value);
void recalcInteractivity(void);
private:
void init();
void init();
double _maxAltitude;
double _maxAltitude;
QMap<QString, FactMetaData*> _metaDataMap;
SettingsFact _borderPolygonOffset;
SettingsFact _showBorderPolygon;
QMap<QString, FactMetaData *> _metaDataMap;
SettingsFact _borderPolygonOffset;
SettingsFact _showBorderPolygon;
QGCMapPolygon _borderPolygon;
QGCMapPolygon _borderPolygon;
bool _wimaAreaInteractive;
bool _wimaAreaInteractive;
};
#include "WimaAreaData.h"
WimaAreaData::WimaAreaData(QObject *parent)
: QObject(parent)
{
_maxAltitude = 0;
WimaAreaData::WimaAreaData(QObject *parent) : QObject(parent) {
_maxAltitude = 0;
}
WimaAreaData::~WimaAreaData() {}
/*!
* \fn double WimaAreaData::maxAltitude()
*
* Returns the maximum altitude at which vehicles are allowed to fly.
*/
double WimaAreaData::maxAltitude() const
{
return _maxAltitude;
}
double WimaAreaData::maxAltitude() const { return _maxAltitude; }
/*!
* \fn double WimaAreaData::maxAltitude()
*
* Returns the path (vertex list defining the \l {Simple Polygon}).
*/
QVariantList WimaAreaData::path() const
{
return _path;
}
QVariantList WimaAreaData::path() const { return _path; }
QGeoCoordinate WimaAreaData::center() const
{
return _center;
}
QGeoCoordinate WimaAreaData::center() const { return _center; }
const QList<QGeoCoordinate> &WimaAreaData::coordinateList() const
{
return _list;
const QList<QGeoCoordinate> &WimaAreaData::coordinateList() const {
return _list;
}
bool WimaAreaData::containsCoordinate(const QGeoCoordinate &coordinate) const
{
using namespace PlanimetryCalculus;
using namespace PolygonCalculus;
using namespace GeoUtilities;
if (_path.size() > 2) {
QPolygonF polygon;
toCartesianList(this->coordinateList(), coordinate, polygon);
return PlanimetryCalculus::contains(polygon, QPointF(0,0));
} else
return false;
bool WimaAreaData::containsCoordinate(const QGeoCoordinate &coordinate) const {
using namespace PlanimetryCalculus;
using namespace PolygonCalculus;
using namespace GeoUtilities;
if (_path.size() > 2) {
QPolygonF polygon;
toCartesianList(this->coordinateList(), coordinate, polygon);
return PlanimetryCalculus::contains(polygon, QPointF(0, 0));
} else
return false;
}
void WimaAreaData::append(const QGeoCoordinate &c) {
_list.append(c);
_path.push_back(QVariant::fromValue(c));
_list.append(c);
_path.push_back(QVariant::fromValue(c));
}
void WimaAreaData::push_back(const QGeoCoordinate &c)
{
append(c);
}
void WimaAreaData::push_back(const QGeoCoordinate &c) { append(c); }
void WimaAreaData::clear() {
_list.clear();
_path.clear();
_list.clear();
_path.clear();
}
/*!
* \fn void WimaAreaData::setMaxAltitude(double maxAltitude)
*
* Sets the maximum altitude member to \a maxAltitude and emits the \c maxAltitudeChanged() signal if
* \a maxAltitude differs from the members value.
* Sets the maximum altitude member to \a maxAltitude and emits the \c
* maxAltitudeChanged() signal if \a maxAltitude differs from the members value.
*/
void WimaAreaData::setMaxAltitude(double maxAltitude)
{
if ( !qFuzzyCompare(_maxAltitude, maxAltitude) ) {
_maxAltitude = maxAltitude;
void WimaAreaData::setMaxAltitude(double maxAltitude) {
if (!qFuzzyCompare(_maxAltitude, maxAltitude)) {
_maxAltitude = maxAltitude;
emit maxAltitudeChanged(_maxAltitude);
}
emit maxAltitudeChanged(_maxAltitude);
}
}
void WimaAreaData::setPath(const QVariantList &coordinateList)
{
_path = coordinateList;
_list.clear();
for (auto variant : coordinateList) {
_list.push_back(variant.value<QGeoCoordinate>());
}
void WimaAreaData::setPath(const QVariantList &coordinateList) {
_path = coordinateList;
_list.clear();
for (auto variant : coordinateList) {
_list.push_back(variant.value<QGeoCoordinate>());
}
}
void WimaAreaData::setCenter(const QGeoCoordinate &center)
{
if (_center != center) {
_center = center;
void WimaAreaData::setCenter(const QGeoCoordinate &center) {
if (_center != center) {
_center = center;
emit centerChanged();
}
emit centerChanged();
}
}
/*!
......@@ -104,46 +86,43 @@ void WimaAreaData::setCenter(const QGeoCoordinate &center)
*
* Assigns \a other to the invoking object
*/
void WimaAreaData::assign(const WimaAreaData &other)
{
setMaxAltitude(other.maxAltitude());
setPath(other.path());
setCenter(other.center());
void WimaAreaData::assign(const WimaAreaData &other) {
setMaxAltitude(other.maxAltitude());
setPath(other.path());
setCenter(other.center());
}
void WimaAreaData::assign(const WimaArea &other)
{
setMaxAltitude(other.maxAltitude());
setPath(other.path());
setCenter(other.center());
void WimaAreaData::assign(const WimaArea &other) {
setMaxAltitude(other.maxAltitude());
setPath(other.path());
setCenter(other.center());
}
/*!
* \fn void WimaAreaData::setPath(const QList<QGeoCoordinate> &coordinateList)
*
* Sets the path member to \a coordinateList by copying all entries of \a coordinateList.
* Emits the \c pathChanged() signal.
* Sets the path member to \a coordinateList by copying all entries of \a
* coordinateList. Emits the \c pathChanged() signal.
*/
void WimaAreaData::setPath(const QList<QGeoCoordinate> &coordinateList)
{
_list = coordinateList;
void WimaAreaData::setPath(const QList<QGeoCoordinate> &coordinateList) {
_list = coordinateList;
_path.clear();
// copy all coordinates to _path
for(int i = 0; i < coordinateList.size(); i++) {
_path.append(QVariant::fromValue(coordinateList.value(i)));
}
_path.clear();
// copy all coordinates to _path
for (int i = 0; i < coordinateList.size(); i++) {
_path.append(QVariant::fromValue(coordinateList.value(i)));
}
emit pathChanged(_path);
emit pathChanged(_path);
}
/*!
* \class WimaArea::WimaAreaData
* \brief Class to store and exchange data of a \c WimaArea Object.
* Class to store and exchange data of a \c WimaArea Object. In contrast to \c WimaArea this class
* does not uses the QGC Fact System. It is designed to exchange data between the \c WimaPlaner and
* the \c WimaController class. And it is the base class for any derived data objects
* Class to store and exchange data of a \c WimaArea Object. In contrast to \c
* WimaArea this class does not uses the QGC Fact System. It is designed to
* exchange data between the \c WimaPlaner and the \c WimaController class. And
* it is the base class for any derived data objects
*
* \sa WimaArea
*/
......@@ -6,52 +6,53 @@
#include "WimaArea.h"
class WimaAreaData : public QObject// Abstract class for all WimaAreaData derived objects
class WimaAreaData
: public QObject // Abstract class for all WimaAreaData derived objects
{
Q_OBJECT
Q_OBJECT
public:
Q_PROPERTY(const QVariantList path READ path NOTIFY pathChanged)
Q_PROPERTY(QString type READ type CONSTANT)
WimaAreaData(QObject *parent = nullptr);
WimaAreaData(const WimaAreaData& otherData) = delete; // avoid slicing
WimaAreaData& operator=(const WimaAreaData& otherData) = delete; // avoid slicing
double maxAltitude() const;
QVariantList path() const;
QGeoCoordinate center() const;
const QList<QGeoCoordinate> &coordinateList() const;
bool containsCoordinate(const QGeoCoordinate &coordinate) const;
virtual QString type() const = 0;
void append(const QGeoCoordinate &c);
void push_back(const QGeoCoordinate &c);
void clear();
Q_PROPERTY(const QVariantList path READ path NOTIFY pathChanged)
Q_PROPERTY(QString type READ type CONSTANT)
WimaAreaData(QObject *parent = nullptr);
~WimaAreaData();
WimaAreaData(const WimaAreaData &otherData) = delete; // avoid slicing
WimaAreaData &
operator=(const WimaAreaData &otherData) = delete; // avoid slicing
double maxAltitude() const;
QVariantList path() const;
QGeoCoordinate center() const;
const QList<QGeoCoordinate> &coordinateList() const;
bool containsCoordinate(const QGeoCoordinate &coordinate) const;
virtual QString type() const = 0;
void append(const QGeoCoordinate &c);
void push_back(const QGeoCoordinate &c);
void clear();
signals:
void maxAltitudeChanged (double maxAltitude);
void pathChanged (const QVariantList& coordinateList);
void centerChanged (void);
void maxAltitudeChanged(double maxAltitude);
void pathChanged(const QVariantList &coordinateList);
void centerChanged(void);
public slots:
void setMaxAltitude(double maxAltitude);
void setPath(const QList<QGeoCoordinate> &coordinateList);
void setPath(const QVariantList &coordinateList);
void setCenter(const QGeoCoordinate &center);
void setMaxAltitude(double maxAltitude);
void setPath(const QList<QGeoCoordinate> &coordinateList);
void setPath(const QVariantList &coordinateList);
void setCenter(const QGeoCoordinate &center);
protected:
void assign(const WimaAreaData &other);
void assign(const WimaArea &other);
void assign(const WimaAreaData &other);
void assign(const WimaArea &other);
private:
// Member Functions
// Member Variables
// see WimaArea.h for explanation
double _maxAltitude;
QVariantList _path;
QList<QGeoCoordinate> _list;
QGeoCoordinate _center;
// Member Functions
// Member Variables
// see WimaArea.h for explanation
double _maxAltitude;
QVariantList _path;
QList<QGeoCoordinate> _list;
QGeoCoordinate _center;
};
......@@ -107,9 +107,13 @@ Fact *WimaMeasurementArea::showTiles() { return &_showTiles; }
QmlObjectListModel *WimaMeasurementArea::tiles() { return this->_pTiles.get(); }
int WimaMeasurementArea::maxTiles() { return SNAKE_MAX_TILES; }
const QmlObjectListModel *WimaMeasurementArea::tiles() const {
return this->_pTiles.get();
}
int WimaMeasurementArea::maxTiles() const { return SNAKE_MAX_TILES; }
bool WimaMeasurementArea::ready() { return !_calculating; }
bool WimaMeasurementArea::ready() const { return !_calculating; }
void WimaMeasurementArea::saveToJson(QJsonObject &json) {
this->WimaArea::saveToJson(json);
......
......@@ -37,8 +37,9 @@ public:
Fact *minTransectLength();
Fact *showTiles();
QmlObjectListModel *tiles();
int maxTiles();
bool ready();
const QmlObjectListModel *tiles() const;
int maxTiles() const;
bool ready() const;
// Member Methodes
void saveToJson(QJsonObject &json);
......
......@@ -47,9 +47,9 @@ QString WimaMeasurementAreaData::type() const { return this->typeString; }
void WimaMeasurementAreaData::assign(const WimaMeasurementAreaData &other) {
WimaAreaData::assign(other);
this->tiles.clearAndDeleteContents();
for (std::size_t i = 0; i < other.tiles.count(); ++i) {
auto *obj = other.tiles.get(i);
auto *tile = qobject_cast<SnakeTile *>(obj);
for (std::size_t i = 0; i < std::size_t(other.tiles.count()); ++i) {
const auto *obj = other.tiles.get(i);
const auto *tile = qobject_cast<const SnakeTile *>(obj);
if (tile != nullptr) {
this->tiles.append(new SnakeTile(*tile, this));
} else {
......@@ -62,9 +62,9 @@ void WimaMeasurementAreaData::assign(const WimaMeasurementArea &other) {
WimaAreaData::assign(other);
this->tiles.clearAndDeleteContents();
if (other.ready()) {
for (std::size_t i = 0; i < other.tiles()->count(); ++i) {
auto *obj = other.tiles()->get(i);
auto *tile = qobject_cast<SnakeTile *>(obj);
for (std::size_t i = 0; i < std::size_t(other.tiles()->count()); ++i) {
const auto *obj = other.tiles()->get(i);
const auto *tile = qobject_cast<const SnakeTile *>(obj);
if (tile != nullptr) {
this->tiles.append(new SnakeTile(*tile, this));
} else {
......
......@@ -7,6 +7,12 @@ SnakeTile::SnakeTile(const SnakeTile &other, QObject *parent)
*this = other;
}
SnakeTile::~SnakeTile() {}
QString SnakeTile::type() const { return "Tile"; }
SnakeTile *SnakeTile::Clone() const { return new SnakeTile(*this); }
SnakeTile &SnakeTile::operator=(const SnakeTile &other) {
this->assign(other);
return *this;
......
......@@ -3,12 +3,14 @@
#include "Wima/Geometry/WimaAreaData.h"
class SnakeTile : public WimaAreaData {
Q_OBJECT
public:
SnakeTile(QObject *parent = nullptr);
SnakeTile(const SnakeTile &other, QObject *parent = nullptr);
~SnakeTile();
QString type() const { return "Tile"; }
SnakeTile *Clone() const { return new SnakeTile(*this); }
QString type() const override;
SnakeTile *Clone() const;
SnakeTile &operator=(const SnakeTile &other);
......
......@@ -424,41 +424,34 @@ bool WimaController::setWimaPlanData(QSharedPointer<WimaPlanData> planData) {
emit visualItemsChanged();
// Copy transects.
this->_rawTransects = planData->transects();
auto tempMissionItems = planData->missionItems();
if (tempMissionItems.size() < 1) {
qWarning("WimaController: Mission items from WimaPlaner empty!");
return false;
}
for (auto *item : tempMissionItems) {
_defaultWM.push_back(item->coordinate());
}
// // extract mission items
_WMSettings.setHomePosition(QGeoCoordinate(
_serviceArea.depot().latitude(), _serviceArea.depot().longitude(), 0));
// auto tempMissionItems = planData->missionItems();
if (!_defaultWM.reset()) {
Q_ASSERT(false);
return false;
}
// if (tempMissionItems.size() < 1) {
emit missionItemsChanged();
emit currentMissionItemsChanged();
emit waypointPathChanged();
emit currentWaypointPathChanged();
// qWarning("WimaController: Mission items from WimaPlaner empty!");
// return false;
// }
// qWarning() << "WimaController:";
// for (auto *item : tempMissionItems) {
// qWarning() << item->coordinate();
// _defaultWM.push_back(item->coordinate());
// }
// _WMSettings.setHomePosition(QGeoCoordinate(
// _serviceArea.depot().latitude(), _serviceArea.depot().longitude(),
// 0));
// qWarning() << "service area depot: " << _serviceArea.depot();
// if (!_defaultWM.reset()) {
// qWarning() << "_defaultWM.reset() failed";
// return false;
// }
// emit missionItemsChanged();
// emit currentMissionItemsChanged();
// emit waypointPathChanged();
// emit currentWaypointPathChanged();
// // Update Snake Data Manager
// _snakeThread.setMeasurementArea(_measurementArea.coordinateList());
// _snakeThread.setServiceArea(_serviceArea.coordinateList());
// _snakeThread.setCorridor(_corridor.coordinateList());
// _currentThread->start();
_snakeThread.setMeasurementArea(_measurementArea.coordinateList());
_snakeThread.setServiceArea(_serviceArea.coordinateList());
_snakeThread.setCorridor(_corridor.coordinateList());
_currentThread->start();
_localPlanDataValid = true;
return true;
......
......@@ -294,6 +294,11 @@ private:
SettingsFact _arrivalReturnSpeed; // arrival and return path speed
SettingsFact _altitude; // mission altitude
SettingsFact _enableSnake; // Enable Snake (see snake.h)
SettingsFact _snakeTileWidth;
SettingsFact _snakeTileHeight;
SettingsFact _snakeMinTileArea;
SettingsFact _snakeLineDistance;
SettingsFact _snakeMinTransectLength;
// Smart RTL.
QTimer _smartRTLTimer;
......@@ -304,6 +309,7 @@ private:
// Snake
QList<QList<QGeoCoordinate>> _rawTransects;
QmlObjectListModel tiles;
SnakeThread _snakeThread; // Snake Data Manager
SnakeThread _emptyThread;
SnakeThread *_currentThread;
......
......@@ -76,10 +76,6 @@ void WimaPlanData::append(const WimaCorridorData &areaData) {
}
}
void WimaPlanData::setTransects(const QList<QList<QGeoCoordinate>> &transects) {
this->_transects = transects;
}
/*!
* \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
*
......@@ -114,10 +110,6 @@ const QList<const WimaAreaData *> &WimaPlanData::areaList() const {
return _areaList;
}
const QList<QList<QGeoCoordinate>> &WimaPlanData::transects() const {
return _transects;
}
const QList<MissionItem *> &WimaPlanData::missionItems() const {
return _missionItems;
}
......
......@@ -8,6 +8,7 @@
#include "Geometry/WimaJoinedAreaData.h"
#include "Geometry/WimaMeasurementAreaData.h"
#include "Geometry/WimaServiceAreaData.h"
#include "MissionItem.h"
class WimaPlanData : public QObject {
Q_OBJECT
......@@ -20,6 +21,7 @@ public:
void append(const WimaJoinedAreaData &areaData);
void append(const WimaServiceAreaData &areaData);
void append(const WimaCorridorData &areaData);
void append(const WimaMeasurementAreaData &areaData);
void setTransects(const QList<QList<QGeoCoordinate>> &transects);
//!
......@@ -31,6 +33,7 @@ public:
const QList<const WimaAreaData *> &areaList() const;
const QList<QList<QGeoCoordinate>> &transects() const;
const QList<MissionItem *> &missionItems() const;
signals:
void areaListChanged();
......@@ -43,4 +46,5 @@ private:
QList<const WimaAreaData *> _areaList;
QList<QList<QGeoCoordinate>> _transects;
QList<MissionItem *> _missionItems;
};
#include "WimaPlanData.h"
WimaPlanData::WimaPlanData(QObject *parent) : QObject(parent) {}
WimaPlanData::WimaPlanData(const WimaPlanData &other, QObject *parent)
: QObject(parent) {
*this = other;
}
/*!
* \fn WimaPlanData &WimaPlanData::operator=(const WimaPlanData &other)
*
* Copies the data area list of \a other to the calling \c WimaPlanData object.
* Returns a reference to the calling \c WimaPlanData object.
*/
WimaPlanData &WimaPlanData::operator=(const WimaPlanData &other) {
// copy wima areas
QList<const WimaAreaData *> areaList = other.areaList();
_areaList.clear();
for (int i = 0; i < areaList.size(); i++) {
const WimaAreaData *areaData = areaList[i];
// determine area type and append
if (areaData->type() == WimaJoinedAreaData::typeString) {
this->append(*qobject_cast<const WimaJoinedAreaData *>(areaData));
} else if (areaData->type() == WimaServiceAreaData::typeString) {
this->append(*qobject_cast<const WimaServiceAreaData *>(areaData));
} else if (areaData->type() == WimaMeasurementAreaData::typeString) {
this->append(*qobject_cast<const WimaMeasurementAreaData *>(areaData));
} else if (areaData->type() == WimaCorridorData::typeString) {
this->append(*qobject_cast<const WimaCorridorData *>(areaData));
}
}
// copy mission items
_missionItems = other.missionItems();
return *this;
}
/*!
* \fn void WimaPlanData::append(const WimaAreaData &areaData)
*
* Adds a WimaAreaData item.
*/
void WimaPlanData::append(const WimaJoinedAreaData &areaData) {
_joinedArea = areaData;
if (!_areaList.contains(&_joinedArea)) {
_areaList.append(&_joinedArea);
}
}
/*!
* \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
*
* Adds a WimaServiceAreaData item.
*/
void WimaPlanData::append(const WimaServiceAreaData &areaData) {
_serviceArea = areaData;
if (!_areaList.contains(&_serviceArea)) {
_areaList.append(&_serviceArea);
}
}
/*!
* \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
*
* Adds a WimaCorridorData item.
*/
void WimaPlanData::append(const WimaCorridorData &areaData) {
_corridor = areaData;
if (!_areaList.contains(&_corridor)) {
_areaList.append(&_corridor);
}
}
/*!
* \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
*
* Adds a WimaMeasurementAreaData item.
*/
void WimaPlanData::append(const WimaMeasurementAreaData &areaData) {
_measurementArea = areaData;
if (!_areaList.contains(&_measurementArea)) {
_areaList.append(&_measurementArea);
}
}
void WimaPlanData::append(const QList<MissionItem *> &missionItems) {
for (auto *item : missionItems) {
item->setParent(this);
_missionItems.append(item);
}
}
/*!
* \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
*
* Clears all stored objects
*/
void WimaPlanData::clear() {
_areaList.clear();
_missionItems.clear();
}
const QList<const WimaAreaData *> &WimaPlanData::areaList() const {
return _areaList;
}
const QList<MissionItem> &WimaPlanData::missionItems() const {
return _missionItems;
}
/*!
* \class WimaPlanData
* \brief Class storing data generated by the \c WimaPlaner class.
*
* This class is designed to store data generated by the \c WimaPlaner class and
* meant for data exchange between the \c WimaController and the \c WimaPlanner.
* It stores a QList of \c WimaAreaData objects, called area data list,
* containing the data of serveral \c WimaAreas generated by the \c WimaPlaner.
*
* \sa QList
*/
......@@ -741,7 +741,14 @@ QSharedPointer<WimaPlanData> WimaPlaner::toPlanData() {
planData->append(WimaJoinedAreaData(_joinedArea));
// convert mission items to mavlink commands
planData->setTransects(this->_TSComplexItem->rawTransects());
QList<MissionItem *> missionItems;
_TSComplexItem->appendMissionItems(missionItems, nullptr);
// store mavlink commands
qWarning() << "WimaPlaner";
for (auto *item : missionItems) {
qWarning() << item->coordinate();
}
planData->append(missionItems);
return planData;
}
......
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