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 <[email protected]>
8 * @author Tomasz Wlostowski <[email protected]>
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
37class BOARD_COMMIT;
38class BOARD_ITEM;
41
42namespace KIGFX
43{
44 namespace PREVIEW
45 {
46 class RULER_ITEM;
47 }
48}
49
50
52{
53public:
55};
56
65{
66public:
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& aTrack );
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 static const std::vector<KICAD_T> MirrorableItems;
115
119 int Swap( const TOOL_EVENT& aEvent );
120
124 int PackAndMoveFootprints( const TOOL_EVENT& aEvent );
125
126 int ChangeTrackWidth( const TOOL_EVENT& aEvent );
127
131 int FilletTracks( const TOOL_EVENT& aEvent );
132
136 int FilletLines( const TOOL_EVENT& aEvent );
137
141 int Remove( const TOOL_EVENT& aEvent );
142
143 void DeleteItems( const PCB_SELECTION& aItems, bool aIsCut );
144
148 int Duplicate( const TOOL_EVENT& aEvent );
149
153 int MoveExact( const TOOL_EVENT& aEvent );
154
158 int CreateArray( const TOOL_EVENT& aEvent );
159
163 static void FootprintFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector,
164 PCB_SELECTION_TOOL* sTool );
165
169 static void PadFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector,
170 PCB_SELECTION_TOOL* sTool );
171
172 BOARD_COMMIT* GetCurrentCommit() const { return m_commit.get(); }
173
174private:
176 void setTransitions() override;
177
182 int copyToClipboard( const TOOL_EVENT& aEvent );
183
188 int cutToClipboard( const TOOL_EVENT& aEvent );
189
192 bool updateModificationPoint( PCB_SELECTION& aSelection );
193
194 bool invokeInlineRouter( int aDragMode );
195 bool isRouterActive() const;
196
197 int doMoveSelection( const TOOL_EVENT& aEvent, const wxString& aCommitMessage );
198
199 VECTOR2I getSafeMovement( const VECTOR2I& aMovement, const BOX2I& aSourceBBox,
200 const VECTOR2D& aBBoxOffset );
201
202 bool pickReferencePoint( const wxString& aTooltip, const wxString& aSuccessMessage,
203 const wxString& aCanceledMessage, VECTOR2I& aReferencePoint );
204
206 void rebuildConnectivity();
207
208private:
210 std::unique_ptr<BOARD_COMMIT> m_commit;
211 bool m_dragging; // Indicates objects are currently being dragged
212 VECTOR2I m_cursor; // Last cursor position (so getModificationPoint()
213 // can avoid changes of edit reference point).
214 std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
215
216 static const unsigned int COORDS_PADDING; // Padding from coordinates limits for this tool
217};
218
219#endif
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:70
The interactive edit tool.
Definition: edit_tool.h:65
bool isRouterActive() const
Definition: edit_tool.cpp:327
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:335
int Flip(const TOOL_EVENT &aEvent)
Rotate currently selected items.
Definition: edit_tool.cpp:1730
int Duplicate(const TOOL_EVENT &aEvent)
Duplicate the current selection and starts a move action.
Definition: edit_tool.cpp:2190
int FilletLines(const TOOL_EVENT &aEvent)
Fillet (i.e.
Definition: edit_tool.cpp:1058
int Swap(const TOOL_EVENT &aEvent)
Swap currently selected items' positions.
int PackAndMoveFootprints(const TOOL_EVENT &aEvent)
Try to fit selected footprints inside a minimal area and start movement.
int Mirror(const TOOL_EVENT &aEvent)
Mirror the current selection.
Definition: edit_tool.cpp:1617
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:2334
bool pickReferencePoint(const wxString &aTooltip, const wxString &aSuccessMessage, const wxString &aCanceledMessage, VECTOR2I &aReferencePoint)
Rebuilds the ratsnest for operations that require it outside the commit rebuild.
Definition: edit_tool.cpp:2415
bool Init() override
Init() is called once upon a registration of the tool.
Definition: edit_tool.cpp:105
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
Definition: edit_tool.cpp:81
void DeleteItems(const PCB_SELECTION &aItems, bool aIsCut)
Definition: edit_tool.cpp:1814
bool m_dragging
Definition: edit_tool.h:211
int MoveExact(const TOOL_EVENT &aEvent)
Invoke a dialog box to allow moving of the item by an exact amount.
Definition: edit_tool.cpp:2087
BOARD_COMMIT * GetCurrentCommit() const
Definition: edit_tool.h:172
int Move(const TOOL_EVENT &aEvent)
Main loop in which events are handled.
static const unsigned int COORDS_PADDING
Definition: edit_tool.h:216
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:210
bool updateModificationPoint(PCB_SELECTION &aSelection)
Definition: edit_tool.cpp:2388
VECTOR2I getSafeMovement(const VECTOR2I &aMovement, const BOX2I &aSourceBBox, const VECTOR2D &aBBoxOffset)
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
Definition: edit_tool.h:214
int DragArcTrack(const TOOL_EVENT &aTrack)
Drag-resize an arc (and change end points of connected straight segments).
Definition: edit_tool.cpp:419
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:2497
int doMoveSelection(const TOOL_EVENT &aEvent, const wxString &aCommitMessage)
int Remove(const TOOL_EVENT &aEvent)
Delete currently selected items.
Definition: edit_tool.cpp:2009
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:2567
static const std::vector< KICAD_T > MirrorableItems
Definition: edit_tool.h:114
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:2362
VECTOR2I m_cursor
Definition: edit_tool.h:212
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:297
void rebuildConnectivity()
Definition: edit_tool.cpp:2583
void setTransitions() override
< Set up handlers for various events.
Definition: edit_tool.cpp:2591
int ChangeTrackWidth(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:784
int GetAndPlace(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:274
int FilletTracks(const TOOL_EVENT &aEvent)
Fillet (i.e.
Definition: edit_tool.cpp:854
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:209
int Properties(const TOOL_EVENT &aEvent)
Display properties window for the selected object.
Definition: edit_tool.cpp:1338
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:2375
int Rotate(const TOOL_EVENT &aEvent)
Rotate currently selected items.
Definition: edit_tool.cpp:1398
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:204
The selection tool: currently supports:
POSITIONING_TOOLS_MENU(TOOL_INTERACTIVE *aTool)
Definition: edit_tool.cpp:92
Extension of STATUS_POPUP for displaying a single line text.
Definition: status_popup.h:83
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
Generic, UI-independent tool event.
Definition: tool_event.h:156
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:246