Commit 6256464b authored by Valentin Platzgummer's avatar Valentin Platzgummer

saveToJson works

parent c82f5a2a
...@@ -6,28 +6,41 @@ const char* WimaArea::wimaAreaName = "WimaArea"; ...@@ -6,28 +6,41 @@ const char* WimaArea::wimaAreaName = "WimaArea";
const char* WimaArea::areaTypeName = "AreaType"; const char* WimaArea::areaTypeName = "AreaType";
WimaArea::WimaArea(QObject *parent) : WimaArea::WimaArea()
WimaArea (nullptr, parent) : QGCMapPolygon (nullptr)
{ {
//qWarning() << "WimaPolygon:: polygon count" << _polygon->count(); this->setObjectName(wimaAreaName);
_maxAltitude = 30;
_wimaVehicle = new WimaVehicle(this);
} }
WimaArea::WimaArea(QGCMapPolygon *other, QObject *parent) WimaArea::WimaArea(QObject *parent)
: QGCMapPolygon (other, parent) : QGCMapPolygon (parent)
{ {
this->setObjectName(wimaAreaName); this->setObjectName(wimaAreaName);
WimaArea* wimaPoly = qobject_cast<WimaArea*>(other);
if (wimaPoly != nullptr) {
_maxAltitude = wimaPoly->maxAltitude();
_wimaVehicle = wimaPoly->vehicle();
} else {
_maxAltitude = 30; _maxAltitude = 30;
_wimaVehicle = new WimaVehicle(this); _wimaVehicle = new WimaVehicle(this);
}
} }
WimaArea::WimaArea(const QGCMapPolygon &other, QObject *parent)
: QGCMapPolygon (other, parent)
{
this->setObjectName(wimaAreaName);
_maxAltitude = 30;
_wimaVehicle = new WimaVehicle(this);
}
WimaArea::WimaArea(const WimaArea &other, QObject *parent)
: WimaArea (parent)
{
this->setObjectName(wimaAreaName);
this->setPath(other.path());
this->setCenter(other.center());
this->setCenterDrag(other.centerDrag());
this->setInteractive(other.interactive());
_maxAltitude = other.maxAltitude();
_wimaVehicle = other.vehicle();
}
void WimaArea::setMaxAltitude(double alt) void WimaArea::setMaxAltitude(double alt)
...@@ -38,7 +51,6 @@ void WimaArea::setMaxAltitude(double alt) ...@@ -38,7 +51,6 @@ void WimaArea::setMaxAltitude(double alt)
} }
} }
void WimaArea::setVehicle(WimaVehicle *vehicle) void WimaArea::setVehicle(WimaVehicle *vehicle)
{ {
if(_wimaVehicle != vehicle){ if(_wimaVehicle != vehicle){
...@@ -94,15 +106,15 @@ QGeoCoordinate WimaArea::getClosestVertex(const QGeoCoordinate& coordinate) cons ...@@ -94,15 +106,15 @@ QGeoCoordinate WimaArea::getClosestVertex(const QGeoCoordinate& coordinate) cons
return this->vertexCoordinate(getClosestVertexIndex(coordinate)); return this->vertexCoordinate(getClosestVertexIndex(coordinate));
} }
QGCMapPolygon &WimaArea::toQGCPolygon(const WimaArea &poly) const QGCMapPolygon WimaArea::toQGCPolygon(const WimaArea &poly) const
{ {
QGCMapPolygon* qgcPoly = new QGCMapPolygon(); QGCMapPolygon qgcPoly;
qgcPoly->setPath(poly.path()); qgcPoly.setPath(poly.path());
qgcPoly->setCenter(poly.center()); qgcPoly.setCenter(poly.center());
qgcPoly->setCenterDrag(poly.centerDrag()); qgcPoly.setCenterDrag(poly.centerDrag());
qgcPoly->setInteractive(poly.interactive()); qgcPoly.setInteractive(poly.interactive());
return *qgcPoly; return QGCMapPolygon(qgcPoly);
} }
void WimaArea::join(QList<WimaArea *>* polyList, WimaArea* joinedPoly) void WimaArea::join(QList<WimaArea *>* polyList, WimaArea* joinedPoly)
...@@ -110,18 +122,16 @@ void WimaArea::join(QList<WimaArea *>* polyList, WimaArea* joinedPoly) ...@@ -110,18 +122,16 @@ void WimaArea::join(QList<WimaArea *>* polyList, WimaArea* joinedPoly)
return; return;
} }
void WimaArea::join(const WimaArea &poly1, const WimaArea &poly2, WimaArea &joinedPoly) void WimaArea::join(WimaArea &poly1, WimaArea &poly2, WimaArea &joinedPoly)
{ {
if (poly1.count() >= 3 && poly2.count() >= 3) { if (poly1.count() >= 3 && poly2.count() >= 3) {
WimaArea cpoly1(poly1); poly1.verifyClockwiseWinding();
WimaArea cpoly2(poly2); poly2.verifyClockwiseWinding();
cpoly1.verifyClockwiseWinding();
cpoly2.verifyClockwiseWinding();
WimaArea* walkerPoly = &cpoly1; // "walk" on this polygon towards higher indices WimaArea* walkerPoly = &poly1; // "walk" on this polygon towards higher indices
WimaArea* crossPoly = &cpoly2; // check for crossings with this polygon while "walking" WimaArea* crossPoly = &poly2; // check for crossings with this polygon while "walking"
// and swicht to this polygon on a intersection, // and swicht to this polygon on a intersection,
// continue to walk towards higher indices // continue to walk towards higher indices
...@@ -160,7 +170,7 @@ void WimaArea::join(const WimaArea &poly1, const WimaArea &poly2, WimaArea &join ...@@ -160,7 +170,7 @@ void WimaArea::join(const WimaArea &poly1, const WimaArea &poly2, WimaArea &join
QList<QPair<int, int>> neighbourList; QList<QPair<int, int>> neighbourList;
QList<QGeoCoordinate> intersectionList; QList<QGeoCoordinate> intersectionList;
//qDebug("IntersectionList.size() on init: %i", intersectionList.size()); //qDebug("IntersectionList.size() on init: %i", intersectionList.size());
intersects(walkerPolySegment, crossPoly, intersectionList, neighbourList); intersects(walkerPolySegment, *crossPoly, intersectionList, neighbourList);
//qDebug("IntersectionList.size(): %i", intersectionList.size()); //qDebug("IntersectionList.size(): %i", intersectionList.size());
...@@ -215,10 +225,10 @@ void WimaArea::join(const WimaArea &poly1, const WimaArea &poly2, WimaArea &join ...@@ -215,10 +225,10 @@ void WimaArea::join(const WimaArea &poly1, const WimaArea &poly2, WimaArea &join
} }
} }
void WimaArea::join(const WimaArea &poly) void WimaArea::join(WimaArea &poly)
{ {
WimaArea joinedArea(this); WimaArea joinedArea;
join(this, poly, joinedArea); join(*this, poly, joinedArea);
this->setPath(joinedArea.path()); this->setPath(joinedArea.path());
return; return;
} }
...@@ -302,7 +312,7 @@ bool WimaArea::intersects(const QGCMapPolyline &line1, const QGCMapPolyline &lin ...@@ -302,7 +312,7 @@ bool WimaArea::intersects(const QGCMapPolyline &line1, const QGCMapPolyline &lin
QPointF pt21(x, y); QPointF pt21(x, y);
convertGeoToNed(line2.vertexCoordinate(1), origin, &x, &y, &z); convertGeoToNed(line2.vertexCoordinate(1), origin, &x, &y, &z);
QPointF pt22(x, y); QPointF pt22(x, y);;
QLineF kartLine2(pt21, pt22); QLineF kartLine2(pt21, pt22);
...@@ -377,6 +387,8 @@ double WimaArea::distInsidePoly(const QGeoCoordinate &c1, const QGeoCoordinate & ...@@ -377,6 +387,8 @@ double WimaArea::distInsidePoly(const QGeoCoordinate &c1, const QGeoCoordinate &
//if ( intersectionList.size() == (c1InPolyRim || c2InPolyRim ? 2:0) ){ //if ( intersectionList.size() == (c1InPolyRim || c2InPolyRim ? 2:0) ){
if ( intersectionList.size() == 0 ){ if ( intersectionList.size() == 0 ){
return c1.distanceTo(c2); return c1.distanceTo(c2);
} else {
return std::numeric_limits<qreal>::infinity();
} }
} else { } else {
......
...@@ -15,8 +15,10 @@ class WimaArea : public QGCMapPolygon //abstract base class for all WimaAreas ...@@ -15,8 +15,10 @@ class WimaArea : public QGCMapPolygon //abstract base class for all WimaAreas
{ {
Q_OBJECT Q_OBJECT
public: public:
WimaArea(QObject* parent = nullptr); WimaArea();
WimaArea(QGCMapPolygon* other = nullptr, QObject* parent = nullptr); WimaArea(QObject* parent);
WimaArea(const QGCMapPolygon& other, QObject* parent);
WimaArea(const WimaArea& other, QObject* parent);
...@@ -45,13 +47,13 @@ public: ...@@ -45,13 +47,13 @@ public:
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 //iterates over all vertices in _polygon and returns that one closest to coordinate
QGeoCoordinate getClosestVertex (const QGeoCoordinate& coordinate) const; QGeoCoordinate getClosestVertex (const QGeoCoordinate& coordinate) const;
QGCMapPolygon& toQGCPolygon (const WimaArea& poly) const; QGCMapPolygon toQGCPolygon (const WimaArea& poly) const;
static void join (QList<WimaArea*>* polyList, WimaArea* joinedPoly);// change to & notation 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) /// 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 /// see https://en.wikipedia.org/wiki/Simple_polygon
/// @return the joined polygon of poly1 and poly2 if possible, poly1 else /// @return the joined polygon of poly1 and poly2 if possible, poly1 else
static void join (const WimaArea& poly1, const WimaArea& poly2, WimaArea& joinedPoly); static void join (WimaArea &poly1, WimaArea &poly2, WimaArea& joinedPoly);
void join (const WimaArea& poly); void join (WimaArea &poly);
bool isDisjunct (QList<WimaArea*>* polyList);// change to & notation, if necessary bool isDisjunct (QList<WimaArea*>* polyList);// change to & notation, if necessary
bool isDisjunct (WimaArea* poly1, WimaArea* poly2);// change to & notation, if necessary bool isDisjunct (WimaArea* poly1, WimaArea* poly2);// change to & notation, if necessary
/// calculates the next polygon vertex index /// calculates the next polygon vertex index
......
...@@ -11,6 +11,16 @@ WimaController::WimaController(QObject *parent) : ...@@ -11,6 +11,16 @@ WimaController::WimaController(QObject *parent) :
connect(this, &WimaController::currentPolygonIndexChanged, this, &WimaController::recalcPolygonInteractivity); connect(this, &WimaController::currentPolygonIndexChanged, this, &WimaController::recalcPolygonInteractivity);
} }
QStringList WimaController::loadNameFilters() const
{
QStringList filters;
filters << tr("Supported types (*.%1)").arg(wimaFileExtension) <<
tr("All Files (*.*)");
return filters;
}
void WimaController::setMasterController(PlanMasterController *masterC) void WimaController::setMasterController(PlanMasterController *masterC)
{ {
_masterController = masterC; _masterController = masterC;
...@@ -106,6 +116,7 @@ void WimaController::resumeMission() ...@@ -106,6 +116,7 @@ void WimaController::resumeMission()
bool WimaController::updateMission() bool WimaController::updateMission()
{ {
#define debug 0
// pick first WimaGOperationArea // pick first WimaGOperationArea
WimaGOperationArea* opArea = nullptr; WimaGOperationArea* opArea = nullptr;
for (int i = 0; i < _visualItems->count(); i++) { for (int i = 0; i < _visualItems->count(); i++) {
...@@ -115,6 +126,8 @@ bool WimaController::updateMission() ...@@ -115,6 +126,8 @@ bool WimaController::updateMission()
break; break;
} }
} }
if (opArea == nullptr)
return false;
// pick first WimaServiceArea // pick first WimaServiceArea
WimaServiceArea* serArea = nullptr; WimaServiceArea* serArea = nullptr;
...@@ -125,6 +138,8 @@ bool WimaController::updateMission() ...@@ -125,6 +138,8 @@ bool WimaController::updateMission()
break; break;
} }
} }
if ( serArea == nullptr )
return false;
// pick first WimaVCorridor // pick first WimaVCorridor
WimaVCorridor* corridor = nullptr; WimaVCorridor* corridor = nullptr;
...@@ -135,18 +150,20 @@ bool WimaController::updateMission() ...@@ -135,18 +150,20 @@ bool WimaController::updateMission()
break; break;
} }
} }
// join service area and op area // join service area and op area
WimaArea joinedArea(this); WimaArea joinedArea;
if (corridor != nullptr) { if (corridor != nullptr) {
WimaArea::join(*corridor, *serArea, joinedArea); WimaArea::join(*corridor, *serArea, joinedArea);
joinedArea.join(*opArea); joinedArea.join(*opArea);
} else { } else {
WimaArea::join(serArea, opArea, joinedArea); WimaArea::join(*serArea, *opArea, joinedArea);
} }
#if debug
WimaArea* joinedAreaPt = new WimaArea(joinedArea, this);
_visualItems->append(joinedAreaPt);
#endif
_visualItems->append(&joinedArea);
// reset visual items // reset visual items
...@@ -208,6 +225,8 @@ bool WimaController::updateMission() ...@@ -208,6 +225,8 @@ bool WimaController::updateMission()
} }
} }
saveToFile("TestFile");
return true; return true;
} }
...@@ -306,21 +325,21 @@ QJsonDocument WimaController::saveToJson() ...@@ -306,21 +325,21 @@ QJsonDocument WimaController::saveToJson()
if (opArea != nullptr) { if (opArea != nullptr) {
opArea->saveToJson(json); opArea->saveToJson(json);
jsonArray.append(json); jsonArray.append(json);
break; continue;
} }
WimaServiceArea* serArea = qobject_cast<WimaServiceArea*>(area); WimaServiceArea* serArea = qobject_cast<WimaServiceArea*>(area);
if (serArea != nullptr) { if (serArea != nullptr) {
serArea->saveToJson(json); serArea->saveToJson(json);
jsonArray.append(json); jsonArray.append(json);
break; continue;
} }
WimaVCorridor* corridor = qobject_cast<WimaVCorridor*>(area); WimaVCorridor* corridor = qobject_cast<WimaVCorridor*>(area);
if (corridor != nullptr) { if (corridor != nullptr) {
corridor->saveToJson(json); corridor->saveToJson(json);
jsonArray.append(json); jsonArray.append(json);
break; continue;
} }
// if non of the obove branches was trigger, type must be WimaArea // if non of the obove branches was trigger, type must be WimaArea
......
...@@ -28,6 +28,8 @@ public: ...@@ -28,6 +28,8 @@ public:
Q_PROPERTY(QmlObjectListModel* visualItems READ visualItems NOTIFY visualItemsChanged) Q_PROPERTY(QmlObjectListModel* visualItems READ visualItems NOTIFY visualItemsChanged)
Q_PROPERTY(int currentPolygonIndex READ currentPolygonIndex WRITE setCurrentPolygonIndex NOTIFY currentPolygonIndexChanged) Q_PROPERTY(int currentPolygonIndex READ currentPolygonIndex WRITE setCurrentPolygonIndex NOTIFY currentPolygonIndexChanged)
Q_PROPERTY(const QString currentFile READ currentFile NOTIFY currentFileChanged) Q_PROPERTY(const QString currentFile READ currentFile NOTIFY currentFileChanged)
Q_PROPERTY(QStringList loadNameFilters READ loadNameFilters CONSTANT)
Q_PROPERTY(QString fileExtenstion READ fileExtenstion CONSTANT)
// Property accessors // Property accessors
...@@ -35,8 +37,9 @@ public: ...@@ -35,8 +37,9 @@ public:
MissionController* missionController (void) const { return _missionController; } MissionController* missionController (void) const { return _missionController; }
QmlObjectListModel* visualItems (void) const { return _visualItems; } QmlObjectListModel* visualItems (void) const { return _visualItems; }
int currentPolygonIndex (void) const { return _currentPolygonIndex; } int currentPolygonIndex (void) const { return _currentPolygonIndex; }
const QString& currentFile (void) const { return _currentFile; } const QString currentFile (void) const { return _currentFile; }
QStringList loadNameFilters (void) const;
QString fileExtenstion (void) const { return wimaFileExtension; }
......
...@@ -8,14 +8,14 @@ const char* WimaGOperationArea::layerDistanceName = "LayerDistance ...@@ -8,14 +8,14 @@ const char* WimaGOperationArea::layerDistanceName = "LayerDistance
const char* WimaGOperationArea::borderPolygonOffsetName = "BorderPolygonOffset"; const char* WimaGOperationArea::borderPolygonOffsetName = "BorderPolygonOffset";
const char* WimaGOperationArea::wimaGOperationAreaName = "Operation Area"; const char* WimaGOperationArea::wimaGOperationAreaName = "Operation Area";
WimaGOperationArea::WimaGOperationArea(QObject *parent) WimaGOperationArea::WimaGOperationArea()
: WimaGOperationArea (nullptr, parent) : WimaGOperationArea(nullptr)
{ {
} }
WimaGOperationArea::WimaGOperationArea(WimaArea *other, QObject *parent) WimaGOperationArea::WimaGOperationArea(QObject *parent)
: WimaArea(other, parent) : WimaArea (parent)
, _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/WimaGOperationArea.SettingsGroup.json"), this /* QObject parent */)) , _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/WimaGOperationArea.SettingsGroup.json"), this /* QObject parent */))
, _bottomLayerAltitude (settingsGroup, _metaDataMap[bottomLayerAltitudeName]) , _bottomLayerAltitude (settingsGroup, _metaDataMap[bottomLayerAltitudeName])
, _numberOfLayers (settingsGroup, _metaDataMap[numberOfLayersName]) , _numberOfLayers (settingsGroup, _metaDataMap[numberOfLayersName])
...@@ -26,10 +26,22 @@ WimaGOperationArea::WimaGOperationArea(WimaArea *other, QObject *parent) ...@@ -26,10 +26,22 @@ WimaGOperationArea::WimaGOperationArea(WimaArea *other, QObject *parent)
this->setObjectName(wimaGOperationAreaName); this->setObjectName(wimaGOperationAreaName);
connect(this, &WimaGOperationArea::pathChanged, this, &WimaGOperationArea::recalcBorderPolygon); connect(this, &WimaGOperationArea::pathChanged, this, &WimaGOperationArea::recalcBorderPolygon);
connect(&_borderPolygonOffset, &SettingsFact::rawValueChanged, this, &WimaGOperationArea::recalcBorderPolygon); connect(&_borderPolygonOffset, &SettingsFact::rawValueChanged, this, &WimaGOperationArea::recalcBorderPolygon);
//qWarning("Here I am!");
//connect(&_polyline, &WimaTrackerPolyline::pathChanged, this, &WimaGOperationArea::polylineChanged );
} }
WimaGOperationArea::WimaGOperationArea(const WimaArea &other, QObject *parent)
: WimaArea(other, parent)
, _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/WimaGOperationArea.SettingsGroup.json"), this /* QObject parent */))
, _bottomLayerAltitude (settingsGroup, _metaDataMap[bottomLayerAltitudeName])
, _numberOfLayers (settingsGroup, _metaDataMap[numberOfLayersName])
, _layerDistance (settingsGroup, _metaDataMap[layerDistanceName])
, _borderPolygonOffset (settingsGroup, _metaDataMap[borderPolygonOffsetName])
, _borderPolygon (new QGCMapPolygon(this))
{
this->setObjectName(wimaGOperationAreaName);
connect(this, &WimaGOperationArea::pathChanged, this, &WimaGOperationArea::recalcBorderPolygon);
connect(&_borderPolygonOffset, &SettingsFact::rawValueChanged, this, &WimaGOperationArea::recalcBorderPolygon);
}
void WimaGOperationArea::addVehicle(WimaVehicle *vehicle) void WimaGOperationArea::addVehicle(WimaVehicle *vehicle)
{ {
if(vehicle != nullptr){ if(vehicle != nullptr){
...@@ -113,7 +125,7 @@ bool WimaGOperationArea::loadFromJson(const QJsonObject &json, QString& errorStr ...@@ -113,7 +125,7 @@ bool WimaGOperationArea::loadFromJson(const QJsonObject &json, QString& errorStr
void WimaGOperationArea::recalcBorderPolygon() void WimaGOperationArea::recalcBorderPolygon()
{ {
//qWarning("WimaGOperationArea::recalcBorderPolygon() %f", _borderPolygonOffset.rawValue().toDouble()); //qWarning("WimaGOperationArea::recalcBorderPolygon() %f", _borderPolygonOffset.rawValue().toDouble());
QGCMapPolygon polyCopy = this->toQGCPolygon(this); QGCMapPolygon polyCopy = this->toQGCPolygon(*this);
polyCopy.offset(_borderPolygonOffset.rawValue().toDouble()); polyCopy.offset(_borderPolygonOffset.rawValue().toDouble());
_borderPolygon.setPath(polyCopy.path()); _borderPolygon.setPath(polyCopy.path());
polyCopy.deleteLater(); polyCopy.deleteLater();
......
...@@ -12,8 +12,9 @@ class WimaGOperationArea : public WimaArea ...@@ -12,8 +12,9 @@ class WimaGOperationArea : public WimaArea
{ {
Q_OBJECT Q_OBJECT
public: public:
WimaGOperationArea(QObject* parent = nullptr); WimaGOperationArea();
WimaGOperationArea(WimaArea* other, QObject* parent = nullptr); WimaGOperationArea(QObject* parent);
WimaGOperationArea(const WimaArea& other, QObject* parent = nullptr);
Q_PROPERTY(Fact* bottomLayerAltitude READ bottomLayerAltitude CONSTANT) Q_PROPERTY(Fact* bottomLayerAltitude READ bottomLayerAltitude CONSTANT)
Q_PROPERTY(Fact* numberOfLayers READ numberOfLayers CONSTANT) Q_PROPERTY(Fact* numberOfLayers READ numberOfLayers CONSTANT)
...@@ -88,10 +89,6 @@ private: ...@@ -88,10 +89,6 @@ private:
QmlObjectListModel* _vehiclePolygons;*/ QmlObjectListModel* _vehiclePolygons;*/
WimaVCorridor* _vehicleCorridor; WimaVCorridor* _vehicleCorridor;
QGCMapPolygon _borderPolygon; QGCMapPolygon _borderPolygon;
}; };
...@@ -2,14 +2,20 @@ ...@@ -2,14 +2,20 @@
const char* WimaServiceArea::wimaServiceAreaName = "Service Area"; const char* WimaServiceArea::wimaServiceAreaName = "Service Area";
WimaServiceArea::WimaServiceArea(QObject *parent): WimaServiceArea::WimaServiceArea()
WimaServiceArea (nullptr, parent) : WimaServiceArea(nullptr)
{ {
} }
WimaServiceArea::WimaServiceArea(WimaArea *other, QObject *parent): WimaServiceArea::WimaServiceArea(QObject *parent)
WimaArea (other, parent) : WimaArea (parent)
{
this->setObjectName(wimaServiceAreaName);
}
WimaServiceArea::WimaServiceArea(const WimaArea &other, QObject *parent)
: WimaArea (other, parent)
{ {
this->setObjectName(wimaServiceAreaName); this->setObjectName(wimaServiceAreaName);
} }
......
...@@ -8,8 +8,9 @@ class WimaServiceArea : public WimaArea ...@@ -8,8 +8,9 @@ class WimaServiceArea : public WimaArea
{ {
Q_OBJECT Q_OBJECT
public: public:
WimaServiceArea(QObject* parent = nullptr); WimaServiceArea();
WimaServiceArea(WimaArea* other = nullptr, QObject* parent = nullptr); WimaServiceArea(QObject* parent);
WimaServiceArea(const WimaArea& other, QObject* parent);
Q_PROPERTY(const QGeoCoordinate& takeOffPosition READ takeOffPosition WRITE setTakeOffPosition NOTIFY takeOffPositionChanged) Q_PROPERTY(const QGeoCoordinate& takeOffPosition READ takeOffPosition WRITE setTakeOffPosition NOTIFY takeOffPositionChanged)
Q_PROPERTY(const QGeoCoordinate& landPosition READ landPosition WRITE setLandPosition NOTIFY landPositionChanged) Q_PROPERTY(const QGeoCoordinate& landPosition READ landPosition WRITE setLandPosition NOTIFY landPositionChanged)
...@@ -22,7 +23,7 @@ public: ...@@ -22,7 +23,7 @@ public:
// Property acessors // Property acessors
const QGeoCoordinate& takeOffPosition (void) const { return _takeOffPosition;} const QGeoCoordinate& takeOffPosition (void) const { return _takeOffPosition;}
const QGeoCoordinate& landPosition (void) const { return _landPosition;} const QGeoCoordinate& landPosition (void) const { return _landPosition;}
WimaVCorridor& vehicleCorridor (void) const { return *_vehicleCorridor;} WimaVCorridor *vehicleCorridor (void) const { return _vehicleCorridor;}
// Property setters // Property setters
......
...@@ -2,16 +2,24 @@ ...@@ -2,16 +2,24 @@
const char* WimaVCorridor::wimaVCorridorName = "Corridor"; const char* WimaVCorridor::wimaVCorridorName = "Corridor";
WimaVCorridor::WimaVCorridor(QObject *parent): WimaVCorridor::WimaVCorridor()
WimaVCorridor(nullptr, parent) : WimaVCorridor(nullptr)
{ {
} }
WimaVCorridor::WimaVCorridor(WimaArea *other, QObject *parent): WimaVCorridor::WimaVCorridor(QObject *parent)
WimaArea (other, parent) : WimaArea (parent)
,_serviceArea (nullptr) , _serviceArea (nullptr)
,_opArea (nullptr) , _opArea (nullptr)
{
this->setObjectName(wimaVCorridorName);
}
WimaVCorridor::WimaVCorridor(const WimaArea &other, QObject *parent)
: WimaArea (other, parent)
, _serviceArea (nullptr)
, _opArea (nullptr)
{ {
this->setObjectName(wimaVCorridorName); this->setObjectName(wimaVCorridorName);
} }
......
...@@ -9,8 +9,9 @@ class WimaVCorridor : public WimaArea ...@@ -9,8 +9,9 @@ class WimaVCorridor : public WimaArea
{ {
Q_OBJECT Q_OBJECT
public: public:
WimaVCorridor(QObject* parent = nullptr); WimaVCorridor();
WimaVCorridor(WimaArea* other = nullptr, QObject* parent = nullptr); WimaVCorridor(QObject* parent);
WimaVCorridor(const WimaArea& other, QObject* parent);
// Overrides from WimaPolygon // Overrides from WimaPolygon
QString mapVisualQML (void) const { return "WimaVCorridorMapVisual.qml";} QString mapVisualQML (void) const { return "WimaVCorridorMapVisual.qml";}
...@@ -19,8 +20,8 @@ public: ...@@ -19,8 +20,8 @@ public:
// Methodes // Methodes
void setServiceArea (WimaServiceArea& serviceArea); void setServiceArea (WimaServiceArea& serviceArea);
void setOpArea (WimaGOperationArea& opArea); void setOpArea (WimaGOperationArea& opArea);
WimaServiceArea& serviceArea (void) const {return *_serviceArea;} WimaServiceArea* serviceArea (void) const {return _serviceArea;}
WimaGOperationArea& opArea (void) const {return *_opArea;} WimaGOperationArea* opArea (void) const {return _opArea;}
void saveToJson (QJsonObject& json); void saveToJson (QJsonObject& json);
bool loadFromJson (const QJsonObject& json, QString& errorString); bool loadFromJson (const QJsonObject& json, QString& errorString);
......
...@@ -27,21 +27,21 @@ Rectangle { ...@@ -27,21 +27,21 @@ Rectangle {
property real _margin: ScreenTools.defaultFontPixelWidth / 2 property real _margin: ScreenTools.defaultFontPixelWidth / 2
property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5 property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5
property var polyline: areaItem.polyline //property var polyline: areaItem.polyline
property bool polylineInteractive: polyline.interactive //property bool polylineInteractive: polyline.interactive
property bool polygonInteractive: areaItem.interactive property bool polygonInteractive: areaItem.interactive
property var polygon: areaItem property var polygon: areaItem
property bool initNecesarry: true property bool initNecesarry: true
onPolylineInteractiveChanged: { /*onPolylineInteractiveChanged: {
polyline.interactive = polylineInteractive; polyline.interactive = polylineInteractive;
} }*/
onPolygonInteractiveChanged: { onPolygonInteractiveChanged: {
polygon.interactive = polygonInteractive; polygon.interactive = polygonInteractive;
} }
function editPolyline(){ /*function editPolyline(){
if (polylineInteractive){ if (polylineInteractive){
//polyline.interactive = false; //polyline.interactive = false;
polylineInteractive = false; polylineInteractive = false;
...@@ -51,7 +51,7 @@ Rectangle { ...@@ -51,7 +51,7 @@ Rectangle {
polylineInteractive = true; polylineInteractive = true;
//polygonInteractive = false; //polygonInteractive = false;
} }
} }*/
...@@ -120,7 +120,7 @@ Rectangle { ...@@ -120,7 +120,7 @@ Rectangle {
width: 1 width: 1
} }
} // Column - Settings } // Column - Settings
SectionHeader { /*SectionHeader {
id: polylineHeader id: polylineHeader
text: qsTr("Gateway Poly Line") text: qsTr("Gateway Poly Line")
} }
...@@ -143,7 +143,7 @@ Rectangle { ...@@ -143,7 +143,7 @@ Rectangle {
text: "Swap End-Points" text: "Swap End-Points"
onClicked: polyline.swapEndPoints() onClicked: polyline.swapEndPoints()
} }*/
SectionHeader { SectionHeader {
id: statsHeader id: statsHeader
......
...@@ -27,7 +27,6 @@ Item { ...@@ -27,7 +27,6 @@ Item {
property var areaItem: object property var areaItem: object
property var _polygon: areaItem property var _polygon: areaItem
property var _polyline: areaItem.polyline
property var _borderPolygon: areaItem.borderPolygon property var _borderPolygon: areaItem.borderPolygon
signal clicked(int sequenceNumber) signal clicked(int sequenceNumber)
...@@ -64,16 +63,16 @@ Item { ...@@ -64,16 +63,16 @@ Item {
} }
} }
function _addInitialPolyline(){ /*function _addInitialPolyline(){
_polyline.setStartVertexIndex(0); _polyline.setStartVertexIndex(0);
_polyline.setEndVertexIndex(1); _polyline.setEndVertexIndex(1);
} }*/
Component.onCompleted: { Component.onCompleted: {
_addInitialPolygon() _addInitialPolygon()
_addInitialPolyline() //_addInitialPolyline()
} }
Component.onDestruction: { Component.onDestruction: {
...@@ -101,7 +100,7 @@ Item { ...@@ -101,7 +100,7 @@ Item {
} }
WimaMapPolylineVisuals { /*WimaMapPolylineVisuals {
qgcView: _root.qgcView qgcView: _root.qgcView
mapControl: map mapControl: map
mapPolyline: _polyline mapPolyline: _polyline
...@@ -110,6 +109,6 @@ Item { ...@@ -110,6 +109,6 @@ Item {
enableSplitHandels: false enableSplitHandels: false
enableDragHandels: true enableDragHandels: true
edgeHandelsOnly: true edgeHandelsOnly: true
} }*/
} }
...@@ -27,21 +27,21 @@ Rectangle { ...@@ -27,21 +27,21 @@ Rectangle {
property real _margin: ScreenTools.defaultFontPixelWidth / 2 property real _margin: ScreenTools.defaultFontPixelWidth / 2
property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5 property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5
property var polyline: areaItem.polyline //property var polyline: areaItem.polyline
property bool polylineInteractive: polyline.interactive //property bool polylineInteractive: polyline.interactive
property bool polygonInteractive: areaItem.interactive property bool polygonInteractive: areaItem.interactive
property var polygon: areaItem property var polygon: areaItem
property bool initNecesarry: true property bool initNecesarry: true
onPolylineInteractiveChanged: { /*onPolylineInteractiveChanged: {
polyline.interactive = polylineInteractive; polyline.interactive = polylineInteractive;
} }*/
onPolygonInteractiveChanged: { onPolygonInteractiveChanged: {
polygon.interactive = polygonInteractive; polygon.interactive = polygonInteractive;
} }
function editPolyline(){ /*function editPolyline(){
if (polylineInteractive){ if (polylineInteractive){
//polyline.interactive = false; //polyline.interactive = false;
polylineInteractive = false; polylineInteractive = false;
...@@ -51,7 +51,7 @@ Rectangle { ...@@ -51,7 +51,7 @@ Rectangle {
polylineInteractive = true; polylineInteractive = true;
//polygonInteractive = false; //polygonInteractive = false;
} }
} }*/
...@@ -112,7 +112,7 @@ Rectangle { ...@@ -112,7 +112,7 @@ Rectangle {
width: 1 width: 1
} }
} // Column - Scan } // Column - Scan
SectionHeader { /*SectionHeader {
id: polylineHeader id: polylineHeader
text: qsTr("Gateway Poly Line") text: qsTr("Gateway Poly Line")
} }
...@@ -135,7 +135,7 @@ Rectangle { ...@@ -135,7 +135,7 @@ Rectangle {
text: "Swap End-Points" text: "Swap End-Points"
onClicked: polyline.swapEndPoints() onClicked: polyline.swapEndPoints()
} }*/
SectionHeader { SectionHeader {
id: statsHeader id: statsHeader
......
...@@ -27,7 +27,7 @@ Item { ...@@ -27,7 +27,7 @@ Item {
property var areaItem: object property var areaItem: object
property var _polygon: areaItem property var _polygon: areaItem
property var _polyline: areaItem.polyline //property var _polyline: areaItem.polyline
signal clicked(int sequenceNumber) signal clicked(int sequenceNumber)
...@@ -63,16 +63,16 @@ Item { ...@@ -63,16 +63,16 @@ Item {
} }
} }
function _addInitialPolyline(){ /*function _addInitialPolyline(){
_polyline.setStartVertexIndex(0); _polyline.setStartVertexIndex(0);
_polyline.setEndVertexIndex(1); _polyline.setEndVertexIndex(1);
} }*/
Component.onCompleted: { Component.onCompleted: {
_addInitialPolygon() _addInitialPolygon()
_addInitialPolyline() //_addInitialPolyline()
} }
Component.onDestruction: { Component.onDestruction: {
...@@ -88,7 +88,7 @@ Item { ...@@ -88,7 +88,7 @@ Item {
interiorOpacity: 0.25 interiorOpacity: 0.25
} }
WimaMapPolylineVisuals { /*WimaMapPolylineVisuals {
qgcView: _root.qgcView qgcView: _root.qgcView
mapControl: map mapControl: map
mapPolyline: _polyline mapPolyline: _polyline
...@@ -97,5 +97,5 @@ Item { ...@@ -97,5 +97,5 @@ Item {
enableSplitHandels: false enableSplitHandels: false
enableDragHandels: true enableDragHandels: true
edgeHandelsOnly: true edgeHandelsOnly: true
} }*/
} }
...@@ -96,7 +96,7 @@ QGCView { ...@@ -96,7 +96,7 @@ QGCView {
MapFitFunctions { MapFitFunctions {
id: mapFitFunctions // The name for this id cannot be changed without breaking references outside of this code. Beware! id: mapFitFunctions // The name for this id cannot be changed without breaking references outside of this code. Beware!
map: editorMap map: editorMap
usePlannedHomePosition: true usePlannedHomePosition: masterController
planMasterController: _planMasterController planMasterController: _planMasterController
} }
...@@ -177,6 +177,14 @@ QGCView { ...@@ -177,6 +177,14 @@ QGCView {
wimaController.masterController = Qt.binding(function () { return masterController}) wimaController.masterController = Qt.binding(function () { return masterController})
wimaController.missionController = Qt.binding(function () { return masterController.missionController}) wimaController.missionController = Qt.binding(function () { return masterController.missionController})
} }
function loadFromSelectedFile() {
wimaFileDialog.title = qsTr("Select Wima File")
wimaFileDialog.selectExisting = true
wimaFileDialog.nameFilters = wimaController.loadNameFilters
wimaFileDialog.fileExtension = wimaController.fileExtension
wimaFileDialog.openForLoad()
}
} }
PlanMasterController { PlanMasterController {
...@@ -318,6 +326,22 @@ QGCView { ...@@ -318,6 +326,22 @@ QGCView {
} }
} }
QGCFileDialog {
id: wimaFileDialog
qgcView: _qgcView
folder: _appSettings.missionSavePath
onAcceptedForSave: {
wimaController.saveToFile(file)
close()
}
onAcceptedForLoad: {
wimaController.loadFromFile(file)
close()
}
}
property string polygonSelectPatternFile property string polygonSelectPatternFile
Component { Component {
id: patternPolygonSelectDialog id: patternPolygonSelectDialog
...@@ -559,11 +583,11 @@ QGCView { ...@@ -559,11 +583,11 @@ QGCView {
color: qgcPal.window color: qgcPal.window
title: qsTr("Plan") title: qsTr("Plan")
z: QGroundControl.zOrderWidgets z: QGroundControl.zOrderWidgets
showAlternateIcon: [ masterController.dirty, false, false, false, false, false, false ] showAlternateIcon: [ masterController.dirty, false, false, false, false, false, false, false, false ]
rotateImage: [ masterController.syncInProgress, false, false, false, false, false, false ] rotateImage: [ masterController.syncInProgress, false, false, false, false, false, false, false, false ]
animateImage: [ masterController.dirty, false, false, false, false, false, false ] animateImage: [ masterController.dirty, false, false, false, false, false, false, false, false ]
buttonEnabled: [ !masterController.syncInProgress, true, true, true, true, true, true ] buttonEnabled: [ !masterController.syncInProgress, true, true, true, true, true, true, true, true ]
buttonVisible: [ true, true, true, true, true, _showZoom, _showZoom ] buttonVisible: [ true, true, true, true, true, true, true, _showZoom, _showZoom ]
maxHeight: mapScale.y - toolStrip.y maxHeight: mapScale.y - toolStrip.y
property bool _showZoom: !ScreenTools.isMobile property bool _showZoom: !ScreenTools.isMobile
...@@ -1003,7 +1027,7 @@ QGCView { ...@@ -1003,7 +1027,7 @@ QGCView {
id: columnHolder id: columnHolder
spacing: _margin spacing: _margin
property string _overwriteText: (_editingLayer == _layerMission) ? qsTr("Mission overwrite") : ((_editingLayer == _layerGeoFence) ? qsTr("GeoFence overwrite") : qsTr("Rally Points overwrite")) property string _overwriteText: qsTr("Mission overwrite")
QGCLabel { QGCLabel {
width: sendSaveGrid.width width: sendSaveGrid.width
...@@ -1142,6 +1166,8 @@ QGCView { ...@@ -1142,6 +1166,8 @@ QGCView {
Rectangle { Rectangle {
id: debugMessageWindow id: debugMessageWindow
visible: false
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
width: parent.width*0.7 width: parent.width*0.7
x: (parent.width-width)/2 x: (parent.width-width)/2
...@@ -1170,9 +1196,4 @@ QGCView { ...@@ -1170,9 +1196,4 @@ QGCView {
} }
} }
} // QGCVIew } // QGCVIew
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