KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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#include <unordered_set>
36
37
38class BOARD_COMMIT;
39class BOARD_ITEM;
42
43namespace KIGFX::PREVIEW
44{
45 class RULER_ITEM;
46}
47
48
56{
57public:
58 EDIT_TOOL();
59
61 void Reset( RESET_REASON aReason ) override;
62
64 bool Init() override;
65
67 int GetAndPlace( const TOOL_EVENT& aEvent );
68
72 int Move( const TOOL_EVENT& aEvent );
73
78 int Drag( const TOOL_EVENT& aEvent );
79
83 int DragArcTrack( const TOOL_EVENT& aTrack );
84
88 int Properties( const TOOL_EVENT& aEvent );
89
93 int Rotate( const TOOL_EVENT& aEvent );
94
98 int Flip( const TOOL_EVENT& aEvent );
99
103 int Mirror( const TOOL_EVENT& aEvent );
104
105 static const std::vector<KICAD_T> MirrorableItems;
106
110 int JustifyText( const TOOL_EVENT& aEvent );
111
115 int Swap( const TOOL_EVENT& aEvent );
116
120 int PackAndMoveFootprints( const TOOL_EVENT& aEvent );
121
122 int ChangeTrackWidth( const TOOL_EVENT& aEvent );
123
127 int FilletTracks( const TOOL_EVENT& aEvent );
128
133 int ModifyLines( const TOOL_EVENT& aEvent );
134
138 int HealShapes( const TOOL_EVENT& aEvent );
139
143 int SimplifyPolygons( const TOOL_EVENT& aEvent );
144
148 int OutsetItems( const TOOL_EVENT& aEvent );
149
154 int BooleanPolygons( const TOOL_EVENT& aEvent );
155
159 int Remove( const TOOL_EVENT& aEvent );
160
161 void DeleteItems( const PCB_SELECTION& aItem, bool aIsCut );
162
166 int Duplicate( const TOOL_EVENT& aItem );
167
171 int MoveExact( const TOOL_EVENT& aEvent );
172
176 int CreateArray( const TOOL_EVENT& aEvent );
177
181 static void FootprintFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector,
182 PCB_SELECTION_TOOL* sTool );
183
187 static void PadFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector,
188 PCB_SELECTION_TOOL* sTool );
189
190private:
192 void setTransitions() override;
193
198 int copyToClipboard( const TOOL_EVENT& aEvent );
199
203 int copyToClipboardAsText( const TOOL_EVENT& aEvent );
204
209 int cutToClipboard( const TOOL_EVENT& aEvent );
210
213 bool updateModificationPoint( PCB_SELECTION& aSelection );
214
215 bool invokeInlineRouter( int aDragMode );
216 bool isRouterActive() const;
217
218 VECTOR2I getSafeMovement( const VECTOR2I& aMovement, const BOX2I& aSourceBBox,
219 const VECTOR2D& aBBoxOffset );
220
221 bool pickReferencePoint( const wxString& aTooltip, const wxString& aSuccessMessage,
222 const wxString& aCanceledMessage, VECTOR2I& aReferencePoint );
223
224 bool doMoveSelection( const TOOL_EVENT& aEvent, BOARD_COMMIT* aCommit, bool aAutoStart );
225
227 void rebuildConnectivity();
228
231 void removeNonRootItems( std::unordered_set<EDA_ITEM*>& items );
232
235 std::unordered_set<BOARD_ITEM*>& children );
236
237
238private:
240 bool m_dragging; // Indicates objects are currently being dragged
241 VECTOR2I m_cursor; // Last cursor position (so getModificationPoint()
242 // can avoid changes of edit reference point).
243 std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
244
245 static const unsigned int COORDS_PADDING; // Padding from coordinates limits for this tool
246};
247
248#endif
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
The interactive edit tool.
Definition: edit_tool.h:56
bool isRouterActive() const
Definition: edit_tool.cpp:466
int Duplicate(const TOOL_EVENT &aItem)
Duplicate the current selection and starts a move action.
Definition: edit_tool.cpp:2765
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:474
bool doMoveSelection(const TOOL_EVENT &aEvent, BOARD_COMMIT *aCommit, bool aAutoStart)
Rebuilds the ratsnest for operations that require it outside the commit rebuild.
int Swap(const TOOL_EVENT &aEvent)
Swap currently selected items' positions.
int OutsetItems(const TOOL_EVENT &aEvent)
Create outset items from selection.
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:2067
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:2931
bool pickReferencePoint(const wxString &aTooltip, const wxString &aSuccessMessage, const wxString &aCanceledMessage, VECTOR2I &aReferencePoint)
Definition: edit_tool.cpp:3027
bool Init() override
Init() is called once upon a registration of the tool.
Definition: edit_tool.cpp:207
int ModifyLines(const TOOL_EVENT &aEvent)
"Modify" graphical lines.
Definition: edit_tool.cpp:1305
bool m_dragging
Definition: edit_tool.h:240
int MoveExact(const TOOL_EVENT &aEvent)
Invoke a dialog box to allow moving of the item by an exact amount.
Definition: edit_tool.cpp:2673
int Move(const TOOL_EVENT &aEvent)
Main loop in which events are handled.
static const unsigned int COORDS_PADDING
Definition: edit_tool.h:245
int JustifyText(const TOOL_EVENT &aEvent)
Set the justification on any text items (or fields) in the current selection.
Definition: edit_tool.cpp:2181
void getChildItemsOfGroupsAndGenerators(EDA_ITEM *item, std::unordered_set< BOARD_ITEM * > &children)
Definition: edit_tool.cpp:2344
bool updateModificationPoint(PCB_SELECTION &aSelection)
Definition: edit_tool.cpp:2981
VECTOR2I getSafeMovement(const VECTOR2I &aMovement, const BOX2I &aSourceBBox, const VECTOR2D &aBBoxOffset)
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
Definition: edit_tool.h:243
int DragArcTrack(const TOOL_EVENT &aTrack)
Drag-resize an arc (and change end points of connected straight segments).
Definition: edit_tool.cpp:585
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:3133
int Remove(const TOOL_EVENT &aEvent)
Delete currently selected items.
Definition: edit_tool.cpp:2600
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:3310
static const std::vector< KICAD_T > MirrorableItems
Definition: edit_tool.h:105
void DeleteItems(const PCB_SELECTION &aItem, bool aIsCut)
Definition: edit_tool.cpp:2391
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:2959
VECTOR2I m_cursor
Definition: edit_tool.h:241
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:437
void removeNonRootItems(std::unordered_set< EDA_ITEM * > &items)
Recursively adds any child items of the given item to the set.
Definition: edit_tool.cpp:2361
void rebuildConnectivity()
Removes all items from the set which are children of other PCB_GROUP or PCB_GENERATOR items in the se...
Definition: edit_tool.cpp:3326
void setTransitions() override
< Set up handlers for various events.
Definition: edit_tool.cpp:3335
int HealShapes(const TOOL_EVENT &aEvent)
Make ends of selected shapes meet by extending or cutting them, or adding extra geometry.
Definition: edit_tool.cpp:1625
int ChangeTrackWidth(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:938
int BooleanPolygons(const TOOL_EVENT &aEvent)
Modify selected polygons into a single polygon using boolean operations such as merge (union) or subt...
Definition: edit_tool.cpp:1704
int copyToClipboardAsText(const TOOL_EVENT &aEvent)
Send the current selection to the clipboard as text.
Definition: edit_tool.cpp:3214
int GetAndPlace(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:414
int FilletTracks(const TOOL_EVENT &aEvent)
Fillet (i.e.
Definition: edit_tool.cpp:1011
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:239
int SimplifyPolygons(const TOOL_EVENT &aEvent)
Simplify the outlines of selected polygon objects.
Definition: edit_tool.cpp:1555
int Properties(const TOOL_EVENT &aEvent)
Display properties window for the selected object.
Definition: edit_tool.cpp:1814
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:2970
int Rotate(const TOOL_EVENT &aEvent)
Rotate currently selected items.
Definition: edit_tool.cpp:1896
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:202
The selection tool: currently supports:
Extension of STATUS_POPUP for displaying a single line text.
Definition: status_popup.h:84
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
Generic, UI-independent tool event.
Definition: tool_event.h:167
void Reset() override
void Flip(T &aValue)
#define EDIT_TOOL(tool)