From 7db355e34acc11d90fe65477429efe194673f3fc Mon Sep 17 00:00:00 2001 From: Michael Kavanagh Date: Sun, 19 Apr 2020 15:39:16 +0100 Subject: [PATCH] ADDED: TOOL_ACTION for switching PNS router mode. Fixes https://gitlab.com/kicad/code/kicad/issues/2249 --- pcbnew/router/router_tool.cpp | 16 ++++++++++++++-- pcbnew/router/router_tool.h | 1 + pcbnew/tools/pcb_actions.cpp | 17 ++++++++++++++++- pcbnew/tools/pcb_actions.h | 4 ++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index b91de953ee..3ab2b19ea4 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -895,6 +895,17 @@ int ROUTER_TOOL::SettingsDialog( const TOOL_EVENT& aEvent ) } +int ROUTER_TOOL::ChangeRouterMode( const TOOL_EVENT& aEvent ) +{ + PNS::PNS_MODE mode = aEvent.Parameter(); + PNS::ROUTING_SETTINGS& settings = m_router->Settings(); + + settings.SetMode( mode ); + + return 0; +} + + void ROUTER_TOOL::breakTrack() { if( m_startItem && m_startItem->OfKind( PNS::ITEM::SEGMENT_T ) ) @@ -1358,6 +1369,9 @@ void ROUTER_TOOL::setTransitions() Go( &ROUTER_TOOL::MainLoop, PCB_ACTIONS::routeDiffPair.MakeEvent() ); Go( &ROUTER_TOOL::DpDimensionsDialog, PCB_ACTIONS::routerDiffPairDialog.MakeEvent() ); Go( &ROUTER_TOOL::SettingsDialog, PCB_ACTIONS::routerSettingsDialog.MakeEvent() ); + Go( &ROUTER_TOOL::ChangeRouterMode, PCB_ACTIONS::routerHighlightMode.MakeEvent() ); + Go( &ROUTER_TOOL::ChangeRouterMode, PCB_ACTIONS::routerShoveMode.MakeEvent() ); + Go( &ROUTER_TOOL::ChangeRouterMode, PCB_ACTIONS::routerWalkaroundMode.MakeEvent() ); Go( &ROUTER_TOOL::InlineDrag, PCB_ACTIONS::routerInlineDrag.MakeEvent() ); Go( &ROUTER_TOOL::InlineBreakTrack, PCB_ACTIONS::inlineBreakTrack.MakeEvent() ); @@ -1370,5 +1384,3 @@ void ROUTER_TOOL::setTransitions() Go( &ROUTER_TOOL::CustomTrackWidthDialog, ACT_CustomTrackWidth.MakeEvent() ); Go( &ROUTER_TOOL::onTrackViaSizeChanged, PCB_ACTIONS::trackViaSizeChanged.MakeEvent() ); } - - diff --git a/pcbnew/router/router_tool.h b/pcbnew/router/router_tool.h index 00188fd8f8..91bbb809b6 100644 --- a/pcbnew/router/router_tool.h +++ b/pcbnew/router/router_tool.h @@ -43,6 +43,7 @@ public: int SelectCopperLayerPair( const TOOL_EVENT& aEvent ); int DpDimensionsDialog( const TOOL_EVENT& aEvent ); int SettingsDialog( const TOOL_EVENT& aEvent ); + int ChangeRouterMode( const TOOL_EVENT& aEvent ); int CustomTrackWidthDialog( const TOOL_EVENT& aEvent ); void setTransitions() override; diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index e7ca6930d3..1e4cca3cac 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -30,6 +30,7 @@ #include #include #include +#include OPT PCB_ACTIONS::TranslateLegacyId( int aId ) { @@ -1120,6 +1121,21 @@ TOOL_ACTION PCB_ACTIONS::routerDiffPairDialog( "pcbnew.InteractiveRouter.DiffPai _( "Differential Pair Dimensions..." ), _( "Open Differential Pair Dimension settings" ), ps_diff_pair_gap_xpm ); +TOOL_ACTION PCB_ACTIONS::routerHighlightMode( "pcbnew.InteractiveRouter.HighlightMode", + AS_GLOBAL, 0, "", + _( "Router Highlight Mode" ), _( "Switch router to highlight mode" ), + nullptr, AF_NONE, (void*) PNS::RM_MarkObstacles ); + +TOOL_ACTION PCB_ACTIONS::routerShoveMode( "pcbnew.InteractiveRouter.ShoveMode", + AS_GLOBAL, 0, "", + _( "Router Shove Mode" ), _( "Switch router to shove mode" ), + nullptr, AF_NONE, (void*) PNS::RM_Shove ); + +TOOL_ACTION PCB_ACTIONS::routerWalkaroundMode( "pcbnew.InteractiveRouter.WalkaroundMode", + AS_GLOBAL, 0, "", + _( "Router Walkaround Mode" ), _( "Switch router to walkaround mode" ), + nullptr, AF_NONE, (void*) PNS::RM_Walkaround ); + TOOL_ACTION PCB_ACTIONS::selectLayerPair( "pcbnew.InteractiveRouter.SelectLayerPair", AS_GLOBAL, 0, "", _( "Set Layer Pair..." ), _( "Change active layer pair for routing" ), @@ -1176,4 +1192,3 @@ TOOL_ACTION PCB_ACTIONS::dragFreeAngle( "pcbnew.InteractiveRouter.DragFreeAngle" _( "Drag (free angle)" ), _( "Drags the nearest joint in the track without restricting the track angle." ), move_xpm ); - diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 6bd09a4a67..b0e0c301db 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -184,6 +184,10 @@ public: static TOOL_ACTION routerSettingsDialog; static TOOL_ACTION routerDiffPairDialog; + /// Actions to enable switching modes via hotkey assignments + static TOOL_ACTION routerHighlightMode; + static TOOL_ACTION routerShoveMode; + static TOOL_ACTION routerWalkaroundMode; /// Activation of the Push and Shove router (inline dragging mode) static TOOL_ACTION routerInlineDrag;