KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_picker_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) 2015 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Maciej Suminski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifndef PCB_PICKER_TOOL_H
24#define PCB_PICKER_TOOL_H
25
26#include <layer_ids.h>
27#include <set>
28#include <snap/snap_resolver.h>
29#include <tool/picker_tool.h>
31#include <tools/pcb_tool_base.h>
32
37{
38public:
45 {
46 public:
47 virtual void UpdatePickedPoint( const std::optional<VECTOR2I>& aPoint ) = 0;
48 virtual void UpdatePickedItem( const EDA_ITEM* aItem ) = 0;
49
50 protected:
51 ~RECEIVER() = default;
52 };
53
55 {
56 RECEIVER* m_Receiver = nullptr;
57 wxString m_Prompt;
58 std::function<bool(EDA_ITEM*)> m_ItemFilter = nullptr;
59 };
60
62 virtual ~PCB_PICKER_TOOL() = default;
63
65 bool Init() override;
66
68 int Main( const TOOL_EVENT& aEvent );
69
73 inline void SetLayerSet( const LSET& aLayerSet ) { m_layerMask = aLayerSet; }
74
75 int SelectPointInteractively( const TOOL_EVENT& aEvent );
76 int SelectItemInteractively( const TOOL_EVENT& aEvent );
77
85 {
86 m_areaPreviewHandler = aHandler;
87 }
88
90 inline void SetConstructionGeometry( bool aEnable ) { m_constructionGeometry = aEnable; }
91
94 inline void SetSuppressedSnaps( std::set<SNAP_CANDIDATE_SUBTYPE> aSubtypes )
95 {
96 m_suppressedSnaps = std::move( aSubtypes );
97 }
98
101 inline void ClearHandlers()
102 {
103 m_areaPreviewHandler = nullptr;
105 }
106
107protected:
109 void setTransitions() override;
110
112 void setControls();
113
115 void reset() override;
116
117private:
120
122
124
125 std::set<SNAP_CANDIDATE_SUBTYPE> m_suppressedSnaps;
126};
127
128#endif /* PCB_PICKER_TOOL_H */
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
Interface class for something that receives picked points or items from this tool.
virtual void UpdatePickedItem(const EDA_ITEM *aItem)=0
virtual void UpdatePickedPoint(const std::optional< VECTOR2I > &aPoint)=0
int SelectItemInteractively(const TOOL_EVENT &aEvent)
LSET m_layerMask
The layer set to use for optional snapping.
PCB_SELECTION_TOOL::AREA_PREVIEW m_areaPreviewHandler
bool Init() override
Init() is called once upon a registration of the tool.
int SelectPointInteractively(const TOOL_EVENT &aEvent)
virtual ~PCB_PICKER_TOOL()=default
std::set< SNAP_CANDIDATE_SUBTYPE > m_suppressedSnaps
void SetSuppressedSnaps(std::set< SNAP_CANDIDATE_SUBTYPE > aSubtypes)
Snap kinds this run never wants.
void SetAreaPreviewHandler(PCB_SELECTION_TOOL::AREA_PREVIEW aHandler)
Set a handler called with the drag box each time it changes, before anything is selected.
int Main(const TOOL_EVENT &aEvent)
Main event loop.
void setControls()
Applies the requested VIEW_CONTROLS settings.
void reset() override
Reinitialize tool to its initial state.
void SetLayerSet(const LSET &aLayerSet)
Set the tool's snap layer set.
void SetConstructionGeometry(bool aEnable)
Whether the snap system may draw its explanatory geometry over the board this run.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
void ClearHandlers()
Handlers only.
std::function< void(KIGFX::PREVIEW::SELECTION_AREA &aArea)> AREA_PREVIEW
Called with the drag box every time it changes, before anything is selected.
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Generic, UI-independent tool event.
Definition tool_event.h:167
std::function< bool(EDA_ITEM *)> m_ItemFilter