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_base.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 class STATUS_TEXT_POPUP;
39 
40 namespace KIGFX {
41  namespace PREVIEW {
42  class RULER_ITEM;
43  }
44 }
45 
53 #define EXCLUDE_LOCKED 0x0001
54 #define EXCLUDE_LOCKED_PADS 0x0002
55 #define EXCLUDE_TRANSIENTS 0x0004
56 #define INCLUDE_PADS_AND_MODULES 0x0008
57 
58 void EditToolSelectionFilter( GENERAL_COLLECTOR& aCollector, int aFlags );
59 
67 class EDIT_TOOL : public PCB_TOOL_BASE
68 {
69 public:
70  EDIT_TOOL();
71 
73  void Reset( RESET_REASON aReason ) override;
74 
76  bool Init() override;
77 
79  int GetAndPlace( const TOOL_EVENT& aEvent );
80 
85  int Move( const TOOL_EVENT& aEvent );
86 
91  int Drag( const TOOL_EVENT& aEvent );
92 
97  int Properties( const TOOL_EVENT& aEvent );
98 
103  int Rotate( const TOOL_EVENT& aEvent );
104 
109  int Flip( const TOOL_EVENT& aEvent );
110 
115  int Mirror( const TOOL_EVENT& aEvent );
116 
117  int ChangeTrackWidth( const TOOL_EVENT& aEvent );
118 
123  int Remove( const TOOL_EVENT& aEvent );
124 
129  int Duplicate( const TOOL_EVENT& aEvent );
130 
135  int MoveExact( const TOOL_EVENT& aEvent );
136 
140  int MoveWithReference( const TOOL_EVENT& aEvent );
141 
146  int CreateArray( const TOOL_EVENT& aEvent );
147 
152  static void FootprintFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector );
153 
158  static void PadFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector );
159 
161  void setTransitions() override;
162 
168  int copyToClipboard( const TOOL_EVENT& aEvent );
169 
175  int cutToClipboard( const TOOL_EVENT& aEvent );
176 
177  BOARD_COMMIT* GetCurrentCommit() const { return m_commit.get(); }
178 
179 private:
182  bool updateModificationPoint( PCBNEW_SELECTION& aSelection );
183 
184  bool invokeInlineRouter( int aDragMode );
185  bool isInteractiveDragEnabled() const;
186  bool isRouterActive() const;
187 
188  int doMoveSelection( const TOOL_EVENT& aEvent, bool aPickReference = false );
189 
190  bool pickReferencePoint( const wxString& aTooltip, const wxString& aSuccessMessage,
191  const wxString& aCanceledMessage, VECTOR2I& aReferencePoint );
192 
193 private:
194  SELECTION_TOOL* m_selectionTool; // Selection tool used for obtaining selected items
195  bool m_dragging; // Indicates objects are being dragged right now
196  bool m_lockedSelected; // Determines if we prompt before removing locked objects
197  VECTOR2I m_cursor; // Last cursor position (needed for getModificationPoint()
198  // to avoid changes of edit reference point).
199  std::unique_ptr<BOARD_COMMIT> m_commit;
200 };
201 
202 #endif
void setTransitions() override
Sets up handlers for various events.
Definition: edit_tool.cpp:1560
VECTOR2I m_cursor
Definition: edit_tool.h:197
int Properties(const TOOL_EVENT &aEvent)
Function Properties() Displays properties window for the selected object.
Definition: edit_tool.cpp:675
int Rotate(const TOOL_EVENT &aEvent)
Function Rotate() Rotates currently selected items.
Definition: edit_tool.cpp:722
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:175
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:199
SELECTION_TOOL.
int ChangeTrackWidth(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:620
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:194
int Mirror(const TOOL_EVENT &aEvent)
Function Mirror Mirrors the current selection.
Definition: edit_tool.cpp:813
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:1544
bool pickReferencePoint(const wxString &aTooltip, const wxString &aSuccessMessage, const wxString &aCanceledMessage, VECTOR2I &aReferencePoint)
Definition: edit_tool.cpp:1440
bool m_lockedSelected
Definition: edit_tool.h:196
int Flip(const TOOL_EVENT &aEvent)
Function Flip() Rotates currently selected items.
Definition: edit_tool.cpp:910
bool isInteractiveDragEnabled() const
Definition: edit_tool.cpp:273
int GetAndPlace(const TOOL_EVENT &aEvent)
Find an item and start moving.
Definition: edit_tool.cpp:227
bool m_dragging
Definition: edit_tool.h:195
void EditToolSelectionFilter(GENERAL_COLLECTOR &aCollector, int aFlags)
Definition: edit_tool.cpp:61
TOOL_EVENT.
Definition: tool_event.h:171
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: edit_tool.cpp:156
int MoveWithReference(const TOOL_EVENT &aEvent)
Moves an item but with a reference point selected first.
Definition: edit_tool.cpp:314
int Drag(const TOOL_EVENT &aEvent)
Function Drag() Invoke the PNS router to drag tracks.
Definition: edit_tool.cpp:289
EDIT_TOOL.
Definition: edit_tool.h:67
int Move(const TOOL_EVENT &aEvent)
Function Move() Main loop in which events are handled.
Definition: edit_tool.cpp:302
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
Definition: edit_tool.cpp:125
static void PadFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
Function PadFilter() A selection filter which prunes the selection to contain only items of type PCB_...
Definition: edit_tool.cpp:1393
int MoveExact(const TOOL_EVENT &aEvent)
Function MoveExact() Invokes a dialog box to allow moving of the item by an exact amount.
Definition: edit_tool.cpp:1162
int Remove(const TOOL_EVENT &aEvent)
Function Remove() Deletes currently selected items.
Definition: edit_tool.cpp:967
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:245
int CreateArray(const TOOL_EVENT &aEvent)
Function CreateArray() Creates an array of the selected items, invoking the array editor dialog to se...
Definition: edit_tool.cpp:1367
int doMoveSelection(const TOOL_EVENT &aEvent, bool aPickReference=false)
Definition: edit_tool.cpp:326
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
bool isRouterActive() const
Definition: edit_tool.cpp:281
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
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:1513
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
Function FootprintFilter() A selection filter which prunes the selection to contain only items of typ...
Definition: edit_tool.cpp:1405
bool updateModificationPoint(PCBNEW_SELECTION &aSelection)
Returns the right modification point (e.g.
Definition: edit_tool.cpp:1417
BOARD_COMMIT * GetCurrentCommit() const
Definition: edit_tool.h:177
int Duplicate(const TOOL_EVENT &aEvent)
Function Duplicate() Duplicates the current selection and starts a move action.
Definition: edit_tool.cpp:1247