diff --git a/src/MissionManager/SurveyComplexItem.cc b/src/MissionManager/SurveyComplexItem.cc index c4bb728c224a6c2f54079486a120ece556066b2d..4df64aa29588fc96799daa1588426a5552d75775 100644 --- a/src/MissionManager/SurveyComplexItem.cc +++ b/src/MissionManager/SurveyComplexItem.cc @@ -29,14 +29,14 @@ const char* SurveyComplexItem::gridAngleName = "GridAngle"; const char* SurveyComplexItem::gridEntryLocationName = "GridEntryLocation"; const char* SurveyComplexItem::_jsonGridAngleKey = "angle"; -const char* SurveyComplexItem::_jsonGridEntryLocationKey = "entryLocation"; +const char* SurveyComplexItem::_jsonEntryPointKey = "entryLocation"; const char* SurveyComplexItem::_jsonV3GridObjectKey = "grid"; const char* SurveyComplexItem::_jsonV3GridAltitudeKey = "altitude"; const char* SurveyComplexItem::_jsonV3GridAltitudeRelativeKey = "relativeAltitude"; const char* SurveyComplexItem::_jsonV3GridAngleKey = "angle"; const char* SurveyComplexItem::_jsonV3GridSpacingKey = "spacing"; -const char* SurveyComplexItem::_jsonV3GridEntryLocationKey = "entryLocation"; +const char* SurveyComplexItem::_jsonV3EntryPointKey = "entryLocation"; const char* SurveyComplexItem::_jsonV3TurnaroundDistKey = "turnAroundDistance"; const char* SurveyComplexItem::_jsonV3CameraTriggerDistanceKey = "cameraTriggerDistance"; const char* SurveyComplexItem::_jsonV3CameraTriggerInTurnaroundKey = "cameraTriggerInTurnaround"; @@ -62,7 +62,7 @@ SurveyComplexItem::SurveyComplexItem(Vehicle* vehicle, bool flyView, QObject* pa : TransectStyleComplexItem (vehicle, flyView, settingsGroup, parent) , _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/Survey.SettingsGroup.json"), this)) , _gridAngleFact (settingsGroup, _metaDataMap[gridAngleName]) - , _gridEntryLocationFact (settingsGroup, _metaDataMap[gridEntryLocationName]) + , _entryPoint (EntryLocationTopLeft) { _editorQml = "qrc:/qml/SurveyItemEditor.qml"; @@ -79,11 +79,9 @@ SurveyComplexItem::SurveyComplexItem(Vehicle* vehicle, bool flyView, QObject* pa } connect(&_gridAngleFact, &Fact::valueChanged, this, &SurveyComplexItem::_setDirty); - connect(&_gridEntryLocationFact, &Fact::valueChanged, this, &SurveyComplexItem::_setDirty); connect(this, &SurveyComplexItem::refly90DegreesChanged, this, &SurveyComplexItem::_setDirty); connect(&_gridAngleFact, &Fact::valueChanged, this, &SurveyComplexItem::_rebuildTransects); - connect(&_gridEntryLocationFact, &Fact::valueChanged, this, &SurveyComplexItem::_rebuildTransects); connect(this, &SurveyComplexItem::refly90DegreesChanged, this, &SurveyComplexItem::_rebuildTransects); // FIXME: Shouldn't these be in TransectStyleComplexItem? They are also in CorridorScanComplexItem constructur @@ -101,7 +99,7 @@ void SurveyComplexItem::save(QJsonArray& planItems) saveObject[VisualMissionItem::jsonTypeKey] = VisualMissionItem::jsonTypeComplexItemValue; saveObject[ComplexMissionItem::jsonComplexItemTypeKey] = jsonComplexItemTypeValue; saveObject[_jsonGridAngleKey] = _gridAngleFact.rawValue().toDouble(); - saveObject[_jsonGridEntryLocationKey] = _gridEntryLocationFact.rawValue().toInt(); + saveObject[_jsonEntryPointKey] = _entryPoint; // Polygon shape _surveyAreaPolygon.saveToJson(saveObject); @@ -154,7 +152,7 @@ bool SurveyComplexItem::_loadV4(const QJsonObject& complexObject, int sequenceNu QList keyInfoList = { { VisualMissionItem::jsonTypeKey, QJsonValue::String, true }, { ComplexMissionItem::jsonComplexItemTypeKey, QJsonValue::String, true }, - { _jsonGridEntryLocationKey, QJsonValue::Double, true }, + { _jsonEntryPointKey, QJsonValue::Double, true }, { _jsonGridAngleKey, QJsonValue::Double, true }, }; if (!JsonHelper::validateKeys(complexObject, keyInfoList, errorString)) { @@ -183,7 +181,7 @@ bool SurveyComplexItem::_loadV4(const QJsonObject& complexObject, int sequenceNu } _gridAngleFact.setRawValue(complexObject[_jsonGridAngleKey].toDouble()); - _gridEntryLocationFact.setRawValue(complexObject[_jsonGridEntryLocationKey].toInt()); + _entryPoint = complexObject[_jsonEntryPointKey].toInt(); _ignoreRecalc = false; @@ -234,7 +232,7 @@ bool SurveyComplexItem::_loadV3(const QJsonObject& complexObject, int sequenceNu { _jsonV3GridAltitudeRelativeKey, QJsonValue::Bool, true }, { _jsonV3GridAngleKey, QJsonValue::Double, true }, { _jsonV3GridSpacingKey, QJsonValue::Double, true }, - { _jsonV3GridEntryLocationKey, QJsonValue::Double, false }, + { _jsonEntryPointKey, QJsonValue::Double, false }, { _jsonV3TurnaroundDistKey, QJsonValue::Double, true }, }; QJsonObject gridObject = complexObject[_jsonV3GridObjectKey].toObject(); @@ -246,10 +244,10 @@ bool SurveyComplexItem::_loadV3(const QJsonObject& complexObject, int sequenceNu _gridAngleFact.setRawValue (gridObject[_jsonV3GridAngleKey].toDouble()); _turnAroundDistanceFact.setRawValue (gridObject[_jsonV3TurnaroundDistKey].toDouble()); - if (gridObject.contains(_jsonV3GridEntryLocationKey)) { - _gridEntryLocationFact.setRawValue(gridObject[_jsonV3GridEntryLocationKey].toDouble()); + if (gridObject.contains(_jsonEntryPointKey)) { + _entryPoint = gridObject[_jsonEntryPointKey].toDouble(); } else { - _gridEntryLocationFact.setRawValue(_gridEntryLocationFact.rawDefaultValue()); + _entryPoint = EntryLocationTopRight; } _cameraCalc.distanceToSurface()->setRawValue (gridObject[_jsonV3GridAltitudeKey].toDouble()); @@ -408,14 +406,13 @@ void SurveyComplexItem::_adjustTransectsToEntryPointLocation(QList& items, QO } } +void SurveyComplexItem::rotateEntryPoint(void) +{ + if (_entryPoint == EntryLocationLast) { + _entryPoint = EntryLocationFirst; + } else { + _entryPoint++; + } + _rebuildTransects(); + + setDirty(true); +} diff --git a/src/MissionManager/SurveyComplexItem.h b/src/MissionManager/SurveyComplexItem.h index 4e77a30724c7ed029b691c0fea95268e130367c0..bece68b7ed79d66e5f3281054af453b31b0a432e 100644 --- a/src/MissionManager/SurveyComplexItem.h +++ b/src/MissionManager/SurveyComplexItem.h @@ -23,11 +23,11 @@ class SurveyComplexItem : public TransectStyleComplexItem public: SurveyComplexItem(Vehicle* vehicle, bool flyView, QObject* parent); - Q_PROPERTY(Fact* gridAngle READ gridAngle CONSTANT) - Q_PROPERTY(Fact* gridEntryLocation READ gridEntryLocation CONSTANT) + Q_PROPERTY(Fact* gridAngle READ gridAngle CONSTANT) - Fact* gridAngle (void) { return &_gridAngleFact; } - Fact* gridEntryLocation (void) { return &_gridEntryLocationFact; } + Fact* gridAngle(void) { return &_gridAngleFact; } + + Q_INVOKABLE void rotateEntryPoint(void); // Overrides from ComplexMissionItem bool load (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) final; @@ -47,10 +47,12 @@ public: // Must match json spec for GridEntryLocation enum EntryLocation { - EntryLocationTopLeft, + EntryLocationFirst, + EntryLocationTopLeft = EntryLocationFirst, EntryLocationTopRight, EntryLocationBottomLeft, EntryLocationBottomRight, + EntryLocationLast = EntryLocationBottomRight }; static const char* jsonComplexItemTypeValue; @@ -106,17 +108,17 @@ private: QMap _metaDataMap; SettingsFact _gridAngleFact; - SettingsFact _gridEntryLocationFact; + int _entryPoint; static const char* _jsonGridAngleKey; - static const char* _jsonGridEntryLocationKey; + static const char* _jsonEntryPointKey; static const char* _jsonV3GridObjectKey; static const char* _jsonV3GridAltitudeKey; static const char* _jsonV3GridAltitudeRelativeKey; static const char* _jsonV3GridAngleKey; static const char* _jsonV3GridSpacingKey; - static const char* _jsonV3GridEntryLocationKey; + static const char* _jsonV3EntryPointKey; static const char* _jsonV3TurnaroundDistKey; static const char* _jsonV3CameraTriggerDistanceKey; static const char* _jsonV3CameraTriggerInTurnaroundKey; diff --git a/src/MissionManager/SurveyComplexItemTest.cc b/src/MissionManager/SurveyComplexItemTest.cc index 10e0ea88e73d92fe9e6d59bff2b3b2f410bacbda..2f98dc55f71a05d5cb867d20110f80825b621f08 100644 --- a/src/MissionManager/SurveyComplexItemTest.cc +++ b/src/MissionManager/SurveyComplexItemTest.cc @@ -66,12 +66,11 @@ void SurveyComplexItemTest::_testDirty(void) _surveyItem->setDirty(false); QVERIFY(!_surveyItem->dirty()); QVERIFY(_multiSpy->checkOnlySignalByMask(surveyDirtyChangedMask)); - QVERIFY(!_multiSpy->pullBoolFromSignalIndex(surveyDirtyChangedIndex)); _multiSpy->clearAllSignals(); // These facts should set dirty when changed QList rgFacts; - rgFacts << _surveyItem->gridAngle() << _surveyItem->gridEntryLocation(); + rgFacts << _surveyItem->gridAngle(); foreach(Fact* fact, rgFacts) { qDebug() << fact->name(); QVERIFY(!_surveyItem->dirty()); @@ -138,21 +137,15 @@ void SurveyComplexItemTest::_testEntryLocation(void) for (double gridAngle=-360.0; gridAngle<=360.0; gridAngle++) { _surveyItem->gridAngle()->setRawValue(gridAngle); - QList rgSeenEntryCoords; - QList rgEntryLocation; - rgEntryLocation << SurveyComplexItem::EntryLocationTopLeft - << SurveyComplexItem::EntryLocationTopRight - << SurveyComplexItem::EntryLocationBottomLeft - << SurveyComplexItem::EntryLocationBottomRight; - // Validate that each entry location is unique - for (int i=0; igridEntryLocation()->setRawValue(entryLocation); + QList rgSeenEntryCoords; + for (int rotateCount=0; rotateCount<3; rotateCount++) { + _surveyItem->rotateEntryPoint(); QVERIFY(!rgSeenEntryCoords.contains(_surveyItem->coordinate())); rgSeenEntryCoords << _surveyItem->coordinate(); } + + _surveyItem->rotateEntryPoint(); // Rotate back for first entry point rgSeenEntryCoords.clear(); } } diff --git a/src/PlanView/SurveyItemEditor.qml b/src/PlanView/SurveyItemEditor.qml index 52aec11ea9393ae4af04beeebf2bc66bbc020e5f..b99bf0fc5068de24341c527b3ea51819860b9949 100644 --- a/src/PlanView/SurveyItemEditor.qml +++ b/src/PlanView/SurveyItemEditor.qml @@ -97,13 +97,10 @@ Rectangle { Layout.fillWidth: true } - QGCLabel { - text: qsTr("Entry") - } - FactComboBox { - fact: missionItem.gridEntryLocation - indexModel: false - Layout.fillWidth: true + QGCButton { + Layout.columnSpan: 2 + text: qsTr("Rotate Entry Point") + onClicked: missionItem.rotateEntryPoint(); } FactCheckBox {