Browse Source

Merge pull request #6469 from DonLakeFlyer/SurveyEntry

Survey: Rotate survey entry
QGC4.4
Don Gagne 7 years ago committed by GitHub
parent
commit
65ebabe428
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      src/MissionManager/SurveyComplexItem.cc
  2. 18
      src/MissionManager/SurveyComplexItem.h
  3. 19
      src/MissionManager/SurveyComplexItemTest.cc
  4. 11
      src/PlanView/SurveyItemEditor.qml

40
src/MissionManager/SurveyComplexItem.cc

@ -29,14 +29,14 @@ const char* SurveyComplexItem::gridAngleName = "GridAngle"; @@ -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 @@ -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 @@ -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) @@ -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 @@ -154,7 +152,7 @@ bool SurveyComplexItem::_loadV4(const QJsonObject& complexObject, int sequenceNu
QList<JsonHelper::KeyValidateInfo> 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 @@ -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 @@ -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 @@ -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<QList<QGeoCoo @@ -408,14 +406,13 @@ void SurveyComplexItem::_adjustTransectsToEntryPointLocation(QList<QList<QGeoCoo
return;
}
int entryLocation = _gridEntryLocationFact.rawValue().toInt();
bool reversePoints = false;
bool reverseTransects = false;
if (entryLocation == EntryLocationBottomLeft || entryLocation == EntryLocationBottomRight) {
if (_entryPoint == EntryLocationBottomLeft || _entryPoint == EntryLocationBottomRight) {
reversePoints = true;
}
if (entryLocation == EntryLocationTopRight || entryLocation == EntryLocationBottomRight) {
if (_entryPoint == EntryLocationTopRight || _entryPoint == EntryLocationBottomRight) {
reverseTransects = true;
}
@ -428,7 +425,7 @@ void SurveyComplexItem::_adjustTransectsToEntryPointLocation(QList<QList<QGeoCoo @@ -428,7 +425,7 @@ void SurveyComplexItem::_adjustTransectsToEntryPointLocation(QList<QList<QGeoCoo
_reverseTransectOrder(transects);
}
qCDebug(SurveyComplexItemLog) << "_adjustTransectsToEntryPointLocation Modified entry point:entryLocation" << transects.first().first() << entryLocation;
qCDebug(SurveyComplexItemLog) << "_adjustTransectsToEntryPointLocation Modified entry point:entryLocation" << transects.first().first() << _entryPoint;
}
#if 0
@ -1401,4 +1398,15 @@ void SurveyComplexItem::_appendLoadedMissionItems(QList<MissionItem*>& items, QO @@ -1401,4 +1398,15 @@ void SurveyComplexItem::_appendLoadedMissionItems(QList<MissionItem*>& items, QO
}
}
void SurveyComplexItem::rotateEntryPoint(void)
{
if (_entryPoint == EntryLocationLast) {
_entryPoint = EntryLocationFirst;
} else {
_entryPoint++;
}
_rebuildTransects();
setDirty(true);
}

18
src/MissionManager/SurveyComplexItem.h

@ -23,11 +23,11 @@ class SurveyComplexItem : public TransectStyleComplexItem @@ -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: @@ -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: @@ -106,17 +108,17 @@ private:
QMap<QString, FactMetaData*> _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;

19
src/MissionManager/SurveyComplexItemTest.cc

@ -66,12 +66,11 @@ void SurveyComplexItemTest::_testDirty(void) @@ -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<Fact*> 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) @@ -138,21 +137,15 @@ void SurveyComplexItemTest::_testEntryLocation(void)
for (double gridAngle=-360.0; gridAngle<=360.0; gridAngle++) {
_surveyItem->gridAngle()->setRawValue(gridAngle);
QList<QGeoCoordinate> rgSeenEntryCoords;
QList<int> rgEntryLocation;
rgEntryLocation << SurveyComplexItem::EntryLocationTopLeft
<< SurveyComplexItem::EntryLocationTopRight
<< SurveyComplexItem::EntryLocationBottomLeft
<< SurveyComplexItem::EntryLocationBottomRight;
// Validate that each entry location is unique
for (int i=0; i<rgEntryLocation.count(); i++) {
int entryLocation = rgEntryLocation[i];
_surveyItem->gridEntryLocation()->setRawValue(entryLocation);
QList<QGeoCoordinate> 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();
}
}

11
src/PlanView/SurveyItemEditor.qml

@ -97,13 +97,10 @@ Rectangle { @@ -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 {

Loading…
Cancel
Save