diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 6ba3ab3d10e5de46240e5639635cf0bccc78a666..f495fb24d8a6c2a1c7eb4078746c2052bd1aa017 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -421,7 +421,9 @@ HEADERS += \ src/Wima/WimaServiceAreaData.h \ src/Wima/WimaCorridorData.h \ src/Wima/WimaMeasurementAreaData.h \ - src/Wima/WimaPlanData.h + src/Wima/WimaPlanData.h \ + src/Wima/WimaJoinedArea.h \ + src/Wima/WimaJoinedAreaData.h SOURCES += \ src/api/QGCCorePlugin.cc \ src/api/QGCOptions.cc \ @@ -441,7 +443,9 @@ SOURCES += \ src/Wima/WimaServiceAreaData.cc \ src/Wima/WimaCorridorData.cpp \ src/Wima/WimaPlanData.cc \ - src/Wima/WimaMeasurementAreaData.cc + src/Wima/WimaMeasurementAreaData.cc \ + src/Wima/WimaJoinedArea.cc \ + src/Wima/WimaJoinedAreaData.cc # # Unit Test specific configuration goes here (requires full debug build with all plugins) diff --git a/src/Wima/WimaArea.h b/src/Wima/WimaArea.h index 1914f4ccc27181f43c9cf81f0bb2c1a3a2cdba9e..60e0996633e1227914d4c165b6be2bce1f3a389b 100644 --- a/src/Wima/WimaArea.h +++ b/src/Wima/WimaArea.h @@ -28,8 +28,8 @@ public: 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";} + virtual QString mapVisualQML (void) const; + virtual QString editorQML (void) const; // Member Methodes int getClosestVertexIndex (const QGeoCoordinate& coordinate) const; diff --git a/src/Wima/WimaAreaData.cc b/src/Wima/WimaAreaData.cc index 248699a8e754049163b7de3c3b71227747a660f0..371cc627f45e59d9180d478a4f9a05d64fa23e6f 100644 --- a/src/Wima/WimaAreaData.cc +++ b/src/Wima/WimaAreaData.cc @@ -1,8 +1,7 @@ #include "WimaAreaData.h" -const char *WimaAreaData::typeString = "WimaAreaData"; - -WimaAreaData::WimaAreaData(QObject *parent) : QObject(parent) +WimaAreaData::WimaAreaData(QObject *parent) + : QObject(parent) { _maxAltitude = 0; } @@ -47,6 +46,7 @@ WimaAreaData &WimaAreaData::operator=(const WimaArea &otherArea) return *this; } + /*! * \fn double WimaAreaData::maxAltitude() * @@ -67,16 +67,6 @@ QVariantList WimaAreaData::path() const return _path; } -/*! - * \fn QString WimaAreaData::type() - * - * Returns the type name of the object. Used to destinguish between derived objects. - */ -QString WimaAreaData::type() const -{ - return typeString; -} - /*! * \fn void WimaAreaData::setMaxAltitude(double maxAltitude) * @@ -98,6 +88,11 @@ void WimaAreaData::setPath(const QVariantList &coordinateList) _path.append(coordinateList); } +void WimaAreaData::assign(const WimaAreaData &other) +{ + +} + /*! * \fn void WimaAreaData::setPath(const QList &coordinateList) diff --git a/src/Wima/WimaAreaData.h b/src/Wima/WimaAreaData.h index ba2f6c8e1a9827a0e83f66159d46495ffd5d4bdc..62699edc8d7c4e31082cb1bc7f48850de5ed177d 100644 --- a/src/Wima/WimaAreaData.h +++ b/src/Wima/WimaAreaData.h @@ -6,7 +6,7 @@ #include "WimaArea.h" -class WimaAreaData : public QObject +class WimaAreaData : public QObject // Abstract class for all WimaAreaData derived objects { Q_OBJECT @@ -14,16 +14,15 @@ public: Q_PROPERTY(const QVariantList path READ path NOTIFY pathChanged) WimaAreaData(QObject *parent = nullptr); - WimaAreaData(const WimaAreaData &other, QObject *parent = nullptr); - WimaAreaData(const WimaArea &other, QObject *parent = nullptr); - WimaAreaData& operator=(const WimaAreaData& otherData); - WimaAreaData& operator=(const WimaArea& otherArea); + //WimaAreaData(const WimaAreaData &other, QObject *parent = nullptr); + //WimaAreaData(const WimaArea &other, QObject *parent = nullptr); + WimaAreaData& operator=(const WimaAreaData& otherData) = delete; // avoid slicing double maxAltitude() const; QVariantList path() const; - QString type() const; - static const char *typeString; + + virtual QString type() const = 0; signals: void maxAltitudeChanged (double maxAltitude); @@ -34,6 +33,9 @@ public slots: void setPath(const QList &coordinateList); void setPath(const QVariantList &coordinateList); +protected: + void assign(const WimaAreaData &other); + private: // Member Functions diff --git a/src/Wima/WimaController.cc b/src/Wima/WimaController.cc index 810d698f464e7b7086ce4ce4b1101d83e97597c8..31c98906174237a43ecfc29389b40f1a5ec47d5d 100644 --- a/src/Wima/WimaController.cc +++ b/src/Wima/WimaController.cc @@ -106,7 +106,7 @@ void WimaController::saveToCurrent() void WimaController::saveToFile(const QString& filename) { - + QString file = filename; } bool WimaController::loadFromCurrent() @@ -116,6 +116,7 @@ bool WimaController::loadFromCurrent() bool WimaController::loadFromFile(const QString &filename) { + QString file = filename; return true; } @@ -123,6 +124,10 @@ bool WimaController::loadFromFile(const QString &filename) QJsonDocument WimaController::saveToJson(FileType fileType) { + if(fileType) + { + + } return QJsonDocument(); } @@ -148,19 +153,20 @@ void WimaController::containerDataValidChanged(bool valid) int areaCounter = 0; int numAreas = 4; // extract only numAreas Areas, if there are more they are invalid and ignored bool joinedAreaAssigned = false; + qWarning() << QString("List Size: %1").arg(areaList.size()); for (int i = 0; i < areaList.size(); i++) { const WimaAreaData *areaData = areaList[i]; - + qWarning() << areaData->type(); if (areaData->type() == WimaServiceAreaData::typeString) { // is it a service area? - _serviceArea = *qobject_cast(areaData); + //_serviceArea = *qobject_cast(areaData); qWarning("Service area, wuhuuu!"); areaCounter++; continue; } - WimaMeasurementAreaData *measurementAreaData = qobject_cast(areaData); + /*WimaMeasurementAreaData *measurementAreaData = qobject_cast(areaData); if (measurementAreaData != nullptr) { // is it a measurement area? _measurementArea = *measurementAreaData; qWarning("Measurement area, wuhuuu!"); @@ -185,7 +191,7 @@ void WimaController::containerDataValidChanged(bool valid) joinedAreaAssigned = true; continue; - } + }*/ if (areaCounter >= numAreas) break; @@ -197,15 +203,13 @@ void WimaController::containerDataValidChanged(bool valid) //_visualItems.append(&_serviceArea); _visualItems.append(&_joinedArea); - emit visualItemsChanged(); - _localPlanDataValid = true; } else { _localPlanDataValid = false; - _visualItems.clear(); - - emit visualItemsChanged(); + _visualItems.clear(); } + + emit visualItemsChanged(); } diff --git a/src/Wima/WimaCorridorData.cpp b/src/Wima/WimaCorridorData.cpp index 2ebee0dddd572eb6c104acb69a49b7fa958607a9..915c39bad4a71a82c97dff3a4055580a49857e3d 100644 --- a/src/Wima/WimaCorridorData.cpp +++ b/src/Wima/WimaCorridorData.cpp @@ -44,6 +44,12 @@ WimaCorridorData &WimaCorridorData::operator=(const WimaCorridor &other) return *this; } +QString WimaCorridorData::type() const +{ + return this->typeString; +} + + /*! * \class WimaAreaData::WimaCorridorData * \brief Class to store and exchange data of a \c WimaCorridorData Object. diff --git a/src/Wima/WimaCorridorData.h b/src/Wima/WimaCorridorData.h index b8efc26d4022173cab7c9c6253e563f70628cddd..634b735629ee10ffdbc50b8980bafe07e871c4ac 100644 --- a/src/Wima/WimaCorridorData.h +++ b/src/Wima/WimaCorridorData.h @@ -18,6 +18,8 @@ public: WimaCorridorData &operator=(const WimaCorridorData &other); WimaCorridorData &operator=(const WimaCorridor &other); + QString type() const; + static const char* typeString; diff --git a/src/Wima/WimaJoinedArea.cc b/src/Wima/WimaJoinedArea.cc new file mode 100644 index 0000000000000000000000000000000000000000..f59658e8812aed48a8ceec277bad3b459436e8ea --- /dev/null +++ b/src/Wima/WimaJoinedArea.cc @@ -0,0 +1,69 @@ +#include "WimaJoinedArea.h" + +const char* WimaJoinedArea::WimaJoinedAreaName = "WimaJoinedArea"; + +WimaJoinedArea::WimaJoinedArea(QObject *parent) + : WimaArea (parent) +{ + +} + +WimaJoinedArea::WimaJoinedArea(const WimaJoinedArea &other, QObject *parent) + : WimaArea (parent) +{ + *this = other; +} + +/*! + * \overload operator=() + * + * Calls the inherited operator WimaArea::operator=(). + */ +WimaJoinedArea &WimaJoinedArea::operator=(const WimaJoinedArea &other) +{ + WimaArea::operator=(other); + + return *this; +} + + +void WimaJoinedArea::saveToJson(QJsonObject &json) +{ + this->WimaArea::saveToJson(json); + json[areaTypeName] = WimaJoinedAreaName; +} + +bool WimaJoinedArea::loadFromJson(const QJsonObject &json, QString &errorString) +{ + if ( this->WimaArea::loadFromJson(json, errorString)) { + bool retVal = true; + // code for loading here + return retVal; + } else { + qWarning() << errorString; + return false; + } +} + +void WimaJoinedArea::init() +{ + this->setObjectName(WimaJoinedAreaName); +} + +void print(const WimaJoinedArea &area) +{ + QString message; + print(area, message); + qWarning() << message; +} + +void print(const WimaJoinedArea &area, QString &outputString) +{ + print(static_cast(area), outputString); +} + + +/*! + \class WimaJoinedArea + \brief Joined area (derived from \c WimaArea) composed by the \c WimaMeasurementArea, the \c WimaCorridor, and the \c WimaServiceArea. +*/ diff --git a/src/Wima/WimaJoinedArea.h b/src/Wima/WimaJoinedArea.h new file mode 100644 index 0000000000000000000000000000000000000000..33897bae250ca99bb789f2e47ac2babb98ce83ff --- /dev/null +++ b/src/Wima/WimaJoinedArea.h @@ -0,0 +1,40 @@ +#ifndef WIMAJOINEDAREA_H +#define WIMAJOINEDAREA_H + +#include + +#include "WimaArea.h" + +class WimaJoinedArea : public WimaArea +{ + Q_OBJECT +public: + WimaJoinedArea(QObject* parent = nullptr); + WimaJoinedArea(const WimaJoinedArea& other, QObject* parent = nullptr); + + WimaJoinedArea &operator=(const WimaJoinedArea &other); + + // Overrides from WimaPolygon + QString mapVisualQML (void) const { return "WimaJoinedAreaMapVisual.qml";} + QString editorQML (void) const { return "";} + + // Methodes + void saveToJson (QJsonObject& json); + bool loadFromJson (const QJsonObject& json, QString& errorString); + + // static Members + static const char* WimaJoinedAreaName; + + // Friends + friend void print(const WimaJoinedArea& area, QString& outputString); + friend void print(const WimaJoinedArea& area); + +signals: + +public slots: + +private: + void init(); +}; + +#endif // WIMAJOINEDAREA_H diff --git a/src/Wima/WimaJoinedAreaData.cc b/src/Wima/WimaJoinedAreaData.cc new file mode 100644 index 0000000000000000000000000000000000000000..309e4c0105bf64a9d38bc94baf34f8b211e145b3 --- /dev/null +++ b/src/Wima/WimaJoinedAreaData.cc @@ -0,0 +1,61 @@ +#include "WimaJoinedAreaData.h" + +const char *WimaJoinedAreaData::typeString = "WimaJoinedAreaData"; + +WimaJoinedAreaData::WimaJoinedAreaData(QObject *parent) + :WimaAreaData (parent) +{ + +} + +WimaJoinedAreaData::WimaJoinedAreaData(const WimaJoinedAreaData &other, QObject *parent) + : WimaAreaData (parent) +{ + *this = other; +} + +WimaJoinedAreaData::WimaJoinedAreaData(const WimaJoinedArea &other, QObject *parent) + : WimaAreaData (parent) +{ + *this = other; +} + +/*! + * \overload operator=() + * + * Assigns \a other to the invoking object. + */ +WimaJoinedAreaData &WimaJoinedAreaData::operator=(const WimaJoinedAreaData &other) +{ + WimaAreaData::operator=(other); + + return *this; +} + +/*! + * \overload operator=() + * + * Assigns \a other to the invoking object. + */ +WimaJoinedAreaData &WimaJoinedAreaData::operator=(const WimaJoinedArea &other) +{ + WimaAreaData::operator=(other); + return *this; +} + +QString WimaJoinedAreaData::type() const +{ + return this->typeString; +} + + +/*! + * \class WimaAreaData::WimaJoinedAreaData + * \brief Class to store and exchange data of a \c WimaJoinedAreaData Object. + * Class to store and exchange data of a \c WimaJoinedArea Object. In contrast to \c WimaJoinedArea this class + * does not provied any interface to a grafical user interface, neiter it uses the QGC Fact System. + * It is designed to exchange data between the \c WimaPlaner and the \c WimaController class. And it + * is the derived from WimaAreaData. + * + * \sa WimaJoinedArea, WimaAreaData + */ diff --git a/src/Wima/WimaJoinedAreaData.h b/src/Wima/WimaJoinedAreaData.h new file mode 100644 index 0000000000000000000000000000000000000000..1ef83dcfb176ee944c4df4bb8f5253be767bf4aa --- /dev/null +++ b/src/Wima/WimaJoinedAreaData.h @@ -0,0 +1,31 @@ +#pragma once + +#include + +#include "WimaAreaData.h" +#include "WimaJoinedArea.h" + +#include "QGeoCoordinate" + +class WimaJoinedAreaData : public WimaAreaData +{ + Q_OBJECT + +public: + WimaJoinedAreaData(QObject *parent = nullptr); + WimaJoinedAreaData(const WimaJoinedAreaData &other, QObject *parent = nullptr); + WimaJoinedAreaData(const WimaJoinedArea &other, QObject *parent = nullptr); + WimaJoinedAreaData &operator=(const WimaJoinedAreaData &other); + WimaJoinedAreaData &operator=(const WimaJoinedArea &other); + + QString type() const; + + static const char* typeString; + +signals: + +public slots: + +private: +}; + diff --git a/src/Wima/WimaMeasurementArea.h b/src/Wima/WimaMeasurementArea.h index 02ad10af6ac9be3bd40e925bc1bd480c9137ba2b..3d73aa558fc7bce998b24e98ebda56668b8529e6 100644 --- a/src/Wima/WimaMeasurementArea.h +++ b/src/Wima/WimaMeasurementArea.h @@ -4,7 +4,6 @@ #include #include "WimaArea.h" -#include "WimaMeasurementAreaData.h" #include "SettingsFact.h" diff --git a/src/Wima/WimaMeasurementAreaData.cc b/src/Wima/WimaMeasurementAreaData.cc index f40c2f2ea14466c0ca8d9be8a6659b6fcedb126a..9d5b9e007b0c098371e2f180e0574bbaafe82f2a 100644 --- a/src/Wima/WimaMeasurementAreaData.cc +++ b/src/Wima/WimaMeasurementAreaData.cc @@ -44,3 +44,9 @@ WimaMeasurementAreaData &WimaMeasurementAreaData::operator=(const WimaMeasuremen return *this; } +QString WimaMeasurementAreaData::type() const +{ + return this->typeString; +} + + diff --git a/src/Wima/WimaMeasurementAreaData.h b/src/Wima/WimaMeasurementAreaData.h index 9b7a1e517435dfb1b0a293321e55bf8534556d71..fb6c818146e7248c6c28139d5eeb5b7dbb56f660 100644 --- a/src/Wima/WimaMeasurementAreaData.h +++ b/src/Wima/WimaMeasurementAreaData.h @@ -1,7 +1,7 @@ #pragma once #include -#include "QGeoCoordinate" +#include #include "WimaAreaData.h" @@ -20,6 +20,8 @@ public: WimaMeasurementAreaData& operator=(const WimaMeasurementAreaData &other); WimaMeasurementAreaData& operator=(const WimaMeasurementArea &other); + QString type() const; + static const char* typeString; signals: diff --git a/src/Wima/WimaPlanData.cc b/src/Wima/WimaPlanData.cc index 3aba84c11c74b4a10f7bf20906e5d3ee9be9669c..acb52193d965bf22946ffd2d639abc01da26e541 100644 --- a/src/Wima/WimaPlanData.cc +++ b/src/Wima/WimaPlanData.cc @@ -22,15 +22,16 @@ WimaPlanData &WimaPlanData::operator=(const WimaPlanData &other) { QList areaList = other.areaList(); _areaList.clear(); - for (const WimaAreaData* areaData: areaList) { + for (int i = 0; i < areaList.size(); i++) { + const WimaAreaData *areaData = areaList[i]; if (areaData->type() == WimaAreaData::typeString) { this->append(*areaData); }else if (areaData->type() == WimaServiceAreaData::typeString) { - this->append(*qobject_cast(areaData)); + this->append(*qobject_cast(areaData)); }else if (areaData->type() == WimaMeasurementAreaData::typeString) { - this->append(*qobject_cast(areaData)); + this->append(*qobject_cast(areaData)); }else if (areaData->type() == WimaCorridorData::typeString) { - this->append(*qobject_cast(areaData)); + this->append(*qobject_cast(areaData)); } } diff --git a/src/Wima/WimaPlaner.cc b/src/Wima/WimaPlaner.cc index e78c5a3bcd5668bb9bb84f95acd44b678c8ac921..e10749c7f7adc557b476b6099ace47ed217a35f0 100644 --- a/src/Wima/WimaPlaner.cc +++ b/src/Wima/WimaPlaner.cc @@ -516,7 +516,7 @@ bool WimaPlaner::recalcJoinedArea(QString &errorString) } // join service area, op area and corridor - _joinedArea = _serviceArea; + _joinedArea.WimaArea::operator=(_serviceArea); _joinedArea.join(_corridor); if ( !_joinedArea.join(_measurementArea) ) { errorString.append(tr("Not able to join areas. Service area and measurement are" @@ -576,16 +576,13 @@ void WimaPlaner::setInteractive() WimaPlanData WimaPlaner::toPlanData() { WimaPlanData planData; - /* Note: constructor call: WimaMeasuretr(mentAreaData::WimaMeasurementAreaData(const WimaMeasurementArea &other, QObject *parent) - * converts WimaMeasurementArea to WimaMeasurementAreaData, this makes: planData.appendWimaAreaData(_measurementArea); possible. - * Same for the following statements - */ planData.append(WimaMeasurementAreaData(_measurementArea)); planData.append(WimaServiceAreaData(_serviceArea)); planData.append(WimaCorridorData(_corridor)); - planData.append(WimaAreaData(_joinedArea)); + planData.append(WimaJoinedAreaData(_joinedArea)); - return WimaPlanData(planData); + + return planData; } void WimaPlaner::setMissionReady(bool ready) diff --git a/src/Wima/WimaPlaner.h b/src/Wima/WimaPlaner.h index 4b3fdbe6d0f519d33ed3e6f9fd96d6c84ee4b086..c1207ba5f23d7932b7f4a9fb08163b1d139f9a5d 100644 --- a/src/Wima/WimaPlaner.h +++ b/src/Wima/WimaPlaner.h @@ -5,15 +5,17 @@ #include "QmlObjectListModel.h" #include "WimaArea.h" -#include "WimaMeasurementArea.h" -#include "WimaServiceArea.h" -#include "WimaCorridor.h" -#include "WimaDataContainer.h" -#include "WimaPlanData.h" #include "WimaAreaData.h" +#include "WimaServiceArea.h" #include "WimaServiceAreaData.h" +#include "WimaMeasurementArea.h" #include "WimaMeasurementAreaData.h" +#include "WimaCorridor.h" #include "WimaCorridorData.h" +#include "WimaJoinedArea.h" +#include "WimaJoinedAreaData.h" +#include "WimaPlanData.h" +#include "WimaDataContainer.h" #include "PlanMasterController.h" #include "MissionController.h" @@ -129,7 +131,7 @@ private: QString _currentFile; // file for saveing WimaDataContainer *_container; // container for data exchange with WimaController QmlObjectListModel _visualItems; // contains all visible areas - WimaArea _joinedArea; // joined area fromed by _measurementArea, _serviceArea, _corridor + WimaJoinedArea _joinedArea; // joined area fromed by _measurementArea, _serviceArea, _corridor WimaMeasurementArea _measurementArea; // measurement area WimaServiceArea _serviceArea; // area for supplying WimaCorridor _corridor; // corridor connecting _measurementArea and _serviceArea diff --git a/src/Wima/WimaServiceAreaData.cc b/src/Wima/WimaServiceAreaData.cc index a07056be368d41dcc7a766e698cd464b1c522eb5..1e6f66f976078f3e53d7bc8e4618710475e62f58 100644 --- a/src/Wima/WimaServiceAreaData.cc +++ b/src/Wima/WimaServiceAreaData.cc @@ -59,6 +59,10 @@ const QGeoCoordinate &WimaServiceAreaData::landPosition() const return _landPosition; } +QString WimaServiceAreaData::type() const +{ + return this->typeString; +} /*! * \fn void WimaServiceAreaData::setTakeOffPosition(const QGeoCoordinate &newCoordinate) * Sets the takeoff position to the \a newCoordinate and emits the takeOffPositionChanged() signal, @@ -89,6 +93,7 @@ void WimaServiceAreaData::setLandPosition(const QGeoCoordinate &newCoordinate) } } + /*! * \class WimaAreaData::WimaServiceAreaData * \brief Class to store and exchange data of a \c WimaServiceArea Object. diff --git a/src/Wima/WimaServiceAreaData.h b/src/Wima/WimaServiceAreaData.h index ece5574cc5409f0dc1a42b99b07a1bfca071bea2..c6e91a7b2e5a9418d701d405c3a40291e494cb3d 100644 --- a/src/Wima/WimaServiceAreaData.h +++ b/src/Wima/WimaServiceAreaData.h @@ -22,6 +22,8 @@ public: const QGeoCoordinate &takeOffPosition() const; const QGeoCoordinate &landPosition() const; + QString type() const; + static const char* typeString; signals: