Commit 0b96ca82 authored by DoinLakeFlyer's avatar DoinLakeFlyer

parent 1200542b
...@@ -2278,9 +2278,10 @@ bool MissionController::_isROICancelItem(SimpleMissionItem* simpleItem) ...@@ -2278,9 +2278,10 @@ bool MissionController::_isROICancelItem(SimpleMissionItem* simpleItem)
void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force) void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force)
{ {
if (_visualItems && (force || sequenceNumber != _currentPlanViewSeqNum)) { if (_visualItems && (force || sequenceNumber != _currentPlanViewSeqNum)) {
bool foundLand = false; bool foundLand = false;
int takeoffIndex = -1; int takeoffSeqNum = -1;
int landIndex = -1; int landSeqNum = -1;
int lastFlyThroughSeqNum = -1;
_splitSegment = nullptr; _splitSegment = nullptr;
_currentPlanViewItem = nullptr; _currentPlanViewItem = nullptr;
...@@ -2294,10 +2295,11 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force) ...@@ -2294,10 +2295,11 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force)
_previousCoordinate = QGeoCoordinate(); _previousCoordinate = QGeoCoordinate();
for (int viIndex=0; viIndex<_visualItems->count(); viIndex++) { for (int viIndex=0; viIndex<_visualItems->count(); viIndex++) {
VisualMissionItem* pVI = qobject_cast<VisualMissionItem*>(_visualItems->get(viIndex)); VisualMissionItem* pVI = qobject_cast<VisualMissionItem*>(_visualItems->get(viIndex));
SimpleMissionItem* simpleItem = qobject_cast<SimpleMissionItem*>(pVI); SimpleMissionItem* simpleItem = qobject_cast<SimpleMissionItem*>(pVI);
int currentSeqNumber = pVI->sequenceNumber();
if (sequenceNumber != 0 && pVI->sequenceNumber() <= sequenceNumber) { if (sequenceNumber != 0 && currentSeqNumber <= sequenceNumber) {
if (pVI->specifiesCoordinate() && !pVI->isStandaloneCoordinate()) { if (pVI->specifiesCoordinate() && !pVI->isStandaloneCoordinate()) {
// Coordinate based flight commands prior to where the takeoff would be inserted // Coordinate based flight commands prior to where the takeoff would be inserted
_isInsertTakeoffValid = false; _isInsertTakeoffValid = false;
...@@ -2305,7 +2307,7 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force) ...@@ -2305,7 +2307,7 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force)
} }
if (qobject_cast<TakeoffMissionItem*>(pVI)) { if (qobject_cast<TakeoffMissionItem*>(pVI)) {
takeoffIndex = viIndex; takeoffSeqNum = currentSeqNumber;
_isInsertTakeoffValid = false; _isInsertTakeoffValid = false;
} }
...@@ -2317,7 +2319,7 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force) ...@@ -2317,7 +2319,7 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force)
case MAV_CMD_DO_LAND_START: case MAV_CMD_DO_LAND_START:
case MAV_CMD_NAV_RETURN_TO_LAUNCH: case MAV_CMD_NAV_RETURN_TO_LAUNCH:
foundLand = true; foundLand = true;
landIndex = viIndex; landSeqNum = currentSeqNumber;
break; break;
default: default:
break; break;
...@@ -2326,19 +2328,19 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force) ...@@ -2326,19 +2328,19 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force)
FixedWingLandingComplexItem* fwLanding = qobject_cast<FixedWingLandingComplexItem*>(pVI); FixedWingLandingComplexItem* fwLanding = qobject_cast<FixedWingLandingComplexItem*>(pVI);
if (fwLanding) { if (fwLanding) {
foundLand = true; foundLand = true;
landIndex = viIndex; landSeqNum = currentSeqNumber;
} }
} }
} }
if (simpleItem) { if (simpleItem) {
// Remember previous coordinate // Remember previous coordinate
if (pVI->sequenceNumber() < sequenceNumber && simpleItem->specifiesCoordinate() && !simpleItem->isStandaloneCoordinate()) { if (currentSeqNumber < sequenceNumber && simpleItem->specifiesCoordinate() && !simpleItem->isStandaloneCoordinate()) {
_previousCoordinate = simpleItem->coordinate(); _previousCoordinate = simpleItem->coordinate();
} }
// ROI state handling // ROI state handling
if (pVI->sequenceNumber() <= sequenceNumber) { if (currentSeqNumber <= sequenceNumber) {
if (_isROIActive) { if (_isROIActive) {
if (_isROICancelItem(simpleItem)) { if (_isROICancelItem(simpleItem)) {
_isROIActive = false; _isROIActive = false;
...@@ -2349,12 +2351,17 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force) ...@@ -2349,12 +2351,17 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force)
} }
} }
} }
if (pVI->sequenceNumber() == sequenceNumber && _isROIBeginItem(simpleItem)) { if (currentSeqNumber == sequenceNumber && _isROIBeginItem(simpleItem)) {
_isROIBeginCurrentItem = true; _isROIBeginCurrentItem = true;
} }
if (simpleItem->specifiesCoordinate() && !simpleItem->isStandaloneCoordinate()) {
lastFlyThroughSeqNum = currentSeqNumber;
}
} }
if (pVI->sequenceNumber() == sequenceNumber) {
if (currentSeqNumber == sequenceNumber) {
pVI->setIsCurrentItem(true); pVI->setIsCurrentItem(true);
pVI->setHasCurrentChildItem(false); pVI->setHasCurrentChildItem(false);
...@@ -2383,9 +2390,9 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force) ...@@ -2383,9 +2390,9 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force)
} }
} }
if (takeoffIndex != -1) { if (takeoffSeqNum != -1) {
// Takeoff item was found which means mission starts from ground // Takeoff item was found which means mission starts from ground
if (sequenceNumber < takeoffIndex) { if (sequenceNumber < takeoffSeqNum) {
// Land is only valid after the takeoff item. // Land is only valid after the takeoff item.
_isInsertLandValid = false; _isInsertLandValid = false;
// Fly through commands are not allowed prior to the takeoff command // Fly through commands are not allowed prior to the takeoff command
...@@ -2393,10 +2400,17 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force) ...@@ -2393,10 +2400,17 @@ void MissionController::setCurrentPlanViewSeqNum(int sequenceNumber, bool force)
} }
} }
if (lastFlyThroughSeqNum != -1) {
// Land item must be after any fly through coordinates
if (sequenceNumber < lastFlyThroughSeqNum) {
_isInsertLandValid = false;
}
}
if (foundLand) { if (foundLand) {
// Can't have more than one land sequence // Can't have more than one land sequence
_isInsertLandValid = false; _isInsertLandValid = false;
if (sequenceNumber >= landIndex) { if (sequenceNumber >= landSeqNum) {
// Can't have fly through commands after a land item // Can't have fly through commands after a land item
_flyThroughCommandsAllowed = false; _flyThroughCommandsAllowed = false;
} }
......
...@@ -291,6 +291,17 @@ Item { ...@@ -291,6 +291,17 @@ Item {
_missionController.insertComplexMissionItem(complexItemName, mapCenter(), nextIndex, true /* makeCurrentItem */) _missionController.insertComplexMissionItem(complexItemName, mapCenter(), nextIndex, true /* makeCurrentItem */)
} }
function insertTakeItemAfterCurrent() {
var nextIndex = _missionController.currentPlanViewVIIndex + 1
_missionController.insertTakeoffItem(mapCenter(), nextIndex, true /* makeCurrentItem */)
}
function insertLandItemAfterCurrent() {
var nextIndex = _missionController.currentPlanViewVIIndex + 1
_missionController.insertLandItem(mapCenter(), nextIndex, true /* makeCurrentItem */)
}
function selectNextNotReady() { function selectNextNotReady() {
var foundCurrent = false var foundCurrent = false
for (var i=0; i<_missionController.visualItems.count; i++) { for (var i=0; i<_missionController.visualItems.count; i++) {
...@@ -643,7 +654,7 @@ Item { ...@@ -643,7 +654,7 @@ Item {
break*/ break*/
case takeoffButtonIndex: case takeoffButtonIndex:
allAddClickBoolsOff() allAddClickBoolsOff()
_missionController.insertTakeoffItem(mapCenter(), _missionController.currentMissionIndex, true /* makeCurrentItem */) insertTakeItemAfterCurrent()
break break
case waypointButtonIndex: case waypointButtonIndex:
if (_addWaypointOnClick) { if (_addWaypointOnClick) {
...@@ -675,7 +686,7 @@ Item { ...@@ -675,7 +686,7 @@ Item {
break break
case landButtonIndex: case landButtonIndex:
allAddClickBoolsOff() allAddClickBoolsOff()
_missionController.insertLandItem(mapCenter(), _missionController.currentMissionIndex, true /* makeCurrentItem */) insertLandItemAfterCurrent()
break break
} }
} }
......
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