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:
18
20 bool Init() override;
21
23 void Reset( RESET_REASON aReason ) override;
24
25 int Main( const TOOL_EVENT& aEvent );
26
28
29 void ClearSelection();
30
31 void SetSelectionHook( std::function<void(PCB_TEST_FRAME_BASE*, PCB_SELECTION*)> aHook )
32 {
33 m_selectionHook = aHook;
34 }
35
36 void SetSelectableItemTypes( const std::vector<KICAD_T> aTypes );
37
38protected:
40 bool selectPoint( const VECTOR2I& aWhere );
41
42 void setTransitions() override;
43
44 KIGFX::PCB_VIEW* view() const { return static_cast<KIGFX::PCB_VIEW*>( getView() ); }
45
47
48 PCB_TEST_FRAME_BASE* frame() const { return getEditFrame<PCB_TEST_FRAME_BASE>(); }
49
50 BOARD* board() const { return getModel<BOARD>(); }
51
53 {
54 return static_cast<PCB_DRAW_PANEL_GAL*>( frame()->GetPanel().get() );
55 }
56
57 SELECTION& selection() override { return m_selection; }
58
59
60 void highlightInternal( EDA_ITEM* aItem, int aMode, bool aUsingOverlay );
61 void unhighlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup ) override;
62 void unhighlightInternal( EDA_ITEM* aItem, int aMode, bool aUsingOverlay );
63 void highlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup ) override;
64 void select( EDA_ITEM* aItem ) override;
65 void unselect( EDA_ITEM* aItem ) override;
66
67
68private:
70 PCB_SELECTION m_selection; // Current state of selection
71 std::vector<KICAD_T> m_selectableTypes;
72};
73
74
75#endif
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:319
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.
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)
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
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
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