Skip to content

Commit

Permalink
Fix EBL move start point
Browse files Browse the repository at this point in the history
Add PIL move start point
Change right click menu options to include Centre on boat, move to boat lat/lon, pick new start point
  • Loading branch information
jongough committed Mar 11, 2017
1 parent 7dc3708 commit 5bd66a1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion include/ocpn_draw_pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
17 changes: 15 additions & 2 deletions src/ODEventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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") );
Expand Down
32 changes: 28 additions & 4 deletions src/ocpn_draw_pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit 5bd66a1

Please sign in to comment.