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 #include <tools/selection_tool.h>
32 #include <status_popup.h>
33 
34 
35 class BOARD_COMMIT;
36 class BOARD_ITEM;
37 class CONNECTIVITY_DATA;
38 
46 #define EXCLUDE_LOCKED 0x0001
47 #define EXCLUDE_LOCKED_PADS 0x0002
48 #define EXCLUDE_TRANSIENTS 0x0004
49 
50 void EditToolSelectionFilter( GENERAL_COLLECTOR& aCollector, int aFlags );
51 
59 class EDIT_TOOL : public PCB_TOOL
60 {
61 public:
62  EDIT_TOOL();
63 
65  void Reset( RESET_REASON aReason ) override;
66 
68  bool Init() override;
69 
76  int Main( const TOOL_EVENT& aEvent );
77 
83  int Drag( const TOOL_EVENT& aEvent );
84 
90  int Properties( const TOOL_EVENT& aEvent );
91 
97  int Rotate( const TOOL_EVENT& aEvent );
98 
104  int Flip( const TOOL_EVENT& aEvent );
105 
111  int Mirror( const TOOL_EVENT& aEvent );
112 
118  int Remove( const TOOL_EVENT& aEvent );
119 
125  int Duplicate( const TOOL_EVENT& aEvent );
126 
132  int MoveExact( const TOOL_EVENT& aEvent );
133 
140  int CreateArray( const TOOL_EVENT& aEvent );
141 
148  int ExchangeFootprints( const TOOL_EVENT& aEvent );
149 
151  int MeasureTool( const TOOL_EVENT& aEvent );
152 
159  static void FootprintFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector );
160 
167  static void PadFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector );
168 
170  void setTransitions() override;
171 
178  int copyToClipboard( const TOOL_EVENT& aEvent );
179 
180  int copyToClipboardWithAnchor( const TOOL_EVENT& aEvent );
181 
182  int doCopyToClipboard( bool withAnchor );
183 
190  int cutToClipboard( const TOOL_EVENT& aEvent );
191 
193  {
194  return m_commit.get();
195  }
196 
197 private:
200 
203 
206 
210 
213  bool updateModificationPoint( SELECTION& aSelection );
214 
215  int editFootprintInFpEditor( const TOOL_EVENT& aEvent );
216 
217  bool invokeInlineRouter( int aDragMode );
218  bool isInteractiveDragEnabled() const;
219 
221  bool pickCopyReferencePoint( VECTOR2I& aP );
222 
223  std::unique_ptr<BOARD_COMMIT> m_commit;
224 };
225 
226 #endif
void setTransitions() override
Sets up handlers for various events.
Definition: edit_tool.cpp:1363
VECTOR2I m_cursor
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point)...
Definition: edit_tool.h:209
int Main(const TOOL_EVENT &aEvent)
Function Main()
Definition: edit_tool.cpp:338
int Properties(const TOOL_EVENT &aEvent)
Function Edit()
Definition: edit_tool.cpp:627
int Rotate(const TOOL_EVENT &aEvent)
Function Rotate()
Definition: edit_tool.cpp:669
int ExchangeFootprints(const TOOL_EVENT &aEvent)
Function ExchangeFootprints()
Definition: edit_tool.cpp:1242
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:223
int doCopyToClipboard(bool withAnchor)
Definition: edit_tool.cpp:1489
Class SELECTION_TOOL.
bool updateModificationPoint(SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1390
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
Definition: edit_tool.h:199
int Mirror(const TOOL_EVENT &aEvent)
Function Mirror.
Definition: edit_tool.cpp:750
int cutToClipboard(const TOOL_EVENT &aEvent)
Function cutToClipboard() Cuts the current selection to the clipboard by formatting it as a fake pcb ...
Definition: edit_tool.cpp:1533
bool m_lockedSelected
Flag determining whether we are prompting for locked removal
Definition: edit_tool.h:205
int Flip(const TOOL_EVENT &aEvent)
Function Flip()
Definition: edit_tool.cpp:832
bool m_dragging
Flag determining if anything is being dragged right now
Definition: edit_tool.h:202
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:173
Class TOOL_EVENT.
Definition: tool_event.h:168
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: edit_tool.cpp:230
int Drag(const TOOL_EVENT &aEvent)
Function Drag()
Definition: edit_tool.cpp:326
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
bool isInteractiveDragEnabled() const
Definition: edit_tool.cpp:318
Class EDIT_TOOL.
Definition: edit_tool.h:59
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
Definition: edit_tool.cpp:221
static void PadFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
Function PadFilter()
Definition: edit_tool.cpp:1218
int MoveExact(const TOOL_EVENT &aEvent)
Function MoveExact()
Definition: edit_tool.cpp:974
int Remove(const TOOL_EVENT &aEvent)
Function Remove()
Definition: edit_tool.cpp:873
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:297
bool pickCopyReferencePoint(VECTOR2I &aP)
Definition: edit_tool.cpp:1450
int CreateArray(const TOOL_EVENT &aEvent)
Function CreateArray()
Definition: edit_tool.cpp:1200
bool changeTrackWidthOnClick(const SELECTION &selection)
Definition: edit_tool.cpp:586
int MeasureTool(const TOOL_EVENT &aEvent)
Launches a tool to measure between points
Definition: edit_tool.cpp:1266
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:245
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:1413
int copyToClipboard(const TOOL_EVENT &aEvent)
Function copyToClipboard() Sends the current selection to the clipboard by formatting it as a fake pc...
Definition: edit_tool.cpp:1521
int copyToClipboardWithAnchor(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:1527
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
Function FootprintFilter()
Definition: edit_tool.cpp:1230
BOARD_COMMIT * GetCurrentCommit() const
Definition: edit_tool.h:192
int Duplicate(const TOOL_EVENT &aEvent)
Function Duplicate()
Definition: edit_tool.cpp:1050