KiCad PCB EDA Suite
Loading...
Searching...
No Matches
graphic_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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef GRAPHIC_EDIT_TOOL_H
21#define GRAPHIC_EDIT_TOOL_H
22
23#include <snap/snap_resolver.h>
24#include <tools/graphic_edit.h>
25#include <tools/pcb_tool_base.h>
26
27#include <set>
28
30
32{
33public:
35
36 bool Init() override;
37 int Extend( const TOOL_EVENT& aEvent );
38 int Trim( const TOOL_EVENT& aEvent );
39
40private:
47 struct OPERATION
48 {
49 wxString m_NoResult;
51
53 bool ( *m_Accepts )( const PCB_SHAPE& aShape );
54
58 std::set<SNAP_CANDIDATE_SUBTYPE> m_SuppressedSnaps = {};
59
62
64 BOX2I ( *m_QueryBounds )( const BOARD_ITEM& aSource, const VECTOR2I& aPointer, const BOX2I& aWorldBounds );
65 GRAPHIC_EDIT_RESULT ( *m_Plan )( const BOARD_ITEM& aSource, const VECTOR2I& aPointer,
66 const std::vector<const BOARD_ITEM*>& aBoundaries );
67 };
68
69 int runInteractive( const TOOL_EVENT& aEvent, const OPERATION& aOperation );
70 void setTransitions() override;
71
73};
74
75#endif
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int Trim(const TOOL_EVENT &aEvent)
PCB_SELECTION_TOOL * m_selectionTool
bool Init() override
Init() is called once upon a registration of the tool.
int Extend(const TOOL_EVENT &aEvent)
int runInteractive(const TOOL_EVENT &aEvent, const OPERATION &aOperation)
The selection tool: currently supports:
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Generic, UI-independent tool event.
Definition tool_event.h:167
What one edit operation gives the shared interactive loop.
std::set< SNAP_CANDIDATE_SUBTYPE > m_SuppressedSnaps
Snap kinds this operation cannot use.
bool(* m_Accepts)(const PCB_SHAPE &aShape)
Which shapes may be the source. Anything else is not worth hovering.
GRAPHIC_EDIT_RESULT(* m_Plan)(const BOARD_ITEM &aSource, const VECTOR2I &aPointer, const std::vector< const BOARD_ITEM * > &aBoundaries)
BOX2I(* m_QueryBounds)(const BOARD_ITEM &aSource, const VECTOR2I &aPointer, const BOX2I &aWorldBounds)
Null bounds the search by the source's own extent, which only cuts what it crosses.
int m_PreviewLayer
The colour role the preview borrows. Trim marks a removal, extend an addition.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683