Commit 3e36d74a authored by Don Gagne's avatar Don Gagne

Trigger distance not always being written out

parent d2ef6d01
...@@ -115,18 +115,12 @@ ...@@ -115,18 +115,12 @@
"units": "mm", "units": "mm",
"defaultValue": 4.5 "defaultValue": 4.5
}, },
{
"name": "CameraTrigger",
"shortDescription": "Trigger the camera based on distance.",
"type": "bool",
"defaultValue": 0
},
{ {
"name": "CameraTriggerDistance", "name": "CameraTriggerDistance",
"shortDescription": "Distance between each triggering of the camera.", "shortDescription": "Distance between each triggering of the camera. 0 specifies not camera trigger.",
"type": "double", "type": "double",
"decimalPlaces": 2, "decimalPlaces": 2,
"min": 0.1, "min": 0,
"units": "m", "units": "m",
"defaultValue": 25 "defaultValue": 25
}, },
......
...@@ -27,7 +27,6 @@ const char* SurveyMissionItem::_jsonGridAltitudeRelativeKey = "relativeAlt ...@@ -27,7 +27,6 @@ const char* SurveyMissionItem::_jsonGridAltitudeRelativeKey = "relativeAlt
const char* SurveyMissionItem::_jsonGridAngleKey = "angle"; const char* SurveyMissionItem::_jsonGridAngleKey = "angle";
const char* SurveyMissionItem::_jsonGridSpacingKey = "spacing"; const char* SurveyMissionItem::_jsonGridSpacingKey = "spacing";
const char* SurveyMissionItem::_jsonTurnaroundDistKey = "turnAroundDistance"; const char* SurveyMissionItem::_jsonTurnaroundDistKey = "turnAroundDistance";
const char* SurveyMissionItem::_jsonCameraTriggerKey = "cameraTrigger";
const char* SurveyMissionItem::_jsonCameraTriggerDistanceKey = "cameraTriggerDistance"; const char* SurveyMissionItem::_jsonCameraTriggerDistanceKey = "cameraTriggerDistance";
const char* SurveyMissionItem::_jsonCameraTriggerInTurnaroundKey = "cameraTriggerInTurnaround"; const char* SurveyMissionItem::_jsonCameraTriggerInTurnaroundKey = "cameraTriggerInTurnaround";
const char* SurveyMissionItem::_jsonHoverAndCaptureKey = "hoverAndCapture"; const char* SurveyMissionItem::_jsonHoverAndCaptureKey = "hoverAndCapture";
...@@ -77,6 +76,7 @@ SurveyMissionItem::SurveyMissionItem(Vehicle* vehicle, QObject* parent) ...@@ -77,6 +76,7 @@ SurveyMissionItem::SurveyMissionItem(Vehicle* vehicle, QObject* parent)
, _cameraOrientationFixed(false) , _cameraOrientationFixed(false)
, _missionCommandCount(0) , _missionCommandCount(0)
, _refly90Degrees(false) , _refly90Degrees(false)
, _ignoreRecalc(false)
, _surveyDistance(0.0) , _surveyDistance(0.0)
, _cameraShots(0) , _cameraShots(0)
, _coveredArea(0.0) , _coveredArea(0.0)
...@@ -88,7 +88,6 @@ SurveyMissionItem::SurveyMissionItem(Vehicle* vehicle, QObject* parent) ...@@ -88,7 +88,6 @@ SurveyMissionItem::SurveyMissionItem(Vehicle* vehicle, QObject* parent)
, _gridAngleFact (settingsGroup, _metaDataMap[gridAngleName]) , _gridAngleFact (settingsGroup, _metaDataMap[gridAngleName])
, _gridSpacingFact (settingsGroup, _metaDataMap[gridSpacingName]) , _gridSpacingFact (settingsGroup, _metaDataMap[gridSpacingName])
, _turnaroundDistFact (settingsGroup, _metaDataMap[turnaroundDistName]) , _turnaroundDistFact (settingsGroup, _metaDataMap[turnaroundDistName])
, _cameraTriggerFact (settingsGroup, _metaDataMap[cameraTriggerName])
, _cameraTriggerDistanceFact (settingsGroup, _metaDataMap[cameraTriggerDistanceName]) , _cameraTriggerDistanceFact (settingsGroup, _metaDataMap[cameraTriggerDistanceName])
, _cameraTriggerInTurnaroundFact (settingsGroup, _metaDataMap[cameraTriggerInTurnaroundName]) , _cameraTriggerInTurnaroundFact (settingsGroup, _metaDataMap[cameraTriggerInTurnaroundName])
, _hoverAndCaptureFact (settingsGroup, _metaDataMap[hoverAndCaptureName]) , _hoverAndCaptureFact (settingsGroup, _metaDataMap[hoverAndCaptureName])
...@@ -117,7 +116,6 @@ SurveyMissionItem::SurveyMissionItem(Vehicle* vehicle, QObject* parent) ...@@ -117,7 +116,6 @@ SurveyMissionItem::SurveyMissionItem(Vehicle* vehicle, QObject* parent)
connect(&_cameraTriggerDistanceFact, &Fact::valueChanged, this, &SurveyMissionItem::_generateGrid); connect(&_cameraTriggerDistanceFact, &Fact::valueChanged, this, &SurveyMissionItem::_generateGrid);
connect(&_cameraTriggerInTurnaroundFact, &Fact::valueChanged, this, &SurveyMissionItem::_generateGrid); connect(&_cameraTriggerInTurnaroundFact, &Fact::valueChanged, this, &SurveyMissionItem::_generateGrid);
connect(&_hoverAndCaptureFact, &Fact::valueChanged, this, &SurveyMissionItem::_generateGrid); connect(&_hoverAndCaptureFact, &Fact::valueChanged, this, &SurveyMissionItem::_generateGrid);
connect(&_cameraTriggerFact, &Fact::valueChanged, this, &SurveyMissionItem::_generateGrid);
connect(this, &SurveyMissionItem::refly90DegreesChanged, this, &SurveyMissionItem::_generateGrid); connect(this, &SurveyMissionItem::refly90DegreesChanged, this, &SurveyMissionItem::_generateGrid);
connect(&_gridAltitudeFact, &Fact::valueChanged, this, &SurveyMissionItem::_updateCoordinateAltitude); connect(&_gridAltitudeFact, &Fact::valueChanged, this, &SurveyMissionItem::_updateCoordinateAltitude);
...@@ -209,15 +207,11 @@ void SurveyMissionItem::save(QJsonArray& missionItems) ...@@ -209,15 +207,11 @@ void SurveyMissionItem::save(QJsonArray& missionItems)
saveObject[JsonHelper::jsonVersionKey] = 3; saveObject[JsonHelper::jsonVersionKey] = 3;
saveObject[VisualMissionItem::jsonTypeKey] = VisualMissionItem::jsonTypeComplexItemValue; saveObject[VisualMissionItem::jsonTypeKey] = VisualMissionItem::jsonTypeComplexItemValue;
saveObject[ComplexMissionItem::jsonComplexItemTypeKey] = jsonComplexItemTypeValue; saveObject[ComplexMissionItem::jsonComplexItemTypeKey] = jsonComplexItemTypeValue;
saveObject[_jsonCameraTriggerKey] = _cameraTriggerFact.rawValue().toBool();
saveObject[_jsonManualGridKey] = _manualGridFact.rawValue().toBool(); saveObject[_jsonManualGridKey] = _manualGridFact.rawValue().toBool();
saveObject[_jsonFixedValueIsAltitudeKey] = _fixedValueIsAltitudeFact.rawValue().toBool(); saveObject[_jsonFixedValueIsAltitudeKey] = _fixedValueIsAltitudeFact.rawValue().toBool();
saveObject[_jsonHoverAndCaptureKey] = _hoverAndCaptureFact.rawValue().toBool(); saveObject[_jsonHoverAndCaptureKey] = _hoverAndCaptureFact.rawValue().toBool();
saveObject[_jsonRefly90DegreesKey] = _refly90Degrees; saveObject[_jsonRefly90DegreesKey] = _refly90Degrees;
saveObject[_jsonCameraTriggerDistanceKey] = _cameraTriggerDistanceFact.rawValue().toDouble();
if (_cameraTriggerFact.rawValue().toBool()) {
saveObject[_jsonCameraTriggerDistanceKey] = _cameraTriggerDistanceFact.rawValue().toDouble();
}
QJsonObject gridObject; QJsonObject gridObject;
gridObject[_jsonGridAltitudeKey] = _gridAltitudeFact.rawValue().toDouble(); gridObject[_jsonGridAltitudeKey] = _gridAltitudeFact.rawValue().toDouble();
...@@ -291,8 +285,7 @@ bool SurveyMissionItem::load(const QJsonObject& complexObject, int sequenceNumbe ...@@ -291,8 +285,7 @@ bool SurveyMissionItem::load(const QJsonObject& complexObject, int sequenceNumbe
{ QGCMapPolygon::jsonPolygonKey, QJsonValue::Array, true }, { QGCMapPolygon::jsonPolygonKey, QJsonValue::Array, true },
{ _jsonGridObjectKey, QJsonValue::Object, true }, { _jsonGridObjectKey, QJsonValue::Object, true },
{ _jsonCameraObjectKey, QJsonValue::Object, false }, { _jsonCameraObjectKey, QJsonValue::Object, false },
{ _jsonCameraTriggerKey, QJsonValue::Bool, true }, { _jsonCameraTriggerDistanceKey, QJsonValue::Double, true },
{ _jsonCameraTriggerDistanceKey, QJsonValue::Double, false },
{ _jsonManualGridKey, QJsonValue::Bool, true }, { _jsonManualGridKey, QJsonValue::Bool, true },
{ _jsonFixedValueIsAltitudeKey, QJsonValue::Bool, true }, { _jsonFixedValueIsAltitudeKey, QJsonValue::Bool, true },
{ _jsonHoverAndCaptureKey, QJsonValue::Bool, false }, { _jsonHoverAndCaptureKey, QJsonValue::Bool, false },
...@@ -309,12 +302,13 @@ bool SurveyMissionItem::load(const QJsonObject& complexObject, int sequenceNumbe ...@@ -309,12 +302,13 @@ bool SurveyMissionItem::load(const QJsonObject& complexObject, int sequenceNumbe
return false; return false;
} }
_ignoreRecalc = true;
_mapPolygon.clear(); _mapPolygon.clear();
setSequenceNumber(sequenceNumber); setSequenceNumber(sequenceNumber);
_manualGridFact.setRawValue (v2Object[_jsonManualGridKey].toBool(true)); _manualGridFact.setRawValue (v2Object[_jsonManualGridKey].toBool(true));
_cameraTriggerFact.setRawValue (v2Object[_jsonCameraTriggerKey].toBool(false));
_fixedValueIsAltitudeFact.setRawValue (v2Object[_jsonFixedValueIsAltitudeKey].toBool(true)); _fixedValueIsAltitudeFact.setRawValue (v2Object[_jsonFixedValueIsAltitudeKey].toBool(true));
_gridAltitudeRelativeFact.setRawValue (v2Object[_jsonGridAltitudeRelativeKey].toBool(true)); _gridAltitudeRelativeFact.setRawValue (v2Object[_jsonGridAltitudeRelativeKey].toBool(true));
_hoverAndCaptureFact.setRawValue (v2Object[_jsonHoverAndCaptureKey].toBool(false)); _hoverAndCaptureFact.setRawValue (v2Object[_jsonHoverAndCaptureKey].toBool(false));
...@@ -332,18 +326,11 @@ bool SurveyMissionItem::load(const QJsonObject& complexObject, int sequenceNumbe ...@@ -332,18 +326,11 @@ bool SurveyMissionItem::load(const QJsonObject& complexObject, int sequenceNumbe
if (!JsonHelper::validateKeys(gridObject, gridKeyInfoList, errorString)) { if (!JsonHelper::validateKeys(gridObject, gridKeyInfoList, errorString)) {
return false; return false;
} }
_gridAltitudeFact.setRawValue (gridObject[_jsonGridAltitudeKey].toDouble()); _gridAltitudeFact.setRawValue (gridObject[_jsonGridAltitudeKey].toDouble());
_gridAngleFact.setRawValue (gridObject[_jsonGridAngleKey].toDouble()); _gridAngleFact.setRawValue (gridObject[_jsonGridAngleKey].toDouble());
_gridSpacingFact.setRawValue (gridObject[_jsonGridSpacingKey].toDouble()); _gridSpacingFact.setRawValue (gridObject[_jsonGridSpacingKey].toDouble());
_turnaroundDistFact.setRawValue (gridObject[_jsonTurnaroundDistKey].toDouble()); _turnaroundDistFact.setRawValue (gridObject[_jsonTurnaroundDistKey].toDouble());
_cameraTriggerDistanceFact.setRawValue (v2Object[_jsonCameraTriggerDistanceKey].toDouble());
if (_cameraTriggerFact.rawValue().toBool()) {
if (!v2Object.contains(_jsonCameraTriggerDistanceKey)) {
errorString = tr("%1 but %2 is missing").arg("cameraTrigger = true").arg("cameraTriggerDistance");
return false;
}
_cameraTriggerDistanceFact.setRawValue(v2Object[_jsonCameraTriggerDistanceKey].toDouble());
}
if (!_manualGridFact.rawValue().toBool()) { if (!_manualGridFact.rawValue().toBool()) {
if (!v2Object.contains(_jsonCameraObjectKey)) { if (!v2Object.contains(_jsonCameraObjectKey)) {
...@@ -400,6 +387,9 @@ bool SurveyMissionItem::load(const QJsonObject& complexObject, int sequenceNumbe ...@@ -400,6 +387,9 @@ bool SurveyMissionItem::load(const QJsonObject& complexObject, int sequenceNumbe
return false; return false;
} }
_ignoreRecalc = false;
_generateGrid();
return true; return true;
} }
...@@ -467,6 +457,10 @@ void SurveyMissionItem::_convertPointsToGeo(const QList<QPointF>& pointsNED, con ...@@ -467,6 +457,10 @@ void SurveyMissionItem::_convertPointsToGeo(const QList<QPointF>& pointsNED, con
void SurveyMissionItem::_generateGrid(void) void SurveyMissionItem::_generateGrid(void)
{ {
if (_ignoreRecalc) {
return;
}
if (_mapPolygon.count() < 3 || _gridSpacingFact.rawValue().toDouble() <= 0) { if (_mapPolygon.count() < 3 || _gridSpacingFact.rawValue().toDouble() <= 0) {
_clearInternal(); _clearInternal();
return; return;
...@@ -1029,7 +1023,7 @@ double SurveyMissionItem::_triggerDistance(void) const { ...@@ -1029,7 +1023,7 @@ double SurveyMissionItem::_triggerDistance(void) const {
bool SurveyMissionItem::_triggerCamera(void) const bool SurveyMissionItem::_triggerCamera(void) const
{ {
return _cameraTriggerFact.rawValue().toBool() && _triggerDistance() > 0; return _triggerDistance() > 0;
} }
bool SurveyMissionItem::_imagesEverywhere(void) const bool SurveyMissionItem::_imagesEverywhere(void) const
......
...@@ -31,7 +31,6 @@ public: ...@@ -31,7 +31,6 @@ public:
Q_PROPERTY(Fact* gridAngle READ gridAngle CONSTANT) Q_PROPERTY(Fact* gridAngle READ gridAngle CONSTANT)
Q_PROPERTY(Fact* gridSpacing READ gridSpacing CONSTANT) Q_PROPERTY(Fact* gridSpacing READ gridSpacing CONSTANT)
Q_PROPERTY(Fact* turnaroundDist READ turnaroundDist CONSTANT) Q_PROPERTY(Fact* turnaroundDist READ turnaroundDist CONSTANT)
Q_PROPERTY(Fact* cameraTrigger READ cameraTrigger CONSTANT)
Q_PROPERTY(Fact* cameraTriggerDistance READ cameraTriggerDistance CONSTANT) Q_PROPERTY(Fact* cameraTriggerDistance READ cameraTriggerDistance CONSTANT)
Q_PROPERTY(Fact* cameraTriggerInTurnaround READ cameraTriggerInTurnaround CONSTANT) Q_PROPERTY(Fact* cameraTriggerInTurnaround READ cameraTriggerInTurnaround CONSTANT)
Q_PROPERTY(Fact* hoverAndCapture READ hoverAndCapture CONSTANT) Q_PROPERTY(Fact* hoverAndCapture READ hoverAndCapture CONSTANT)
...@@ -74,7 +73,6 @@ public: ...@@ -74,7 +73,6 @@ public:
Fact* gridAngle (void) { return &_gridAngleFact; } Fact* gridAngle (void) { return &_gridAngleFact; }
Fact* gridSpacing (void) { return &_gridSpacingFact; } Fact* gridSpacing (void) { return &_gridSpacingFact; }
Fact* turnaroundDist (void) { return &_turnaroundDistFact; } Fact* turnaroundDist (void) { return &_turnaroundDistFact; }
Fact* cameraTrigger (void) { return &_cameraTriggerFact; }
Fact* cameraTriggerDistance (void) { return &_cameraTriggerDistanceFact; } Fact* cameraTriggerDistance (void) { return &_cameraTriggerDistanceFact; }
Fact* cameraTriggerInTurnaround (void) { return &_cameraTriggerInTurnaroundFact; } Fact* cameraTriggerInTurnaround (void) { return &_cameraTriggerInTurnaroundFact; }
Fact* hoverAndCapture (void) { return &_hoverAndCaptureFact; } Fact* hoverAndCapture (void) { return &_hoverAndCaptureFact; }
...@@ -221,6 +219,7 @@ private: ...@@ -221,6 +219,7 @@ private:
int _missionCommandCount; int _missionCommandCount;
bool _refly90Degrees; bool _refly90Degrees;
bool _ignoreRecalc;
double _surveyDistance; double _surveyDistance;
int _cameraShots; int _cameraShots;
double _coveredArea; double _coveredArea;
...@@ -235,7 +234,6 @@ private: ...@@ -235,7 +234,6 @@ private:
SettingsFact _gridAngleFact; SettingsFact _gridAngleFact;
SettingsFact _gridSpacingFact; SettingsFact _gridSpacingFact;
SettingsFact _turnaroundDistFact; SettingsFact _turnaroundDistFact;
SettingsFact _cameraTriggerFact;
SettingsFact _cameraTriggerDistanceFact; SettingsFact _cameraTriggerDistanceFact;
SettingsFact _cameraTriggerInTurnaroundFact; SettingsFact _cameraTriggerInTurnaroundFact;
SettingsFact _hoverAndCaptureFact; SettingsFact _hoverAndCaptureFact;
...@@ -257,7 +255,6 @@ private: ...@@ -257,7 +255,6 @@ private:
static const char* _jsonGridAngleKey; static const char* _jsonGridAngleKey;
static const char* _jsonGridSpacingKey; static const char* _jsonGridSpacingKey;
static const char* _jsonTurnaroundDistKey; static const char* _jsonTurnaroundDistKey;
static const char* _jsonCameraTriggerKey;
static const char* _jsonCameraTriggerDistanceKey; static const char* _jsonCameraTriggerDistanceKey;
static const char* _jsonCameraTriggerInTurnaroundKey; static const char* _jsonCameraTriggerInTurnaroundKey;
static const char* _jsonHoverAndCaptureKey; static const char* _jsonHoverAndCaptureKey;
......
...@@ -229,17 +229,25 @@ Rectangle { ...@@ -229,17 +229,25 @@ Rectangle {
spacing: _margin spacing: _margin
visible: missionItem.manualGrid.value == true visible: missionItem.manualGrid.value == true
FactCheckBox { QGCCheckBox {
id: cameraTriggerDistanceCheckBox
anchors.baseline: cameraTriggerDistanceField.baseline anchors.baseline: cameraTriggerDistanceField.baseline
text: qsTr("Trigger Distance") text: qsTr("Trigger Distance")
fact: missionItem.cameraTrigger checked: missionItem.cameraTriggerDistance.rawValue > 0
onClicked: {
if (checked) {
missionItem.cameraTriggerDistance.value = missionItem.cameraTriggerDistance.defaultValue
} else {
missionItem.cameraTriggerDistance.value = 0
}
}
} }
FactTextField { FactTextField {
id: cameraTriggerDistanceField id: cameraTriggerDistanceField
Layout.fillWidth: true Layout.fillWidth: true
fact: missionItem.cameraTriggerDistance fact: missionItem.cameraTriggerDistance
enabled: missionItem.cameraTrigger.value enabled: cameraTriggerDistanceCheckBox.checked
} }
} }
......
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