Commit 4ab73ba5 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #5343 from DonLakeFlyer/AltRelativeFixes

Fixes for relative altitude signalling
parents 25c19fb6 36377fa7
......@@ -74,8 +74,8 @@ public:
void applyNewAltitude (double newAltitude) final { Q_UNUSED(newAltitude); /* no action */ }
double specifiedFlightSpeed (void) final;
bool coordinateHasRelativeAltitude (void) const final { return true; }
bool exitCoordinateHasRelativeAltitude (void) const final { return true; }
bool coordinateHasRelativeAltitude (void) const final { return false; }
bool exitCoordinateHasRelativeAltitude (void) const final { return false; }
bool exitCoordinateSameAsEntry (void) const final { return true; }
void setDirty (bool dirty) final;
......
......@@ -604,6 +604,7 @@ void SimpleMissionItem::_syncAltitudeRelativeToHomeToFrame(const QVariant& value
if (!_syncingAltitudeRelativeToHomeAndFrame) {
_syncingAltitudeRelativeToHomeAndFrame = true;
_missionItem.setFrame(value.toBool() ? MAV_FRAME_GLOBAL_RELATIVE_ALT : MAV_FRAME_GLOBAL);
emit coordinateHasRelativeAltitudeChanged(value.toBool());
_syncingAltitudeRelativeToHomeAndFrame = false;
}
}
......@@ -613,6 +614,7 @@ void SimpleMissionItem::_syncFrameToAltitudeRelativeToHome(void)
if (!_syncingAltitudeRelativeToHomeAndFrame) {
_syncingAltitudeRelativeToHomeAndFrame = true;
_altitudeRelativeToHomeFact.setRawValue(relativeAltitude());
emit coordinateHasRelativeAltitudeChanged(_altitudeRelativeToHomeFact.rawValue().toBool());
_syncingAltitudeRelativeToHomeAndFrame = false;
}
}
......
......@@ -79,13 +79,14 @@ void SimpleMissionItemTest::init(void)
{
VisualMissionItemTest::init();
rgSimpleItemSignals[commandChangedIndex] = SIGNAL(commandChanged(int));
rgSimpleItemSignals[frameChangedIndex] = SIGNAL(frameChanged(int));
rgSimpleItemSignals[friendlyEditAllowedChangedIndex] = SIGNAL(friendlyEditAllowedChanged(bool));
rgSimpleItemSignals[headingDegreesChangedIndex] = SIGNAL(headingDegreesChanged(double));
rgSimpleItemSignals[rawEditChangedIndex] = SIGNAL(rawEditChanged(bool));
rgSimpleItemSignals[cameraSectionChangedIndex] = SIGNAL(rawEditChanged(bool));
rgSimpleItemSignals[speedSectionChangedIndex] = SIGNAL(rawEditChanged(bool));
rgSimpleItemSignals[commandChangedIndex] = SIGNAL(commandChanged(int));
rgSimpleItemSignals[frameChangedIndex] = SIGNAL(frameChanged(int));
rgSimpleItemSignals[friendlyEditAllowedChangedIndex] = SIGNAL(friendlyEditAllowedChanged(bool));
rgSimpleItemSignals[headingDegreesChangedIndex] = SIGNAL(headingDegreesChanged(double));
rgSimpleItemSignals[rawEditChangedIndex] = SIGNAL(rawEditChanged(bool));
rgSimpleItemSignals[cameraSectionChangedIndex] = SIGNAL(rawEditChanged(bool));
rgSimpleItemSignals[speedSectionChangedIndex] = SIGNAL(rawEditChanged(bool));
rgSimpleItemSignals[coordinateHasRelativeAltitudeChangedIndex] = SIGNAL(coordinateHasRelativeAltitudeChanged(bool));
MissionItem missionItem(1, // sequence number
MAV_CMD_NAV_WAYPOINT,
......@@ -231,13 +232,14 @@ void SimpleMissionItemTest::_testSignals(void)
// frameChanged
// dirtyChanged
// friendlyEditAllowedChanged - this signal is not very smart on when it gets sent
// coordinateHasRelativeAltitudeChanged
missionItem.setFrame(MAV_FRAME_GLOBAL_RELATIVE_ALT);
QVERIFY(_spyVisualItem->checkNoSignals());
QVERIFY(_spySimpleItem->checkNoSignals());
missionItem.setFrame(MAV_FRAME_GLOBAL);
QVERIFY(_spySimpleItem->checkOnlySignalByMask(frameChangedMask | dirtyChangedMask | friendlyEditAllowedChangedMask));
QVERIFY(_spySimpleItem->checkOnlySignalByMask(frameChangedMask | dirtyChangedMask | friendlyEditAllowedChangedMask | coordinateHasRelativeAltitudeChangedMask));
_spySimpleItem->clearAllSignals();
_spyVisualItem->clearAllSignals();
......
......@@ -41,17 +41,19 @@ private:
rawEditChangedIndex,
cameraSectionChangedIndex,
speedSectionChangedIndex,
coordinateHasRelativeAltitudeChangedIndex,
maxSignalIndex,
};
enum {
commandChangedMask = 1 << commandChangedIndex,
frameChangedMask = 1 << frameChangedIndex,
friendlyEditAllowedChangedMask = 1 << friendlyEditAllowedChangedIndex,
headingDegreesChangedMask = 1 << headingDegreesChangedIndex,
rawEditChangedMask = 1 << rawEditChangedIndex,
cameraSectionChangedMask = 1 << cameraSectionChangedIndex,
speedSectionChangedMask = 1 << speedSectionChangedIndex
commandChangedMask = 1 << commandChangedIndex,
frameChangedMask = 1 << frameChangedIndex,
friendlyEditAllowedChangedMask = 1 << friendlyEditAllowedChangedIndex,
headingDegreesChangedMask = 1 << headingDegreesChangedIndex,
rawEditChangedMask = 1 << rawEditChangedIndex,
cameraSectionChangedMask = 1 << cameraSectionChangedIndex,
speedSectionChangedMask = 1 << speedSectionChangedIndex,
coordinateHasRelativeAltitudeChangedMask = 1 << coordinateHasRelativeAltitudeChangedIndex,
};
static const size_t cSimpleItemSignals = maxSignalIndex;
......
......@@ -102,7 +102,7 @@ public:
virtual bool isSimpleItem (void) const = 0;
virtual bool isStandaloneCoordinate (void) const = 0;
virtual bool specifiesCoordinate (void) const = 0;
virtual bool specifiesAltitudeOnly (void) const = 0;;
virtual bool specifiesAltitudeOnly (void) const = 0;
virtual QString commandDescription (void) const = 0;
virtual QString commandName (void) const = 0;
virtual QString abbreviation (void) const = 0;
......
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