Commit b6bee338 authored by Valentin Platzgummer's avatar Valentin Platzgummer

updateMission working + borderPoly added

parent cc5ba699
......@@ -92,4 +92,25 @@ QGeoCoordinate WimaArea::getClosestVertex(QGeoCoordinate coordinate)
return this->vertexCoordinate(getClosestVertexIndex(coordinate));
}
QGCMapPolygon* WimaArea::toQGCPolygon(WimaArea *poly)
{
if (poly != nullptr) {
QGCMapPolygon* qgcPoly = new QGCMapPolygon(this);
qgcPoly->setPath(poly->path());
qgcPoly->setCenter(poly->center());
qgcPoly->setCenterDrag(poly->centerDrag());
qgcPoly->setInteractive(poly->interactive());
return qgcPoly;
} else {
qWarning("WimaArea::toQGCPolygon(): poly == nullptr");
return nullptr;
}
}
QGCMapPolygon *WimaArea::joinPolygons(QList<QGCMapPolygon *> polyList)
{
}
......@@ -39,7 +39,9 @@ public:
//iterates over all vertices in _polygon and returns the index of that one closest to coordinate
int getClosestVertexIndex (QGeoCoordinate coordinate);
//iterates over all vertices in _polygon and returns that one closest to coordinate
QGeoCoordinate getClosestVertex (QGeoCoordinate coordinate);
QGeoCoordinate getClosestVertex (QGeoCoordinate coordinate);
QGCMapPolygon* toQGCPolygon (WimaArea* poly);
QGCMapPolygon* joinPolygons (QList<QGCMapPolygon*> polyList);
signals:
void maxAltitudeChanged (void);
......
......@@ -90,7 +90,7 @@ bool WimaController::addVehicleCorridor(WimaGOperationArea *opArea, WimaServiceA
bool newCorridorCreated = false;
if(corridor == nullptr){
corridor = new WimaVCorridor(this);
corridor = new WimaVCorridor(opArea);
newCorridorCreated = true;
}else {
corridor->clear();
......@@ -175,15 +175,42 @@ bool WimaController::updateMission()
return false;
}
// create survey mission, will be extened with more mission types in the future
int secNumber = _missionController->insertComplexMissionItem(_missionController->surveyComplexItemName(), new QGeoCoordinate(), _missionController->visualItems()->count());
SurveyComplexItem* survey = qobject_cast<SurveyComplexItem*>(_missionController->visualItems()->get(secNumber));
if (survey != nullptr)
{
survey->
}else{
// reset visual items
_missionController->removeAll();
QmlObjectListModel* missionItems = _missionController->visualItems();
// set home position to serArea center
MissionSettingsItem* settingsItem= qobject_cast<MissionSettingsItem*>(missionItems->get(0));
if (settingsItem == nullptr){
qWarning("WimaController::updateMission(): settingsItem == nullptr");
return false;
}
settingsItem->setCoordinate(serArea->center());
// set take off position item
_missionController->insertSimpleMissionItem(serArea->center(), 1);
// create survey item, will be extened with more mission types in the future
_missionController->insertComplexMissionItem(_missionController->surveyComplexItemName(), opArea->center(), 2);
SurveyComplexItem* survey = qobject_cast<SurveyComplexItem*>(missionItems->get(missionItems->count()-1));
if (survey == nullptr){
qWarning("WimaController::updateMission(): survey == nullptr");
return false;
} else {
survey->surveyAreaPolygon()->clear();
survey->surveyAreaPolygon()->appendVertices(opArea->coordinateList());
}
// create land position item
_missionController->insertSimpleMissionItem(serArea->center(), 3);
SimpleMissionItem* landItem = qobject_cast<SimpleMissionItem*>(missionItems->get(missionItems->count()-1));
if (landItem == nullptr){
qWarning("WimaController::updateMission(): landItem == nullptr");
return false;
} else {
Vehicle* controllerVehicle = _masterController->controllerVehicle();
MAV_CMD landCmd = controllerVehicle->vtol() ? MAV_CMD_NAV_VTOL_LAND : MAV_CMD_NAV_LAND;
if (controllerVehicle->firmwarePlugin()->supportedMissionCommands().contains(landCmd)) {
landItem->setCommand(landCmd);
}
}
return true;
}
void WimaController::saveMission()
......@@ -213,19 +240,28 @@ void WimaController::recalcAll()
void WimaController::recalcPolygonInteractivity(int index)
{
resetAllIsCurrentPolygon();
WimaArea* interactivePoly = qobject_cast<WimaArea*>(_visualItems->get(index));
interactivePoly->setInteractive(true);
if (index >= 0 && index < _visualItems->count()) {
resetAllInteractive();
WimaArea* interactivePoly = qobject_cast<WimaArea*>(_visualItems->get(index));
interactivePoly->setInteractive(true);
}
}
void WimaController::resetAllIsCurrentPolygon()
void WimaController::resetAllInteractive()
{
int itemCount = _visualItems->count();
for (int i = 0; i < itemCount; i++) {
WimaArea* iteratorPoly = qobject_cast<WimaArea*>(_visualItems->get(i));
iteratorPoly->setInteractive(false);
if (itemCount > 0){
for (int i = 0; i < itemCount; i++) {
WimaArea* iteratorPoly = qobject_cast<WimaArea*>(_visualItems->get(i));
iteratorPoly->setInteractive(false);
}
}
}
void WimaController::setInteractive()
{
recalcPolygonInteractivity(_currentPolygonIndex);
}
......@@ -12,6 +12,8 @@
#include "PlanMasterController.h"
#include "MissionController.h"
#include "SurveyComplexItem.h"
#include "SimpleMissionItem.h"
#include "MissionSettingsItem.h"
class WimaController : public QObject
......@@ -60,7 +62,8 @@ public:
Q_INVOKABLE void saveMission();
Q_INVOKABLE void loadMission();
Q_INVOKABLE void resetAllIsCurrentPolygon(void);
Q_INVOKABLE void resetAllInteractive(void);
Q_INVOKABLE void setInteractive(void);
......
......@@ -23,5 +23,14 @@
"min": 0,
"decimalPlaces": 2,
"defaultValue": 10
},
{
"name": "BorderPolygonOffset",
"shortDescription": "The distance between the Operation Area and it's surounding Border Polygon.",
"type": "double",
"units": "m",
"min": 0,
"decimalPlaces": 1,
"defaultValue": 5
}
]
......@@ -5,6 +5,7 @@ const char* WimaGOperationArea::settingsGroup = "OperatingArea
const char* WimaGOperationArea::bottomLayerAltitudeName = "BottomLayerAltitude";
const char* WimaGOperationArea::numberOfLayersName = "NumberOfLayers";
const char* WimaGOperationArea::layerDistanceName = "LayerDistance";
const char* WimaGOperationArea::borderPolygonOffsetName = "BorderPolygonOffset";
WimaGOperationArea::WimaGOperationArea(QObject *parent)
: WimaGOperationArea (nullptr, parent)
......@@ -18,10 +19,14 @@ WimaGOperationArea::WimaGOperationArea(WimaArea *other, QObject *parent)
, _bottomLayerAltitude (settingsGroup, _metaDataMap[bottomLayerAltitudeName])
, _numberOfLayers (settingsGroup, _metaDataMap[numberOfLayersName])
, _layerDistance (settingsGroup, _metaDataMap[layerDistanceName])
, _borderPolygonOffset (settingsGroup, _metaDataMap[borderPolygonOffsetName])
, _polyline (new WimaTrackerPolyline(this))
, _borderPolygon (new QGCMapPolygon(this))
{
this->setObjectName("Operating Area");
this->setObjectName("Operation Area");
_polyline.bindPolygon(this);
connect(this, &WimaGOperationArea::pathChanged, this, &WimaGOperationArea::recalcBorderPolygon);
connect(&_borderPolygonOffset, &SettingsFact::rawValueChanged, this, &WimaGOperationArea::recalcBorderPolygon);
//qWarning("Here I am!");
//connect(&_polyline, &WimaTrackerPolyline::pathChanged, this, &WimaGOperationArea::polylineChanged );
}
......@@ -57,6 +62,17 @@ void WimaGOperationArea::setVehicleCorridor(WimaVCorridor *corridor)
}
}
void WimaGOperationArea::recalcBorderPolygon()
{
//qWarning("WimaGOperationArea::recalcBorderPolygon() %f", _borderPolygonOffset.rawValue().toDouble());
QGCMapPolygon* polyCopy = this->toQGCPolygon(this);
polyCopy->offset(_borderPolygonOffset.rawValue().toDouble());
_borderPolygon.setPath(polyCopy->path());
polyCopy->deleteLater();
emit borderPolygonChanged();
}
/*void WimaGOperationArea::recalculatesubPolygons()
{
int vehicleCount = _vehicleList->count();
......
......@@ -15,12 +15,14 @@ public:
WimaGOperationArea(QObject* parent = nullptr);
WimaGOperationArea(WimaArea* other, QObject* parent = nullptr);
Q_PROPERTY(Fact* bottomLayerAltitude READ bottomLayerAltitude CONSTANT)
Q_PROPERTY(Fact* numberOfLayers READ numberOfLayers CONSTANT)
Q_PROPERTY(Fact* layerDistance READ layerDistance CONSTANT)
Q_PROPERTY(Fact* bottomLayerAltitude READ bottomLayerAltitude CONSTANT)
Q_PROPERTY(Fact* numberOfLayers READ numberOfLayers CONSTANT)
Q_PROPERTY(Fact* layerDistance READ layerDistance CONSTANT)
Q_PROPERTY(Fact* borderPolygonOffset READ borderPolygonOffset CONSTANT)
/*Q_PROPERTY(QmlObjectListModel* vehicleList READ vehicleList NOTIFY vehicleListChanged)
Q_PROPERTY(QmlObjectListModel* vehiclePolygons READ vehiclePolygons NOTIFY vehiclePolygonsChanged)*/
Q_PROPERTY(WimaTrackerPolyline* polyline READ polyline CONSTANT)
Q_PROPERTY(QGCMapPolygon* borderPolygon READ borderPolygon NOTIFY borderPolygonChanged)
Q_INVOKABLE void addVehicle (WimaVehicle *vehicle);
......@@ -41,16 +43,19 @@ public:
Fact* bottomLayerAltitude (void) { return &_bottomLayerAltitude;}
Fact* numberOfLayers (void) { return &_numberOfLayers;}
Fact* layerDistance (void) { return &_layerDistance;}
Fact* borderPolygonOffset (void) { return &_borderPolygonOffset;}
/*QmlObjectListModel* vehicleList (void) const { return _vehicleList;}
QmlObjectListModel* vehiclePolygons (void) const { return _vehiclePolygons;}*/
WimaTrackerPolyline* polyline (void) { return &_polyline;}
WimaVCorridor* vehicleCorridor (void) { return _vehicleCorridor;}
QGCMapPolygon* borderPolygon (void) { return &_borderPolygon;}
static const char* settingsGroup;
static const char* bottomLayerAltitudeName;
static const char* numberOfLayersName;
static const char* layerDistanceName;
static const char* borderPolygonOffsetName;
signals:
......@@ -61,6 +66,11 @@ signals:
void polylineChanged (void);
//void vehiclePolygonsChanged (void);
void vehicleCorridorChanged (WimaVCorridor* corridor);
void borderPolygonChanged (void);
private slots:
void recalcBorderPolygon (void);
private:
QMap<QString, FactMetaData*> _metaDataMap;
......@@ -68,12 +78,14 @@ private:
SettingsFact _bottomLayerAltitude;
SettingsFact _numberOfLayers;
SettingsFact _layerDistance;
SettingsFact _borderPolygonOffset;
/*QmlObjectListModel* _vehicleList;
QmlObjectListModel* _vehiclePolygons;*/
WimaTrackerPolyline _polyline;
WimaVCorridor* _vehicleCorridor;
QGCMapPolygon _borderPolygon;
......
......@@ -85,7 +85,7 @@ Rectangle {
columns: 2
QGCLabel {
text: qsTr("Bottom Layer Altitude")
text: qsTr("Bottom Layer Alt.")
}
FactTextField {
fact: areaItem.bottomLayerAltitude
......@@ -104,6 +104,12 @@ Rectangle {
Layout.fillWidth: true
}
QGCLabel { text: qsTr("Border Offset") }
FactTextField {
fact: areaItem.borderPolygonOffset
Layout.fillWidth: true
}
}
......
......@@ -28,6 +28,7 @@ Item {
property var areaItem: object
property var _polygon: areaItem
property var _polyline: areaItem.polyline
property var _borderPolygon: areaItem.borderPolygon
signal clicked(int sequenceNumber)
......@@ -89,6 +90,16 @@ Item {
interiorOpacity: 0.25
}
WimaMapPolygonVisuals {
qgcView: _root.qgcView
mapControl: map
mapPolygon: _borderPolygon
borderWidth: 1
borderColor: "white"
interiorColor: "transparent"
interiorOpacity: 1
}
WimaMapPolylineVisuals {
qgcView: _root.qgcView
......
......@@ -756,9 +756,11 @@ QGCView {
switch (current) {
case planElementMission:
_editingLayer = _layerMission
_wimaController.resetAllInteractive();
break
case planElementWima:
_editingLayer = _layerWima
_wimaController.setInteractive();
break
}
}
......
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