void doUndoAppendWaypoint( UndoAction* action ) { RoutePoint* point = (RoutePoint*) action->before[0]; Route* route = (Route*) action->after[0]; bool noRouteLeftToRedo = false; if( (route->GetnPoints() == 2) && (gFrame->nRoute_State == 0) ) noRouteLeftToRedo = true; cc1->RemovePointFromRoute( point, route ); if( action->beforeType[0] == Undo_IsOrphanded ) { pConfig->DeleteWayPoint( point ); pSelect->DeleteSelectablePoint( point, SELTYPE_ROUTEPOINT ); if( NULL != pWayPointMan ) pWayPointMan->RemoveRoutePoint( point ); } if( noRouteLeftToRedo ) { cc1->undo->InvalidateRedo(); } if( pRouteManagerDialog && pRouteManagerDialog->IsShown() ) pRouteManagerDialog->UpdateWptListCtrl(); if( gFrame->nRoute_State > 1 ) { gFrame->nRoute_State--; cc1->m_prev_pMousePoint = route->GetLastPoint(); cc1->m_prev_rlat = cc1->m_prev_pMousePoint->m_lat; cc1->m_prev_rlon = cc1->m_prev_pMousePoint->m_lon; route->m_lastMousePointIndex = route->GetnPoints(); } }
void doRedoAppendWaypoint( UndoAction* action ) { RoutePoint* point = (RoutePoint*) action->before[0]; Route* route = (Route*) action->after[0]; if( action->beforeType[0] == Undo_IsOrphanded ) { pConfig->AddNewWayPoint( point, -1 ); pSelect->AddSelectableRoutePoint( point->m_lat, point->m_lon, point ); } RoutePoint* prevpoint = route->GetLastPoint(); route->AddPoint( point ); pSelect->AddSelectableRouteSegment( prevpoint->m_lat, prevpoint->m_lon, point->m_lat, point->m_lon, prevpoint, point, route ); if( pRouteManagerDialog && pRouteManagerDialog->IsShown() ) pRouteManagerDialog->UpdateWptListCtrl(); if( gFrame->nRoute_State > 1 ) { gFrame->nRoute_State++; cc1->m_prev_pMousePoint = route->GetLastPoint(); cc1->m_prev_rlat = cc1->m_prev_pMousePoint->m_lat; cc1->m_prev_rlon = cc1->m_prev_pMousePoint->m_lon; route->m_lastMousePointIndex = route->GetnPoints(); } }
void WayPointman::DestroyWaypoint( RoutePoint *pRp ) { if( pRp ) { // Get a list of all routes containing this point // and remove the point from them all wxArrayPtrVoid *proute_array = g_pRouteMan->GetRouteArrayContaining( pRp ); if( proute_array ) { for( unsigned int ir = 0; ir < proute_array->GetCount(); ir++ ) { Route *pr = (Route *) proute_array->Item( ir ); /* FS#348 if ( g_pRouteMan->GetpActiveRoute() == pr ) // Deactivate any route containing this point g_pRouteMan->DeactivateRoute(); */ pr->RemovePoint( pRp ); } // Scrub the routes, looking for one-point routes for( unsigned int ir = 0; ir < proute_array->GetCount(); ir++ ) { Route *pr = (Route *) proute_array->Item( ir ); if( pr->GetnPoints() < 2 ) { pConfig->m_bIsImporting = true; pConfig->DeleteConfigRoute( pr ); g_pRouteMan->DeleteRoute( pr ); pConfig->m_bIsImporting = false; } } delete proute_array; } // Now it is safe to delete the point pConfig->DeleteWayPoint( pRp ); pSelect->DeleteSelectablePoint( pRp, SELTYPE_ROUTEPOINT ); //TODO FIXME // Some memory corruption occurs if the wp is deleted here. // To continue running OK, it is sufficient to simply remove the wp from the global list // This will leak, although called infrequently.... // 12/15/10...Seems to occur only on MOB delete.... if( NULL != pWayPointMan ) pWayPointMan->m_pWayPointList->DeleteObject( pRp ); // The RoutePoint might be currently in use as an anchor watch point if( pRp == pAnchorWatchPoint1 ) pAnchorWatchPoint1 = NULL; if( pRp == pAnchorWatchPoint2 ) pAnchorWatchPoint2 = NULL; } }
void Routeman::AssembleAllRoutes( void ) { // Iterate on the RouteList wxRouteListNode *node = pRouteList->GetFirst(); while( node ) { Route *proute = node->GetData(); proute->AssembleRoute(); if( proute->GetnPoints() ) { pSelect->AddAllSelectableRouteSegments( proute ); } else // this route has no points { pConfig->DeleteConfigRoute( proute ); DeleteRoute( proute ); } node = node->GetNext(); // Route } }