Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modify and Delete waypoints in the Route Properties window.

  • Loading branch information...
commit eec467a2efe88badcc1ab6b47e87e4c411e638f6 1 parent 03931f1
@JesperWe JesperWe authored
View
3  include/chcanv.h
@@ -275,6 +275,9 @@ class ChartCanvas: public wxWindow
bool PurgeGLCanvasChartCache(ChartBase *pc);
+ void RemovePointFromRoute( RoutePoint* point, Route* route );
+
+
private:
ViewPort VPoint;
void PositionConsole(void);
View
2  include/routemanagerdialog.h
@@ -55,6 +55,8 @@ class RouteManagerDialog : public wxDialog {
void UpdateWptListCtrl(RoutePoint *rp_select = NULL, bool b_retain_sort = false);
void UpdateLayListCtrl();
void OnTabSwitch(wxNotebookEvent& event);
+ static void RouteManagerDialog::WptShowPropertiesDialog( RoutePoint* wp, wxWindow* parent );
+
private:
void Create();
View
5 include/routeprop.h
@@ -86,6 +86,9 @@ class HyperlinkList;
#define ID_STARTTIMECTL 7011
#define ID_TIMEZONESEL 7012
#define ID_TRACKLISTCTRL 7013
+#define ID_RCLK_MENU_COPY_TEXT 7014
+#define ID_RCLK_MENU_EDIT_WP 7015
+#define ID_RCLK_MENU_DELETE 7016
#define ID_MARKPROP 8000
#define SYMBOL_MARKPROP_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
@@ -153,6 +156,8 @@ class RouteProp: public wxDialog
void OnRoutepropSplitClick( wxCommandEvent& event );
void OnRoutepropExtendClick( wxCommandEvent& event );
void OnRoutepropCopyTxtClick( wxCommandEvent& event );
+ void OnRoutePropRightClick( wxListEvent &event );
+ void OnRoutePropMenuSelected( wxCommandEvent &event );
bool IsThisRouteExtendable();
bool IsThisTrackExtendable();
void OnEvtColDragEnd(wxListEvent& event);
View
57 src/chcanv.cpp
@@ -7903,7 +7903,7 @@ void ChartCanvas::CanvasPopupMenu( int x, int y, int seltype )
#endif
if( seltype & SELTYPE_TRACKSEGMENT ) {
- pdef_menu->Append( ID_TK_MENU_PROPERTIES, _( "Track Properties" ) );
+ pdef_menu->Append( ID_TK_MENU_PROPERTIES, _( "Track Properties..." ) );
pdef_menu->Append( ID_TK_MENU_DELETE, _( "Delete Track" ) );
pdef_menu->AppendSeparator();
@@ -7916,7 +7916,7 @@ void ChartCanvas::CanvasPopupMenu( int x, int y, int seltype )
pdef_menu->Append( ID_RT_MENU_APPEND, _( "Append Waypoint" ) );
pdef_menu->Append( ID_RT_MENU_DELETE, _( "Delete Route" ) );
pdef_menu->Append( ID_RT_MENU_REVERSE, _( "Reverse Route" ) );
- pdef_menu->Append( ID_RT_MENU_PROPERTIES, _( "Route Properties" ) );
+ pdef_menu->Append( ID_RT_MENU_PROPERTIES, _( "Route Properties..." ) );
if( m_pSelectedRoute ) {
pdef_menu->Enable( ID_RT_MENU_ACTIVATE, !m_pSelectedRoute->m_bRtIsActive );
@@ -8187,6 +8187,28 @@ void ChartCanvas::ShowObjectQueryWindow( int x, int y, float zlat, float zlon )
}
}
+void ChartCanvas::RemovePointFromRoute( RoutePoint* point, Route* route ) {
+ // Rebuild the route selectables
+ pSelect->DeleteAllSelectableRoutePoints( route );
+ pSelect->DeleteAllSelectableRouteSegments( route );
+
+ route->RemovePoint( point );
+
+ // Check for 1 point routes
+ if( route->GetnPoints() <= 1 ) {
+ pConfig->DeleteConfigRoute( route );
+ g_pRouteMan->DeleteRoute( route );
+ route = NULL;
+ }
+ // Add this point back into the selectables
+ pSelect->AddSelectableRoutePoint( point->m_lat, point->m_lon, point );
+
+ if( pRoutePropDialog && ( pRoutePropDialog->IsShown() ) ) {
+ pRoutePropDialog->SetRouteAndUpdate( route );
+ pRoutePropDialog->UpdateProperties();
+ }
+}
+
void ChartCanvas::PopupMenuHandler( wxCommandEvent& event )
{
RoutePoint *pLast;
@@ -8632,36 +8654,7 @@ void ChartCanvas::PopupMenuHandler( wxCommandEvent& event )
case ID_RT_MENU_REMPOINT:
if( m_pSelectedRoute ) {
if( m_pSelectedRoute->m_bIsInLayer ) break;
-
- // Rebuild the route selectables
- pSelect->DeleteAllSelectableRoutePoints( m_pSelectedRoute );
- pSelect->DeleteAllSelectableRouteSegments( m_pSelectedRoute );
-
- m_pSelectedRoute->RemovePoint( m_pFoundRoutePoint );
-
- // Check for 1 point routes
- if( m_pSelectedRoute->GetnPoints() > 1 ) {
- /* All this is done by Route::RemovePoint()
- pSelect->AddAllSelectableRouteSegments ( m_pSelectedRoute );
- pSelect->AddAllSelectableRoutePoints ( m_pSelectedRoute );
-
- pConfig->UpdateRoute ( m_pSelectedRoute );
- m_pSelectedRoute->RebuildGUIDList(); // ensure the GUID list is intact and good
- */
- } else {
- pConfig->DeleteConfigRoute( m_pSelectedRoute );
- g_pRouteMan->DeleteRoute( m_pSelectedRoute );
- m_pSelectedRoute = NULL;
- }
- // Add this point back into the selectables
- pSelect->AddSelectableRoutePoint( m_pFoundRoutePoint->m_lat,
- m_pFoundRoutePoint->m_lon, m_pFoundRoutePoint );
-
- if( pRoutePropDialog && ( pRoutePropDialog->IsShown() ) ) {
- pRoutePropDialog->SetRouteAndUpdate( m_pSelectedRoute );
- pRoutePropDialog->UpdateProperties();
- }
-
+ RemovePointFromRoute( m_pFoundRoutePoint, m_pSelectedRoute );
}
break;
View
16 src/routemanagerdialog.cpp
@@ -1807,8 +1807,16 @@ void RouteManagerDialog::OnWptPropertiesClick( wxCommandEvent &event )
if( !wp ) return;
- if( NULL == pMarkPropDialog ) // There is one global instance of the MarkProp Dialog
- pMarkPropDialog = new MarkInfoImpl( GetParent() );
+ WptShowPropertiesDialog( wp, GetParent() );
+
+ UpdateWptListCtrl();
+ m_bNeedConfigFlush = true;
+}
+
+void RouteManagerDialog::WptShowPropertiesDialog( RoutePoint* wp, wxWindow* parent )
+{
+ // There is one global instance of the MarkProp Dialog
+ if( NULL == pMarkPropDialog ) pMarkPropDialog = new MarkInfoImpl( parent );
pMarkPropDialog->SetRoutePoint( wp );
pMarkPropDialog->UpdateProperties();
@@ -1821,10 +1829,6 @@ void RouteManagerDialog::OnWptPropertiesClick( wxCommandEvent &event )
if( !pMarkPropDialog->IsShown() ) pMarkPropDialog->ShowModal();
- // waypoint might have changed
- UpdateWptListCtrl();
-
- m_bNeedConfigFlush = true;
}
void RouteManagerDialog::OnWptZoomtoClick( wxCommandEvent &event )
View
194 src/routeprop.cpp
@@ -56,7 +56,6 @@ extern WayPointman *pWayPointMan;
extern ChartCanvas *cc1;
extern Select *pSelect;
extern Routeman *g_pRouteMan;
-extern RouteProp *pRoutePropDialog;
extern RouteManagerDialog *pRouteManagerDialog;
extern Track *g_pActiveTrack;
extern RouteList *pRouteList;
@@ -447,20 +446,18 @@ int OCPNTrackListCtrl::OnGetItemColumnImage( long item, long column ) const
IMPLEMENT_DYNAMIC_CLASS( RouteProp, wxDialog )
/*!
* RouteProp event table definition
- */BEGIN_EVENT_TABLE( RouteProp, wxDialog )
-
-EVT_TEXT( ID_PLANSPEEDCTL, RouteProp::OnPlanSpeedCtlUpdated )
-EVT_TEXT_ENTER( ID_STARTTIMECTL, RouteProp::OnStartTimeCtlUpdated )
-//EVT_RADIOBOX ( ID_TIMEZONESEL, RouteProp::OnStartTimeCtlUpdated )
-EVT_RADIOBOX ( ID_TIMEZONESEL, RouteProp::OnTimeZoneSelected )
-EVT_BUTTON( ID_ROUTEPROP_CANCEL, RouteProp::OnRoutepropCancelClick )
-EVT_BUTTON( ID_ROUTEPROP_OK, RouteProp::OnRoutepropOkClick )
-EVT_LIST_ITEM_SELECTED( ID_LISTCTRL, RouteProp::OnRoutepropListClick )
-EVT_LIST_ITEM_SELECTED( ID_TRACKLISTCTRL, RouteProp::OnRoutepropListClick )
-EVT_BUTTON( ID_ROUTEPROP_SPLIT, RouteProp::OnRoutepropSplitClick )
-EVT_BUTTON( ID_ROUTEPROP_EXTEND, RouteProp::OnRoutepropExtendClick )
-EVT_BUTTON( ID_ROUTEPROP_COPYTXT, RouteProp::OnRoutepropCopyTxtClick )
+ */
+BEGIN_EVENT_TABLE( RouteProp, wxDialog )
+ EVT_TEXT( ID_PLANSPEEDCTL, RouteProp::OnPlanSpeedCtlUpdated )
+ EVT_TEXT_ENTER( ID_STARTTIMECTL, RouteProp::OnStartTimeCtlUpdated )
+ EVT_RADIOBOX ( ID_TIMEZONESEL, RouteProp::OnTimeZoneSelected )
+ EVT_BUTTON( ID_ROUTEPROP_CANCEL, RouteProp::OnRoutepropCancelClick )
+ EVT_BUTTON( ID_ROUTEPROP_OK, RouteProp::OnRoutepropOkClick )
+ EVT_LIST_ITEM_SELECTED( ID_LISTCTRL, RouteProp::OnRoutepropListClick )
+ EVT_LIST_ITEM_SELECTED( ID_TRACKLISTCTRL, RouteProp::OnRoutepropListClick )
+ EVT_BUTTON( ID_ROUTEPROP_SPLIT, RouteProp::OnRoutepropSplitClick )
+ EVT_BUTTON( ID_ROUTEPROP_EXTEND, RouteProp::OnRoutepropExtendClick )
END_EVENT_TABLE()
/*!
@@ -504,6 +501,27 @@ RouteProp::RouteProp( wxWindow* parent, wxWindowID id, const wxString& caption,
Centre();
}
+void RouteProp::OnRoutePropRightClick( wxListEvent &event )
+{
+ wxMenu menu;
+
+ if( m_pRoute->m_bIsTrack ) {
+ // No track specific items so far.
+ } else {
+ if( ! m_pRoute->m_bIsInLayer ) {
+ wxMenuItem* editItem = menu.Append( ID_RCLK_MENU_EDIT_WP, _("&Waypoint Properties...") );
+ editItem->Enable( m_wpList->GetSelectedItemCount() == 1 );
+
+ wxMenuItem* delItem = menu.Append( ID_RCLK_MENU_DELETE, _("&Remove Selected") );
+ delItem->Enable( m_wpList->GetSelectedItemCount() > 0 && m_wpList->GetItemCount() > 2 );
+ }
+ }
+
+ wxMenuItem* copyItem = menu.Append( ID_RCLK_MENU_COPY_TEXT, _("&Copy all as text") );
+
+ PopupMenu( &menu );
+}
+
void RouteProp::OnRoutepropSplitClick( wxCommandEvent& event )
{
m_SplitButton->Enable( false );
@@ -747,49 +765,6 @@ bool RouteProp::IsThisTrackExtendable()
return false;
}
-void RouteProp::OnRoutepropListClick( wxListEvent& event )
-{
- long itemno = 0;
- m_nSelected = 0;
-
- // We use different methods to determine the selected point,
- // depending on whether this is a Route or a Track.
- int selected_no;
- if( !m_pRoute->m_bIsTrack ) {
- const wxListItem &i = event.GetItem();
- i.GetText().ToLong( &itemno );
- selected_no = itemno;
- } else {
- itemno = -1;
- itemno = m_wpTrackList->GetNextItem( itemno, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
- if( itemno == -1 ) selected_no = 0;
- else
- selected_no = itemno;
- }
-
- m_pRoute->ClearHighlights();
-
- wxRoutePointListNode *node = m_pRoute->pRoutePointList->GetFirst();
- while( node && itemno-- ) {
- node = node->GetNext();
- }
- if( node ) {
- RoutePoint *prp = node->GetData();
- if( prp ) {
- prp->m_bPtIsSelected = true; // highlight the routepoint
-
- if( !( m_pRoute->m_bIsInLayer ) && !( m_pRoute == g_pActiveTrack )
- && !( m_pRoute->m_bRtIsActive ) ) {
- m_nSelected = selected_no + 1;
- m_SplitButton->Enable( true );
- }
-
- gFrame->JumpToPosition( prp->m_lat, prp->m_lon, cc1->GetVPScale() );
-
- }
- }
-}
-
RouteProp::~RouteProp()
{
delete m_TotalDistCtl;
@@ -981,11 +956,6 @@ void RouteProp::CreateControls()
wxBoxSizer* itemBoxSizer16 = new wxBoxSizer( wxHORIZONTAL );
itemBoxSizer2->Add( itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5 );
- m_CopyTxtButton = new wxButton( itemDialog1, ID_ROUTEPROP_COPYTXT, _("Copy as Text"),
- wxDefaultPosition, wxDefaultSize, 0 );
- itemBoxSizer16->Add( m_CopyTxtButton, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 5 );
- m_CopyTxtButton->Enable( true );
-
m_ExtendButton = new wxButton( itemDialog1, ID_ROUTEPROP_EXTEND, _("Extend Route"),
wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer16->Add( m_ExtendButton, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 5 );
@@ -1045,6 +1015,11 @@ void RouteProp::CreateControls()
m_wpTrackList->InsertColumn( 7, _("Speed (Kts)"), wxLIST_FORMAT_CENTER, 100 );
m_wpTrackList->Hide();
+ Connect( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
+ wxListEventHandler(RouteProp::OnRoutePropRightClick), NULL, this );
+ Connect( wxEVT_COMMAND_MENU_SELECTED,
+ wxCommandEventHandler(RouteProp::OnRoutePropMenuSelected), NULL, this );
+
// Fetch any config file values
m_planspeed = g_PlanSpeed;
@@ -1054,11 +1029,103 @@ void RouteProp::CreateControls()
}
+
+void RouteProp::OnRoutepropListClick( wxListEvent& event )
+{
+ long itemno = 0;
+ m_nSelected = 0;
+
+ // We use different methods to determine the selected point,
+ // depending on whether this is a Route or a Track.
+ int selected_no;
+ if( !m_pRoute->m_bIsTrack ) {
+ const wxListItem &i = event.GetItem();
+ i.GetText().ToLong( &itemno );
+ selected_no = itemno;
+ } else {
+ itemno = -1;
+ itemno = m_wpTrackList->GetNextItem( itemno, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
+ if( itemno == -1 ) selected_no = 0;
+ else
+ selected_no = itemno;
+ }
+
+ m_pRoute->ClearHighlights();
+
+ wxRoutePointListNode *node = m_pRoute->pRoutePointList->GetFirst();
+ while( node && itemno-- ) {
+ node = node->GetNext();
+ }
+ if( node ) {
+ RoutePoint *prp = node->GetData();
+ if( prp ) {
+ prp->m_bPtIsSelected = true; // highlight the routepoint
+
+ if( !( m_pRoute->m_bIsInLayer ) && !( m_pRoute == g_pActiveTrack )
+ && !( m_pRoute->m_bRtIsActive ) ) {
+ m_nSelected = selected_no + 1;
+ m_SplitButton->Enable( true );
+ }
+
+ gFrame->JumpToPosition( prp->m_lat, prp->m_lon, cc1->GetVPScale() );
+
+ }
+ }
+}
+
+
+void RouteProp::OnRoutePropMenuSelected( wxCommandEvent& event )
+{
+ switch( event.GetId() ) {
+ case ID_RCLK_MENU_COPY_TEXT: {
+ OnRoutepropCopyTxtClick( event );
+ break;
+ }
+ case ID_RCLK_MENU_DELETE: {
+ OCPNMessageDialog wpDeleteConfirm( this,
+ _("Are you sure you want to remove this waypoint?"),
+ _("OpenCPN Remove Waypoint"), (long) wxYES_NO | wxCANCEL | wxYES_DEFAULT );
+ int dlg_return = wpDeleteConfirm.ShowModal();
+
+ if( dlg_return == wxID_YES ) {
+ long item = -1;
+ item = m_wpList->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
+
+ if( item == -1 ) break;
+
+ RoutePoint *wp;
+ wp = (RoutePoint *) m_wpList->GetItemData( item );
+
+ cc1->RemovePointFromRoute( wp, m_pRoute );
+
+ SetRouteAndUpdate( m_pRoute );
+ }
+ break;
+ }
+ case ID_RCLK_MENU_EDIT_WP: {
+ long item = -1;
+
+ item = m_wpList->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
+
+ if( item == -1 ) break;
+
+ RoutePoint *wp = (RoutePoint *) m_wpList->GetItemData( item );
+ if( !wp ) break;
+
+ RouteManagerDialog::WptShowPropertiesDialog( wp, this );
+
+ UpdateProperties();
+ break;
+ }
+ }
+}
+
void RouteProp::SetColorScheme( ColorScheme cs )
{
DimeControl( this );
}
-/*!
+
+/*
* Should we show tooltips?
*/
@@ -1175,6 +1242,7 @@ void RouteProp::InitializeList()
int in = 0;
while( pnode ) {
m_wpList->InsertItem( in, _T(""), 0 );
+ m_wpList->SetItemPtrData( in, (wxUIntPtr)pnode->GetData() );
in++;
if( pnode->GetData()->m_seg_etd.IsValid() ) {
m_wpList->InsertItem( in, _T(""), 0 );
Please sign in to comment.
Something went wrong with that request. Please try again.