diff --git a/src/Wima/WimaPlaner.cc b/src/Wima/WimaPlaner.cc index 872dabe78efbae1e314a42454ed01f31ccb5ca7f..4186b7db751ff97baec228011d82852c69187e90 100644 --- a/src/Wima/WimaPlaner.cc +++ b/src/Wima/WimaPlaner.cc @@ -182,7 +182,6 @@ bool WimaPlaner::updateMission() { QString errorString; - setMissionReady(false); #define debug 0 if ( !recalcJoinedArea(errorString)) { @@ -252,18 +251,28 @@ bool WimaPlaner::updateMission() if (survey == nullptr){ qWarning("WimaPlaner::updateMission(): survey == nullptr"); return false; - } else { - if ( oldSurveyExists ) { - survey->setRefPoint(oldSurveyRef); - } else { - survey->setRefPoint(_measurementArea.center()); - } + } + if ( oldSurveyExists ) { + survey->setRefPoint(oldSurveyRef); - survey->setAutoGenerated(true); // prevents reinitialisation from gui - survey->surveyAreaPolygon()->clear(); - survey->surveyAreaPolygon()->appendVertices(_measurementArea.coordinateList()); + disconnect(OldSurveyPt->deltaR(), &Fact::rawValueChanged, this, &WimaPlaner::resetMissionReady); + disconnect(OldSurveyPt->deltaAlpha(), &Fact::rawValueChanged, this, &WimaPlaner::resetMissionReady); + disconnect(OldSurveyPt->isSnakePath(), &Fact::rawValueChanged, this, &WimaPlaner::resetMissionReady); + disconnect(OldSurveyPt->transectMinLength(), &Fact::rawValueChanged, this, &WimaPlaner::resetMissionReady); + } else { + survey->setRefPoint(_measurementArea.center()); } + survey->setAutoGenerated(true); // prevents reinitialisation from gui + survey->surveyAreaPolygon()->clear(); + survey->surveyAreaPolygon()->appendVertices(_measurementArea.coordinateList()); + + connect(survey->deltaR(), &Fact::rawValueChanged, this, &WimaPlaner::resetMissionReady); + connect(survey->deltaAlpha(), &Fact::rawValueChanged, this, &WimaPlaner::resetMissionReady); + connect(survey->isSnakePath(), &Fact::rawValueChanged, this, &WimaPlaner::resetMissionReady); + connect(survey->transectMinLength(), &Fact::rawValueChanged, this, &WimaPlaner::resetMissionReady); + + // calculate path from take off to opArea if (survey->visualTransectPoints().size() == 0) { @@ -652,6 +661,11 @@ void WimaPlaner::setMissionReady(bool ready) } } +void WimaPlaner::resetMissionReady() +{ + setMissionReady(false); +} + QJsonDocument WimaPlaner::saveToJson(FileType fileType) { /// This function save all areas (of WimaPlaner) and all mission items (of MissionController) to a QJsonDocument diff --git a/src/Wima/WimaPlaner.h b/src/Wima/WimaPlaner.h index dbc3fe04f1ac1cdf7280b4c5a93d99e7d590a26a..36bfff29e5e1a7f6b31825cfd9575a6d9cfe2c79 100644 --- a/src/Wima/WimaPlaner.h +++ b/src/Wima/WimaPlaner.h @@ -123,7 +123,8 @@ signals: private slots: void recalcPolygonInteractivity (int index); bool recalcJoinedArea (QString &errorString); - void pushToContainer (); + void pushToContainer (); + void resetMissionReady (); private: // Member Functions diff --git a/src/WimaView/WimaToolBar.qml b/src/WimaView/WimaToolBar.qml index 4d2cfa3416bf5771aef9e88da01366e36ddca18a..35f25c611fcf4f268145e1b23f8cd0f3197bb9bf 100644 --- a/src/WimaView/WimaToolBar.qml +++ b/src/WimaView/WimaToolBar.qml @@ -24,6 +24,7 @@ Rectangle { signal showFlyView property var planMasterController + property var wimaPlaner property var currentMissionItem ///< Mission item to display status for property var missionItems: _controllerValid ? planMasterController.missionController.visualItems : undefined @@ -284,18 +285,18 @@ Rectangle { anchors.rightMargin: _margins anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter - text: _controllerDirty ? qsTr("Upload Required") : qsTr("Upload") - enabled: !_controllerSyncInProgress - visible: !_controllerOffline && !_controllerSyncInProgress && !uploadCompleteText.visible - primary: _controllerDirty - onClicked: planMasterController.upload() + text: qsTr("Calculate") + enabled: true + visible: true + primary: !wimaPlaner.missionReady + onClicked: wimaPlaner.updateMission() PropertyAnimation on opacity { easing.type: Easing.OutQuart from: 0.5 to: 1 loops: Animation.Infinite - running: _controllerDirty && !_controllerSyncInProgress + running: !wimaPlaner.missionReady alwaysRunToEnd: true duration: 2000 } diff --git a/src/WimaView/WimaView.qml b/src/WimaView/WimaView.qml index d2046ec7ceeda60a96fc691261968855cdfe1e61..c3c2c0a5921a341018bea068f49f5421419c03b9 100644 --- a/src/WimaView/WimaView.qml +++ b/src/WimaView/WimaView.qml @@ -74,6 +74,8 @@ QGCView { Component.onCompleted: { toolbar.planMasterController = Qt.binding(function () { return _planMasterController }) toolbar.currentMissionItem = Qt.binding(function () { return _missionController.currentPlanViewItem }) + toolbar.wimaPlaner = Qt.binding(function () { return _wimaPlaner }) + } function addComplexItem(complexItemName) {