Commit 8f3d2001 authored by DonLakeFlyer's avatar DonLakeFlyer

Set defaults even when param is not shown

parent 73d856d5
...@@ -70,7 +70,9 @@ void MissionCommandTreeTest::_checkBaseValues(const MissionCommandUIInfo* uiInfo ...@@ -70,7 +70,9 @@ void MissionCommandTreeTest::_checkBaseValues(const MissionCommandUIInfo* uiInfo
QCOMPARE(uiInfo->isStandaloneCoordinate(), true); QCOMPARE(uiInfo->isStandaloneCoordinate(), true);
QCOMPARE(uiInfo->specifiesCoordinate(), true); QCOMPARE(uiInfo->specifiesCoordinate(), true);
for (int i=1; i<=7; i++) { 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); QVERIFY(paramInfo);
QCOMPARE(paramInfo->decimalPlaces(), 1); QCOMPARE(paramInfo->decimalPlaces(), 1);
QCOMPARE(paramInfo->defaultValue(), 1.0); QCOMPARE(paramInfo->defaultValue(), 1.0);
...@@ -91,7 +93,9 @@ void MissionCommandTreeTest::_checkOverrideParamValues(const MissionCommandUIInf ...@@ -91,7 +93,9 @@ void MissionCommandTreeTest::_checkOverrideParamValues(const MissionCommandUIInf
{ {
QString overrideString = QString("override fw %1 %2").arg(command).arg(paramIndex); 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); QVERIFY(paramInfo);
QCOMPARE(paramInfo->decimalPlaces(), 1); QCOMPARE(paramInfo->decimalPlaces(), 1);
QCOMPARE(paramInfo->defaultValue(), 1.0); QCOMPARE(paramInfo->defaultValue(), 1.0);
...@@ -109,6 +113,7 @@ void MissionCommandTreeTest::_checkOverrideParamValues(const MissionCommandUIInf ...@@ -109,6 +113,7 @@ void MissionCommandTreeTest::_checkOverrideParamValues(const MissionCommandUIInf
// Verifies that values match settings for an override // Verifies that values match settings for an override
void MissionCommandTreeTest::_checkOverrideValues(const MissionCommandUIInfo* uiInfo, int command) void MissionCommandTreeTest::_checkOverrideValues(const MissionCommandUIInfo* uiInfo, int command)
{ {
bool showUI;
QString overrideString = QString("override fw %1").arg(command); QString overrideString = QString("override fw %1").arg(command);
QVERIFY(uiInfo != NULL); QVERIFY(uiInfo != NULL);
...@@ -121,9 +126,12 @@ void MissionCommandTreeTest::_checkOverrideValues(const MissionCommandUIInfo* ui ...@@ -121,9 +126,12 @@ void MissionCommandTreeTest::_checkOverrideValues(const MissionCommandUIInfo* ui
QCOMPARE(uiInfo->friendlyName(), _friendlyName(command)); QCOMPARE(uiInfo->friendlyName(), _friendlyName(command));
QCOMPARE(uiInfo->isStandaloneCoordinate(), false); QCOMPARE(uiInfo->isStandaloneCoordinate(), false);
QCOMPARE(uiInfo->specifiesCoordinate(), false); QCOMPARE(uiInfo->specifiesCoordinate(), false);
QVERIFY(uiInfo->getParamInfo(2) == NULL); QVERIFY(uiInfo->getParamInfo(2, showUI));
QVERIFY(uiInfo->getParamInfo(4) == NULL); QCOMPARE(showUI, false);
QVERIFY(uiInfo->getParamInfo(6) == NULL); QVERIFY(uiInfo->getParamInfo(4, showUI));
QCOMPARE(showUI, false);
QVERIFY(uiInfo->getParamInfo(6, showUI));
QCOMPARE(showUI, false);
_checkOverrideParamValues(uiInfo, command, 1); _checkOverrideParamValues(uiInfo, command, 1);
_checkOverrideParamValues(uiInfo, command, 3); _checkOverrideParamValues(uiInfo, command, 3);
_checkOverrideParamValues(uiInfo, command, 5); _checkOverrideParamValues(uiInfo, command, 5);
...@@ -131,6 +139,8 @@ void MissionCommandTreeTest::_checkOverrideValues(const MissionCommandUIInfo* ui ...@@ -131,6 +139,8 @@ void MissionCommandTreeTest::_checkOverrideValues(const MissionCommandUIInfo* ui
void MissionCommandTreeTest::testJsonLoad(void) void MissionCommandTreeTest::testJsonLoad(void)
{ {
bool showUI;
// Test loading from the bad command list // Test loading from the bad command list
MissionCommandList* commandList = _commandTree->_staticCommandTree[MAV_AUTOPILOT_GENERIC][MAV_TYPE_GENERIC]; MissionCommandList* commandList = _commandTree->_staticCommandTree[MAV_AUTOPILOT_GENERIC][MAV_TYPE_GENERIC];
QVERIFY(commandList != NULL); QVERIFY(commandList != NULL);
...@@ -148,14 +158,16 @@ void MissionCommandTreeTest::testJsonLoad(void) ...@@ -148,14 +158,16 @@ void MissionCommandTreeTest::testJsonLoad(void)
QCOMPARE(uiInfo->isStandaloneCoordinate(), false); QCOMPARE(uiInfo->isStandaloneCoordinate(), false);
QCOMPARE(uiInfo->specifiesCoordinate(), false); QCOMPARE(uiInfo->specifiesCoordinate(), false);
for (int i=1; i<=7; i++) { 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 // Command 2 should all values defaulted for param 1
uiInfo = commandList->getUIInfo((MAV_CMD)2); uiInfo = commandList->getUIInfo((MAV_CMD)2);
QVERIFY(uiInfo != NULL); QVERIFY(uiInfo != NULL);
const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(1); const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(1, showUI);
QVERIFY(paramInfo); QVERIFY(paramInfo);
QCOMPARE(showUI, true);
QCOMPARE(paramInfo->decimalPlaces(), -1); QCOMPARE(paramInfo->decimalPlaces(), -1);
QCOMPARE(paramInfo->defaultValue(), 0.0); QCOMPARE(paramInfo->defaultValue(), 0.0);
QCOMPARE(paramInfo->enumStrings().count(), 0); QCOMPARE(paramInfo->enumStrings().count(), 0);
...@@ -164,7 +176,8 @@ void MissionCommandTreeTest::testJsonLoad(void) ...@@ -164,7 +176,8 @@ void MissionCommandTreeTest::testJsonLoad(void)
QCOMPARE(paramInfo->param(), 1); QCOMPARE(paramInfo->param(), 1);
QVERIFY(paramInfo->units().isEmpty()); QVERIFY(paramInfo->units().isEmpty());
for (int i=2; i<=7; i++) { 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 // Command 3 should have all values set
......
...@@ -407,11 +407,15 @@ bool MissionCommandUIInfo::loadJsonInfo(const QJsonObject& jsonObject, bool requ ...@@ -407,11 +407,15 @@ bool MissionCommandUIInfo::loadJsonInfo(const QJsonObject& jsonObject, bool requ
return true; 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)) { const MissionCmdParamInfo* paramInfo = NULL;
return _paramInfoMap[index];
} else { if (_paramInfoMap.contains(index)) {
return NULL; paramInfo = _paramInfoMap[index];
} }
showUI = (paramInfo != NULL) && !_paramRemoveList.contains(index);
return paramInfo;
} }
...@@ -138,8 +138,11 @@ public: ...@@ -138,8 +138,11 @@ public:
/// @return true: success, false: failure, errorString set /// @return true: success, false: failure, errorString set
bool loadJsonInfo(const QJsonObject& jsonObject, bool requireFullObject, QString& errorString); bool loadJsonInfo(const QJsonObject& jsonObject, bool requireFullObject, QString& errorString);
/// Return param info for index, NULL for param should not be shown /// Retruns parameter information for specified parameter
const MissionCmdParamInfo* getParamInfo(int index) const; /// @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: private:
QString _loadErrorString(const QString& errorString) const; QString _loadErrorString(const QString& errorString) const;
......
...@@ -414,9 +414,10 @@ void SimpleMissionItem::_rebuildTextFieldFacts(void) ...@@ -414,9 +414,10 @@ void SimpleMissionItem::_rebuildTextFieldFacts(void)
const MissionCommandUIInfo* uiInfo = _commandTree->getUIInfo(_vehicle, command); const MissionCommandUIInfo* uiInfo = _commandTree->getUIInfo(_vehicle, command);
for (int i=1; i<=7; i++) { 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]; Fact* paramFact = rgParamFacts[i-1];
FactMetaData* paramMetaData = rgParamMetaData[i-1]; FactMetaData* paramMetaData = rgParamMetaData[i-1];
...@@ -458,9 +459,10 @@ void SimpleMissionItem::_rebuildNaNFacts(void) ...@@ -458,9 +459,10 @@ void SimpleMissionItem::_rebuildNaNFacts(void)
const MissionCommandUIInfo* uiInfo = _commandTree->getUIInfo(_vehicle, command); const MissionCommandUIInfo* uiInfo = _commandTree->getUIInfo(_vehicle, command);
for (int i=1; i<=7; i++) { 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 // 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. // and not _vehicle which is always offline.
Vehicle* firmwareVehicle = qgcApp()->toolbox()->multiVehicleManager()->activeVehicle(); Vehicle* firmwareVehicle = qgcApp()->toolbox()->multiVehicleManager()->activeVehicle();
...@@ -517,9 +519,10 @@ void SimpleMissionItem::_rebuildComboBoxFacts(void) ...@@ -517,9 +519,10 @@ void SimpleMissionItem::_rebuildComboBoxFacts(void)
} }
for (int i=1; i<=7; i++) { 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]; Fact* paramFact = rgParamFacts[i-1];
FactMetaData* paramMetaData = rgParamMetaData[i-1]; FactMetaData* paramMetaData = rgParamMetaData[i-1];
...@@ -635,7 +638,8 @@ void SimpleMissionItem::setDefaultsForCommand(void) ...@@ -635,7 +638,8 @@ void SimpleMissionItem::setDefaultsForCommand(void)
const MissionCommandUIInfo* uiInfo = _commandTree->getUIInfo(_vehicle, command); const MissionCommandUIInfo* uiInfo = _commandTree->getUIInfo(_vehicle, command);
if (uiInfo) { if (uiInfo) {
for (int i=1; i<=7; i++) { for (int i=1; i<=7; i++) {
const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(i); bool showUI;
const MissionCmdParamInfo* paramInfo = uiInfo->getParamInfo(i, showUI);
if (paramInfo) { if (paramInfo) {
Fact* rgParamFacts[7] = { &_missionItem._param1Fact, &_missionItem._param2Fact, &_missionItem._param3Fact, &_missionItem._param4Fact, &_missionItem._param5Fact, &_missionItem._param6Fact, &_missionItem._param7Fact }; Fact* rgParamFacts[7] = { &_missionItem._param1Fact, &_missionItem._param2Fact, &_missionItem._param3Fact, &_missionItem._param4Fact, &_missionItem._param5Fact, &_missionItem._param6Fact, &_missionItem._param7Fact };
rgParamFacts[paramInfo->param()-1]->setRawValue(paramInfo->defaultValue()); rgParamFacts[paramInfo->param()-1]->setRawValue(paramInfo->defaultValue());
......
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