diff --git a/src/MissionManager/Survey.SettingsGroup.json b/src/MissionManager/Survey.SettingsGroup.json index 2690fdd..2f61020 100644 --- a/src/MissionManager/Survey.SettingsGroup.json +++ b/src/MissionManager/Survey.SettingsGroup.json @@ -14,5 +14,11 @@ "shortDescription": "Fly every other transect in each pass.", "type": "bool", "defaultValue": false +}, +{ + "name": "SplitConcavePolygons", + "shortDescription": "Split mission concave polygons into separate regular, convex polygons.", + "type": "bool", + "defaultValue": true } ] diff --git a/src/MissionManager/SurveyComplexItem.cc b/src/MissionManager/SurveyComplexItem.cc index 8f4cc91..07bc974 100644 --- a/src/MissionManager/SurveyComplexItem.cc +++ b/src/MissionManager/SurveyComplexItem.cc @@ -28,6 +28,7 @@ const char* SurveyComplexItem::settingsGroup = "Survey"; const char* SurveyComplexItem::gridAngleName = "GridAngle"; const char* SurveyComplexItem::gridEntryLocationName = "GridEntryLocation"; const char* SurveyComplexItem::flyAlternateTransectsName = "FlyAlternateTransects"; +const char* SurveyComplexItem::splitConcavePolygonsName = "SplitConcavePolygons"; const char* SurveyComplexItem::_jsonGridAngleKey = "angle"; const char* SurveyComplexItem::_jsonEntryPointKey = "entryLocation"; @@ -58,12 +59,14 @@ const char* SurveyComplexItem::_jsonV3CameraOrientationLandscapeKey = "orienta const char* SurveyComplexItem::_jsonV3FixedValueIsAltitudeKey = "fixedValueIsAltitude"; const char* SurveyComplexItem::_jsonV3Refly90DegreesKey = "refly90Degrees"; const char* SurveyComplexItem::_jsonFlyAlternateTransectsKey = "flyAlternateTransects"; +const char* SurveyComplexItem::_jsonSplitConcavePolygonsKey = "splitConcavePolygons"; SurveyComplexItem::SurveyComplexItem(Vehicle* vehicle, bool flyView, const QString& kmlFile, QObject* parent) : TransectStyleComplexItem (vehicle, flyView, settingsGroup, parent) , _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/Survey.SettingsGroup.json"), this)) , _gridAngleFact (settingsGroup, _metaDataMap[gridAngleName]) , _flyAlternateTransectsFact(settingsGroup, _metaDataMap[flyAlternateTransectsName]) + , _splitConcavePolygonsFact (settingsGroup, _metaDataMap[splitConcavePolygonsName]) , _entryPoint (EntryLocationTopLeft) { _editorQml = "qrc:/qml/SurveyItemEditor.qml"; @@ -82,14 +85,14 @@ SurveyComplexItem::SurveyComplexItem(Vehicle* vehicle, bool flyView, const QStri connect(&_gridAngleFact, &Fact::valueChanged, this, &SurveyComplexItem::_setDirty); connect(&_flyAlternateTransectsFact,&Fact::valueChanged, this, &SurveyComplexItem::_setDirty); + connect(&_splitConcavePolygonsFact, &Fact::valueChanged, this, &SurveyComplexItem::_setDirty); connect(this, &SurveyComplexItem::refly90DegreesChanged, this, &SurveyComplexItem::_setDirty); connect(&_gridAngleFact, &Fact::valueChanged, this, &SurveyComplexItem::_rebuildTransects); connect(&_flyAlternateTransectsFact,&Fact::valueChanged, this, &SurveyComplexItem::_rebuildTransects); + connect(&_splitConcavePolygonsFact, &Fact::valueChanged, this, &SurveyComplexItem::_rebuildTransects); connect(this, &SurveyComplexItem::refly90DegreesChanged, this, &SurveyComplexItem::_rebuildTransects); - connect(qgcApp()->toolbox()->settingsManager()->appSettings()->splitConcavePolygons(), &Fact::valueChanged, this, &SurveyComplexItem::_rebuildTransects); - // FIXME: Shouldn't these be in TransectStyleComplexItem? They are also in CorridorScanComplexItem constructur connect(&_cameraCalc, &CameraCalc::distanceToSurfaceRelativeChanged, this, &SurveyComplexItem::coordinateHasRelativeAltitudeChanged); connect(&_cameraCalc, &CameraCalc::distanceToSurfaceRelativeChanged, this, &SurveyComplexItem::exitCoordinateHasRelativeAltitudeChanged); @@ -112,6 +115,7 @@ void SurveyComplexItem::save(QJsonArray& planItems) saveObject[ComplexMissionItem::jsonComplexItemTypeKey] = jsonComplexItemTypeValue; saveObject[_jsonGridAngleKey] = _gridAngleFact.rawValue().toDouble(); saveObject[_jsonFlyAlternateTransectsKey] = _flyAlternateTransectsFact.rawValue().toBool(); + saveObject[_jsonSplitConcavePolygonsKey] = _splitConcavePolygonsFact.rawValue().toBool(); saveObject[_jsonEntryPointKey] = _entryPoint; // Polygon shape @@ -168,6 +172,7 @@ bool SurveyComplexItem::_loadV4(const QJsonObject& complexObject, int sequenceNu { _jsonEntryPointKey, QJsonValue::Double, true }, { _jsonGridAngleKey, QJsonValue::Double, true }, { _jsonFlyAlternateTransectsKey, QJsonValue::Bool, false }, + { _jsonSplitConcavePolygonsKey, QJsonValue::Bool, false }, }; if (!JsonHelper::validateKeys(complexObject, keyInfoList, errorString)) { return false; @@ -196,6 +201,7 @@ bool SurveyComplexItem::_loadV4(const QJsonObject& complexObject, int sequenceNu _gridAngleFact.setRawValue (complexObject[_jsonGridAngleKey].toDouble()); _flyAlternateTransectsFact.setRawValue (complexObject[_jsonFlyAlternateTransectsKey].toBool(false)); + _splitConcavePolygonsFact.setRawValue (complexObject[_jsonSplitConcavePolygonsKey].toBool(true)); _entryPoint = complexObject[_jsonEntryPointKey].toInt(); @@ -1062,7 +1068,7 @@ bool SurveyComplexItem::_hoverAndCaptureEnabled(void) const void SurveyComplexItem::_rebuildTransectsPhase1(void) { - bool split = qgcApp()->toolbox()->settingsManager()->appSettings()->splitConcavePolygons()->rawValue().toBool(); + bool split = splitConcavePolygons()->rawValue().toBool(); if (split) { _rebuildTransectsPhase1WorkerSplitPolygons(false /* refly */); } else { @@ -1087,7 +1093,7 @@ void SurveyComplexItem::_rebuildTransectsPhase1WorkerSinglePolygon(bool refly) if (_loadedMissionItemsParent) { _loadedMissionItems.clear(); _loadedMissionItemsParent->deleteLater(); - _loadedMissionItemsParent = NULL; + _loadedMissionItemsParent = nullptr; } // First pass will clear old transect data, refly will append to existing data @@ -1260,7 +1266,7 @@ void SurveyComplexItem::_rebuildTransectsPhase1WorkerSinglePolygon(bool refly) double transectLength = transect[0].distanceTo(transect[1]); double transectAzimuth = transect[0].azimuthTo(transect[1]); if (triggerDistance() < transectLength) { - int cInnerHoverPoints = floor(transectLength / triggerDistance()); + int cInnerHoverPoints = static_cast(floor(transectLength / triggerDistance())); qCDebug(SurveyComplexItemLog) << "cInnerHoverPoints" << cInnerHoverPoints; for (int i=0; ideleteLater(); - _loadedMissionItemsParent = NULL; + _loadedMissionItemsParent = nullptr; } // First pass will clear old transect data, refly will append to existing data @@ -1669,7 +1675,7 @@ void SurveyComplexItem::_rebuildTranscetsFromPolygon(bool refly, const QPolygonF double transectLength = transect[0].distanceTo(transect[1]); double transectAzimuth = transect[0].azimuthTo(transect[1]); if (triggerDistance() < transectLength) { - int cInnerHoverPoints = floor(transectLength / triggerDistance()); + int cInnerHoverPoints = static_cast(floor(transectLength / triggerDistance())); qCDebug(SurveyComplexItemLog) << "cInnerHoverPoints" << cInnerHoverPoints; for (int i=0; i("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only"); @@ -429,13 +427,3 @@ Fact* AppSettings::followTarget(void) return _followTargetFact; } - -Fact* AppSettings::splitConcavePolygons(void) -{ - if (!_splitConcavePolygonsFact) { - _splitConcavePolygonsFact = _createSettingsFact(splitConcavePolygonsName); - } - - return _splitConcavePolygonsFact; -} - diff --git a/src/Settings/AppSettings.h b/src/Settings/AppSettings.h index b12bdf5..2887a90 100644 --- a/src/Settings/AppSettings.h +++ b/src/Settings/AppSettings.h @@ -18,7 +18,7 @@ class AppSettings : public SettingsGroup Q_OBJECT public: - AppSettings(QObject* parent = NULL); + AppSettings(QObject* parent = nullptr); Q_PROPERTY(Fact* offlineEditingFirmwareType READ offlineEditingFirmwareType CONSTANT) Q_PROPERTY(Fact* offlineEditingVehicleType READ offlineEditingVehicleType CONSTANT) @@ -43,7 +43,6 @@ public: Q_PROPERTY(Fact* defaultFirmwareType READ defaultFirmwareType CONSTANT) Q_PROPERTY(Fact* gstDebug READ gstDebug CONSTANT) Q_PROPERTY(Fact* followTarget READ followTarget CONSTANT) - Q_PROPERTY(Fact* splitConcavePolygons READ splitConcavePolygons CONSTANT) Q_PROPERTY(QString missionSavePath READ missionSavePath NOTIFY savePathsChanged) Q_PROPERTY(QString parameterSavePath READ parameterSavePath NOTIFY savePathsChanged) @@ -83,7 +82,6 @@ public: Fact* defaultFirmwareType (void); Fact* gstDebug (void); Fact* followTarget (void); - Fact* splitConcavePolygons (void); QString missionSavePath (void); QString parameterSavePath (void); @@ -121,7 +119,6 @@ public: static const char* defaultFirmwareTypeName; static const char* gstDebugName; static const char* followTargetName; - static const char* splitConcavePolygonsName; // Application wide file extensions static const char* parameterFileExtension; @@ -173,7 +170,6 @@ private: SettingsFact* _defaultFirmwareTypeFact; SettingsFact* _gstDebugFact; SettingsFact* _followTargetFact; - SettingsFact* _splitConcavePolygonsFact; }; #endif