Browse Source

Set defaults even when param is not shown

QGC4.4
DonLakeFlyer 8 years ago
parent
commit
8f3d200169
  1. 29
      src/MissionManager/MissionCommandTreeTest.cc
  2. 14
      src/MissionManager/MissionCommandUIInfo.cc
  3. 7
      src/MissionManager/MissionCommandUIInfo.h
  4. 18
      src/MissionManager/SimpleMissionItem.cc

29
src/MissionManager/MissionCommandTreeTest.cc

@ -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->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 @@ -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 @@ -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 @@ -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 @@ -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) @@ -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) @@ -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

14
src/MissionManager/MissionCommandUIInfo.cc

@ -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;
}
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;
}

7
src/MissionManager/MissionCommandUIInfo.h

@ -138,8 +138,11 @@ public: @@ -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;

18
src/MissionManager/SimpleMissionItem.cc

@ -414,9 +414,10 @@ void SimpleMissionItem::_rebuildTextFieldFacts(void) @@ -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) @@ -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) @@ -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) @@ -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());

Loading…
Cancel
Save