Commit 69996a2e authored by Don Gagne's avatar Don Gagne

parent 6d658c51
......@@ -285,7 +285,7 @@ QList<MAV_CMD> PX4FirmwarePlugin::supportedMissionCommands(void)
list << MAV_CMD_NAV_WAYPOINT
<< MAV_CMD_NAV_LOITER_UNLIM << MAV_CMD_NAV_LOITER_TIME << MAV_CMD_NAV_LOITER_TO_ALT
<< MAV_CMD_NAV_LAND << MAV_CMD_NAV_TAKEOFF
<< MAV_CMD_NAV_LAND << MAV_CMD_NAV_TAKEOFF << MAV_CMD_NAV_RETURN_TO_LAUNCH
<< MAV_CMD_DO_JUMP
<< MAV_CMD_DO_VTOL_TRANSITION << MAV_CMD_NAV_VTOL_TAKEOFF << MAV_CMD_NAV_VTOL_LAND
<< MAV_CMD_DO_DIGICAM_CONTROL
......
......@@ -355,7 +355,6 @@ int MissionController::insertSimpleMissionItem(QGeoCoordinate coordinate, int i)
newItem->setCommand(takeoffCmd);
}
}
newItem->setDefaultsForCommand();
if (newItem->specifiesAltitude()) {
double prevAltitude;
int prevAltitudeMode;
......@@ -382,7 +381,6 @@ int MissionController::insertROIMissionItem(QGeoCoordinate coordinate, int i)
MAV_CMD_DO_SET_ROI_LOCATION :
MAV_CMD_DO_SET_ROI));
_initVisualItem(newItem);
newItem->setDefaultsForCommand();
newItem->setCoordinate(coordinate);
double prevAltitude;
......
......@@ -78,7 +78,7 @@ SimpleMissionItem::SimpleMissionItem(Vehicle* vehicle, bool flyView, QObject* pa
_connectSignals();
_updateOptionalSections();
setDefaultsForCommand();
_setDefaultsForCommand();
_rebuildFacts();
setDirty(false);
......@@ -213,7 +213,7 @@ void SimpleMissionItem::_connectSignals(void)
connect(&_missionItem._frameFact, &Fact::valueChanged, this, &SimpleMissionItem::_sendFriendlyEditAllowedChanged);
// A command change triggers a number of other changes as well.
connect(&_missionItem._commandFact, &Fact::valueChanged, this, &SimpleMissionItem::setDefaultsForCommand);
connect(&_missionItem._commandFact, &Fact::valueChanged, this, &SimpleMissionItem::_setDefaultsForCommand);
connect(&_missionItem._commandFact, &Fact::valueChanged, this, &SimpleMissionItem::commandNameChanged);
connect(&_missionItem._commandFact, &Fact::valueChanged, this, &SimpleMissionItem::commandDescriptionChanged);
connect(&_missionItem._commandFact, &Fact::valueChanged, this, &SimpleMissionItem::abbreviationChanged);
......@@ -729,15 +729,32 @@ bool SimpleMissionItem::readyForSave(void) const
return !specifiesAltitude() || !qIsNaN(_missionItem._param7Fact.rawValue().toDouble());
}
void SimpleMissionItem::setDefaultsForCommand(void)
void SimpleMissionItem::_setDefaultsForCommand(void)
{
// We set these global defaults first, then if there are param defaults they will get reset
// First reset params 1-4 to 0, we leave 5-7 alone to preserve any previous location information on command change
_missionItem._param1Fact.setRawValue(0);
_missionItem._param2Fact.setRawValue(0);
_missionItem._param3Fact.setRawValue(0);
_missionItem._param4Fact.setRawValue(0);
if (!specifiesCoordinate() && !isStandaloneCoordinate()) {
// No need to carry across previous lat/lon
_missionItem._param5Fact.setRawValue(0);
_missionItem._param6Fact.setRawValue(0);
}
// Set global defaults first, then if there are param defaults they will get reset
_altitudeMode = AltitudeRelative;
emit altitudeModeChanged();
double defaultAlt = qgcApp()->toolbox()->settingsManager()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble();
_altitudeFact.setRawValue(defaultAlt);
_missionItem._param7Fact.setRawValue(defaultAlt);
_amslAltAboveTerrainFact.setRawValue(qQNaN());
if (specifiesCoordinate() || isStandaloneCoordinate() || specifiesAltitudeOnly()) {
double defaultAlt = qgcApp()->toolbox()->settingsManager()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble();
_altitudeFact.setRawValue(defaultAlt);
_missionItem._param7Fact.setRawValue(defaultAlt);
} else {
_altitudeFact.setRawValue(0);
_missionItem._param7Fact.setRawValue(0);
}
MAV_CMD command = (MAV_CMD)this->command();
const MissionCommandUIInfo* uiInfo = _commandTree->getUIInfo(_vehicle, command);
......
......@@ -134,9 +134,6 @@ public:
int lastSequenceNumber (void) const final;
void save (QJsonArray& missionItems) final;
public slots:
void setDefaultsForCommand(void);
signals:
void commandChanged (int command);
void friendlyEditAllowedChanged (bool friendlyEditAllowed);
......@@ -160,6 +157,7 @@ private slots:
void _rebuildFacts (void);
void _rebuildTextFieldFacts (void);
void _possibleAdditionalTimeDelayChanged(void);
void _setDefaultsForCommand (void);
private:
void _connectSignals (void);
......
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