From 72c1e9a331a39b44966e387f4477570b0461b48b Mon Sep 17 00:00:00 2001 From: Valentin Platzgummer Date: Mon, 21 Oct 2019 00:27:31 +0200 Subject: [PATCH] calc button added to plan view --- src/Wima/WimaPlaner.cc | 34 ++++++++++++++++++++++++---------- src/Wima/WimaPlaner.h | 3 ++- src/WimaView/WimaToolBar.qml | 13 +++++++------ src/WimaView/WimaView.qml | 2 ++ 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/Wima/WimaPlaner.cc b/src/Wima/WimaPlaner.cc index 872dabe78..4186b7db7 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 dbc3fe04f..36bfff29e 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 4d2cfa341..35f25c611 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 d2046ec7c..c3c2c0a59 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) { -- 2.22.0