From cf178232679ca851eb84338a6190f704c5f6c73a Mon Sep 17 00:00:00 2001 From: pixhawk Date: Mon, 9 Jan 2012 16:57:11 +0100 Subject: [PATCH] Fixed some bugs that allowed to have multiple or no "current" mission elements in Edit list --- src/uas/UASWaypointManager.cc | 13 +++++++++++++ src/ui/WaypointList.cc | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/uas/UASWaypointManager.cc b/src/uas/UASWaypointManager.cc index 44c86f68b..3e78f4f96 100644 --- a/src/uas/UASWaypointManager.cc +++ b/src/uas/UASWaypointManager.cc @@ -401,6 +401,19 @@ int UASWaypointManager::removeWaypoint(quint16 seq) if (seq < waypointsEditable.size()) { Waypoint *t = waypointsEditable[seq]; + + if (t->getCurrent() == true) //trying to remove the current waypoint + { + if (seq+1 < waypointsEditable.size()) // setting the next waypoint as current + { + waypointsEditable[seq+1]->setCurrent(true); + } + else if (seq-1 >= 0) //if deleting the last on the list, then setting the previous waypoint as current + { + waypointsEditable[seq-1]->setCurrent(true); + } + } + waypointsEditable.remove(seq); delete t; t = NULL; diff --git a/src/ui/WaypointList.cc b/src/ui/WaypointList.cc index 0133a8bbd..fa49ceae2 100644 --- a/src/ui/WaypointList.cc +++ b/src/ui/WaypointList.cc @@ -293,7 +293,7 @@ void WaypointList::addCurrentPositionWaypoint() yawGlobal = last->getYaw(); } // Create global frame waypoint per default - wp = new Waypoint(0, uas->getLatitude(), uas->getLongitude(), uas->getAltitude(), 0, acceptanceRadiusGlobal, holdTime, yawGlobal, true, true, MAV_FRAME_GLOBAL_RELATIVE_ALT, MAV_CMD_NAV_WAYPOINT); + wp = new Waypoint(0, uas->getLatitude(), uas->getLongitude(), uas->getAltitude(), 0, acceptanceRadiusGlobal, holdTime, yawGlobal, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT, MAV_CMD_NAV_WAYPOINT); WPM->addWaypointEditable(wp); updateStatusLabel(tr("Added GLOBAL, ALTITUDE OVER GROUND waypoint")); } @@ -307,7 +307,7 @@ void WaypointList::addCurrentPositionWaypoint() holdTime = last->getHoldTime(); } // Create local frame waypoint as second option - wp = new Waypoint(0, uas->getLocalX(), uas->getLocalY(), uas->getLocalZ(), uas->getYaw(), acceptanceRadiusLocal, holdTime, 0.0, true, true, MAV_FRAME_LOCAL_NED, MAV_CMD_NAV_WAYPOINT); + wp = new Waypoint(0, uas->getLocalX(), uas->getLocalY(), uas->getLocalZ(), uas->getYaw(), acceptanceRadiusLocal, holdTime, 0.0, true, false, MAV_FRAME_LOCAL_NED, MAV_CMD_NAV_WAYPOINT); WPM->addWaypointEditable(wp); updateStatusLabel(tr("Added LOCAL (NED) waypoint")); } -- 2.22.0