diff --git a/src/MissionManager/MissionCommandTreeTest.cc b/src/MissionManager/MissionCommandTreeTest.cc index bd16a41f5d9cd9595379deaa78a6b93f12a58947..9407d9f8b6c64d0480a8cede0e64dcd740c3a5e7 100644 --- a/src/MissionManager/MissionCommandTreeTest.cc +++ b/src/MissionManager/MissionCommandTreeTest.cc @@ -70,7 +70,9 @@ void MissionCommandTreeTest::_checkBaseValues(const MissionCommandUIInfo* uiInfo QCOMPARE(uiInfo->isStandaloneCoordinate(), true); QCOMPARE(uiInfo->specifiesCoordinate(), true); for (int i=1; i<=7; i++) { - const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(i); + bool showUI; + const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(i, showUI); + QVERIFY(showUI); QVERIFY(paramInfo); QCOMPARE(paramInfo->decimalPlaces(), 1); QCOMPARE(paramInfo->defaultValue(), 1.0); @@ -91,7 +93,9 @@ void MissionCommandTreeTest::_checkOverrideParamValues(const MissionCommandUIInf { QString overrideString = QString("override fw %1 %2").arg(command).arg(paramIndex); - const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(paramIndex); + bool showUI; + const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(paramIndex, showUI); + QVERIFY(showUI); QVERIFY(paramInfo); QCOMPARE(paramInfo->decimalPlaces(), 1); QCOMPARE(paramInfo->defaultValue(), 1.0); @@ -109,6 +113,7 @@ void MissionCommandTreeTest::_checkOverrideParamValues(const MissionCommandUIInf // Verifies that values match settings for an override void MissionCommandTreeTest::_checkOverrideValues(const MissionCommandUIInfo* uiInfo, int command) { + bool showUI; QString overrideString = QString("override fw %1").arg(command); QVERIFY(uiInfo != NULL); @@ -121,9 +126,12 @@ void MissionCommandTreeTest::_checkOverrideValues(const MissionCommandUIInfo* ui QCOMPARE(uiInfo->friendlyName(), _friendlyName(command)); QCOMPARE(uiInfo->isStandaloneCoordinate(), false); QCOMPARE(uiInfo->specifiesCoordinate(), false); - QVERIFY(uiInfo->getParamInfo(2) == NULL); - QVERIFY(uiInfo->getParamInfo(4) == NULL); - QVERIFY(uiInfo->getParamInfo(6) == NULL); + QVERIFY(uiInfo->getParamInfo(2, showUI)); + QCOMPARE(showUI, false); + QVERIFY(uiInfo->getParamInfo(4, showUI)); + QCOMPARE(showUI, false); + QVERIFY(uiInfo->getParamInfo(6, showUI)); + QCOMPARE(showUI, false); _checkOverrideParamValues(uiInfo, command, 1); _checkOverrideParamValues(uiInfo, command, 3); _checkOverrideParamValues(uiInfo, command, 5); @@ -131,6 +139,8 @@ void MissionCommandTreeTest::_checkOverrideValues(const MissionCommandUIInfo* ui void MissionCommandTreeTest::testJsonLoad(void) { + bool showUI; + // Test loading from the bad command list MissionCommandList* commandList = _commandTree->_staticCommandTree[MAV_AUTOPILOT_GENERIC][MAV_TYPE_GENERIC]; QVERIFY(commandList != NULL); @@ -148,14 +158,16 @@ void MissionCommandTreeTest::testJsonLoad(void) QCOMPARE(uiInfo->isStandaloneCoordinate(), false); QCOMPARE(uiInfo->specifiesCoordinate(), false); for (int i=1; i<=7; i++) { - QVERIFY(uiInfo->getParamInfo(i) == NULL); + QVERIFY(uiInfo->getParamInfo(i, showUI) == NULL); + QCOMPARE(showUI, false); } // Command 2 should all values defaulted for param 1 uiInfo = commandList->getUIInfo((MAV_CMD)2); QVERIFY(uiInfo != NULL); - const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(1); + const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(1, showUI); QVERIFY(paramInfo); + QCOMPARE(showUI, true); QCOMPARE(paramInfo->decimalPlaces(), -1); QCOMPARE(paramInfo->defaultValue(), 0.0); QCOMPARE(paramInfo->enumStrings().count(), 0); @@ -164,7 +176,8 @@ void MissionCommandTreeTest::testJsonLoad(void) QCOMPARE(paramInfo->param(), 1); QVERIFY(paramInfo->units().isEmpty()); for (int i=2; i<=7; i++) { - QVERIFY(uiInfo->getParamInfo(i) == NULL); + QVERIFY(uiInfo->getParamInfo(i, showUI) == NULL); + QCOMPARE(showUI, false); } // Command 3 should have all values set diff --git a/src/MissionManager/MissionCommandUIInfo.cc b/src/MissionManager/MissionCommandUIInfo.cc index ad63a6b1d77006ce0e45f9e87ea6ffe017f8e1ee..c12b7aaa8c94fa68adc02efa52f630dcafee747c 100644 --- a/src/MissionManager/MissionCommandUIInfo.cc +++ b/src/MissionManager/MissionCommandUIInfo.cc @@ -407,11 +407,15 @@ bool MissionCommandUIInfo::loadJsonInfo(const QJsonObject& jsonObject, bool requ return true; } -const MissionCmdParamInfo* MissionCommandUIInfo::getParamInfo(int index) const +const MissionCmdParamInfo* MissionCommandUIInfo::getParamInfo(int index, bool& showUI) const { - if (!_paramRemoveList.contains(index) && _paramInfoMap.contains(index)) { - return _paramInfoMap[index]; - } else { - return NULL; + const MissionCmdParamInfo* paramInfo = NULL; + + if (_paramInfoMap.contains(index)) { + paramInfo = _paramInfoMap[index]; } + + showUI = (paramInfo != NULL) && !_paramRemoveList.contains(index); + + return paramInfo; } diff --git a/src/MissionManager/MissionCommandUIInfo.h b/src/MissionManager/MissionCommandUIInfo.h index f2a66929308c4ec47cd8ff45aca2eaa8779c650e..f3c50a714bb57eb51f7c8393be53116d37094c24 100644 --- a/src/MissionManager/MissionCommandUIInfo.h +++ b/src/MissionManager/MissionCommandUIInfo.h @@ -138,8 +138,11 @@ public: /// @return true: success, false: failure, errorString set bool loadJsonInfo(const QJsonObject& jsonObject, bool requireFullObject, QString& errorString); - /// Return param info for index, NULL for param should not be shown - const MissionCmdParamInfo* getParamInfo(int index) const; + /// Retruns parameter information for specified parameter + /// @param index paremeter index to retrieve, 1-7 + /// @param showUI true: show parameter in editor, false: hide parameter in editor + /// @return Param info for index, NULL for none available + const MissionCmdParamInfo* getParamInfo(int index, bool& showUI) const; private: QString _loadErrorString(const QString& errorString) const; diff --git a/src/MissionManager/SimpleMissionItem.cc b/src/MissionManager/SimpleMissionItem.cc index 132505f57cad1e926ea5244fc03f6d69390f8ab6..cc3ee0783eb534c86811db514ce1031909d9056d 100644 --- a/src/MissionManager/SimpleMissionItem.cc +++ b/src/MissionManager/SimpleMissionItem.cc @@ -414,9 +414,10 @@ void SimpleMissionItem::_rebuildTextFieldFacts(void) const MissionCommandUIInfo* uiInfo = _commandTree->getUIInfo(_vehicle, command); for (int i=1; i<=7; i++) { - const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(i); + bool showUI; + const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(i, showUI); - if (paramInfo && paramInfo->enumStrings().count() == 0 && !paramInfo->nanUnchanged()) { + if (showUI && paramInfo && paramInfo->enumStrings().count() == 0 && !paramInfo->nanUnchanged()) { Fact* paramFact = rgParamFacts[i-1]; FactMetaData* paramMetaData = rgParamMetaData[i-1]; @@ -458,9 +459,10 @@ void SimpleMissionItem::_rebuildNaNFacts(void) const MissionCommandUIInfo* uiInfo = _commandTree->getUIInfo(_vehicle, command); for (int i=1; i<=7; i++) { - const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(i); + bool showUI; + const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(i, showUI); - if (paramInfo && paramInfo->nanUnchanged()) { + if (showUI && paramInfo && paramInfo->nanUnchanged()) { // Show hide Heading field on waypoint based on vehicle yaw to next waypoint setting. This needs to come from the actual vehicle if it exists // and not _vehicle which is always offline. Vehicle* firmwareVehicle = qgcApp()->toolbox()->multiVehicleManager()->activeVehicle(); @@ -517,9 +519,10 @@ void SimpleMissionItem::_rebuildComboBoxFacts(void) } for (int i=1; i<=7; i++) { - const MissionCmdParamInfo* paramInfo = _commandTree->getUIInfo(_vehicle, command)->getParamInfo(i); + bool showUI; + const MissionCmdParamInfo* paramInfo = _commandTree->getUIInfo(_vehicle, command)->getParamInfo(i, showUI); - if (paramInfo && paramInfo->enumStrings().count() != 0) { + if (showUI && paramInfo && paramInfo->enumStrings().count() != 0) { Fact* paramFact = rgParamFacts[i-1]; FactMetaData* paramMetaData = rgParamMetaData[i-1]; @@ -635,7 +638,8 @@ void SimpleMissionItem::setDefaultsForCommand(void) const MissionCommandUIInfo* uiInfo = _commandTree->getUIInfo(_vehicle, command); if (uiInfo) { for (int i=1; i<=7; i++) { - const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(i); + bool showUI; + const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(i, showUI); if (paramInfo) { Fact* rgParamFacts[7] = { &_missionItem._param1Fact, &_missionItem._param2Fact, &_missionItem._param3Fact, &_missionItem._param4Fact, &_missionItem._param5Fact, &_missionItem._param6Fact, &_missionItem._param7Fact }; rgParamFacts[paramInfo->param()-1]->setRawValue(paramInfo->defaultValue());