From d99b0008cb1bdf211350128603d364a78e8ae764 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 16 Nov 2017 08:48:10 +1100 Subject: [PATCH] Minor fixes --- CMakeLists.txt | 2 +- src/Boundary.cpp | 2 + src/GZ.cpp | 25 ++++-------- src/ODNavObjectChanges.cpp | 71 +++++++++++++++------------------ src/PILPropertiesDialogImpl.cpp | 2 + src/ocpn_draw_pi.cpp | 34 ++++++++-------- 6 files changed, 64 insertions(+), 72 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff3736d4..282aad80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ SET(CPACK_PACKAGE_CONTACT "Jon Gough") SET(VERSION_MAJOR "1") SET(VERSION_MINOR "4") -SET(VERSION_PATCH "15") +SET(VERSION_PATCH "16") SET(VERSION_DATE "16/11/2017") SET(BUNDLE_DATA FALSE) diff --git a/src/Boundary.cpp b/src/Boundary.cpp index 3f20cf12..681e4fbb 100644 --- a/src/Boundary.cpp +++ b/src/Boundary.cpp @@ -154,6 +154,7 @@ void Boundary::Draw( ODDC& dc, PlugIn_ViewPort &piVP ) wxClientDC *pcdc = wxDynamicCast(dc.GetDC(), wxClientDC); if( pcdc ) wxGC = wxGraphicsContext::Create( *pcdc ); } + assert(wxGC); wxGC->SetPen(*wxTRANSPARENT_PEN); wxColour tCol; @@ -215,6 +216,7 @@ void Boundary::Draw( ODDC& dc, PlugIn_ViewPort &piVP ) wxClientDC *pcdc = wxDynamicCast(dc.GetDC(), wxClientDC); if( pcdc ) wxGC = wxGraphicsContext::Create( *pcdc ); } + assert(wxGC); wxGC->SetPen(*wxTRANSPARENT_PEN); wxColour tCol; diff --git a/src/GZ.cpp b/src/GZ.cpp index edadf3ac..76b136b6 100644 --- a/src/GZ.cpp +++ b/src/GZ.cpp @@ -411,8 +411,8 @@ void GZ::UpdateGZSelectablePath( void ) l_iSteps = ceil(24 * (fabs((360 - m_dFirstLineDirection) + m_dSecondLineDirection))/360) - 1; l_dStepSize = fabs((360 - m_dFirstLineDirection) + m_dSecondLineDirection) / l_iSteps; } - double firstDirection; - double secondDirection; + double firstDirection = m_dFirstLineDirection; + double secondDirection = m_dSecondLineDirection; if(m_bRotateWithBoat) { switch(m_iMaintainWith) { case ID_MAINTAIN_WITH_HEADING: @@ -434,10 +434,7 @@ void GZ::UpdateGZSelectablePath( void ) } break; } - } else { - firstDirection = m_dFirstLineDirection; - secondDirection = m_dSecondLineDirection; - } + } PositionBearingDistanceMercator_Plugin( m_dCentreLat, m_dCentreLon, firstDirection, m_dFirstDistance, &l_dPrevLat, &l_dPrevLon); PositionBearingDistanceMercator_Plugin( m_dCentreLat, m_dCentreLon, firstDirection, m_dSecondDistance, &l_dLat, &l_dLon); @@ -508,8 +505,8 @@ void GZ::GetLatLonPoints( PlugIn_ViewPort &piVP, wxPoint *l_pCentre, wxPoint *l_ { double l_dLat; double l_dLon; - double firstDirection; - double secondDirection; + double firstDirection = m_dFirstLineDirection; + double secondDirection = m_dSecondLineDirection; if(m_bRotateWithBoat) { switch(m_iMaintainWith) { case ID_MAINTAIN_WITH_HEADING: @@ -531,10 +528,7 @@ void GZ::GetLatLonPoints( PlugIn_ViewPort &piVP, wxPoint *l_pCentre, wxPoint *l_ } break; } - } else { - firstDirection = m_dFirstLineDirection; - secondDirection = m_dSecondLineDirection; - } + } // get x, y of first point on first line ODPoint *l_point = m_pODPointList->GetFirst()->GetData(); GetCanvasPixLL( &piVP, *&l_l1p1, l_point->m_lat, l_point->m_lon ); @@ -574,8 +568,8 @@ LLBBox GZ::GetBBox( void ) double l_dLat; double l_dLon; - double firstDirection; - double secondDirection; + double firstDirection = m_dFirstLineDirection; + double secondDirection = m_dSecondLineDirection; if(m_bRotateWithBoat) { switch(m_iMaintainWith) { case ID_MAINTAIN_WITH_HEADING: @@ -597,9 +591,6 @@ LLBBox GZ::GetBBox( void ) } break; } - } else { - firstDirection = m_dFirstLineDirection; - secondDirection = m_dSecondLineDirection; } PositionBearingDistanceMercator_Plugin( m_dCentreLat, m_dCentreLon, firstDirection, m_dFirstDistance, &l_dLat, &l_dLon); diff --git a/src/ODNavObjectChanges.cpp b/src/ODNavObjectChanges.cpp index 39f7832d..0c35cd92 100644 --- a/src/ODNavObjectChanges.cpp +++ b/src/ODNavObjectChanges.cpp @@ -161,9 +161,6 @@ bool ODNavObjectChanges::GPXCreateODPoint( pugi::xml_node node, ODPoint *pop, un wxString s; pugi::xml_node child; pugi::xml_attribute attr; - TextPoint *tp; - BoundaryPoint *bp; - ODPoint *pp; #ifndef __WXMSW__ wxString *l_locale = new wxString(wxSetlocale(LC_NUMERIC, NULL)); @@ -174,49 +171,45 @@ bool ODNavObjectChanges::GPXCreateODPoint( pugi::xml_node node, ODPoint *pop, un #endif #endif - if(pop->m_sTypeString == wxT("Text Point")) - tp = (TextPoint *)pop; - else if(pop->m_sTypeString == wxT("Boundary Point")) - bp = (BoundaryPoint *)pop; - pp = pop; - - s.Printf(_T("%.9f"), pp->m_lat); + s.Printf(_T("%.9f"), pop->m_lat); node.append_attribute("lat") = s.mb_str(); - s.Printf(_T("%.9f"), pp->m_lon); + s.Printf(_T("%.9f"), pop->m_lon); node.append_attribute("lon") = s.mb_str(); if(flags & OUT_TYPE) { child = node.append_child("opencpn:type"); - child.append_child(pugi::node_pcdata).set_value(pp->GetTypeString().mb_str()); + child.append_child(pugi::node_pcdata).set_value(pop->GetTypeString().mb_str()); } if(flags & OUT_TIME) { child = node.append_child("time"); - if( pp->m_timestring.Len() ) - child.append_child(pugi::node_pcdata).set_value(pp->m_timestring.mb_str()); + if( pop->m_timestring.Len() ) + child.append_child(pugi::node_pcdata).set_value(pop->m_timestring.mb_str()); else { - wxString t = pp->GetCreateTime().FormatISODate().Append(_T("T")).Append(pp->GetCreateTime().FormatISOTime()).Append(_T("Z")); + wxString t = pop->GetCreateTime().FormatISODate().Append(_T("T")).Append(pop->GetCreateTime().FormatISOTime()).Append(_T("Z")); child.append_child(pugi::node_pcdata).set_value(t.mb_str()); } } - if ( (!pp->GetName().IsEmpty() && (flags & OUT_NAME)) || (flags & OUT_NAME_FORCE) ) { - wxCharBuffer buffer=pp->GetName().ToUTF8(); + if ( (!pop->GetName().IsEmpty() && (flags & OUT_NAME)) || (flags & OUT_NAME_FORCE) ) { + wxCharBuffer buffer = pop->GetName().ToUTF8(); if(buffer.data()) { child = node.append_child("name"); child.append_child(pugi::node_pcdata).set_value(buffer.data()); } } - if ( (!pp->GetDescription().IsEmpty() && (flags & OUT_DESC)) || (flags & OUT_DESC_FORCE) ) { - wxCharBuffer buffer=pp->GetDescription().ToUTF8(); + if ( (!pop->GetDescription().IsEmpty() && (flags & OUT_DESC)) || (flags & OUT_DESC_FORCE) ) { + wxCharBuffer buffer = pop->GetDescription().ToUTF8(); if(buffer.data()) { child = node.append_child("desc"); child.append_child(pugi::node_pcdata).set_value(buffer.data()); } } - if(pp->m_sTypeString == wxT("Text Point")) { + if(pop->m_sTypeString == wxT("Text Point")) { + TextPoint *tp = dynamic_cast(pop); + assert(tp !=0); if ( !tp->GetPointText().IsEmpty() && (flags & OUT_POINTTEXT) ) { wxCharBuffer buffer=tp->GetPointText().ToUTF8(); if(buffer.data()) { @@ -263,7 +256,9 @@ bool ODNavObjectChanges::GPXCreateODPoint( pugi::xml_node node, ODPoint *pop, un } } - if(pp->m_sTypeString == wxT("Boundary Point")) { + if(pop->m_sTypeString == wxT("Boundary Point")) { + BoundaryPoint *bp = dynamic_cast(pop); + assert(bp != 0); child = node.append_child("opencpn:boundary_type"); if( bp->m_bExclusionBoundaryPoint && !bp->m_bInclusionBoundaryPoint ) child.append_child(pugi::node_pcdata).set_value( "Exclusion" ); @@ -276,7 +271,7 @@ bool ODNavObjectChanges::GPXCreateODPoint( pugi::xml_node node, ODPoint *pop, un // Hyperlinks if(flags & OUT_HYPERLINKS ){ - HyperlinkList *linklist = pp->m_HyperlinkList; + HyperlinkList *linklist = pop->m_HyperlinkList; if( linklist && linklist->GetCount() ) { wxHyperlinkListNode *linknode = linklist->GetFirst(); while( linknode ) { @@ -306,8 +301,8 @@ bool ODNavObjectChanges::GPXCreateODPoint( pugi::xml_node node, ODPoint *pop, un if (flags & OUT_SYM_FORCE) { child = node.append_child("sym"); - if (!pp->GetIconName().IsEmpty()) { - child.append_child(pugi::node_pcdata).set_value(pp->GetIconName().mb_str()); + if (!pop->GetIconName().IsEmpty()) { + child.append_child(pugi::node_pcdata).set_value(pop->GetIconName().mb_str()); } else { child.append_child("empty"); @@ -319,14 +314,14 @@ bool ODNavObjectChanges::GPXCreateODPoint( pugi::xml_node node, ODPoint *pop, un //pugi::xml_node child_ext = node.append_child("extensions"); - if (!pp->m_GUID.IsEmpty() && (flags & OUT_GUID) ) { + if (!pop->m_GUID.IsEmpty() && (flags & OUT_GUID) ) { child = node.append_child("opencpn:guid"); - child.append_child(pugi::node_pcdata).set_value(pp->m_GUID.mb_str()); + child.append_child(pugi::node_pcdata).set_value(pop->m_GUID.mb_str()); } if(flags & OUT_VIZ) { child = node.append_child("opencpn:viz"); - if ( pp->m_bIsVisible ) + if ( pop->m_bIsVisible ) child.append_child(pugi::node_pcdata).set_value("1"); else child.append_child(pugi::node_pcdata).set_value("0"); @@ -334,41 +329,41 @@ bool ODNavObjectChanges::GPXCreateODPoint( pugi::xml_node node, ODPoint *pop, un if(flags & OUT_VIZ_NAME) { child = node.append_child("opencpn:viz_name"); - if ( pp->m_bShowName ) + if ( pop->m_bShowName ) child.append_child(pugi::node_pcdata).set_value("1"); else child.append_child(pugi::node_pcdata).set_value("0"); } - if((flags & OUT_AUTO_NAME) && pp->m_bDynamicName) { + if((flags & OUT_AUTO_NAME) && pop->m_bDynamicName) { child = node.append_child("opencpn:auto_name"); child.append_child(pugi::node_pcdata).set_value("1"); } - if((flags & OUT_SHARED) && pp->m_bKeepXPath) { + if((flags & OUT_SHARED) && pop->m_bKeepXPath) { child = node.append_child("opencpn:shared"); child.append_child(pugi::node_pcdata).set_value("1"); } if(flags & OUT_ARRIVAL_RADIUS) { child = node.append_child("opencpn:arrival_radius"); - s.Printf(_T("%.3f"), pp->GetODPointArrivalRadius()); + s.Printf(_T("%.3f"), pop->GetODPointArrivalRadius()); child.append_child(pugi::node_pcdata).set_value( s.mbc_str() ); } if(flags & OUT_OCPNPOINT_RANGE_RINGS) { child = node.append_child("opencpn:ODPoint_range_rings"); pugi::xml_attribute viz = child.append_attribute( "visible" ); - viz.set_value( pp->m_bShowODPointRangeRings ); + viz.set_value( pop->m_bShowODPointRangeRings ); pugi::xml_attribute number = child.append_attribute( "number" ); - number.set_value( pp->m_iODPointRangeRingsNumber ); + number.set_value( pop->m_iODPointRangeRingsNumber ); pugi::xml_attribute step = child.append_attribute( "step" ); - step.set_value( pp->m_fODPointRangeRingsStep ); + step.set_value( pop->m_fODPointRangeRingsStep ); pugi::xml_attribute units = child.append_attribute( "units" ); - units.set_value( pp->m_iODPointRangeRingsStepUnits ); + units.set_value( pop->m_iODPointRangeRingsStepUnits ); pugi::xml_attribute colour = child.append_attribute( "colour" ); - colour.set_value( pp->m_wxcODPointRangeRingsColour.GetAsString( wxC2S_HTML_SYNTAX ).utf8_str() ) ; + colour.set_value( pop->m_wxcODPointRangeRingsColour.GetAsString( wxC2S_HTML_SYNTAX ).utf8_str() ) ; pugi::xml_attribute width = child.append_attribute( "width" ); - width.set_value( pp->m_iRangeRingWidth ); + width.set_value( pop->m_iRangeRingWidth ); pugi::xml_attribute style = child.append_attribute( "line_style" ); - style.set_value( pp->m_iRangeRingStyle ); + style.set_value( pop->m_iRangeRingStyle ); } } diff --git a/src/PILPropertiesDialogImpl.cpp b/src/PILPropertiesDialogImpl.cpp index f6f3b408..32aee062 100644 --- a/src/PILPropertiesDialogImpl.cpp +++ b/src/PILPropertiesDialogImpl.cpp @@ -84,6 +84,7 @@ void PILPropertiesDialogImpl::SaveChanges() if(it->iID == m_iID) break; ++it; } + assert(it != m_pPIL->m_PilLineList.end()); it->sName = m_textCtrlName->GetValue(); it->sDescription = m_textCtrlDesctription->GetValue(); it->dOffset = wxAtof(m_textCtrlOffset->GetValue()); @@ -110,6 +111,7 @@ void PILPropertiesDialogImpl:: UpdateProperties( PIL *pPIL, int iID ) if(it->iID == iID) break; ++it; } + assert(it != pPIL->m_PilLineList.end()); m_textCtrlIDNum->SetValue(wxString::Format("%i", iID)); m_textCtrlName->Clear(); m_textCtrlName->AppendText(it->sName); diff --git a/src/ocpn_draw_pi.cpp b/src/ocpn_draw_pi.cpp index cf5e1da5..508a0561 100644 --- a/src/ocpn_draw_pi.cpp +++ b/src/ocpn_draw_pi.cpp @@ -3685,22 +3685,24 @@ void ocpn_draw_pi::DrawAllPathsAndODPoints( PlugIn_ViewPort &pivp ) DR *pDRDraw = NULL; GZ *pGZDraw = NULL; PIL *pPILDraw = NULL; - - if(pTempPath->m_sTypeString == wxT("Boundary")) { - pBoundaryDraw = (Boundary *)pTempPath; - pPathDraw = pBoundaryDraw; - } else if(pTempPath->m_sTypeString == wxT("EBL")) { - pEBLDraw = (EBL *)pTempPath; - pPathDraw = pEBLDraw; - } else if(pTempPath->m_sTypeString == wxT("DR")) { - pDRDraw = (DR *)pTempPath; - pPathDraw = pDRDraw; - } else if(pTempPath->m_sTypeString == wxT("Guard Zone")) { - pGZDraw = (GZ *)pTempPath; - pPathDraw = pGZDraw; - } else if(pTempPath->m_sTypeString == wxT("PIL")) { - pPILDraw = (PIL *)pTempPath; - pPathDraw = pPILDraw; + { + if(pTempPath->m_sTypeString == wxT("Boundary")) { + pBoundaryDraw = (Boundary *)pTempPath; + pPathDraw = pBoundaryDraw; + } else if(pTempPath->m_sTypeString == wxT("EBL")) { + pEBLDraw = (EBL *)pTempPath; + pPathDraw = pEBLDraw; + } else if(pTempPath->m_sTypeString == wxT("DR")) { + pDRDraw = (DR *)pTempPath; + pPathDraw = pDRDraw; + } else if(pTempPath->m_sTypeString == wxT("Guard Zone")) { + pGZDraw = (GZ *)pTempPath; + pPathDraw = pGZDraw; + } else if(pTempPath->m_sTypeString == wxT("PIL")) { + pPILDraw = (PIL *)pTempPath; + pPathDraw = pPILDraw; + } + assert(pPathDraw != 0); } /* defer rendering active routes until later */