KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_test_selection_tool.h
Go to the documentation of this file.
1#ifndef __PCB_TEST_SELECTION_TOOL_H
2#define __PCB_TEST_SELECTION_TOOL_H
3
4#include <tool/action_menu.h>
6#include <tool/tool_menu.h>
10
12
14{
15public:
16
17 typedef std::function<void(PCB_TEST_SELECTION_TOOL*, const TOOL_EVENT&, PCB_SELECTION&)> CUSTOM_HANDLER;
18
21
23 bool Init() override;
24
26 void Reset( RESET_REASON aReason ) override;
27
28 int Main( const TOOL_EVENT& aEvent );
29
31
32 void ClearSelection();
33
34 void SetSelectionHook( std::function<void(PCB_TEST_FRAME_BASE*, PCB_SELECTION*)> aHook )
35 {
36 m_selectionHook = aHook;
37 }
38
39 void SetSelectableItemTypes( const std::vector<KICAD_T> aTypes );
41 {
42 m_customEventHandler = aHandler;
43 }
44
45protected:
47 bool selectPoint( const VECTOR2I& aWhere );
48
49 void setTransitions() override;
50
51 KIGFX::PCB_VIEW* view() const { return static_cast<KIGFX::PCB_VIEW*>( getView() ); }
52
54
56
57 BOARD* board() const { return getModel<BOARD>(); }
58
60 {
61 return static_cast<PCB_DRAW_PANEL_GAL*>( frame()->GetPanel().get() );
62 }
63
64 SELECTION& selection() override { return m_selection; }
65
66
67 void highlightInternal( EDA_ITEM* aItem, int aMode, bool aUsingOverlay );
68 void unhighlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup ) override;
69 void unhighlightInternal( EDA_ITEM* aItem, int aMode, bool aUsingOverlay );
70 void highlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup ) override;
71 void select( EDA_ITEM* aItem ) override;
72 void unselect( EDA_ITEM* aItem ) override;
73
74
75private:
77 PCB_SELECTION m_selection; // Current state of selection
78 std::vector<KICAD_T> m_selectableTypes;
80};
81
82
83#endif
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
A general implementation of a COLLECTORS_GUIDE.
Definition collectors.h:320
An interface for classes handling user events controlling the view behavior such as zooming,...
std::shared_ptr< PCB_DRAW_PANEL_GAL > GetPanel()
void highlight(EDA_ITEM *aItem, int aMode, SELECTION *aGroup) override
Highlight the item visually.
void SetSelectableItemTypes(const std::vector< KICAD_T > aTypes)
void unhighlight(EDA_ITEM *aItem, int aMode, SELECTION *aGroup) override
Unhighlight the item visually.
std::function< void(PCB_TEST_FRAME_BASE *, PCB_SELECTION *)> m_selectionHook
SELECTION & selection() override
Return a reference to the selection.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
bool selectPoint(const VECTOR2I &aWhere)
void highlightInternal(EDA_ITEM *aItem, int aMode, bool aUsingOverlay)
void SetSelectionHook(std::function< void(PCB_TEST_FRAME_BASE *, PCB_SELECTION *)> aHook)
bool Init() override
Init() is called once upon a registration of the tool.
void SetCustomEventHandler(CUSTOM_HANDLER aHandler)
std::vector< KICAD_T > m_selectableTypes
const GENERAL_COLLECTORS_GUIDE getCollectorsGuide() const
void select(EDA_ITEM *aItem) override
Take necessary action mark an item as selected.
void unhighlightInternal(EDA_ITEM *aItem, int aMode, bool aUsingOverlay)
int Main(const TOOL_EVENT &aEvent)
std::function< void(PCB_TEST_SELECTION_TOOL *, const TOOL_EVENT &, PCB_SELECTION &)> CUSTOM_HANDLER
PCB_DRAW_PANEL_GAL * canvas() const
PCB_TEST_FRAME_BASE * frame() const
void unselect(EDA_ITEM *aItem) override
Take necessary action mark an item as unselected.
KIGFX::VIEW_CONTROLS * controls() const
KIGFX::PCB_VIEW * view() const
SELECTION_TOOL(const std::string &aName)
T * getEditFrame() const
Return the application window object, casted to requested user type.
Definition tool_base.h:182
T * getModel() const
Return the model object if it matches the requested type.
Definition tool_base.h:195
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition tool_base.cpp:40
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition tool_base.cpp:34
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:74
Generic, UI-independent tool event.
Definition tool_event.h:167
void Reset() override
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683