From dc9298730d65a3dc1f840eb1255bb627b85168e7 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 24 Mar 2014 08:45:05 +0100 Subject: [PATCH] Added PCBNEW_CONTROLS for handling miscellaneous hot keys (trying to be compatible with the default hot key settings). Currently there are a lot of stubs to be filled out (in pcbnew_controls.cpp). Handled actions: - switching layers - switching grids - changing track width & via size --- pcbnew/CMakeLists.txt | 1 + pcbnew/tools/common_actions.cpp | 147 +++++++++- pcbnew/tools/common_actions.h | 50 ++++ pcbnew/tools/pcb_tools.cpp | 4 +- pcbnew/tools/pcbnew_control.cpp | 458 ++++++++++++++++++++++++++++++++ pcbnew/tools/pcbnew_control.h | 97 +++++++ 6 files changed, 753 insertions(+), 4 deletions(-) create mode 100644 pcbnew/tools/pcbnew_control.cpp create mode 100644 pcbnew/tools/pcbnew_control.h diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index dee4a0af07..b68f93e05b 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -260,6 +260,7 @@ set( PCBNEW_CLASS_SRCS tools/point_editor.cpp tools/drawing_tool.cpp tools/edit_tool.cpp + tools/pcbnew_control.cpp tools/pcb_tools.cpp tools/common_actions.cpp ) diff --git a/pcbnew/tools/common_actions.cpp b/pcbnew/tools/common_actions.cpp index d5a996c284..f409cc610d 100644 --- a/pcbnew/tools/common_actions.cpp +++ b/pcbnew/tools/common_actions.cpp @@ -92,17 +92,160 @@ TOOL_ACTION COMMON_ACTIONS::placeTarget( "pcbnew.InteractiveDrawing.placeTarget" "Add layer alignment target", "Add layer alignment target" ); TOOL_ACTION COMMON_ACTIONS::placeModule( "pcbnew.InteractiveDrawing.placeModule", - AS_GLOBAL, 0, + AS_GLOBAL, 'O', "Add modules", "Add modules" ); TOOL_ACTION COMMON_ACTIONS::routerActivate( "pcbnew.InteractiveRouter", - AS_GLOBAL, 0, + AS_GLOBAL, 'X', "Run push & shove router", "Run push & shove router" ); TOOL_ACTION COMMON_ACTIONS::pointEditorUpdate( "pcbnew.PointEditor.update", AS_GLOBAL, 0, "", "" ); // No description, it is not supposed to be shown anywhere +// View Controls +TOOL_ACTION COMMON_ACTIONS::zoomIn( "pcbnew.zoomIn", + AS_GLOBAL, WXK_F1, + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::zoomOut( "pcbnew.zoomOut", + AS_GLOBAL, WXK_F2, + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::zoomCenter( "pcbnew.zoomCenter", + AS_GLOBAL, WXK_F4, + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::zoomFitScreen( "pcbnew.zoomFitScreen", + AS_GLOBAL, WXK_HOME, + "", "" ); + +// Display modes +TOOL_ACTION COMMON_ACTIONS::trackDisplayMode( "pcbnew.trackDisplayMode", + AS_GLOBAL, 'K', + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::padDisplayMode( "pcbnew.padDisplayMode", + AS_GLOBAL, 'J', // TODO temporarily, find a better hot key + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::viaDisplayMode( "pcbnew.viaDisplayMode", + AS_GLOBAL, 'L', // TODO temporarily, find a better hot key + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::highContrastMode( "pcbnew.highContrastMode", + AS_GLOBAL, 'H', + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::highContrastInc( "pcbnew.highContrastInc", + AS_GLOBAL, MD_SHIFT + '.', // shift+. == > + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::highContrastDec( "pcbnew.highContrastDec", + AS_GLOBAL, MD_SHIFT + 60, // shift+, == < + "", "" ); + + +// Layer control +TOOL_ACTION COMMON_ACTIONS::layerTop( "pcbnew.layerTop", + AS_GLOBAL, WXK_PAGEUP, + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::layerInner1( "pcbnew.layerInner1", + AS_GLOBAL, WXK_F5, + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::layerInner2( "pcbnew.layerInner2", + AS_GLOBAL, WXK_F6, + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::layerInner3( "pcbnew.layerInner3", + AS_GLOBAL, WXK_F7, + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::layerInner4( "pcbnew.layerInner4", + AS_GLOBAL, WXK_F8, + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::layerInner5( "pcbnew.layerInner5", + AS_GLOBAL, WXK_F9, + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::layerInner6( "pcbnew.layerInner6", + AS_GLOBAL, WXK_F10, + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::layerBottom( "pcbnew.layerBottom", + AS_GLOBAL, WXK_PAGEDOWN, + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::layerNext( "pcbnew.layerNext", + AS_GLOBAL, '=', + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::layerPrev( "pcbnew.layerPrev", + AS_GLOBAL, '-', + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::layerAlphaInc( "pcbnew.layerAlphaInc", + AS_GLOBAL, MD_SHIFT + '[', // shift+[ == { + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::layerAlphaDec( "pcbnew.layerAlphaDec", + AS_GLOBAL, MD_SHIFT + ']', // shift+] == } + "", "" ); + + +// Grid control +TOOL_ACTION COMMON_ACTIONS::gridFast1( "pcbnew.gridFast1", + AS_GLOBAL, MD_ALT + '1', + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::gridFast2( "pcbnew.gridFast2", + AS_GLOBAL, MD_ALT + '2', + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::gridNext( "pcbnew.gridNext", + AS_GLOBAL, '`', + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::gridPrev( "pcbnew.gridPrev", + AS_GLOBAL, MD_CTRL + '`', + "", "" ); + + +// Track & via size control +TOOL_ACTION COMMON_ACTIONS::trackWidthInc( "pcbnew.trackWidthInc", + AS_GLOBAL, '[', + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::trackWidthDec( "pcbnew.trackWidthDec", + AS_GLOBAL, ']', + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::viaSizeInc( "pcbnew.viaSizeInc", + AS_GLOBAL, '\'', + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::viaSizeDec( "pcbnew.viaSizeDec", + AS_GLOBAL, '\\', + "", "" ); + + +// Miscellaneous +TOOL_ACTION COMMON_ACTIONS::resetCoords( "pcbnew.resetCoords", + AS_GLOBAL, ' ', + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::switchUnits( "pcbnew.switchUnits", + AS_GLOBAL, MD_CTRL + 'U', + "", "" ); + +TOOL_ACTION COMMON_ACTIONS::showHelp( "pcbnew.showHelp", + AS_GLOBAL, MD_SHIFT + '/', // shift+/ == ? + "", "" ); + + std::string COMMON_ACTIONS::TranslateLegacyId( int aId ) { switch( aId ) diff --git a/pcbnew/tools/common_actions.h b/pcbnew/tools/common_actions.h index 321c372436..c97fa154cf 100644 --- a/pcbnew/tools/common_actions.h +++ b/pcbnew/tools/common_actions.h @@ -33,6 +33,7 @@ class COMMON_ACTIONS { public: + // Selection Tool /// Activation of the selection tool static TOOL_ACTION selectionActivate; @@ -42,6 +43,7 @@ public: /// Clears the current selection static TOOL_ACTION selectionClear; + // Edit Tool /// Activation of the edit tool static TOOL_ACTION editActivate; @@ -57,6 +59,7 @@ public: /// Deleting a BOARD_ITEM static TOOL_ACTION remove; + // Drawing Tool /// Activation of the drawing tool (line) static TOOL_ACTION drawLine; @@ -84,12 +87,59 @@ public: /// Activation of the drawing tool (placing a MODULE) static TOOL_ACTION placeModule; + // Push and Shove Router Tool /// Activation of the Push and Shove router static TOOL_ACTION routerActivate; + // Point Editor /// Update edit points static TOOL_ACTION pointEditorUpdate; + // View controls + static TOOL_ACTION zoomIn; + static TOOL_ACTION zoomOut; + static TOOL_ACTION zoomCenter; + static TOOL_ACTION zoomFitScreen; + + // Display modes + static TOOL_ACTION trackDisplayMode; + static TOOL_ACTION padDisplayMode; + static TOOL_ACTION viaDisplayMode; + static TOOL_ACTION highContrastMode; + static TOOL_ACTION highContrastInc; + static TOOL_ACTION highContrastDec; + + // Layer control + static TOOL_ACTION layerTop; + static TOOL_ACTION layerInner1; + static TOOL_ACTION layerInner2; + static TOOL_ACTION layerInner3; + static TOOL_ACTION layerInner4; + static TOOL_ACTION layerInner5; + static TOOL_ACTION layerInner6; + static TOOL_ACTION layerBottom; + static TOOL_ACTION layerNext; + static TOOL_ACTION layerPrev; + static TOOL_ACTION layerAlphaInc; + static TOOL_ACTION layerAlphaDec; + + // Grid control + static TOOL_ACTION gridFast1; + static TOOL_ACTION gridFast2; + static TOOL_ACTION gridNext; + static TOOL_ACTION gridPrev; + + // Track & via size control + static TOOL_ACTION trackWidthInc; + static TOOL_ACTION trackWidthDec; + static TOOL_ACTION viaSizeInc; + static TOOL_ACTION viaSizeDec; + + // Miscellaneous + static TOOL_ACTION resetCoords; + static TOOL_ACTION switchUnits; + static TOOL_ACTION showHelp; + /** * Function TranslateLegacyId() * Translates legacy tool ids to the corresponding TOOL_ACTION name. diff --git a/pcbnew/tools/pcb_tools.cpp b/pcbnew/tools/pcb_tools.cpp index 437ad4fba8..45a46a9cdd 100644 --- a/pcbnew/tools/pcb_tools.cpp +++ b/pcbnew/tools/pcb_tools.cpp @@ -38,7 +38,7 @@ #include "edit_tool.h" #include "drawing_tool.h" #include "point_editor.h" -#include "settings_tool.h" +#include "pcbnew_control.h" #include "common_actions.h" #include @@ -55,7 +55,7 @@ void PCB_EDIT_FRAME::setupTools() m_toolManager.RegisterTool( new EDIT_TOOL ); m_toolManager.RegisterTool( new DRAWING_TOOL ); m_toolManager.RegisterTool( new POINT_EDITOR ); - m_toolManager.RegisterTool( new SETTINGS_TOOL ); + m_toolManager.RegisterTool( new PCBNEW_CONTROL ); m_toolManager.SetEnvironment( NULL, GetGalCanvas()->GetView(), GetGalCanvas()->GetViewControls(), this ); diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp new file mode 100644 index 0000000000..c3ffab9c9c --- /dev/null +++ b/pcbnew/tools/pcbnew_control.cpp @@ -0,0 +1,458 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2014 CERN + * @author Maciej Suminski + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "pcbnew_control.h" +#include "common_actions.h" + +#include +#include +#include +#include +#include +#include + +using namespace KIGFX; +using boost::optional; + +PCBNEW_CONTROL::PCBNEW_CONTROL() : + TOOL_INTERACTIVE( "pcbnew.Settings" ) +{ +} + + +bool PCBNEW_CONTROL::Init() +{ + setTransitions(); + + return true; +} + + +int PCBNEW_CONTROL::ZoomIn( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::ZoomOut( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::ZoomCenter( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::ZoomFitScreen( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::TrackDisplayMode( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::PadDisplayMode( TOOL_EVENT& aEvent ) +{ + wxCommandEvent dummy; + getEditFrame()->OnTogglePadDrawMode( dummy ); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::ViaDisplayMode( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::HighContrastMode( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::HighContrastInc( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::HighContrastDec( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +// Layer control +int PCBNEW_CONTROL::LayerTop( TOOL_EVENT& aEvent ) +{ + getEditFrame()->SwitchLayer( NULL, LAYER_N_FRONT ); + getEditFrame()->GetGalCanvas()->SetFocus(); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::LayerInner1( TOOL_EVENT& aEvent ) +{ + getEditFrame()->SwitchLayer( NULL, LAYER_N_2 ); + getEditFrame()->GetGalCanvas()->SetFocus(); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::LayerInner2( TOOL_EVENT& aEvent ) +{ + getEditFrame()->SwitchLayer( NULL, LAYER_N_3 ); + getEditFrame()->GetGalCanvas()->SetFocus(); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::LayerInner3( TOOL_EVENT& aEvent ) +{ + getEditFrame()->SwitchLayer( NULL, LAYER_N_4 ); + getEditFrame()->GetGalCanvas()->SetFocus(); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::LayerInner4( TOOL_EVENT& aEvent ) +{ + getEditFrame()->SwitchLayer( NULL, LAYER_N_5 ); + getEditFrame()->GetGalCanvas()->SetFocus(); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::LayerInner5( TOOL_EVENT& aEvent ) +{ + getEditFrame()->SwitchLayer( NULL, LAYER_N_6 ); + getEditFrame()->GetGalCanvas()->SetFocus(); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::LayerInner6( TOOL_EVENT& aEvent ) +{ + getEditFrame()->SwitchLayer( NULL, LAYER_N_7 ); + getEditFrame()->GetGalCanvas()->SetFocus(); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::LayerBottom( TOOL_EVENT& aEvent ) +{ + getEditFrame()->SetActiveLayer( LAYER_N_BACK, true ); + getEditFrame()->GetGalCanvas()->SetFocus(); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::LayerNext( TOOL_EVENT& aEvent ) +{ + PCB_EDIT_FRAME* editFrame = getEditFrame(); + LAYER_NUM layer = editFrame->GetActiveLayer(); + layer = ( layer + 1 ) % ( LAST_COPPER_LAYER + 1 ); + assert( IsCopperLayer( layer ) ); + + editFrame->SwitchLayer( NULL, layer ); + editFrame->GetGalCanvas()->SetFocus(); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::LayerPrev( TOOL_EVENT& aEvent ) +{ + PCB_EDIT_FRAME* editFrame = getEditFrame(); + LAYER_NUM layer = editFrame->GetActiveLayer(); + + if( --layer < 0 ) + layer = LAST_COPPER_LAYER; + + assert( IsCopperLayer( layer ) ); + editFrame->SwitchLayer( NULL, layer ); + editFrame->GetGalCanvas()->SetFocus(); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::LayerAlphaInc( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::LayerAlphaDec( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +// Grid control +int PCBNEW_CONTROL::GridFast1( TOOL_EVENT& aEvent ) +{ + getEditFrame()->SetFastGrid1(); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::GridFast2( TOOL_EVENT& aEvent ) +{ + getEditFrame()->SetFastGrid2(); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::GridNext( TOOL_EVENT& aEvent ) +{ + getEditFrame()->SetNextGrid(); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::GridPrev( TOOL_EVENT& aEvent ) +{ + getEditFrame()->SetPrevGrid(); + setTransitions(); + + return 0; +} + + +// Track & via size control +int PCBNEW_CONTROL::TrackWidthInc( TOOL_EVENT& aEvent ) +{ + BOARD* board = getModel( PCB_T ); + int widthIndex = board->GetTrackWidthIndex() + 1; + + if( widthIndex >= (int) board->m_TrackWidthList.size() ) + widthIndex = board->m_TrackWidthList.size() - 1; + + board->SetTrackWidthIndex( widthIndex ); + + wxUpdateUIEvent dummy; + getEditFrame()->OnUpdateSelectTrackWidth( dummy ); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::TrackWidthDec( TOOL_EVENT& aEvent ) +{ + BOARD* board = getModel( PCB_T ); + int widthIndex = board->GetTrackWidthIndex() - 1; + + if( widthIndex < 0 ) + widthIndex = 0; + + board->SetTrackWidthIndex( widthIndex ); + + wxUpdateUIEvent dummy; + getEditFrame()->OnUpdateSelectTrackWidth( dummy ); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::ViaSizeInc( TOOL_EVENT& aEvent ) +{ + BOARD* board = getModel( PCB_T ); + int sizeIndex = board->GetViaSizeIndex() + 1; + + if( sizeIndex >= (int) board->m_ViasDimensionsList.size() ) + sizeIndex = board->m_ViasDimensionsList.size() - 1; + + board->SetViaSizeIndex( sizeIndex ); + + wxUpdateUIEvent dummy; + getEditFrame()->OnUpdateSelectViaSize( dummy ); + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::ViaSizeDec( TOOL_EVENT& aEvent ) +{ + BOARD* board = getModel( PCB_T ); + int sizeIndex = board->GetViaSizeIndex() - 1; + + if( sizeIndex < 0 ) + sizeIndex = 0; + + board->SetViaSizeIndex( sizeIndex ); + + wxUpdateUIEvent dummy; + getEditFrame()->OnUpdateSelectViaSize( dummy ); + setTransitions(); + + return 0; +} + + +// Miscellaneous +int PCBNEW_CONTROL::ResetCoords( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::SwitchUnits( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +int PCBNEW_CONTROL::ShowHelp( TOOL_EVENT& aEvent ) +{ + std::cout << __PRETTY_FUNCTION__ << std::endl; + setTransitions(); + + return 0; +} + + +void PCBNEW_CONTROL::setTransitions() +{ + // View controls + Go( &PCBNEW_CONTROL::ZoomIn, COMMON_ACTIONS::zoomIn.MakeEvent() ); + Go( &PCBNEW_CONTROL::ZoomOut, COMMON_ACTIONS::zoomOut.MakeEvent() ); + Go( &PCBNEW_CONTROL::ZoomCenter, COMMON_ACTIONS::zoomCenter.MakeEvent() ); + Go( &PCBNEW_CONTROL::ZoomFitScreen, COMMON_ACTIONS::zoomFitScreen.MakeEvent() ); + + // Display modes + Go( &PCBNEW_CONTROL::TrackDisplayMode, COMMON_ACTIONS::trackDisplayMode.MakeEvent() ); + Go( &PCBNEW_CONTROL::PadDisplayMode, COMMON_ACTIONS::padDisplayMode.MakeEvent() ); + Go( &PCBNEW_CONTROL::ViaDisplayMode, COMMON_ACTIONS::viaDisplayMode.MakeEvent() ); + Go( &PCBNEW_CONTROL::HighContrastMode, COMMON_ACTIONS::highContrastMode.MakeEvent() ); + Go( &PCBNEW_CONTROL::HighContrastInc, COMMON_ACTIONS::highContrastInc.MakeEvent() ); + Go( &PCBNEW_CONTROL::HighContrastDec, COMMON_ACTIONS::highContrastDec.MakeEvent() ); + + // Layer control + Go( &PCBNEW_CONTROL::LayerTop, COMMON_ACTIONS::layerTop.MakeEvent() ); + Go( &PCBNEW_CONTROL::LayerInner1, COMMON_ACTIONS::layerInner1.MakeEvent() ); + Go( &PCBNEW_CONTROL::LayerInner2, COMMON_ACTIONS::layerInner2.MakeEvent() ); + Go( &PCBNEW_CONTROL::LayerInner3, COMMON_ACTIONS::layerInner3.MakeEvent() ); + Go( &PCBNEW_CONTROL::LayerInner4, COMMON_ACTIONS::layerInner4.MakeEvent() ); + Go( &PCBNEW_CONTROL::LayerInner5, COMMON_ACTIONS::layerInner5.MakeEvent() ); + Go( &PCBNEW_CONTROL::LayerInner6, COMMON_ACTIONS::layerInner6.MakeEvent() ); + Go( &PCBNEW_CONTROL::LayerBottom, COMMON_ACTIONS::layerBottom.MakeEvent() ); + Go( &PCBNEW_CONTROL::LayerNext, COMMON_ACTIONS::layerNext.MakeEvent() ); + Go( &PCBNEW_CONTROL::LayerPrev, COMMON_ACTIONS::layerPrev.MakeEvent() ); + Go( &PCBNEW_CONTROL::LayerAlphaInc, COMMON_ACTIONS::layerAlphaInc.MakeEvent() ); + Go( &PCBNEW_CONTROL::LayerAlphaDec , COMMON_ACTIONS::layerAlphaDec.MakeEvent() ); + + // Grid control + Go( &PCBNEW_CONTROL::GridFast1, COMMON_ACTIONS::gridFast1.MakeEvent() ); + Go( &PCBNEW_CONTROL::GridFast2, COMMON_ACTIONS::gridFast2.MakeEvent() ); + Go( &PCBNEW_CONTROL::GridNext, COMMON_ACTIONS::gridNext.MakeEvent() ); + Go( &PCBNEW_CONTROL::GridPrev, COMMON_ACTIONS::gridPrev.MakeEvent() ); + + // Track & via size control + Go( &PCBNEW_CONTROL::TrackWidthInc, COMMON_ACTIONS::trackWidthInc.MakeEvent() ); + Go( &PCBNEW_CONTROL::TrackWidthDec, COMMON_ACTIONS::trackWidthDec.MakeEvent() ); + Go( &PCBNEW_CONTROL::ViaSizeInc, COMMON_ACTIONS::viaSizeInc.MakeEvent() ); + Go( &PCBNEW_CONTROL::ViaSizeDec, COMMON_ACTIONS::viaSizeDec.MakeEvent() ); + + // Miscellaneous + Go( &PCBNEW_CONTROL::ResetCoords, COMMON_ACTIONS::resetCoords.MakeEvent() ); + Go( &PCBNEW_CONTROL::SwitchUnits, COMMON_ACTIONS::switchUnits.MakeEvent() ); + Go( &PCBNEW_CONTROL::ShowHelp, COMMON_ACTIONS::showHelp.MakeEvent() ); +} diff --git a/pcbnew/tools/pcbnew_control.h b/pcbnew/tools/pcbnew_control.h new file mode 100644 index 0000000000..41861cd3c0 --- /dev/null +++ b/pcbnew/tools/pcbnew_control.h @@ -0,0 +1,97 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2014 CERN + * @author Maciej Suminski + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef PCBNEW_CONTROL_H +#define PCBNEW_CONTROL_H + +#include + +/** + * Class PCBNEW_CONTROL + * + * TODO + */ + +class PCBNEW_CONTROL : public TOOL_INTERACTIVE +{ +public: + PCBNEW_CONTROL(); + + /// @copydoc TOOL_INTERACTIVE::Reset() + void Reset( RESET_REASON aReason ) {}; + + /// @copydoc TOOL_INTERACTIVE::Init() + bool Init(); + + // View controls + int ZoomIn( TOOL_EVENT& aEvent ); + int ZoomOut( TOOL_EVENT& aEvent ); + int ZoomCenter( TOOL_EVENT& aEvent ); + int ZoomFitScreen( TOOL_EVENT& aEvent ); + + // Display modes + int TrackDisplayMode( TOOL_EVENT& aEvent ); + int PadDisplayMode( TOOL_EVENT& aEvent ); + int ViaDisplayMode( TOOL_EVENT& aEvent ); + int HighContrastMode( TOOL_EVENT& aEvent ); + int HighContrastInc( TOOL_EVENT& aEvent ); + int HighContrastDec( TOOL_EVENT& aEvent ); + + // Layer control + int LayerTop( TOOL_EVENT& aEvent ); + int LayerInner1( TOOL_EVENT& aEvent ); + int LayerInner2( TOOL_EVENT& aEvent ); + int LayerInner3( TOOL_EVENT& aEvent ); + int LayerInner4( TOOL_EVENT& aEvent ); + int LayerInner5( TOOL_EVENT& aEvent ); + int LayerInner6( TOOL_EVENT& aEvent ); + int LayerBottom( TOOL_EVENT& aEvent ); + int LayerNext( TOOL_EVENT& aEvent ); + int LayerPrev( TOOL_EVENT& aEvent ); + int LayerAlphaInc( TOOL_EVENT& aEvent ); + int LayerAlphaDec( TOOL_EVENT& aEvent ); + + // Grid control + int GridFast1( TOOL_EVENT& aEvent ); + int GridFast2( TOOL_EVENT& aEvent ); + int GridNext( TOOL_EVENT& aEvent ); + int GridPrev( TOOL_EVENT& aEvent ); + + // Track & via size control + int TrackWidthInc( TOOL_EVENT& aEvent ); + int TrackWidthDec( TOOL_EVENT& aEvent ); + int ViaSizeInc( TOOL_EVENT& aEvent ); + int ViaSizeDec( TOOL_EVENT& aEvent ); + + // Miscellaneous + int ResetCoords( TOOL_EVENT& aEvent ); + int SwitchUnits( TOOL_EVENT& aEvent ); + int ShowHelp( TOOL_EVENT& aEvent ); + +private: + ///> Sets up handlers for various events. + void setTransitions(); +}; + +#endif