Skip to content

Commit

Permalink
Modify and Delete waypoints in the Route Properties window.
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperWe committed Jun 19, 2012
1 parent 03931f1 commit eec467a
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 101 deletions.
3 changes: 3 additions & 0 deletions include/chcanv.h
Expand Up @@ -275,6 +275,9 @@ class ChartCanvas: public wxWindow

bool PurgeGLCanvasChartCache(ChartBase *pc);

void RemovePointFromRoute( RoutePoint* point, Route* route );


private:
ViewPort VPoint;
void PositionConsole(void);
Expand Down
2 changes: 2 additions & 0 deletions include/routemanagerdialog.h
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions include/routeprop.h
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
57 changes: 25 additions & 32 deletions src/chcanv.cpp
Expand Up @@ -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();

Expand All @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
16 changes: 10 additions & 6 deletions src/routemanagerdialog.cpp
Expand Up @@ -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();
Expand All @@ -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 )
Expand Down

0 comments on commit eec467a

Please sign in to comment.