Commit e63bb142 authored by Valentin Platzgummer's avatar Valentin Platzgummer

about to add SphericalGeometryCalculus class

parent 32c7f879
...@@ -423,7 +423,8 @@ HEADERS += \ ...@@ -423,7 +423,8 @@ HEADERS += \
src/Wima/WimaMeasurementAreaData.h \ src/Wima/WimaMeasurementAreaData.h \
src/Wima/WimaPlanData.h \ src/Wima/WimaPlanData.h \
src/Wima/WimaJoinedArea.h \ src/Wima/WimaJoinedArea.h \
src/Wima/WimaJoinedAreaData.h src/Wima/WimaJoinedAreaData.h \
src/Wima/SphericalGeometryCalculus.h
SOURCES += \ SOURCES += \
src/api/QGCCorePlugin.cc \ src/api/QGCCorePlugin.cc \
src/api/QGCOptions.cc \ src/api/QGCOptions.cc \
...@@ -445,7 +446,8 @@ SOURCES += \ ...@@ -445,7 +446,8 @@ SOURCES += \
src/Wima/WimaPlanData.cc \ src/Wima/WimaPlanData.cc \
src/Wima/WimaMeasurementAreaData.cc \ src/Wima/WimaMeasurementAreaData.cc \
src/Wima/WimaJoinedArea.cc \ src/Wima/WimaJoinedArea.cc \
src/Wima/WimaJoinedAreaData.cc src/Wima/WimaJoinedAreaData.cc \
src/Wima/SphericalGeometryCalculus.cc
# #
# Unit Test specific configuration goes here (requires full debug build with all plugins) # Unit Test specific configuration goes here (requires full debug build with all plugins)
......
...@@ -200,7 +200,10 @@ FlightMap { ...@@ -200,7 +200,10 @@ FlightMap {
delegate: MapPolygon{ delegate: MapPolygon{
path: object.path; path: object.path;
border.color: "black" border.color: "black"
color: "green" color: object.type === "WimaJoinedAreaData" ? "gray"
: object.type === "WimaServiceAreaData" ? "yellow"
: object.type === "WimaMeasurementAreaData" ? "green"
: "transparent"
opacity: 0.25 opacity: 0.25
z: QGroundControl.zOrderTrajectoryLines-1 z: QGroundControl.zOrderTrajectoryLines-1
} }
......
#include "SphericalGeometryCalculus.h"
SphericalGeometryCalculus::SphericalGeometryCalculus(QObject *parent) : QObject(parent)
{
}
#ifndef SPHERICALGEOMETRYCALCULUS_H
#define SPHERICALGEOMETRYCALCULUS_H
#include <QObject>
class SphericalGeometryCalculus : public QObject
{
Q_OBJECT
public:
explicit SphericalGeometryCalculus(QObject *parent = nullptr);
signals:
public slots:
};
#endif // SPHERICALGEOMETRYCALCULUS_H
\ No newline at end of file
...@@ -28,8 +28,8 @@ public: ...@@ -28,8 +28,8 @@ public:
double maxAltitude (void) const { return _maxAltitude;} double maxAltitude (void) const { return _maxAltitude;}
// overrides from WimaArea // overrides from WimaArea
virtual QString mapVisualQML (void) const; virtual QString mapVisualQML (void) const { return ""; }
virtual QString editorQML (void) const; virtual QString editorQML (void) const { return ""; }
// Member Methodes // Member Methodes
int getClosestVertexIndex (const QGeoCoordinate& coordinate) const; int getClosestVertexIndex (const QGeoCoordinate& coordinate) const;
......
...@@ -6,47 +6,6 @@ WimaAreaData::WimaAreaData(QObject *parent) ...@@ -6,47 +6,6 @@ WimaAreaData::WimaAreaData(QObject *parent)
_maxAltitude = 0; _maxAltitude = 0;
} }
WimaAreaData::WimaAreaData(const WimaAreaData &other, QObject *parent)
: QObject (parent)
{
*this = other;
}
WimaAreaData::WimaAreaData(const WimaArea &other, QObject *parent)
: QObject (parent)
{
*this = other;
}
/*!
* \fn WimaAreaData &WimaAreaData::operator=(const WimaAreaData &otherData)
*
* Copies the maximum altitude and the path of the \c WimaAreaData \a otherData to the calling object.
* Returns a reference to the calling object.
*/
WimaAreaData &WimaAreaData::operator=(const WimaAreaData &otherData)
{
setMaxAltitude(otherData.maxAltitude());
setPath(otherData.path());
return *this;
}
/*!
* \overload operator=()
*
* Copies the maximum altitude and the path of \c WimaArea \a otherArea to the calling object.
* Returns a reference to the calling object.
*/
WimaAreaData &WimaAreaData::operator=(const WimaArea &otherArea)
{
setMaxAltitude(otherArea.maxAltitude());
setPath(otherArea.coordinateList());
return *this;
}
/*! /*!
* \fn double WimaAreaData::maxAltitude() * \fn double WimaAreaData::maxAltitude()
* *
...@@ -88,9 +47,21 @@ void WimaAreaData::setPath(const QVariantList &coordinateList) ...@@ -88,9 +47,21 @@ void WimaAreaData::setPath(const QVariantList &coordinateList)
_path.append(coordinateList); _path.append(coordinateList);
} }
/*!
* \fn void WimaAreaData::assign(const WimaAreaData &other)
*
* Assigns \a other to the invoking object
*/
void WimaAreaData::assign(const WimaAreaData &other) void WimaAreaData::assign(const WimaAreaData &other)
{ {
setMaxAltitude(other.maxAltitude());
setPath(other.path());
}
void WimaAreaData::assign(const WimaArea &other)
{
setMaxAltitude(other.maxAltitude());
setPath(other.path());
} }
......
...@@ -12,6 +12,7 @@ class WimaAreaData : public QObject // Abstract class for all WimaAreaData deriv ...@@ -12,6 +12,7 @@ class WimaAreaData : public QObject // Abstract class for all WimaAreaData deriv
public: public:
Q_PROPERTY(const QVariantList path READ path NOTIFY pathChanged) Q_PROPERTY(const QVariantList path READ path NOTIFY pathChanged)
Q_PROPERTY(QString type READ type CONSTANT)
WimaAreaData(QObject *parent = nullptr); WimaAreaData(QObject *parent = nullptr);
//WimaAreaData(const WimaAreaData &other, QObject *parent = nullptr); //WimaAreaData(const WimaAreaData &other, QObject *parent = nullptr);
...@@ -35,6 +36,7 @@ public slots: ...@@ -35,6 +36,7 @@ public slots:
protected: protected:
void assign(const WimaAreaData &other); void assign(const WimaAreaData &other);
void assign(const WimaArea &other);
private: private:
// Member Functions // Member Functions
......
...@@ -145,6 +145,7 @@ void WimaController::containerDataValidChanged(bool valid) ...@@ -145,6 +145,7 @@ void WimaController::containerDataValidChanged(bool valid)
qWarning("WimaController::containerDataValidChanged(): No container assigned!"); qWarning("WimaController::containerDataValidChanged(): No container assigned!");
} }
_localPlanDataValid = false; _localPlanDataValid = false;
_visualItems.clear();
WimaPlanData planData = _container->pull(); WimaPlanData planData = _container->pull();
// extract list with WimaAreas // extract list with WimaAreas
...@@ -152,58 +153,53 @@ void WimaController::containerDataValidChanged(bool valid) ...@@ -152,58 +153,53 @@ void WimaController::containerDataValidChanged(bool valid)
int areaCounter = 0; int areaCounter = 0;
int numAreas = 4; // extract only numAreas Areas, if there are more they are invalid and ignored 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()); qWarning() << QString("List Size: %1").arg(areaList.size());
for (int i = 0; i < areaList.size(); i++) { for (int i = 0; i < areaList.size(); i++) {
const WimaAreaData *areaData = areaList[i]; const WimaAreaData *areaData = areaList[i];
qWarning() << areaData->type(); qWarning() << areaData->type();
if (areaData->type() == WimaServiceAreaData::typeString) { // is it a service area? if (areaData->type() == WimaServiceAreaData::typeString) { // is it a service area?
//_serviceArea = *qobject_cast<WimaServiceAreaData*>(areaData); _serviceArea = *qobject_cast<const WimaServiceAreaData*>(areaData);
qWarning("Service area, wuhuuu!"); qWarning("Service area, wuhuuu!");
areaCounter++; areaCounter++;
_visualItems.append(&_serviceArea);
continue; continue;
} }
/*WimaMeasurementAreaData *measurementAreaData = qobject_cast<WimaMeasurementAreaData*>(areaData); if (areaData->type() == WimaMeasurementAreaData::typeString) { // is it a measurement area?
if (measurementAreaData != nullptr) { // is it a measurement area? _measurementArea = *qobject_cast<const WimaMeasurementAreaData*>(areaData);
_measurementArea = *measurementAreaData;
qWarning("Measurement area, wuhuuu!"); qWarning("Measurement area, wuhuuu!");
areaCounter++; areaCounter++;
_visualItems.append(&_measurementArea);
continue; continue;
} }
WimaCorridorData *corridorAreaData = qobject_cast<WimaCorridorData*>(areaData); if (areaData->type() == WimaCorridorData::typeString) { // is it a corridor?
if (corridorAreaData != nullptr) { // is it a corridor? _corridor = *qobject_cast<const WimaCorridorData*>(areaData);
_corridor = *corridorAreaData; qWarning("WimaCorridorData, wuhuuu!");
qWarning("Corridor, wuhuuu!");
areaCounter++; areaCounter++;
//_visualItems.append(&_corridor); // not needed
continue; continue;
} }
if (!joinedAreaAssigned) { // first WimaAreaData object is assumed to be the joined Area if (areaData->type() == WimaJoinedAreaData::typeString) { // is it a corridor?
_joinedArea = *areaData; _joinedArea = *qobject_cast<const WimaJoinedAreaData*>(areaData);
qWarning("Joined area, wuhuuu!"); qWarning("WimaJoinedAreaData, wuhuuu!");
areaCounter++; areaCounter++;
joinedAreaAssigned = true; _visualItems.append(&_joinedArea);
continue; continue;
}*/ }
if (areaCounter >= numAreas) if (areaCounter >= numAreas)
break; break;
} }
// append areas to _visualItems, don't append _corridor, it's not necessary to display it in flyView if (areaCounter == numAreas)
_visualItems.clear(); _localPlanDataValid = true;
//_visualItems.append(&_measurementArea);
//_visualItems.append(&_serviceArea);
_visualItems.append(&_joinedArea);
_localPlanDataValid = true;
} else { } else {
_localPlanDataValid = false; _localPlanDataValid = false;
_visualItems.clear(); _visualItems.clear();
......
...@@ -98,7 +98,7 @@ private: ...@@ -98,7 +98,7 @@ private:
QString _currentFile; // file for saveing QString _currentFile; // file for saveing
WimaDataContainer *_container; // container for data exchange with WimaController WimaDataContainer *_container; // container for data exchange with WimaController
QmlObjectListModel _visualItems; // contains all visible areas QmlObjectListModel _visualItems; // contains all visible areas
WimaAreaData _joinedArea; // joined area fromed by opArea, serArea, _corridor WimaJoinedAreaData _joinedArea; // joined area fromed by opArea, serArea, _corridor
WimaMeasurementAreaData _measurementArea; // measurement area WimaMeasurementAreaData _measurementArea; // measurement area
WimaServiceAreaData _serviceArea; // area for supplying WimaServiceAreaData _serviceArea; // area for supplying
WimaCorridorData _corridor; // corridor connecting opArea and serArea WimaCorridorData _corridor; // corridor connecting opArea and serArea
......
...@@ -27,7 +27,7 @@ WimaCorridorData::WimaCorridorData(const WimaCorridor &other, QObject *parent) ...@@ -27,7 +27,7 @@ WimaCorridorData::WimaCorridorData(const WimaCorridor &other, QObject *parent)
*/ */
WimaCorridorData &WimaCorridorData::operator=(const WimaCorridorData &other) WimaCorridorData &WimaCorridorData::operator=(const WimaCorridorData &other)
{ {
WimaAreaData::operator=(other); this->assign(other);
return *this; return *this;
} }
...@@ -39,7 +39,7 @@ WimaCorridorData &WimaCorridorData::operator=(const WimaCorridorData &other) ...@@ -39,7 +39,7 @@ WimaCorridorData &WimaCorridorData::operator=(const WimaCorridorData &other)
*/ */
WimaCorridorData &WimaCorridorData::operator=(const WimaCorridor &other) WimaCorridorData &WimaCorridorData::operator=(const WimaCorridor &other)
{ {
WimaAreaData::operator=(other); this->assign(other);
return *this; return *this;
} }
...@@ -49,6 +49,16 @@ QString WimaCorridorData::type() const ...@@ -49,6 +49,16 @@ QString WimaCorridorData::type() const
return this->typeString; return this->typeString;
} }
void WimaCorridorData::assign(const WimaCorridorData &corridorData)
{
WimaAreaData::assign(corridorData);
}
void WimaCorridorData::assign(const WimaCorridor &corridor)
{
WimaAreaData::assign(corridor);
}
/*! /*!
* \class WimaAreaData::WimaCorridorData * \class WimaAreaData::WimaCorridorData
......
...@@ -27,6 +27,10 @@ signals: ...@@ -27,6 +27,10 @@ signals:
public slots: public slots:
protected:
void assign(const WimaCorridorData &corridorData);
void assign(const WimaCorridor &corridor);
private: private:
}; };
...@@ -27,7 +27,7 @@ WimaJoinedAreaData::WimaJoinedAreaData(const WimaJoinedArea &other, QObject *par ...@@ -27,7 +27,7 @@ WimaJoinedAreaData::WimaJoinedAreaData(const WimaJoinedArea &other, QObject *par
*/ */
WimaJoinedAreaData &WimaJoinedAreaData::operator=(const WimaJoinedAreaData &other) WimaJoinedAreaData &WimaJoinedAreaData::operator=(const WimaJoinedAreaData &other)
{ {
WimaAreaData::operator=(other); assign(other);
return *this; return *this;
} }
...@@ -39,7 +39,7 @@ WimaJoinedAreaData &WimaJoinedAreaData::operator=(const WimaJoinedAreaData &othe ...@@ -39,7 +39,7 @@ WimaJoinedAreaData &WimaJoinedAreaData::operator=(const WimaJoinedAreaData &othe
*/ */
WimaJoinedAreaData &WimaJoinedAreaData::operator=(const WimaJoinedArea &other) WimaJoinedAreaData &WimaJoinedAreaData::operator=(const WimaJoinedArea &other)
{ {
WimaAreaData::operator=(other); assign(other);
return *this; return *this;
} }
...@@ -48,6 +48,17 @@ QString WimaJoinedAreaData::type() const ...@@ -48,6 +48,17 @@ QString WimaJoinedAreaData::type() const
return this->typeString; return this->typeString;
} }
void WimaJoinedAreaData::assign(const WimaJoinedAreaData &other)
{
WimaAreaData::assign(other);
}
void WimaJoinedAreaData::assign(const WimaJoinedArea &other)
{
WimaAreaData::assign(other);
}
/*! /*!
* \class WimaAreaData::WimaJoinedAreaData * \class WimaAreaData::WimaJoinedAreaData
......
...@@ -26,6 +26,10 @@ signals: ...@@ -26,6 +26,10 @@ signals:
public slots: public slots:
protected:
void assign(const WimaJoinedAreaData &other);
void assign(const WimaJoinedArea &other);
private: private:
}; };
...@@ -27,7 +27,7 @@ WimaMeasurementAreaData::WimaMeasurementAreaData(const WimaMeasurementArea &othe ...@@ -27,7 +27,7 @@ WimaMeasurementAreaData::WimaMeasurementAreaData(const WimaMeasurementArea &othe
*/ */
WimaMeasurementAreaData &WimaMeasurementAreaData::operator=(const WimaMeasurementAreaData &other) WimaMeasurementAreaData &WimaMeasurementAreaData::operator=(const WimaMeasurementAreaData &other)
{ {
WimaAreaData::operator=(other); assign(other);
return *this; return *this;
} }
...@@ -39,7 +39,7 @@ WimaMeasurementAreaData &WimaMeasurementAreaData::operator=(const WimaMeasuremen ...@@ -39,7 +39,7 @@ WimaMeasurementAreaData &WimaMeasurementAreaData::operator=(const WimaMeasuremen
*/ */
WimaMeasurementAreaData &WimaMeasurementAreaData::operator=(const WimaMeasurementArea &other) WimaMeasurementAreaData &WimaMeasurementAreaData::operator=(const WimaMeasurementArea &other)
{ {
WimaAreaData::operator=(other); assign(other);
return *this; return *this;
} }
...@@ -49,4 +49,16 @@ QString WimaMeasurementAreaData::type() const ...@@ -49,4 +49,16 @@ QString WimaMeasurementAreaData::type() const
return this->typeString; return this->typeString;
} }
void WimaMeasurementAreaData::assign(const WimaMeasurementAreaData &other)
{
WimaAreaData::assign(other);
}
void WimaMeasurementAreaData::assign(const WimaMeasurementArea &other)
{
WimaAreaData::assign(other);
}
...@@ -28,6 +28,10 @@ signals: ...@@ -28,6 +28,10 @@ signals:
public slots: public slots:
protected:
void assign(const WimaMeasurementAreaData &other);
void assign(const WimaMeasurementArea &other);
private: private:
// see WimaMeasurementArea.h for explanation // see WimaMeasurementArea.h for explanation
}; };
...@@ -24,8 +24,8 @@ WimaPlanData &WimaPlanData::operator=(const WimaPlanData &other) ...@@ -24,8 +24,8 @@ WimaPlanData &WimaPlanData::operator=(const WimaPlanData &other)
_areaList.clear(); _areaList.clear();
for (int i = 0; i < areaList.size(); i++) { for (int i = 0; i < areaList.size(); i++) {
const WimaAreaData *areaData = areaList[i]; const WimaAreaData *areaData = areaList[i];
if (areaData->type() == WimaAreaData::typeString) { if (areaData->type() == WimaJoinedAreaData::typeString) {
this->append(*areaData); this->append(*qobject_cast<const WimaJoinedAreaData*>(areaData));
}else if (areaData->type() == WimaServiceAreaData::typeString) { }else if (areaData->type() == WimaServiceAreaData::typeString) {
this->append(*qobject_cast<const WimaServiceAreaData*>(areaData)); this->append(*qobject_cast<const WimaServiceAreaData*>(areaData));
}else if (areaData->type() == WimaMeasurementAreaData::typeString) { }else if (areaData->type() == WimaMeasurementAreaData::typeString) {
...@@ -44,7 +44,7 @@ WimaPlanData &WimaPlanData::operator=(const WimaPlanData &other) ...@@ -44,7 +44,7 @@ WimaPlanData &WimaPlanData::operator=(const WimaPlanData &other)
* *
* Adds a WimaAreaData item. * Adds a WimaAreaData item.
*/ */
void WimaPlanData::append(const WimaAreaData &areaData) void WimaPlanData::append(const WimaJoinedAreaData &areaData)
{ {
_joinedArea = areaData; _joinedArea = areaData;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "WimaServiceAreaData.h" #include "WimaServiceAreaData.h"
#include "WimaCorridorData.h" #include "WimaCorridorData.h"
#include "WimaMeasurementAreaData.h" #include "WimaMeasurementAreaData.h"
#include "WimaJoinedAreaData.h"
class WimaPlanData : QObject class WimaPlanData : QObject
{ {
...@@ -16,7 +17,7 @@ public: ...@@ -16,7 +17,7 @@ public:
WimaPlanData& operator=(const WimaPlanData &other); WimaPlanData& operator=(const WimaPlanData &other);
// Member Methodes // Member Methodes
void append(const WimaAreaData &areaData); void append(const WimaJoinedAreaData &areaData);
void append(const WimaServiceAreaData &areaData); void append(const WimaServiceAreaData &areaData);
void append(const WimaCorridorData &areaData); void append(const WimaCorridorData &areaData);
void append(const WimaMeasurementAreaData &areaData); void append(const WimaMeasurementAreaData &areaData);
...@@ -30,7 +31,7 @@ signals: ...@@ -30,7 +31,7 @@ signals:
void areaListChanged(); void areaListChanged();
private: private:
WimaAreaData _joinedArea; WimaJoinedAreaData _joinedArea;
WimaServiceAreaData _serviceArea; WimaServiceAreaData _serviceArea;
WimaCorridorData _corridor; WimaCorridorData _corridor;
WimaMeasurementAreaData _measurementArea; WimaMeasurementAreaData _measurementArea;
......
...@@ -516,7 +516,7 @@ bool WimaPlaner::recalcJoinedArea(QString &errorString) ...@@ -516,7 +516,7 @@ bool WimaPlaner::recalcJoinedArea(QString &errorString)
} }
// join service area, op area and corridor // join service area, op area and corridor
_joinedArea.WimaArea::operator=(_serviceArea); _joinedArea.setPath(_serviceArea.path());
_joinedArea.join(_corridor); _joinedArea.join(_corridor);
if ( !_joinedArea.join(_measurementArea) ) { if ( !_joinedArea.join(_measurementArea) ) {
errorString.append(tr("Not able to join areas. Service area and measurement are" errorString.append(tr("Not able to join areas. Service area and measurement are"
......
...@@ -23,18 +23,14 @@ WimaServiceAreaData::WimaServiceAreaData(const WimaServiceArea &other, QObject * ...@@ -23,18 +23,14 @@ WimaServiceAreaData::WimaServiceAreaData(const WimaServiceArea &other, QObject *
WimaServiceAreaData &WimaServiceAreaData::operator=(const WimaServiceAreaData &otherData) WimaServiceAreaData &WimaServiceAreaData::operator=(const WimaServiceAreaData &otherData)
{ {
WimaAreaData::operator=(otherData); this->assign(otherData);
setLandPosition(otherData.landPosition());
setTakeOffPosition(otherData.takeOffPosition());
return *this; return *this;
} }
WimaServiceAreaData &WimaServiceAreaData::operator=(const WimaServiceArea &otherArea) WimaServiceAreaData &WimaServiceAreaData::operator=(const WimaServiceArea &otherArea)
{ {
WimaAreaData::operator=(otherArea); this->assign(otherArea);
setLandPosition(otherArea.landPosition());
setTakeOffPosition(otherArea.takeOffPosition());
return *this; return *this;
} }
...@@ -93,6 +89,20 @@ void WimaServiceAreaData::setLandPosition(const QGeoCoordinate &newCoordinate) ...@@ -93,6 +89,20 @@ void WimaServiceAreaData::setLandPosition(const QGeoCoordinate &newCoordinate)
} }
} }
void WimaServiceAreaData::assign(const WimaServiceAreaData &other)
{
WimaAreaData::assign(other);
setLandPosition(other.landPosition());
setTakeOffPosition(other.takeOffPosition());
}
void WimaServiceAreaData::assign(const WimaServiceArea &other)
{
WimaAreaData::assign(other);
setLandPosition(other.landPosition());
setTakeOffPosition(other.takeOffPosition());
}
/*! /*!
* \class WimaAreaData::WimaServiceAreaData * \class WimaAreaData::WimaServiceAreaData
......
...@@ -34,6 +34,9 @@ public slots: ...@@ -34,6 +34,9 @@ public slots:
void setTakeOffPosition(const QGeoCoordinate& newCoordinate); void setTakeOffPosition(const QGeoCoordinate& newCoordinate);
void setLandPosition(const QGeoCoordinate& newCoordinate); void setLandPosition(const QGeoCoordinate& newCoordinate);
protected:
void assign(const WimaServiceAreaData &other);
void assign(const WimaServiceArea &other);
private: private:
// see WimaServieArea.h for explanation // see WimaServieArea.h for explanation
QGeoCoordinate _takeOffPosition; QGeoCoordinate _takeOffPosition;
......
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