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 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
160private:
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 isRouterActive() const;
182
183 int doMoveSelection( TOOL_EVENT aEvent, bool aPickReference = false );
184
185 bool pickReferencePoint( const wxString& aTooltip, const wxString& aSuccessMessage,
186 const wxString& aCanceledMessage, VECTOR2I& aReferencePoint );
187
188private:
190 std::unique_ptr<BOARD_COMMIT> m_commit;
191 bool m_dragging; // Indicates objects are currently being dragged
192 VECTOR2I m_cursor; // Last cursor position (so getModificationPoint()
193 // can avoid changes of edit reference point).
194 std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
195};
196
197#endif
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:53
The interactive edit tool.
Definition: edit_tool.h:65
bool isRouterActive() const
Definition: edit_tool.cpp:266
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
int Flip(const TOOL_EVENT &aEvent)
Rotate currently selected items.
Definition: edit_tool.cpp:1263
int Duplicate(const TOOL_EVENT &aEvent)
Duplicate the current selection and starts a move action.
Definition: edit_tool.cpp:1696
int doMoveSelection(TOOL_EVENT aEvent, bool aPickReference=false)
int Mirror(const TOOL_EVENT &aEvent)
Mirror the current selection.
Definition: edit_tool.cpp:1149
int MoveWithReference(const TOOL_EVENT &aEvent)
Move an item but with a reference point selected first.
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:1840
bool pickReferencePoint(const wxString &aTooltip, const wxString &aSuccessMessage, const wxString &aCanceledMessage, VECTOR2I &aReferencePoint)
Definition: edit_tool.cpp:1921
bool Init() override
Init() is called once upon a registration of the tool.
Definition: edit_tool.cpp:100
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
Definition: edit_tool.cpp:76
bool m_dragging
Definition: edit_tool.h:191
int MoveExact(const TOOL_EVENT &aEvent)
Invoke a dialog box to allow moving of the item by an exact amount.
Definition: edit_tool.cpp:1593
BOARD_COMMIT * GetCurrentCommit() const
Definition: edit_tool.h:158
int Move(const TOOL_EVENT &aEvent)
Main loop in which events are handled.
std::unique_ptr< BOARD_COMMIT > m_commit
Definition: edit_tool.h:190
bool updateModificationPoint(PCB_SELECTION &aSelection)
Definition: edit_tool.cpp:1894
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
Definition: edit_tool.h:194
int DragArcTrack(const TOOL_EVENT &aTrack)
Drag-resize an arc (and change end points of connected straight segments).
Definition: edit_tool.cpp:329
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:2002
int Remove(const TOOL_EVENT &aEvent)
Delete currently selected items.
Definition: edit_tool.cpp:1347
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:2067
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:1868
VECTOR2I m_cursor
Definition: edit_tool.h:192
bool invokeInlineRouter(int aDragMode)
Definition: edit_tool.cpp:235
void setTransitions() override
< Set up handlers for various events.
Definition: edit_tool.cpp:2083
int ChangeTrackWidth(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:678
int GetAndPlace(const TOOL_EVENT &aEvent)
Definition: edit_tool.cpp:212
int FilletTracks(const TOOL_EVENT &aEvent)
Fillet (i.e.
Definition: edit_tool.cpp:748
PCB_SELECTION_TOOL * m_selectionTool
Definition: edit_tool.h:189
int Properties(const TOOL_EVENT &aEvent)
Display properties window for the selected object.
Definition: edit_tool.cpp:950
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:1881
int Rotate(const TOOL_EVENT &aEvent)
Rotate currently selected items.
Definition: edit_tool.cpp:1009
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:219
The selection tool: currently supports:
SPECIAL_TOOLS_CONTEXT_MENU(TOOL_INTERACTIVE *aTool)
Definition: edit_tool.cpp:87
Extension of STATUS_POPUP for displaying a single line text.
Definition: status_popup.h:80
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
Generic, UI-independent tool event.
Definition: tool_event.h:155
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:243