From 7c59d0dcc440020ec92563c385cc61bce308b069 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 18 May 2015 13:48:11 +0200 Subject: [PATCH] Layer toggling with 'Place Via' hot key when router is --- pcbnew/tools/common_actions.cpp | 4 ++++ pcbnew/tools/common_actions.h | 1 + pcbnew/tools/pcbnew_control.cpp | 17 ++++++++++++++++- pcbnew/tools/pcbnew_control.h | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pcbnew/tools/common_actions.cpp b/pcbnew/tools/common_actions.cpp index fea8eacc12..a7df2afae0 100644 --- a/pcbnew/tools/common_actions.cpp +++ b/pcbnew/tools/common_actions.cpp @@ -293,6 +293,10 @@ TOOL_ACTION COMMON_ACTIONS::layerPrev( "pcbnew.Control.layerPrev", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_PREVIOUS ), "", "" ); +TOOL_ACTION COMMON_ACTIONS::layerToggle( "pcbnew.Control.layerToggle", + AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_THROUGH_VIA ), + "", "" ); + TOOL_ACTION COMMON_ACTIONS::layerAlphaInc( "pcbnew.Control.layerAlphaInc", AS_GLOBAL, '}', "", "" ); diff --git a/pcbnew/tools/common_actions.h b/pcbnew/tools/common_actions.h index 08b3a049c2..8835a951f2 100644 --- a/pcbnew/tools/common_actions.h +++ b/pcbnew/tools/common_actions.h @@ -217,6 +217,7 @@ public: static TOOL_ACTION layerPrev; static TOOL_ACTION layerAlphaInc; static TOOL_ACTION layerAlphaDec; + static TOOL_ACTION layerToggle; static TOOL_ACTION layerChanged; // notification diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index aee1eb30ff..fc73206f6c 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -344,6 +344,20 @@ int PCBNEW_CONTROL::LayerPrev( const TOOL_EVENT& aEvent ) } +int PCBNEW_CONTROL::LayerToggle( const TOOL_EVENT& aEvent ) +{ + LAYER_NUM currentLayer = m_frame->GetActiveLayer(); + PCB_SCREEN* screen = m_frame->GetScreen(); + + if( currentLayer == screen->m_Route_Layer_TOP ) + m_frame->SwitchLayer( NULL, screen->m_Route_Layer_BOTTOM ); + else + m_frame->SwitchLayer( NULL, screen->m_Route_Layer_TOP ); + + return 0; +} + + int PCBNEW_CONTROL::LayerAlphaInc( const TOOL_EVENT& aEvent ) { KIGFX::PCB_PAINTER* painter = @@ -559,8 +573,9 @@ void PCBNEW_CONTROL::SetTransitions() Go( &PCBNEW_CONTROL::LayerSwitch, COMMON_ACTIONS::layerBottom.MakeEvent() ); Go( &PCBNEW_CONTROL::LayerNext, COMMON_ACTIONS::layerNext.MakeEvent() ); Go( &PCBNEW_CONTROL::LayerPrev, COMMON_ACTIONS::layerPrev.MakeEvent() ); + Go( &PCBNEW_CONTROL::LayerToggle, COMMON_ACTIONS::layerToggle.MakeEvent() ); Go( &PCBNEW_CONTROL::LayerAlphaInc, COMMON_ACTIONS::layerAlphaInc.MakeEvent() ); - Go( &PCBNEW_CONTROL::LayerAlphaDec , COMMON_ACTIONS::layerAlphaDec.MakeEvent() ); + Go( &PCBNEW_CONTROL::LayerAlphaDec, COMMON_ACTIONS::layerAlphaDec.MakeEvent() ); // Grid control Go( &PCBNEW_CONTROL::GridFast1, COMMON_ACTIONS::gridFast1.MakeEvent() ); diff --git a/pcbnew/tools/pcbnew_control.h b/pcbnew/tools/pcbnew_control.h index 4275b9afbb..873d5b5292 100644 --- a/pcbnew/tools/pcbnew_control.h +++ b/pcbnew/tools/pcbnew_control.h @@ -63,6 +63,7 @@ public: int LayerSwitch( const TOOL_EVENT& aEvent ); int LayerNext( const TOOL_EVENT& aEvent ); int LayerPrev( const TOOL_EVENT& aEvent ); + int LayerToggle( const TOOL_EVENT& aEvent ); int LayerAlphaInc( const TOOL_EVENT& aEvent ); int LayerAlphaDec( const TOOL_EVENT& aEvent );