diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 20de683891..055fac4049 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -954,13 +954,12 @@ void FOOTPRINT_EDIT_FRAME::setupTools() m_toolManager->RegisterTool( new PLACEMENT_TOOL ); m_toolManager->RegisterTool( new PICKER_TOOL ); - m_toolManager->GetTool()->EditModules( true ); - m_toolManager->GetTool()->EditModules( true ); - m_toolManager->GetTool()->EditModules( true ); + m_toolManager->GetTool()->SetEditModules( true ); + m_toolManager->GetTool()->SetEditModules( true ); + m_toolManager->GetTool()->SetEditModules( true ); m_toolManager->ResetTools( TOOL_BASE::RUN ); m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" ); - } diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index bf08187c2f..b6c60c1661 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -49,8 +49,8 @@ #include DRAWING_TOOL::DRAWING_TOOL() : - TOOL_INTERACTIVE( "pcbnew.InteractiveDrawing" ), m_view( NULL ), - m_controls( NULL ), m_board( NULL ), m_frame( NULL ), m_editModules( false ), m_lineWidth( 1 ) + PCB_TOOL( "pcbnew.InteractiveDrawing" ), m_view( NULL ), + m_controls( NULL ), m_board( NULL ), m_frame( NULL ), m_lineWidth( 1 ) { } diff --git a/pcbnew/tools/drawing_tool.h b/pcbnew/tools/drawing_tool.h index 828ac17435..904c18f80b 100644 --- a/pcbnew/tools/drawing_tool.h +++ b/pcbnew/tools/drawing_tool.h @@ -25,7 +25,7 @@ #ifndef __DRAWING_TOOL_H #define __DRAWING_TOOL_H -#include +#include #include namespace KIGFX @@ -43,7 +43,7 @@ class DRAWSEGMENT; * Tool responsible for drawing graphical elements like lines, arcs, circles, etc. */ -class DRAWING_TOOL : public TOOL_INTERACTIVE +class DRAWING_TOOL : public PCB_TOOL { public: DRAWING_TOOL(); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 66e7907456..8d83cdbd1e 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -57,7 +57,7 @@ using namespace std::placeholders; #include EDIT_TOOL::EDIT_TOOL() : - TOOL_INTERACTIVE( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ), + PCB_TOOL( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ), m_dragging( false ), m_editModules( false ), m_undoInhibit( 0 ), m_updateFlag( KIGFX::VIEW_ITEM::NONE ) { diff --git a/pcbnew/tools/edit_tool.h b/pcbnew/tools/edit_tool.h index 8adaf5cb49..ad775b647c 100644 --- a/pcbnew/tools/edit_tool.h +++ b/pcbnew/tools/edit_tool.h @@ -27,7 +27,7 @@ #define __EDIT_TOOL_H #include -#include +#include #include class BOARD_ITEM; @@ -45,7 +45,7 @@ class VIEW_GROUP; * using the pcbnew.InteractiveSelection tool. */ -class EDIT_TOOL : public TOOL_INTERACTIVE +class EDIT_TOOL : public PCB_TOOL { public: EDIT_TOOL(); @@ -114,17 +114,6 @@ public: */ int CreateArray( const TOOL_EVENT& aEvent ); - /** - * Function EditModules() - * - * Toggles edit module mode. When enabled, one may select parts of modules individually - * (graphics, pads, etc.), so they can be modified. - * @param aEnabled decides if the mode should be enabled. - */ - void EditModules( bool aEnabled ) - { - m_editModules = aEnabled; - } ///> Sets up handlers for various events. void SetTransitions(); diff --git a/pcbnew/tools/pcb_tool.h b/pcbnew/tools/pcb_tool.h new file mode 100644 index 0000000000..f235945512 --- /dev/null +++ b/pcbnew/tools/pcb_tool.h @@ -0,0 +1,87 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2016 CERN + * @author Tomasz Wlostowski + * + * 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 __PCB_TOOL_H +#define __PCB_TOOL_H + +#include + +#include +#include +#include +#include + +/** + * Class PCB_TOOL + * + * A tool operating on a BOARD object +**/ + +class PCB_TOOL : public TOOL_INTERACTIVE +{ +public: + /** + * Constructor + * + * Creates a tool with given id & name. The name must be unique. */ + PCB_TOOL( TOOL_ID aId, const std::string& aName ) : + TOOL_INTERACTIVE ( aId, aName ), + m_editModules( false ) {}; + + /** + * Constructor + * + * Creates a tool with given name. The name must be unique. */ + PCB_TOOL( const std::string& aName ) : + TOOL_INTERACTIVE ( aName ), + m_editModules( false ) {}; + + virtual ~PCB_TOOL() {}; + + /** + * Function SetEditModules() + * + * Toggles edit module mode. When enabled, one may select parts of modules individually + * (graphics, pads, etc.), so they can be modified. + * @param aEnabled decides if the mode should be enabled. + */ + void SetEditModules( bool aEnabled ) + { + m_editModules = aEnabled; + } + + bool EditingModules() const + { + return m_editModules; + } + +protected: + KIGFX::VIEW* view() const { return getView(); } + PCB_EDIT_FRAME* frame() const { return getEditFrame(); } + BOARD* board() const { return getModel(); } + + bool m_editModules; +}; + +#endif diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 4f81e41612..97c32a5bae 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -68,8 +68,8 @@ public: SELECTION_TOOL::SELECTION_TOOL() : - TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ), - m_frame( NULL ), m_additive( false ), m_multiple( false ), m_editModules( false ), + PCB_TOOL( "pcbnew.InteractiveSelection" ), + m_frame( NULL ), m_additive( false ), m_multiple( false ), m_locked( true ), m_menu( this ), m_contextMenu( NULL ), m_selectMenu( NULL ), m_zoomMenu( NULL ), m_gridMenu( NULL ) { diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index 4a04516f28..b497240c6f 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -27,7 +27,7 @@ #define __SELECTION_TOOL_H #include -#include +#include #include #include @@ -111,7 +111,7 @@ enum SELECTION_LOCK_FLAGS * - takes into account high-contrast & layer visibility settings * - invokes InteractiveEdit tool when user starts to drag selected items */ -class SELECTION_TOOL : public TOOL_INTERACTIVE +class SELECTION_TOOL : public PCB_TOOL { public: SELECTION_TOOL();