Commit 32c7f879 authored by Valentin Platzgummer's avatar Valentin Platzgummer

befor editing WimaAreaData

parent 22be1d1a
......@@ -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)
......
......@@ -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;
......
#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<QGeoCoordinate> &coordinateList)
......
......@@ -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<QGeoCoordinate> &coordinateList);
void setPath(const QVariantList &coordinateList);
protected:
void assign(const WimaAreaData &other);
private:
// Member Functions
......
......@@ -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<WimaServiceAreaData*>(areaData);
//_serviceArea = *qobject_cast<WimaServiceAreaData*>(areaData);
qWarning("Service area, wuhuuu!");
areaCounter++;
continue;
}
WimaMeasurementAreaData *measurementAreaData = qobject_cast<WimaMeasurementAreaData*>(areaData);
/*WimaMeasurementAreaData *measurementAreaData = qobject_cast<WimaMeasurementAreaData*>(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();
}
......
......@@ -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.
......
......@@ -18,6 +18,8 @@ public:
WimaCorridorData &operator=(const WimaCorridorData &other);
WimaCorridorData &operator=(const WimaCorridor &other);
QString type() const;
static const char* typeString;
......
#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<const WimaArea&>(area), outputString);
}
/*!
\class WimaJoinedArea
\brief Joined area (derived from \c WimaArea) composed by the \c WimaMeasurementArea, the \c WimaCorridor, and the \c WimaServiceArea.
*/
#ifndef WIMAJOINEDAREA_H
#define WIMAJOINEDAREA_H
#include <QObject>
#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
#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
*/
#pragma once
#include <QObject>
#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:
};
......@@ -4,7 +4,6 @@
#include <QObject>
#include "WimaArea.h"
#include "WimaMeasurementAreaData.h"
#include "SettingsFact.h"
......
......@@ -44,3 +44,9 @@ WimaMeasurementAreaData &WimaMeasurementAreaData::operator=(const WimaMeasuremen
return *this;
}
QString WimaMeasurementAreaData::type() const
{
return this->typeString;
}
#pragma once
#include <QObject>
#include "QGeoCoordinate"
#include <QGeoCoordinate>
#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:
......
......@@ -22,15 +22,16 @@ WimaPlanData &WimaPlanData::operator=(const WimaPlanData &other)
{
QList<const WimaAreaData*> 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<WimaServiceAreaData*>(areaData));
this->append(*qobject_cast<const WimaServiceAreaData*>(areaData));
}else if (areaData->type() == WimaMeasurementAreaData::typeString) {
this->append(*qobject_cast<WimaMeasurementAreaData*>(areaData));
this->append(*qobject_cast<const WimaMeasurementAreaData*>(areaData));
}else if (areaData->type() == WimaCorridorData::typeString) {
this->append(*qobject_cast<WimaCorridorData*>(areaData));
this->append(*qobject_cast<const WimaCorridorData*>(areaData));
}
}
......
......@@ -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)
......
......@@ -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
......
......@@ -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.
......
......@@ -22,6 +22,8 @@ public:
const QGeoCoordinate &takeOffPosition() const;
const QGeoCoordinate &landPosition() const;
QString type() const;
static const char* typeString;
signals:
......
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