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-2020 CERN
5  * Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Maciej Suminski <maciej.suminski@cern.ch>
8  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, you may find one here:
22  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23  * or you may search the http://www.gnu.org website for the version 2 license,
24  * or you may write to the Free Software Foundation, Inc.,
25  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26  */
27 
28 #ifndef __EDIT_TOOL_H
29 #define __EDIT_TOOL_H
30 
31 #include <math/vector2d.h>
32 #include <tools/pcb_tool_base.h>
34 #include <status_popup.h>
35 
36 
37 class BOARD_COMMIT;
38 class BOARD_ITEM;
39 class CONNECTIVITY_DATA;
40 class STATUS_TEXT_POPUP;
41 
42 namespace KIGFX
43 {
44  namespace PREVIEW
45  {
46  class RULER_ITEM;
47  }
48 }
49 
50 
52 {
53 public:
55 };
56 
64 class EDIT_TOOL : public PCB_TOOL_BASE
65 {
66 public:
67  EDIT_TOOL();
68 
70  void Reset( RESET_REASON aReason ) override;
71 
73  bool Init() override;
74 
76  int GetAndPlace( const TOOL_EVENT& aEvent );
77 
81  int Move( const TOOL_EVENT& aEvent );
82 
87  int Drag( const TOOL_EVENT& aEvent );
88 
92  int DragArcTrack( const TOOL_EVENT& aEvent );
93 
97  int Properties( const TOOL_EVENT& aEvent );
98 
102  int Rotate( const TOOL_EVENT& aEvent );
103 
107  int Flip( const TOOL_EVENT& aEvent );
108 
112  int Mirror( const TOOL_EVENT& aEvent );
113 
114  int ChangeTrackWidth( const TOOL_EVENT& aEvent );
115 
119  int FilletTracks( const TOOL_EVENT& aEvent );
120 
124  int Remove( const TOOL_EVENT& aEvent );
125 
129  int Duplicate( const TOOL_EVENT& aEvent );
130 
134  int MoveExact( const TOOL_EVENT& aEvent );
135 
139  int MoveWithReference( const TOOL_EVENT& aEvent );
140 
144  int CreateArray( const TOOL_EVENT& aEvent );
145 
149  static void FootprintFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector,
150  PCB_SELECTION_TOOL* sTool );
151 
155  static void PadFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector,
156  PCB_SELECTION_TOOL* sTool );
157 
158  BOARD_COMMIT* GetCurrentCommit() const { return m_commit.get(); }
159 
160 private:
162  void setTransitions() override;
163 
168  int copyToClipboard( const TOOL_EVENT& aEvent );
169 
174  int cutToClipboard( const TOOL_EVENT& aEvent );
175 
178  bool updateModificationPoint( PCB_SELECTION& aSelection );
179 
180  bool invokeInlineRouter( int aDragMode );
181  bool isInteractiveDragEnabled() const;
182  bool isRouterActive() const;
183 
184  int doMoveSelection( TOOL_EVENT aEvent, bool aPickReference = false );
185 
186  bool pickReferencePoint( const wxString& aTooltip, const wxString& aSuccessMessage,
187  const wxString& aCanceledMessage, VECTOR2I& aReferencePoint );
188 
189 private:
191  std::unique_ptr<BOARD_COMMIT> m_commit;
192  bool m_dragging; // Indicates objects are currently being dragged
193  VECTOR2I m_cursor; // Last cursor position (so getModificationPoint()
194  // can avoid changes of edit reference point).
195  std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
196 };
197 
198 #endif
void setTransitions() override
< Set up handlers for various events.
Definition: edit_tool.cpp:2372
VECTOR2I m_cursor
Definition: edit_tool.h:193
int DragArcTrack(const TOOL_EVENT &aEvent)
Drag-resize an arc (and change end points of connected straight segments).
Definition: edit_tool.cpp:321
int Properties(const TOOL_EVENT &aEvent)
Display properties window for the selected object.
Definition: edit_tool.cpp:1357
int Rotate(const TOOL_EVENT &aEvent)
Rotate currently selected items.
Definition: edit_tool.cpp:1403
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:175
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:191
int ChangeTrackWidth(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:1084
Extension of STATUS_POPUP for displaying a single line text.
Definition: status_popup.h:79
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:190
int Mirror(const TOOL_EVENT &aEvent)
Mirror the current selection.
Definition: edit_tool.cpp:1519
int cutToClipboard(const TOOL_EVENT &aEvent)
Cut the current selection to the clipboard by formatting it as a fake pcb see #AppendBoardFromClipboa...
Definition: edit_tool.cpp:2356
bool pickReferencePoint(const wxString &aTooltip, const wxString &aSuccessMessage, const wxString &aCanceledMessage, VECTOR2I &aReferencePoint)
Definition: edit_tool.cpp:2219
int Flip(const TOOL_EVENT &aEvent)
Rotate currently selected items.
Definition: edit_tool.cpp:1617
bool isInteractiveDragEnabled() const
Definition: edit_tool.cpp:258
int GetAndPlace(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:212
int doMoveSelection(TOOL_EVENT aEvent, bool aPickReference=false)
Definition: edit_tool.cpp:684
bool updateModificationPoint(PCB_SELECTION &aSelection)
Definition: edit_tool.cpp:2196
bool m_dragging
Definition: edit_tool.h:192
Generic, UI-independent tool event.
Definition: tool_event.h:173
int FilletTracks(const TOOL_EVENT &aEvent)
Fillet (i.e.
Definition: edit_tool.cpp:1154
bool Init() override
Init() is called once upon a registration of the tool.
Definition: edit_tool.cpp:101
int MoveWithReference(const TOOL_EVENT &aEvent)
Move an item but with a reference point selected first.
Definition: edit_tool.cpp:670
int Drag(const TOOL_EVENT &aEvent)
Invoke the PNS router to drag tracks or do an offline resizing of an arc track if a single arc track ...
Definition: edit_tool.cpp:274
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
Definition: edit_tool.h:195
The interactive edit tool.
Definition: edit_tool.h:64
static void PadFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector, PCB_SELECTION_TOOL *sTool)
A selection filter which prunes the selection to contain only items of type PCB_PAD_T.
Definition: edit_tool.cpp:2170
int Move(const TOOL_EVENT &aEvent)
Main loop in which events are handled.
Definition: edit_tool.cpp:658
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
Definition: edit_tool.cpp:77
int MoveExact(const TOOL_EVENT &aEvent)
Invoke a dialog box to allow moving of the item by an exact amount.
Definition: edit_tool.cpp:1887
int Remove(const TOOL_EVENT &aEvent)
Delete currently selected items.
Definition: edit_tool.cpp:1699
SPECIAL_TOOLS_CONTEXT_MENU(TOOL_INTERACTIVE *aTool)
Definition: edit_tool.cpp:88
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:230
int CreateArray(const TOOL_EVENT &aEvent)
Create an array of the selected items, invoking the array editor dialog to set the options.
Definition: edit_tool.cpp:2143
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:241
bool isRouterActive() const
Definition: edit_tool.cpp:266
The selection tool: currently supports:
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
int copyToClipboard(const TOOL_EVENT &aEvent)
Send the current selection to the clipboard by formatting it as a fake pcb see #AppendBoardFromClipbo...
Definition: edit_tool.cpp:2297
static void FootprintFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector, PCB_SELECTION_TOOL *sTool)
A selection filter which prunes the selection to contain only items of type #PCB_MODULE_T.
Definition: edit_tool.cpp:2183
BOARD_COMMIT * GetCurrentCommit() const
Definition: edit_tool.h:158
int Duplicate(const TOOL_EVENT &aEvent)
Duplicate the current selection and starts a move action.
Definition: edit_tool.cpp:1994