void Route::Reverse( bool bRenamePoints ) { RebuildGUIDList(); // ensure the GUID list is intact and good // Reverse the GUID list wxArrayString ArrayTemp; int ncount = RoutePointGUIDList.GetCount(); for( int i = 0; i < ncount; i++ ) ArrayTemp.Add( RoutePointGUIDList[ncount - 1 - i] ); RoutePointGUIDList = ArrayTemp; pRoutePointList->DeleteContents( false ); pRoutePointList->Clear(); m_nPoints = 0; AssembleRoute(); // Rebuild the route points from the GUID list if( bRenamePoints ) RenameRoutePoints(); // Switch start/end strings. anders, 2010-01-29 wxString tmp = m_RouteStartString; m_RouteStartString = m_RouteEndString; m_RouteEndString = tmp; }
void Route::DeletePoint( RoutePoint *rp, bool bRenamePoints ) { // n.b. must delete Selectables and update config before deleting the point if( rp->m_bIsInLayer ) return; pSelect->DeleteAllSelectableRoutePoints( this ); pSelect->DeleteAllSelectableRouteSegments( this ); pConfig->DeleteWayPoint( rp ); pRoutePointList->DeleteObject( rp ); if( ( rp->m_GUID.Len() ) && ( wxNOT_FOUND != RoutePointGUIDList.Index( rp->m_GUID ) ) ) RoutePointGUIDList.Remove( rp->m_GUID ); delete rp; m_nPoints -= 1; if( bRenamePoints ) RenameRoutePoints(); if( m_nPoints > 1 ) { pSelect->AddAllSelectableRouteSegments( this ); pSelect->AddAllSelectableRoutePoints( this ); pConfig->UpdateRoute( this ); RebuildGUIDList(); // ensure the GUID list is intact and good CalculateBBox(); UpdateSegmentDistances(); } }
RoutePoint *Route::InsertPointAfter( RoutePoint *pRP, double rlat, double rlon, bool bRenamePoints ) { int nRP = pRoutePointList->IndexOf( pRP ); if( nRP >= GetnPoints() - 1 ) return NULL; nRP++; RoutePoint *newpoint = new RoutePoint( rlat, rlon, wxString( _T ( "diamond" ) ), GetNewMarkSequenced(), GPX_EMPTY_STRING ); newpoint->m_bIsInRoute = true; newpoint->m_bDynamicName = true; newpoint->SetNameShown( false ); pRoutePointList->Insert( nRP, newpoint ); RoutePointGUIDList.Insert( pRP->m_GUID, nRP ); if( bRenamePoints ) RenameRoutePoints(); FinalizeForRendering(); UpdateSegmentDistances(); return ( newpoint ); }
RoutePoint *Route::InsertPointBefore( RoutePoint *pRP, double rlat, double rlon, bool bRenamePoints ) { RoutePoint *newpoint = new RoutePoint( rlat, rlon, wxString( _T ( "diamond" ) ), GetNewMarkSequenced(), GPX_EMPTY_STRING ); newpoint->m_bIsInRoute = true; newpoint->m_bDynamicName = true; newpoint->SetNameShown( false ); int nRP = pRoutePointList->IndexOf( pRP ); pRoutePointList->Insert( nRP, newpoint ); RoutePointGUIDList.Insert( pRP->m_GUID, nRP ); m_nPoints++; if( bRenamePoints ) RenameRoutePoints(); CalculateBBox(); UpdateSegmentDistances(); return ( newpoint ); }
void Route::RemovePoint( RoutePoint *rp, bool bRenamePoints ) { if( rp->m_bIsActive && this->IsActive() ) //FS#348 g_pRouteMan->DeactivateRoute(); pSelect->DeleteAllSelectableRoutePoints( this ); pSelect->DeleteAllSelectableRouteSegments( this ); pRoutePointList->DeleteObject( rp ); if( wxNOT_FOUND != RoutePointGUIDList.Index( rp->m_GUID ) ) RoutePointGUIDList.Remove( rp->m_GUID ); m_nPoints -= 1; // check all other routes to see if this point appears in any other route Route *pcontainer_route = g_pRouteMan->FindRouteContainingWaypoint( rp ); if( pcontainer_route == NULL ) { rp->m_bIsInRoute = false; // Take this point out of this (and only) route rp->m_bDynamicName = false; rp->m_bIsolatedMark = true; // This has become an isolated mark } if( bRenamePoints ) RenameRoutePoints(); // if ( m_nPoints > 1 ) { pSelect->AddAllSelectableRouteSegments( this ); pSelect->AddAllSelectableRoutePoints( this ); pConfig->UpdateRoute( this ); RebuildGUIDList(); // ensure the GUID list is intact and good CalculateBBox(); UpdateSegmentDistances(); } }