void doRedoAppendWaypoint( UndoAction* action ) { ODPoint* point = (ODPoint*) action->before[0]; ODPath* path = (ODPath*) action->after[0]; if( action->beforeType[0] == Undo_IsOrphanded ) { pConfig->AddNewODPoint( point, -1 ); pSelect->AddSelectableODPoint( point->m_lat, point->m_lon, point ); } ODPoint* prevpoint = ODPath->GetLastPoint(); path->AddPoint( point ); pSelect->AddSelectablePathSegment( prevpoint->m_lat, prevpoint->m_lon, point->m_lat, point->m_lon, prevpoint, point, path ); if( g_pPathManagerDialog && g_pPathManagerDialog->IsShown() ) g_pPathManagerDialog->UpdateODPointsListCtrl(); if( gFrame->nPath_State > 1 ) { gFrame->nPath_State++; cc1->m_prev_pMousePoint = path->GetLastPoint(); cc1->m_prev_rlat = cc1->m_prev_pMousePoint->m_lat; cc1->m_prev_rlon = cc1->m_prev_pMousePoint->m_lon; path->m_lastMousePointIndex = path->GetnPoints(); } }
void doUndoAppenODPoint( UndoAction* action ) { ODPoint* point = (ODPoint*) action->before[0]; ODPath* path = (ODPath*) action->after[0]; bool noPathLeftToRedo = false; if( (path->GetnPoints() == 2) && (gFrame->nPath_State == 0) ) noPathLeftToRedo = true; m_pPath->RemovePointFromPath( point, path ); 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 doUndoMoveODPoint( UndoAction* action ) { double lat, lon; ODPoint* currentPoint = (ODPoint*) action->after[0]; wxRealPoint* lastPoint = (wxRealPoint*) action->before[0]; lat = currentPoint->m_lat; lon = currentPoint->m_lon; currentPoint->m_lat = lastPoint->y; currentPoint->m_lon = lastPoint->x; lastPoint->y = lat; lastPoint->x = lon; SelectItem* selectable = (SelectItem*) action->selectable[0]; selectable->m_slat = currentPoint->m_lat; selectable->m_slon = currentPoint->m_lon; if( ( NULL != pMarkPropDialog ) && ( pMarkPropDialog->IsShown() ) ){ if( currentPoint == pMarkPropDialog->GetRoutePoint() ) pMarkPropDialog->UpdateProperties(true); } wxArrayPtrVoid* pathArray = g_pPathMan->GetPathArrayContaining( currentPoint ); if( pathArray ) { for( unsigned int ir = 0; ir < pathArray->GetCount(); ir++ ) { ODPath *pp = (ODPath *) pathArray->Item( ir ); pp->FinalizeForRendering(); pp->UpdateSegmentDistances(); g_pODConfig->UpdatePath( pp ); } delete pathArray; } }
void GZ::UpdateGZ( ODPoint *pGZPoint, bool bUpdateSelectablePath ) { if(pGZPoint == m_pODPointList->GetFirst()->GetData()) { DistanceBearingMercator_Plugin( pGZPoint->m_lat, pGZPoint->m_lon, g_pfFix.Lat, g_pfFix.Lon, &m_dFirstLineDirection, &m_dFirstDistance ); if(m_bRotateWithBoat) { switch(m_iMaintainWith) { case ID_MAINTAIN_WITH_HEADING: m_dFirstLineDirection -= g_pfFix.Hdt; break; case ID_MAINTAIN_WITH_COG: m_dFirstLineDirection -= g_pfFix.Cog; break; } } } else { DistanceBearingMercator_Plugin( pGZPoint->m_lat, pGZPoint->m_lon, g_pfFix.Lat, g_pfFix.Lon, &m_dSecondLineDirection, &m_dSecondDistance ); if(m_bRotateWithBoat) { switch(m_iMaintainWith) { case ID_MAINTAIN_WITH_HEADING: m_dSecondLineDirection -= g_pfFix.Hdt; break; case ID_MAINTAIN_WITH_COG: m_dSecondLineDirection -= g_pfFix.Cog; break; } } } UpdateGZ( bUpdateSelectablePath ); bool prev_bskip = g_pODConfig->m_bSkipChangeSetUpdate; g_pODConfig->m_bSkipChangeSetUpdate = false; g_pODConfig->UpdatePath( this ); g_pODConfig->m_bSkipChangeSetUpdate = prev_bskip; for( unsigned int ip = 0; ip < m_pODPointList->GetCount(); ip++ ) { ODPath *pp = (ODPath *) m_pODPointList->Item( ip ); if( g_pPathMan->IsPathValid(pp) ) { pp->FinalizeForRendering(); pp->m_bIsBeingEdited = false; g_pODConfig->UpdatePath( pp ); pp->SetHiLite( 0 ); } } // Update the PathProperties Dialog, if currently shown if( ( NULL != g_pGZPropDialog ) && ( g_pGZPropDialog->IsShown() ) ) { for( unsigned int ip = 0; ip < m_pODPointList->GetCount(); ip++ ) { ODPath *pp = (ODPath *) m_pODPointList->Item( ip ); if( g_pPathMan->IsPathValid(pp) ) { g_pGZPropDialog->SetPathAndUpdate( pp, true ); } } } }
void PointMan::DestroyODPoint( ODPoint *pRp, bool b_update_changeset ) { if( ! b_update_changeset ) g_pODConfig->m_bSkipChangeSetUpdate = true; // turn OFF change-set updating if requested if( pRp ) { // Get a list of all boundaries containing this point // and remove the point from them all wxArrayPtrVoid *ppath_array = g_pPathMan->GetPathArrayContaining( pRp ); if( ppath_array ) { for( unsigned int ib = 0; ib < ppath_array->GetCount(); ib++ ) { ODPath *pb = (ODPath *) ppath_array->Item( ib ); pb->RemovePoint( pRp ); } // Scrub the paths, looking for one-point routes for( unsigned int ib = 0; ib < ppath_array->GetCount(); ib++ ) { ODPath *pb = (ODPath *) ppath_array->Item( ib ); if( pb->GetnPoints() < 2 ) { bool prev_bskip = g_pODConfig->m_bSkipChangeSetUpdate; g_pODConfig->m_bSkipChangeSetUpdate = true; g_pODConfig->DeleteConfigPath( pb ); g_pPathMan->DeletePath( pb ); g_pODConfig->m_bSkipChangeSetUpdate = prev_bskip; } } delete ppath_array; } // Now it is safe to delete the point g_pODConfig->DeleteODPoint( pRp ); g_pODConfig->m_bSkipChangeSetUpdate = false; g_pODSelect->DeleteSelectableODPoint( pRp ); RemoveODPoint( pRp); } }
void EBL::UpdateEBL( void ) { g_pODSelect->DeleteAllSelectablePathSegments( this ); g_pODSelect->DeleteAllSelectableODPoints( this ); g_pODSelect->AddAllSelectablePathSegments( this ); g_pODSelect->AddAllSelectableODPoints( this ); FinalizeForRendering(); UpdateSegmentDistances(); bool prev_bskip = g_pODConfig->m_bSkipChangeSetUpdate; g_pODConfig->m_bSkipChangeSetUpdate = false; if(m_iPersistenceType == ID_EBL_PERSISTENT || m_iPersistenceType == ID_EBL_PERSISTENT_CRASH) g_pODConfig->UpdatePath( this ); g_pODConfig->m_bSkipChangeSetUpdate = prev_bskip; for( unsigned int ip = 0; ip < m_pODPointList->GetCount(); ip++ ) { ODPath *pp = (ODPath *) m_pODPointList->Item( ip ); if( g_pPathMan->IsPathValid(pp) ) { pp->FinalizeForRendering(); pp->UpdateSegmentDistances(); pp->m_bIsBeingEdited = false; g_pODConfig->UpdatePath( pp ); pp->SetHiLite( 0 ); } } // Update the PathProperties Dialog, if currently shown if( ( NULL != g_pEBLPropDialog ) && ( g_pEBLPropDialog->IsShown() ) ) { if( m_pODPointList ) { for( unsigned int ip = 0; ip < m_pODPointList->GetCount(); ip++ ) { ODPath *pp = (ODPath *) m_pODPointList->Item( ip ); if( g_pPathMan->IsPathValid(pp) ) { g_pEBLPropDialog->SetPathAndUpdate( pp, true ); } } } } }
void PathMan::SetColorScheme( PI_ColorScheme cs ) { // Iterate on the RouteList wxPathListNode *node = g_pPathList->GetFirst(); while( node ) { ODPath *ppath = node->GetData(); ppath->SetColourScheme(cs); node = node->GetNext(); } // Re-Create the pens and colors m_pActiveODPointPen = wxThePenList->FindOrCreatePen( wxColour( 0, 0, 255 ), g_path_line_width, wxPENSTYLE_SOLID ); m_pODPointPen = wxThePenList->FindOrCreatePen( wxColour( 0, 0, 255 ), g_path_line_width, wxPENSTYLE_SOLID ); // Or in something like S-52 compliance wxColour tColour; GetGlobalColor( wxS("UINFB"), &tColour ); m_pPathPen = wxThePenList->FindOrCreatePen( tColour, g_path_line_width, wxPENSTYLE_SOLID ); m_pPathBrush = wxTheBrushList->FindOrCreateBrush( tColour, wxPENSTYLE_SOLID ); GetGlobalColor( wxS("UINFO"), &tColour ); m_pSelectedPathPen = wxThePenList->FindOrCreatePen( tColour, g_path_line_width, wxPENSTYLE_SOLID ); m_pSelectedPathBrush = wxTheBrushList->FindOrCreateBrush( tColour, wxPENSTYLE_SOLID ); GetGlobalColor( wxS("UARTE"), &tColour ); m_pActivePathPen = wxThePenList->FindOrCreatePen( tColour, g_path_line_width, wxPENSTYLE_SOLID ); GetGlobalColor( wxS("PLRTE"), &tColour ); m_pActivePathBrush = wxTheBrushList->FindOrCreateBrush( tColour, wxPENSTYLE_SOLID ); m_pActiveODPointBrush = wxTheBrushList->FindOrCreateBrush( tColour, wxPENSTYLE_SOLID); m_pActiveODPointPen = wxThePenList->FindOrCreatePen( tColour, g_path_line_width, wxPENSTYLE_SOLID ); GetGlobalColor( wxS("CHBLK"), &tColour ); m_pODPointPen = wxThePenList->FindOrCreatePen( tColour, g_path_line_width, wxPENSTYLE_SOLID ); m_pODPointBrush = wxTheBrushList->FindOrCreateBrush( tColour, wxPENSTYLE_SOLID); }
void ODConfig::ExportGPX( wxWindow* parent, bool bviz_only, bool blayer ) { wxFileDialog saveDialog( NULL, _( "Export GPX file" ), m_gpx_path, wxT ( "" ), wxT ( "GPX files (*.gpx)|*.gpx" ), wxFD_SAVE ); int response = saveDialog.ShowModal(); wxString path = saveDialog.GetPath(); wxFileName fn( path ); m_gpx_path = fn.GetPath(); if( response == wxID_OK ) { fn.SetExt( _T ( "gpx" ) ); if( wxFileExists( fn.GetFullPath() ) ) { int answer = OCPNMessageBox_PlugIn( NULL, _("Overwrite existing file?"), _("Confirm"), wxICON_QUESTION | wxYES_NO | wxCANCEL ); if( answer != wxID_YES ) return; } ::wxBeginBusyCursor(); ODNavObjectChanges *pgpx = new ODNavObjectChanges; wxProgressDialog *pprog = NULL; int count = g_pODPointMan->GetODPointList()->GetCount(); if( count > 200) { pprog = new wxProgressDialog( _("Export GPX file"), _T("0/0"), count, NULL, wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME ); pprog->SetSize( 400, wxDefaultCoord ); pprog->Centre(); } //Points int ic = 0; wxODPointListNode *node = g_pODPointMan->GetODPointList()->GetFirst(); ODPoint *pr; while( node ) { if(pprog) { wxString msg; msg.Printf(_T("%d/%d"), ic, count); pprog->Update( ic, msg ); ic++; } pr = node->GetData(); bool b_add = true; if( bviz_only && !pr->m_bIsVisible ) b_add = false; if( pr->m_bIsInLayer && !blayer ) b_add = false; if( b_add) { if( pr->m_bKeepXPath || !ODPointIsInPathList( pr ) ) pgpx->AddGPXODPoint( pr); } node = node->GetNext(); } //Paths wxPathListNode *node1 = g_pPathList->GetFirst(); while( node1 ) { ODPath *pPath = node1->GetData(); bool b_add = true; if( bviz_only && !pPath->IsVisible() ) b_add = false; if( pPath->m_bIsInLayer && !blayer ) b_add = false; if( b_add ) { pgpx->AddGPXPath( pPath ); } node1 = node1->GetNext(); } pgpx->SaveFile( fn.GetFullPath() ); delete pgpx; ::wxEndBusyCursor(); if( pprog) delete pprog; } }