diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c2752f6..65cad407 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ SET(CPACK_PACKAGE_CONTACT "Jon Gough") SET(VERSION_MAJOR "1") SET(VERSION_MINOR "3") -SET(VERSION_PATCH "29") +SET(VERSION_PATCH "30") SET(VERSION_DATE "11/03/2017") SET(BUNDLE_DATA FALSE) diff --git a/include/ocpn_draw_pi.h b/include/ocpn_draw_pi.h index 37fcfae2..04a9c079 100644 --- a/include/ocpn_draw_pi.h +++ b/include/ocpn_draw_pi.h @@ -180,7 +180,9 @@ enum ID_PIL_MENU_ADD_INDEX_LINE, ID_PIL_MENU_MOVE_INDEX_LINE, ID_PIL_MENU_DELETE_INDEX_LINE, - + ID_PIL_MENU_CENTRE_ON_BOAT, + ID_PIL_MENU_CENTRE_ON_BOAT_LATLON, + ID_UNDO, ID_REDO, diff --git a/src/ODEventHandler.cpp b/src/ODEventHandler.cpp index 597c75c7..8aa66259 100644 --- a/src/ODEventHandler.cpp +++ b/src/ODEventHandler.cpp @@ -781,6 +781,13 @@ void ODEventHandler::PopupMenuHandler(wxCommandEvent& event ) case ID_EBL_MENU_CENTRE_ON_BOAT_LATLON: m_pEBL->CentreOnLatLon( g_pfFix.Lat, g_pfFix.Lon ); break; + case ID_PIL_MENU_CENTRE_ON_BOAT: + m_pPIL->m_bSaveUpdates = true; + m_pPIL->CentreOnBoat(false); + break; + case ID_PIL_MENU_CENTRE_ON_BOAT_LATLON: + m_pPIL->CentreOnLatLon( g_pfFix.Lat, g_pfFix.Lon ); + break; case ID_EBL_MENU_PICK_NEW_START: g_ocpn_draw_pi->m_bEBLMoveOrigin = true; g_ocpn_draw_pi->m_pCurrentCursor = g_ocpn_draw_pi->m_pCursorCross; @@ -1071,11 +1078,17 @@ void ODEventHandler::PopupMenu( int seltype ) if(!m_pEBL->m_bCentreOnBoat) { MenuAppend( menuPath, ID_EBL_MENU_CENTRE_ON_BOAT, _("Centre on moving boat") ); MenuAppend( menuPath, ID_EBL_MENU_CENTRE_ON_BOAT_LATLON, _("Move start point to boat lat/lon") ); - } else - MenuAppend( menuPath, ID_EBL_MENU_PICK_NEW_START, _("Pick a new start point") ); + } + MenuAppend( menuPath, ID_EBL_MENU_PICK_NEW_START, _("Pick a new start point") ); ODPoint *pFirstPoint = m_pEBL->m_pODPointList->GetFirst()->GetData(); if(m_pEBL->GetCurrentColour() != pFirstPoint->GetODPointRangeRingsColour()) MenuAppend( menuPath, ID_EBL_MENU_VRM_MATCH_EBL_COLOUR, _("Match VRM colour to EBL colour")); + } else if(m_pSelectedPath->m_sTypeString == wxT("PIL")) { + if(!m_pPIL->m_bCentreOnBoat) { + MenuAppend( menuPath, ID_PIL_MENU_CENTRE_ON_BOAT, _("Centre on moving boat") ); + MenuAppend( menuPath, ID_PIL_MENU_CENTRE_ON_BOAT_LATLON, _("Move start point to boat lat/lon") ); + } + MenuAppend( menuPath, ID_EBL_MENU_PICK_NEW_START, _("Pick a new start point") ); } else if(m_pSelectedPath->m_sTypeString == wxT("DR")) { MenuAppend( menuPath, ID_DR_MENU_UPDATE_INITIAL_CONDITIONS, _("Update initial conditions") ); diff --git a/src/ocpn_draw_pi.cpp b/src/ocpn_draw_pi.cpp index 45b696b6..f5f36744 100644 --- a/src/ocpn_draw_pi.cpp +++ b/src/ocpn_draw_pi.cpp @@ -1903,7 +1903,7 @@ bool ocpn_draw_pi::MouseEventHook( wxMouseEvent &event ) // bRefresh = FALSE; // bret = FALSE; // } - } else if( g_bAllowLeftDrag ) { + } else if( g_bAllowLeftDrag && !m_bEBLMoveOrigin) { FindSelectedObject(); if( 0 != m_seltype ) { @@ -1993,8 +1993,14 @@ bool ocpn_draw_pi::MouseEventHook( wxMouseEvent &event ) } if (m_bEBLMoveOrigin) { m_bEBLMoveOrigin = false; - m_pSelectedEBL = (EBL *)m_pSelectedPath; - m_pSelectedEBL->CentreOnLatLon( m_cursor_lat, m_cursor_lon ); + if(m_pSelectedPath->m_sTypeString == wxT("EBL")) { + m_pSelectedEBL = (EBL *)m_pSelectedPath; + m_pSelectedEBL->CentreOnLatLon( m_cursor_lat, m_cursor_lon ); + } + else { + m_pSelectedPIL = (PIL *)m_pSelectedPath; + m_pSelectedPIL->CentreOnLatLon( m_cursor_lat, m_cursor_lon ); + } m_bPathEditing = FALSE; m_bODPointEditing = FALSE; m_pCurrentCursor = NULL; @@ -2734,7 +2740,7 @@ void ocpn_draw_pi::RenderPathLegs( ODDC &dc ) wxString info = CreateExtraPathLegInfo(dc, boundary, brg, dist, m_cursorPoint); RenderExtraPathLegInfo( dc, r_rband, info ); - } else if( nEBL_State > 0 || m_bEBLMoveOrigin ) { + } else if( m_pSelectedEBL && (nEBL_State > 0 || m_bEBLMoveOrigin) ) { EBL *ebl = new EBL(); double brg, dist; wxPoint boatpoint; @@ -2752,6 +2758,24 @@ void ocpn_draw_pi::RenderPathLegs( ODDC &dc ) if(info.length() > 0) RenderExtraPathLegInfo( dc, m_cursorPoint, info ); delete ebl; + } else if( m_pSelectedPIL && (nPIL_State > 0 || m_bEBLMoveOrigin) ) { + EBL *ebl = new EBL(); + double brg, dist; + wxPoint boatpoint; + if(m_bEBLMoveOrigin) { + ODPoint *tp = (ODPoint *) m_pSelectedPIL->m_pODPointList->GetLast()->GetData(); + GetCanvasPixLL( g_pVP, &boatpoint, tp->m_lat, tp->m_lon ); + DistanceBearingMercator_Plugin( m_cursor_lat, m_cursor_lon, tp->m_lat, tp->m_lon, &brg, &dist ); + ebl->DrawSegment( dc, &boatpoint, &m_cursorPoint, *m_pVP, false ); + } else { + GetCanvasPixLL( g_pVP, &boatpoint, g_pfFix.Lat, g_pfFix.Lon ); + DistanceBearingMercator_Plugin( m_cursor_lat, m_cursor_lon, g_pfFix.Lat, g_pfFix.Lon, &brg, &dist ); + ebl->DrawSegment( dc, &boatpoint, &m_cursorPoint, *m_pVP, false ); + } + wxString info = CreateExtraPathLegInfo(dc, ebl, brg, dist, m_cursorPoint); + if(info.length() > 0) + RenderExtraPathLegInfo( dc, m_cursorPoint, info ); + delete ebl; } else if( nGZ_State > 0 ) { // draw line from boat to cursor EBL *ebl = new EBL();