KiCad PCB EDA Suite
edit_tool.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2013-2015 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #ifndef __EDIT_TOOL_H
27 #define __EDIT_TOOL_H
28 
29 #include <math/vector2d.h>
30 #include <tools/pcb_tool.h>
31 
32 class BOARD_COMMIT;
33 class BOARD_ITEM;
34 class SELECTION_TOOL;
35 
43 class EDIT_TOOL : public PCB_TOOL
44 {
45 public:
46  EDIT_TOOL();
47 
49  void Reset( RESET_REASON aReason ) override;
50 
52  bool Init() override;
53 
60  int Main( const TOOL_EVENT& aEvent );
61 
67  int Properties( const TOOL_EVENT& aEvent );
68 
74  int Rotate( const TOOL_EVENT& aEvent );
75 
81  int Flip( const TOOL_EVENT& aEvent );
82 
88  int Mirror( const TOOL_EVENT& aEvent );
89 
95  int Remove( const TOOL_EVENT& aEvent );
96 
102  int Duplicate( const TOOL_EVENT& aEvent );
103 
109  int MoveExact( const TOOL_EVENT& aEvent );
110 
117  int CreateArray( const TOOL_EVENT& aEvent );
118 
125  int ExchangeFootprints( const TOOL_EVENT& aEvent );
126 
128  int MeasureTool( const TOOL_EVENT& aEvent );
129 
131  void SetTransitions() override;
132 
133 private:
136 
139 
142 
146 
149  wxPoint getModificationPoint( const SELECTION& aSelection );
150 
151  int editFootprintInFpEditor( const TOOL_EVENT& aEvent );
152 
153  bool invokeInlineRouter();
154 
166  bool hoverSelection( bool aSanitize = true );
167 
177  template<class T> T* uniqueSelected();
178 
190  template<class T>
191  T* uniqueHoverSelection( bool aSanitize = true )
192  {
193  if( !hoverSelection( aSanitize ) )
194  return nullptr;
195 
196  T* item = uniqueSelected<T>();
197 
198  return item;
199  }
200 
201  std::unique_ptr<BOARD_COMMIT> m_commit;
202 };
203 
204 #endif
wxPoint getModificationPoint(const SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1137
VECTOR2I m_cursor
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point)...
Definition: edit_tool.h:145
int Main(const TOOL_EVENT &aEvent)
Function Main()
Definition: edit_tool.cpp:247
int Properties(const TOOL_EVENT &aEvent)
Function Edit()
Definition: edit_tool.cpp:443
int Rotate(const TOOL_EVENT &aEvent)
Function Rotate()
Definition: edit_tool.cpp:490
int ExchangeFootprints(const TOOL_EVENT &aEvent)
Function ExchangeFootprints()
Definition: edit_tool.cpp:992
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:201
T
enum T contains all this lexer's tokens.
Class SELECTION_TOOL.
T * uniqueHoverSelection(bool aSanitize=true)
Function uniqueHoverSelection()
Definition: edit_tool.h:191
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:135
wxPoint m_offset
Offset from the dragged item's center (anchor)
Definition: edit_tool.h:141
int Mirror(const TOOL_EVENT &aEvent)
Function Mirror.
Definition: edit_tool.cpp:563
int Flip(const TOOL_EVENT &aEvent)
Function Flip()
Definition: edit_tool.cpp:632
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:138
T * uniqueSelected()
Function uniqueSelected()
Definition: edit_tool.cpp:1191
Class TOOL_EVENT.
Definition: tool_event.h:162
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: edit_tool.cpp:177
Class PCB_TOOL.
Definition: pcb_tool.h:45
Class EDIT_TOOL.
Definition: edit_tool.h:43
bool invokeInlineRouter()
Definition: edit_tool.cpp:224
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
Definition: edit_tool.cpp:168
int MoveExact(const TOOL_EVENT &aEvent)
Function MoveExact()
Definition: edit_tool.cpp:703
int Remove(const TOOL_EVENT &aEvent)
Function Remove()
Definition: edit_tool.cpp:665
int CreateArray(const TOOL_EVENT &aEvent)
Function CreateArray()
Definition: edit_tool.cpp:976
int MeasureTool(const TOOL_EVENT &aEvent)
Launches a tool to measure between points
Definition: edit_tool.cpp:1024
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
int editFootprintInFpEditor(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:1154
void SetTransitions() override
Sets up handlers for various events.
Definition: edit_tool.cpp:1117
int Duplicate(const TOOL_EVENT &aEvent)
Function Duplicate()
Definition: edit_tool.cpp:831
bool hoverSelection(bool aSanitize=true)
Function hoverSelection()