KiCad PCB EDA Suite
Loading...
Searching...
No Matches
selection_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
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU 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, you may find one here:
18 * http://www.gnu.org/licenses/gpl-3.0.html
19 * or you may search the http://www.gnu.org website for the version 3 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#pragma once
25
26#include <wx/timer.h>
27
28#include <math/vector2d.h>
30#include <eda_item.h>
31
32class COLLECTOR;
33class KIID;
34
35
43
44
45class SELECTION_TOOL : public TOOL_INTERACTIVE, public wxEvtHandler
46{
47public:
48 SELECTION_TOOL( const std::string& aName );
50
55 int UpdateMenu( const TOOL_EVENT& aEvent );
56
57 int AddItemToSel( const TOOL_EVENT& aEvent );
58 void AddItemToSel( EDA_ITEM* aItem, bool aQuietMode = false );
59 int AddItemsToSel( const TOOL_EVENT& aEvent );
60 void AddItemsToSel( EDA_ITEMS* aList, bool aQuietMode = false );
61
62 int RemoveItemFromSel( const TOOL_EVENT& aEvent );
63 void RemoveItemFromSel( EDA_ITEM* aItem, bool aQuietMode = false );
64 int RemoveItemsFromSel( const TOOL_EVENT& aEvent );
65 void RemoveItemsFromSel( EDA_ITEMS* aList, bool aQuietMode = false );
66
67 int ReselectItem( const TOOL_EVENT& aEvent );
68
73 void RemoveItemsFromSel( std::vector<KIID>* aList, bool aQuietMode = false );
74
75 void BrightenItem( EDA_ITEM* aItem );
76 void UnbrightenItem( EDA_ITEM* aItem );
77
84 int SelectionMenu( const TOOL_EVENT& aEvent );
85
87
88 virtual void EnterGroup() {}
89 virtual void ExitGroup( bool aSelectGroup = false ) {}
90
91protected:
95 virtual SELECTION& selection() = 0;
96
102 void onDisambiguationExpire( wxTimerEvent& aEvent );
103
107 virtual void select( EDA_ITEM* aItem ) = 0;
108
112 virtual void unselect( EDA_ITEM* aItem ) = 0;
113
120 virtual void highlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) = 0;
121
128 virtual void unhighlight( EDA_ITEM* aItem, int aHighlightMode,
129 SELECTION* aGroup = nullptr ) = 0;
130
135 void setModifiersState( bool aShiftState, bool aCtrlState, bool aAltState );
136
140 bool hasModifier();
141
145 virtual bool ctrlClickHighlights() { return false; }
146
147 bool doSelectionMenu( COLLECTOR* aCollector );
148
149protected:
154
161
163
165
167};
An abstract class that will find and hold all the objects according to an inspection done by the Insp...
Definition collector.h:49
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
Definition kiid.h:49
bool m_multiple
Multiple selection mode is active.
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
bool doSelectionMenu(COLLECTOR *aCollector)
wxTimer m_disambiguateTimer
Timer to show the disambiguate menu.
bool m_drag_additive
Add multiple items to selection.
bool m_exclusive_or
Items' selection state should be toggled.
int AddItemsToSel(const TOOL_EVENT &aEvent)
void BrightenItem(EDA_ITEM *aItem)
virtual void unselect(EDA_ITEM *aItem)=0
Take necessary action mark an item as unselected.
int AddItemToSel(const TOOL_EVENT &aEvent)
int UpdateMenu(const TOOL_EVENT &aEvent)
Update a menu's state based on the current selection.
void setModifiersState(bool aShiftState, bool aCtrlState, bool aAltState)
Set the configuration of m_additive, m_subtractive, m_exclusive_or, m_skip_heuristics from the state ...
void UnbrightenItem(EDA_ITEM *aItem)
VECTOR2I m_originalCursor
Location of original cursor when starting click.
virtual void select(EDA_ITEM *aItem)=0
Take necessary action mark an item as selected.
int SelectionMenu(const TOOL_EVENT &aEvent)
Show a popup menu to trim the COLLECTOR passed as aEvent's parameter down to a single item.
int RemoveItemsFromSel(const TOOL_EVENT &aEvent)
virtual void EnterGroup()
bool m_subtractive
Items should be removed from selection.
SELECTION_TOOL(const std::string &aName)
SELECTION & GetSelection()
bool m_highlight_modifier
Select highlight net on left click.
bool m_skip_heuristics
Show disambiguation menu for all items under the cursor rather than trying to narrow them down first ...
virtual void unhighlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr)=0
Unhighlight the item visually.
int ReselectItem(const TOOL_EVENT &aEvent)
bool m_drag_subtractive
Remove multiple from selection.
bool m_additive
Items should be added to sel (instead of replacing).
virtual void highlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr)=0
Highlight the item visually.
virtual SELECTION & selection()=0
Return a reference to the selection.
bool hasModifier()
True if a selection modifier is enabled, false otherwise.
virtual bool ctrlClickHighlights()
Determine if ctrl-click is highlight net or XOR selection.
bool m_canceledMenu
Sets to true if the disambiguation menu was canceled.
virtual void ExitGroup(bool aSelectGroup=false)
void onDisambiguationExpire(wxTimerEvent &aEvent)
Start the process to show our disambiguation menu once the user has kept the mouse down for the minim...
Generic, UI-independent tool event.
Definition tool_event.h:171
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Create a tool with given id & name.
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition eda_item.h:566
SELECTION_MODE
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695