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 (C) 2021-2023 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#ifndef INCLUDE_TOOL_SELECTION_TOOL_H_
26#define INCLUDE_TOOL_SELECTION_TOOL_H_
27
28#include <math/vector2d.h>
30#include <wx/timer.h>
31
32class COLLECTOR;
33
34
35class SELECTION_TOOL : public TOOL_INTERACTIVE, public wxEvtHandler
36{
37public:
38 SELECTION_TOOL( const std::string& aName );
40
45 int UpdateMenu( const TOOL_EVENT& aEvent );
46
47 int AddItemToSel( const TOOL_EVENT& aEvent );
48 void AddItemToSel( EDA_ITEM* aItem, bool aQuietMode = false );
49 int AddItemsToSel( const TOOL_EVENT& aEvent );
50 void AddItemsToSel( EDA_ITEMS* aList, bool aQuietMode = false );
51
52 int RemoveItemFromSel( const TOOL_EVENT& aEvent );
53 void RemoveItemFromSel( EDA_ITEM* aItem, bool aQuietMode = false );
54 int RemoveItemsFromSel( const TOOL_EVENT& aEvent );
55 void RemoveItemsFromSel( EDA_ITEMS* aList, bool aQuietMode = false );
56
57 int ReselectItem( const TOOL_EVENT& aEvent );
58
63 void RemoveItemsFromSel( std::vector<KIID>* aList, bool aQuietMode = false );
64
65 void BrightenItem( EDA_ITEM* aItem );
66 void UnbrightenItem( EDA_ITEM* aItem );
67
74 int SelectionMenu( const TOOL_EVENT& aEvent );
75
76protected:
80 virtual SELECTION& selection() = 0;
81
87 void onDisambiguationExpire( wxTimerEvent& aEvent );
88
92 virtual void select( EDA_ITEM* aItem ) = 0;
93
97 virtual void unselect( EDA_ITEM* aItem ) = 0;
98
105 virtual void highlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) = 0;
106
113 virtual void unhighlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) = 0;
114
119 void setModifiersState( bool aShiftState, bool aCtrlState, bool aAltState );
120
124 bool hasModifier();
125
129 virtual bool ctrlClickHighlights() { return false; }
130
131 bool doSelectionMenu( COLLECTOR* aCollector );
132
133protected:
134 bool m_additive; // Items should be added to sel (instead of replacing)
135 bool m_subtractive; // Items should be removed from sel
136 bool m_exclusive_or; // Items' selection state should be toggled
137 bool m_multiple; // Multiple selection mode is active
138 bool m_skip_heuristics; // Show disambuguation menu for all items under the
139 // cursor rather than trying to narrow them down first
140 // using heuristics
141 bool m_highlight_modifier;// select highlight net on left click
142 bool m_drag_additive; // Add multiple items to selection
143 bool m_drag_subtractive; // Remove multiple from selection
144
145 bool m_canceledMenu; // Sets to true if the disambiguation menu was cancelled
146
147 wxTimer m_disambiguateTimer; // Timer to show the disambiguate menu
148
149 VECTOR2I m_originalCursor; // Location of original cursor when starting click
150};
151
152#endif /* INCLUDE_TOOL_SELECTION_TOOL_H_ */
An abstract class that will find and hold all the objects according to an inspection done by the Insp...
Definition: collector.h:48
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
bool doSelectionMenu(COLLECTOR *aCollector)
wxTimer m_disambiguateTimer
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
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 unhighlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr)=0
Unhighlight the item visually.
int ReselectItem(const TOOL_EVENT &aEvent)
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()
Determines if ctrl-click is highlight net or XOR selection.
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:167
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:532