diff --git a/.circleci/config.yml b/.circleci/config.yml index 126a4750..8af99517 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -313,6 +313,7 @@ jobs: - BUILD_GTK3: true - OCPN_TARGET: bionic-gtk3 - DEPLOY_USE_ORB: true + - BUILD_ENV=ubuntu steps: - checkout - run: > @@ -332,6 +333,7 @@ jobs: - BUILD_GTK3: true - OCPN_TARGET: focal-gtk3 - DEPLOY_USE_ORB: true + - BUILD_ENV=ubuntu steps: - checkout - run: > diff --git a/CMakeLists.txt b/CMakeLists.txt index 04b5b1c2..1e8e9a9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,9 +30,9 @@ set(PACKAGE "ocpn_draw") set(VERSION_MAJOR "1") set(VERSION_MINOR "8") -set(VERSION_PATCH "13") -set(VERSION_TWEAK "2") -set(VERSION_DATE "02/02/2021") # DD/MM/YYYY format +set(VERSION_PATCH "14") +set(VERSION_TWEAK "0") +set(VERSION_DATE "09/03/2021") # DD/MM/YYYY format set(OCPN_MIN_VERSION "ov50") set(OCPN_API_VERSION_MAJOR "1") set(OCPN_API_VERSION_MINOR "16") diff --git a/cmake/PluginConfigure.cmake b/cmake/PluginConfigure.cmake index 8454d204..a705857f 100644 --- a/cmake/PluginConfigure.cmake +++ b/cmake/PluginConfigure.cmake @@ -270,10 +270,11 @@ if(MINGW) endif(MINGW) if(APPLE) - add_definitions("-Wall -Wno-unused -fexceptions -Wno-overloaded-virtual") - add_definitions(" -g -fno-strict-aliasing") - add_definitions(" -Wno-deprecated -Wno-deprecated-declarations -Wno-unknown-pragmas") - add_definitions(" -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_") + string(APPEND CMAKE_CXX_FLAGS " -Wall -Wno-unused -fexceptions -Wno-overloaded-virtual") + string(APPEND CMAKE_CXX_FLAGS " -g -fno-strict-aliasing") + string(APPEND CMAKE_CXX_FLAGS " -Wno-deprecated -Wno-deprecated-declarations -Wno-unknown-pragmas") + string(APPEND CMAKE_CXX_FLAGS " -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_") + string(APPEND CMAKE_CXX_FLAGS " -DAPPLE") endif(APPLE) # Add some definitions to satisfy MS diff --git a/src/Boundary.cpp b/src/Boundary.cpp index 47c8f22e..120c95eb 100644 --- a/src/Boundary.cpp +++ b/src/Boundary.cpp @@ -64,7 +64,7 @@ Boundary::Boundary() : ODPath() CreateColourSchemes(); SetColourScheme(); SetActiveColours(); - + } Boundary::~Boundary() @@ -125,7 +125,7 @@ void Boundary::Draw( ODDC& dc, PlugIn_ViewPort &piVP ) GetCanvasPixLL( &piVP, &r, pOp->m_lat, pOp->m_lon ); m_bpts[ l_iBoundaryPointCount++ ] = r; } - + if( m_bExclusionBoundary && !m_bInclusionBoundary ) { // fill boundary with hatching #if wxUSE_GRAPHICS_CONTEXT == 1 @@ -168,7 +168,7 @@ void Boundary::Draw( ODDC& dc, PlugIn_ViewPort &piVP ) } if(l_imaxpointdiffX < 10 && l_imaxpointdiffY < 10 ) return; - // Use ClipperLib to manage Polygon + // Use ClipperLib to manage Polygon // If needed simplify polygons to make shading stay outside Paths poly(1); for( size_t i = 0; i < m_pODPointList->GetCount(); i++ ) { @@ -180,7 +180,7 @@ void Boundary::Draw( ODDC& dc, PlugIn_ViewPort &piVP ) Paths ExpandedBoundaries; co.AddPaths( polys, jtSquare, etClosedPolygon ); co.Execute( ExpandedBoundaries, m_iInclusionBoundarySize ); - + wxPoint *l_InclusionBoundary = new wxPoint[ ExpandedBoundaries[0].size() + 1 ]; for( size_t i = 0; i < ExpandedBoundaries[0].size(); i++ ) { @@ -194,7 +194,7 @@ void Boundary::Draw( ODDC& dc, PlugIn_ViewPort &piVP ) int l_iPolygonPointCount[2]; l_iPolygonPointCount[0] = m_pODPointList->GetCount(); l_iPolygonPointCount[1] = ExpandedBoundaries[0].size() + 1; - + #if wxUSE_GRAPHICS_CONTEXT == 1 wxGraphicsContext *wxGC = NULL; wxMemoryDC *pmdc = wxDynamicCast(dc.GetDC(), wxMemoryDC); @@ -231,10 +231,8 @@ void Boundary::Draw( ODDC& dc, PlugIn_ViewPort &piVP ) co.Clear(); delete [] l_InclusionBoundary; } - wxDELETEA( m_bpts ); } - ODPath::Draw( dc, piVP ); } @@ -256,7 +254,7 @@ void Boundary::DrawGL( PlugIn_ViewPort &piVP ) GetCanvasPixLL( &piVP, &r, pOp->m_lat, pOp->m_lon ); m_bpts[ l_iBoundaryPointCount++ ] = r; } - + if( !m_bExclusionBoundary && m_bInclusionBoundary && m_pODPointList->GetCount() > 3 ) { // surround boundary with hatching if there is more than 10 pixels different between points int l_imaxpointdiffX = 0; @@ -269,7 +267,7 @@ void Boundary::DrawGL( PlugIn_ViewPort &piVP ) } if(l_imaxpointdiffX < 10 && l_imaxpointdiffY < 10 ) return; - // Use ClipperLib to manage Polygon + // Use ClipperLib to manage Polygon // If needed simplify polygons to make shading stay outside Paths poly(1); for( int i = 0; i < l_iBoundaryPointCount; i++ ) { @@ -281,7 +279,7 @@ void Boundary::DrawGL( PlugIn_ViewPort &piVP ) Paths ExpandedBoundaries; co.AddPaths( simplePolys, jtSquare, etClosedPolygon ); co.Execute( ExpandedBoundaries, m_iInclusionBoundarySize ); - + int l_iInclusionBoundarySize = ExpandedBoundaries[0].size(); wxPoint *l_InclusionBoundary = new wxPoint[ l_iInclusionBoundarySize + 1 ]; for( int i = 0; i < l_iInclusionBoundarySize; i++ ) @@ -306,7 +304,7 @@ void Boundary::DrawGL( PlugIn_ViewPort &piVP ) delete [] l_InclusionBoundary; ExpandedBoundaries.clear(); } - + // Each byte represents a single pixel for Alpha. This provides a cross hatch in a 16x16 pixel square GLubyte slope_cross_hatch[] = { 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -316,7 +314,7 @@ void Boundary::DrawGL( PlugIn_ViewPort &piVP ) 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, - 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, @@ -325,7 +323,7 @@ void Boundary::DrawGL( PlugIn_ViewPort &piVP ) 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF - }; + }; GLuint textureID; checkGlError("Before glGenTextures", __FILE__, __LINE__); @@ -393,11 +391,8 @@ void Boundary::DrawGL( PlugIn_ViewPort &piVP ) #endif glDeleteTextures(1, &textureID); checkGlError("glDeleteTextures", __FILE__, __LINE__); + } - wxDELETEA( m_bpts ); - - } - } ODPath::DrawGL( piVP ); #else @@ -409,21 +404,21 @@ void Boundary::DeletePoint( ODPoint *op, bool bRenamePoints ) { // n.b. must delete Selectables and update config before deleting the point if( op->m_bIsInLayer ) return; - + if((ODPoint *)m_pODPointList->GetFirst()->GetData() == op) { m_pODPointList->DeleteObject( op ); m_pODPointList->Append( (ODPoint *)m_pODPointList->GetFirst()->GetData() ); } - + ODPath::DeletePoint( op, bRenamePoints ); } void Boundary::SetActiveColours( void ) { wxString fillcolour; - + ODPath::SetActiveColours(); - + if( m_bVisible && m_bPathIsActive ) m_fillcol = m_wxcSchemeActiveFillColour; else m_fillcol = m_wxcSchemeInActiveFillColour; } @@ -449,24 +444,24 @@ ODPoint *Boundary::InsertPointAfter( ODPoint *pOP, double lat, double lon, bool if( nOP >= m_nPoints - 1 ) return NULL; nOP++; - + BoundaryPoint *newpoint = new BoundaryPoint( lat, lon, g_sODPointIconName, GetNewMarkSequenced(), wxT("") ); newpoint->m_bIsInPath = true; newpoint->m_bDynamicName = true; newpoint->SetNameShown( false ); newpoint->SetTypeString( wxT("Boundary Point") ); - + m_pODPointList->Insert( nOP, newpoint ); - + ODPointGUIDList.Insert( pOP->m_GUID, nOP ); - + m_nPoints++; - + if( bRenamePoints ) RenameODPoints(); - + FinalizeForRendering(); UpdateSegmentDistances(); - + return ( newpoint ); } @@ -485,7 +480,7 @@ void Boundary::RemovePointFromPath(ODPoint* point, ODPath* path) m_pODPointList->DeleteObject( point ); m_pODPointList->Append( (ODPoint *)m_pODPointList->GetFirst()->GetData() ); } - + ODPath::RemovePointFromPath(point, path); } diff --git a/src/ODPath.cpp b/src/ODPath.cpp index e79c0c41..7a8a194d 100644 --- a/src/ODPath.cpp +++ b/src/ODPath.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * * Project: OpenCPN - * Purpose: Path + * Purpose: Path * Author: Jon Gough * *************************************************************************** @@ -59,6 +59,7 @@ ODPath::ODPath( void ) m_bIsBeingCreated = true; m_bDrawArrow = false; m_nPoints = 0; + m_bpts = NULL; m_nm_sequence = 1; m_path_length = 0.0; m_bVisible = true; @@ -77,7 +78,7 @@ ODPath::ODPath( void ) m_pFirstAddedPoint = NULL; m_GUID = GetUUID(); m_bTemporary = false; - + m_bNeedsUpdateBBox = true; RBBox.Set(0.0, 0.0, 0.0, 0.0); m_bcrosses_idl = false; @@ -91,10 +92,10 @@ ODPath::ODPath( void ) CreateColourSchemes(); SetColourScheme(g_global_color_scheme); SetActiveColours(); - + m_lastMousePointIndex = 0; m_NextLegGreatCircle = false; - + m_HyperlinkList = new HyperlinkList; } @@ -128,7 +129,7 @@ void ODPath::AddPoint( ODPoint *pNewPoint, bool b_rename_in_sequence, bool b_def pNewPoint->m_bIsInPath = true; m_pODPointList->Append( pNewPoint ); - + m_nPoints++; @@ -137,7 +138,7 @@ void ODPath::AddPoint( ODPoint *pNewPoint, bool b_rename_in_sequence, bool b_def if ( m_pFirstAddedPoint == NULL ) m_pFirstAddedPoint = pNewPoint; - + if (!b_isLoading) UpdateSegmentDistances(); m_pLastAddedPoint = pNewPoint; @@ -202,7 +203,7 @@ void ODPath::DrawSegment( ODDC& dc, wxPoint *rp1, wxPoint *rp2, PlugIn_ViewPort if( m_bPathIsActive ) dc.SetPen( *g_pPathMan->GetActivePathPen() ); else dc.SetPen( *g_pPathMan->GetPathPen() ); - + RenderSegment( dc, rp1->x, rp1->y, rp2->x, rp2->y, VP, bdraw_arrow ); } @@ -215,7 +216,7 @@ void ODPath::DrawArcSegment( ODDC& dc, wxPoint *rpc, wxPoint *rp1, wxPoint *rp2, dc.SetPen( *g_pPathMan->GetPathPen() ); } dc.SetBrush( *wxTRANSPARENT_BRUSH ); - + RenderArcSegment(dc, rpc, rp1, rp2, rp3, rp4, VP, false); } @@ -231,7 +232,7 @@ void ODPath::Draw( ODDC& dc, PlugIn_ViewPort &VP ) if( m_width != STYLE_UNDEFINED ) width = m_width; SetActiveColours(); - + dc.SetPen( *wxThePenList->FindOrCreatePen( m_col, width, style ) ); dc.SetBrush( *wxTheBrushList->FindOrCreateBrush( m_col, wxBRUSHSTYLE_SOLID ) ); @@ -245,9 +246,9 @@ void ODPath::Draw( ODDC& dc, PlugIn_ViewPort &VP ) wxODPointListNode *node = m_pODPointList->GetFirst(); ODPoint *pOp1 = node->GetData(); node = node->GetNext(); - + m_bpts[ j++ ] = ppt1; - + if ( !m_bVisible && pOp1->m_bKeepXPath ) pOp1->Draw( dc ); @@ -293,30 +294,30 @@ void ODPath::Draw( ODDC& dc, PlugIn_ViewPort &VP ) if( ppt1.x < ppt2.x ) adder = (int) pix_full_circle; else adder = -(int) pix_full_circle; - + float rxd = ppt2.x - ( ppt1.x + adder ); float ryd = ppt1.y - ppt2.y; dtest = rxd*rxd + ryd*ryd; - + if( dp < dtest ) adder = 0; RenderSegment( dc, ppt1.x + adder, ppt1.y, ppt2.x, ppt2.y, VP, m_bDrawArrow, m_hiliteWidth ); } } - + ppt1 = ppt2; pOp1 = pOp2; node = node->GetNext(); } - + for(wxODPointListNode *node = m_pODPointList->GetFirst(); node; node = node->GetNext()) { ODPoint *pOp = node->GetData(); wxPoint r; GetCanvasPixLL( &VP, &r, pOp->m_lat, pOp->m_lon ); if ( m_bVisible || pOp->m_bKeepXPath ) pOp->Draw( dc, &r ); - } + } wxDELETEA( m_bpts ); } @@ -330,30 +331,31 @@ void ODPath::DrawGL( PlugIn_ViewPort &piVP ) /* determine color and width */ wxPenStyle style = wxPENSTYLE_SOLID; int width = g_path_line_width; - + if( m_style != STYLE_UNDEFINED ) style = m_style; if( m_width != STYLE_UNDEFINED ) width = m_width; - + SetActiveColours(); int j = 0; wxPoint r; - m_bpts = new wxPoint[ m_pODPointList->GetCount() ]; - for(wxODPointListNode *node = m_pODPointList->GetFirst(); node; node = node->GetNext()) { - ODPoint *pOp = node->GetData(); - GetCanvasPixLL( &piVP, &r, pOp->m_lat, pOp->m_lon ); - m_bpts[ j++ ] = r; + if(m_bpts == NULL) { + m_bpts = new wxPoint[ m_pODPointList->GetCount() ]; + for(wxODPointListNode *node = m_pODPointList->GetFirst(); node; node = node->GetNext()) { + ODPoint *pOp = node->GetData(); + GetCanvasPixLL( &piVP, &r, pOp->m_lat, pOp->m_lon ); + m_bpts[ j++ ] = r; + } } - dc.SetPen( *wxThePenList->FindOrCreatePen( m_col, width, style ) ); dc.SetBrush( *wxTheBrushList->FindOrCreateBrush( m_col, wxBRUSHSTYLE_TRANSPARENT ) ); dc.SetGLStipple(); - + for( size_t i = 1; i < m_pODPointList->GetCount(); i++ ){ dc.DrawLine(m_bpts[i-1].x, m_bpts[i - 1].y, m_bpts[i].x, m_bpts[i].y); } - + glDisable( GL_LINE_STIPPLE ); dc.SetBrush( *wxTheBrushList->FindOrCreateBrush( m_col, wxBRUSHSTYLE_SOLID ) ); @@ -366,8 +368,8 @@ void ODPath::DrawGL( PlugIn_ViewPort &piVP ) ODPoint *pOp = node->GetData(); if ( m_bVisible || pOp->m_bKeepXPath ) pOp->DrawGL( piVP ); - } - + } + wxDELETEA( m_bpts ); #endif } @@ -464,7 +466,7 @@ void ODPath::RenderSegment( ODDC& dc, int xa, int ya, int xb, int yb, PlugIn_Vie } } -void ODPath::RenderArcSegment( ODDC& dc, wxPoint *rpc, wxPoint *rp1, wxPoint *rp2, wxPoint *rp3, wxPoint *rp4, PlugIn_ViewPort &VP, bool bdraw_arrow ) +void ODPath::RenderArcSegment( ODDC& dc, wxPoint *rpc, wxPoint *rp1, wxPoint *rp2, wxPoint *rp3, wxPoint *rp4, PlugIn_ViewPort &VP, bool bdraw_arrow ) { RenderArcSegment( dc, rpc->x, rpc->y, rp1->x, rp1->y, rp2->x, rp2->y, rp3->x, rp3->y, rp4->x, rp4->y, VP, bdraw_arrow ); } @@ -476,7 +478,7 @@ void ODPath::RenderArcSegment( ODDC& dc, int centre_x, int centre_y, int xa, int int sx, sy; sx = VP.pix_width; sy = VP.pix_height; - + // Try to exit early if the segment is nowhere near the screen wxRect r( 0, 0, sx, sy ); wxRect w( centre_x, centre_y, 1, 1 ); @@ -492,49 +494,49 @@ void ODPath::RenderArcSegment( ODDC& dc, int centre_x, int centre_y, int xa, int if( !r.Intersects( w ) ) { return; } - + // If hilite is desired, use a Native Graphics context to render alpha colours // That is, if wxGraphicsContext is available..... - + if( hilite_width ) { wxPen psave = dc.GetPen(); - + wxColour y; GetGlobalColor( wxS( "YELO1" ), &y ); wxColour hilt( y.Red(), y.Green(), y.Blue(), 128 ); - + wxPen HiPen( hilt, hilite_width, wxPENSTYLE_SOLID ); - + dc.SetPen( HiPen ); dc.StrokeSector( centre_x, centre_y, xa, ya, xb, yb, xc, yc, xd, yd ); - + dc.SetPen( psave ); dc.StrokeSector( centre_x, centre_y, xa, ya, xb, yb, xc, yc, xd, yd ); } else { dc.StrokeSector( centre_x, centre_y, xa, ya, xb, yb, xc, yc, xd, yd ); } - + if( bdraw_arrow ) { // Draw a direction arrow - + double theta = atan2( (double) ( yb - ya ), (double) ( xb - xa ) ); theta -= PI / 2.; - + wxPoint icon[10]; double icon_scale_factor = 100 * VP.view_scale_ppm; icon_scale_factor = fmin ( icon_scale_factor, 1.5 ); // Sets the max size icon_scale_factor = fmax ( icon_scale_factor, .10 ); - + // Get the absolute line length // and constrain the arrow to be no more than xx% of the line length double nom_arrow_size = 20.; double max_arrow_to_leg = .20; double lpp = sqrt( pow( (double) ( xa - xb ), 2 ) + pow( (double) ( ya - yb ), 2 ) ); - + double icon_size = icon_scale_factor * nom_arrow_size; if( icon_size > ( lpp * max_arrow_to_leg ) ) icon_scale_factor = ( lpp * max_arrow_to_leg ) / nom_arrow_size; - + int xc, yc; // move the pointer back from the icon xc = xb - ( ( xb - xa ) / 20 ); yc = yb - ( ( yb - ya ) / 20 ); @@ -542,13 +544,13 @@ void ODPath::RenderArcSegment( ODDC& dc, int centre_x, int centre_y, int xa, int int j = i * 2; double pxa = (double) ( s_arrow_icon[j] ); double pya = (double) ( s_arrow_icon[j + 1] ); - + pya *= icon_scale_factor; pxa *= icon_scale_factor; - + double px = ( pxa * sin( theta ) ) + ( pya * cos( theta ) ); double py = ( pya * sin( theta ) ) - ( pxa * cos( theta ) ); - + icon[i].x = (int) ( px ) + xc; icon[i].y = (int) ( py ) + yc; } @@ -563,17 +565,17 @@ void ODPath::RenderSegmentArrowsGL( int xa, int ya, int xb, int yb, PlugIn_ViewP { #if 0 #ifdef ocpnUSE_GL - // Draw a direction arrow + // Draw a direction arrow float icon_scale_factor = 100 * VP.view_scale_ppm; icon_scale_factor = fmin ( icon_scale_factor, 1.5 ); // Sets the max size icon_scale_factor = fmax ( icon_scale_factor, .10 ); - + // Get the absolute line length // and constrain the arrow to be no more than xx% of the line length float nom_arrow_size = 20.; float max_arrow_to_leg = (float).20; float lpp = sqrtf( powf( (float) (xa - xb), 2) + powf( (float) (ya - yb), 2) ); - + float icon_size = icon_scale_factor * nom_arrow_size; if( icon_size > ( lpp * max_arrow_to_leg ) ) icon_scale_factor = ( lpp * max_arrow_to_leg ) @@ -621,7 +623,7 @@ wxString ODPath::GetNewMarkSequenced( void ) long num; num = 0; ODPoint *pop = NULL; - + wxODPointListNode *node = m_pODPointList->GetFirst(); while ( node ) { pop = node->GetData(); @@ -845,7 +847,7 @@ void ODPath::CalculateDCRect( wxDC& dc_boundary, wxRect *prect, PlugIn_ViewPort { dc_boundary.ResetBoundingBox(); dc_boundary.DestroyClippingRegion(); - + wxRect update_rect; // Draw the path in skeleton form on the dc @@ -868,7 +870,7 @@ void ODPath::CalculateDCRect( wxDC& dc_boundary, wxRect *prect, PlugIn_ViewPort wxRect r = pOp2->CurrentRect_in_DC ; r.Inflate(m_hiliteWidth, m_hiliteWidth); // allow for large hilite circles at segment ends - + update_rect.Union( r ); node = node->GetNext(); } @@ -1035,7 +1037,7 @@ ODPoint *ODPath::InsertPointBefore( ODPoint *pOP, double lat, double lon, bool b newpoint->m_bDynamicName = true; newpoint->SetNameShown( false ); newpoint->SetTypeString( wxT("Boundary Point") ); - + int nOP = m_pODPointList->IndexOf( pOP ); if ( nOP == 0 ) { m_pODPointList->Insert( m_pODPointList->GetCount() - 1, newpoint ); @@ -1063,24 +1065,24 @@ ODPoint *ODPath::InsertPointAfter( ODPoint *pOP, double lat, double lon, bool bR if( nOP >= m_nPoints - 1 ) return NULL; nOP++; - + ODPoint *newpoint = new ODPoint( lat, lon, g_sODPointIconName, GetNewMarkSequenced(), wxT("") ); newpoint->m_bIsInPath = true; newpoint->m_bDynamicName = true; newpoint->SetNameShown( false ); newpoint->SetTypeString( wxT("OD Point") ); - + m_pODPointList->Insert( nOP, newpoint ); - + ODPointGUIDList.Insert( pOP->m_GUID, nOP ); - + m_nPoints++; - + if( bRenamePoints ) RenameODPoints(); - + FinalizeForRendering(); UpdateSegmentDistances(); - + return ( newpoint ); } @@ -1090,18 +1092,18 @@ void ODPath::InsertPointAfter( ODPoint *pOP, ODPoint *pnOP, bool bRenamePoints ) if( nOP >= m_nPoints - 1 ) return; nOP++; - + m_pODPointList->Insert( nOP, pnOP ); - + ODPointGUIDList.Insert( pnOP->m_GUID, nOP ); - + m_nPoints++; - + if( bRenamePoints ) RenameODPoints(); - + FinalizeForRendering(); UpdateSegmentDistances(); - + return; } @@ -1118,8 +1120,8 @@ void ODPath::RemovePointFromPath( ODPoint* point, ODPath* path ) g_pODConfig->DeleteConfigPath( path ); g_pPathMan->DeletePath( path ); path = NULL; - } - + } + // Add this point back into the selectables g_pODSelect->AddSelectableODPoint( point->m_lat, point->m_lon, point ); @@ -1132,7 +1134,7 @@ void ODPath::RemovePointFromPath( ODPoint* point, ODPath* path ) void ODPath::SetActiveColours( void ) { wxString colour; - + if( m_bVisible && m_bPathIsActive ) { if((m_bPathManagerBlink || m_bPathPropertiesBlink) && (g_ocpn_draw_pi->nBlinkerTick & 1)) m_col= m_wxcSchemeInActiveLineColour; @@ -1205,12 +1207,12 @@ void ODPath::SetPointVisibility() for(wxODPointListNode *node = m_pODPointList->GetFirst(); node; node = node->GetNext()) { ODPoint *pOp = node->GetData(); pOp->SetVisible( m_bODPointsVisible ); - } - + } + } void ODPath::SetColours( ODPath *pPath ) { - m_wxcActiveLineColour = pPath->m_wxcActiveLineColour; + m_wxcActiveLineColour = pPath->m_wxcActiveLineColour; m_wxcInActiveLineColour = pPath->m_wxcInActiveLineColour; } diff --git a/src/ocpn_draw_pi.cpp b/src/ocpn_draw_pi.cpp index 3b8fcd29..0f22bdd9 100644 --- a/src/ocpn_draw_pi.cpp +++ b/src/ocpn_draw_pi.cpp @@ -783,74 +783,134 @@ bool ocpn_draw_pi::DeInit(void) { RemoveCanvasContextMenuItem(m_iODToolContextId); - m_BlinkTimer.Stop(); + if(m_BlinkTimer.IsRunning()) + m_BlinkTimer.Stop(); m_BlinkTimer.Unbind(wxEVT_TIMER, &ODEventHandler::OnODTimer, g_ODEventHandler); + if(m_RolloverPopupTimer.IsRunning()) + m_RolloverPopupTimer.Stop(); m_RolloverPopupTimer.Unbind( wxEVT_TIMER, &ODEventHandler::OnRolloverPopupTimerEvent, g_ODEventHandler); - if( g_ODEventHandler ) delete g_ODEventHandler; + + if( g_ODEventHandler ) { + if(g_ODEventHandler->GetEvtHandlerEnabled()) + g_ODEventHandler->SetEvtHandlerEnabled(false); + delete g_ODEventHandler; + } g_ODEventHandler = NULL; - if( g_pODRolloverWin ) g_pODRolloverWin->Destroy(); + if( g_pODRolloverWin ) +#ifdef APPLE + delete g_pODRolloverWin; +#else + g_pODRolloverWin->Close(); +#endif + g_pODRolloverWin = NULL; + if( g_pODPathPropDialog ) { + g_iDefaultPathPropertyDialogPostionX = g_pODPathPropDialog->GetPosition().x; + g_iDefaultPathPropertyDialogPostionY = g_pODPathPropDialog->GetPosition().y; +#ifdef APPLE + delete g_pODPointPropDialog; +#else + g_pODPathPropDialog->Close(); +#endif + } g_pODPathPropDialog = NULL; if( g_pODPointPropDialog ) { g_iDefaultPointPropertyDialogPostionX = g_pODPointPropDialog->GetPosition().x; g_iDefaultPointPropertyDialogPostionY = g_pODPointPropDialog->GetPosition().y; - g_pODPointPropDialog->Destroy(); +#ifdef APPLE + delete g_pODPointPropDialog; +#else + g_pODPointPropDialog->Close(); +#endif } g_pODPointPropDialog = NULL; if ( g_pBoundaryPropDialog ) { g_iDefaultBoundaryPropertyDialogPostionX = g_pBoundaryPropDialog->GetPosition().x; g_iDefaultBoundaryPropertyDialogPostionY = g_pBoundaryPropDialog->GetPosition().y; - g_pBoundaryPropDialog->Destroy(); +#ifdef APPLE + delete g_pBoundaryPropDialog; +#else + g_pBoundaryPropDialog->Close(); +#endif } g_pBoundaryPropDialog = NULL; if ( g_pEBLPropDialog ) { - g_pEBLPropDialog->Destroy(); g_iDefaultEBLPropertyDialogPostionX = g_pEBLPropDialog->GetPosition().x; g_iDefaultEBLPropertyDialogPostionY = g_pEBLPropDialog->GetPosition().y; +#ifdef APPLE + delete g_pEBLPropDialog; +#else + g_pEBLPropDialog->Close(); +#endif } g_pEBLPropDialog = NULL; if ( g_pDRPropDialog ) { g_iDefaultDRPropertyDialogPostionX = g_pDRPropDialog->GetPosition().x; g_iDefaultDRPropertyDialogPostionY = g_pDRPropDialog->GetPosition().y; - g_pDRPropDialog->Destroy(); +#ifdef APPLE + delete g_pDRPropDialog; +#else + g_pDRPropDialog->Close(); +#endif } g_pDRPropDialog = NULL; if ( g_pGZPropDialog ) { g_iDefaultGZPropertyDialogPostionX = g_pGZPropDialog->GetPosition().x; g_iDefaultGZPropertyDialogPostionY = g_pGZPropDialog->GetPosition().y; - g_pGZPropDialog->Destroy(); +#ifdef APPLE + delete g_pGZPropDialog; +#else + g_pGZPropDialog->Close(); +#endif } g_pGZPropDialog = NULL; if ( g_pPILPropDialog ) { g_iDefaultPILPropertyDialogPostionX = g_pPILPropDialog->GetPosition().x; g_iDefaultPILPropertyDialogPostionY = g_pPILPropDialog->GetPosition().y; - g_pPILPropDialog->Destroy(); +#ifdef APPLE + delete g_pPILPropDialog; +#else + g_pPILPropDialog->Close(); +#endif } g_pPILPropDialog = NULL; if ( g_PILIndexLinePropDialog ) { g_iDefaultPILLinePropertyDialogPostionX = g_PILIndexLinePropDialog->GetPosition().x; g_iDefaultPILLinePropertyDialogPostionY = g_PILIndexLinePropDialog->GetPosition().y; - g_PILIndexLinePropDialog->Destroy(); +#ifdef APPLE + delete g_PILIndexLinePropDialog; +#else + g_PILIndexLinePropDialog->Close(); +#endif } g_PILIndexLinePropDialog = NULL; if ( g_pPathAndPointManagerDialog ) { g_iDefaultPathAnPointManagerDialogPostionX = g_pPathAndPointManagerDialog->GetPosition().x; g_iDefaultPathAnPointManagerDialogPostionY = g_pPathAndPointManagerDialog->GetPosition().y; - g_pPathAndPointManagerDialog->Destroy(); +#ifdef APPLE + delete g_pPathAndPointManagerDialog; +#else + g_pPathAndPointManagerDialog->Close(); +#endif } g_pPathAndPointManagerDialog = NULL; - if( g_pODToolbar ) g_pODToolbar->Destroy(); - delete g_pODToolbar; + if( g_pODToolbar ) +#ifdef APPLE + delete g_pODToolbar; +#else + g_pODToolbar->Close(); +#endif + g_pODToolbar = NULL; if( g_pODJSON ) delete g_pODJSON; g_pODJSON = NULL; @@ -873,17 +933,47 @@ bool ocpn_draw_pi::DeInit(void) SaveConfig(); } - delete g_pGZMan; + g_pODConfig->m_bSkipChangeSetUpdate = true; + g_pPathMan->DeleteAllPaths(); + g_pODPointMan->DeleteAllODPoints(false); + + if(g_pGZMan) delete g_pGZMan; g_pGZMan = NULL; - delete g_pBoundaryMan; + if(g_pBoundaryMan) delete g_pBoundaryMan; g_pBoundaryMan = NULL; - delete g_pPathMan; + if(g_pPathMan) { + g_pPathMan->DeleteAllPaths(); + delete g_pPathMan; + } g_pPathMan = NULL; - delete g_pODPointMan; + if(g_pODPointMan) { + g_pODPointMan->DeleteAllODPoints(false); + delete g_pODPointMan; + } g_pODPointMan = NULL; - delete g_pODConfig; + + g_pODConfig->m_bSkipChangeSetUpdate = false; + + if(g_pODConfig) delete g_pODConfig; g_pODConfig = NULL; + if(g_pODJSON) delete g_pODJSON; + g_pODJSON = NULL; + if(g_pODAPI) delete g_pODAPI; + g_pODAPI = NULL; + if(g_pBoundaryList) delete g_pBoundaryList; + g_pBoundaryList = NULL; + if(g_pEBLList) delete g_pEBLList; + g_pEBLList = NULL; + if(g_pGZList) delete g_pGZList; + g_pGZList = NULL; + if(g_pPILList) delete g_pPILList; + g_pPILList = NULL; + if(g_pPathList) delete g_pPathList; + g_pPathList = NULL; + if(g_pLayerList) delete g_pLayerList; + g_pLayerList = NULL; + shutdown(false); return true;