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#include <eda_item.h>
32
33class COLLECTOR;
34class KIID;
35
36
37class SELECTION_TOOL : public TOOL_INTERACTIVE, public wxEvtHandler
38{
39public:
40 SELECTION_TOOL( const std::string& aName );
42
47 int UpdateMenu( const TOOL_EVENT& aEvent );
48
49 int AddItemToSel( const TOOL_EVENT& aEvent );
50 void AddItemToSel( EDA_ITEM* aItem, bool aQuietMode = false );
51 int AddItemsToSel( const TOOL_EVENT& aEvent );
52 void AddItemsToSel( EDA_ITEMS* aList, bool aQuietMode = false );
53
54 int RemoveItemFromSel( const TOOL_EVENT& aEvent );
55 void RemoveItemFromSel( EDA_ITEM* aItem, bool aQuietMode = false );
56 int RemoveItemsFromSel( const TOOL_EVENT& aEvent );
57 void RemoveItemsFromSel( EDA_ITEMS* aList, bool aQuietMode = false );
58
59 int ReselectItem( const TOOL_EVENT& aEvent );
60
65 void RemoveItemsFromSel( std::vector<KIID>* aList, bool aQuietMode = false );
66
67 void BrightenItem( EDA_ITEM* aItem );
68 void UnbrightenItem( EDA_ITEM* aItem );
69
76 int SelectionMenu( const TOOL_EVENT& aEvent );
77
79
80protected:
84 virtual SELECTION& selection() = 0;
85
91 void onDisambiguationExpire( wxTimerEvent& aEvent );
92
96 virtual void select( EDA_ITEM* aItem ) = 0;
97
101 virtual void unselect( EDA_ITEM* aItem ) = 0;
102
109 virtual void highlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) = 0;
110
117 virtual void unhighlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ) = 0;
118
123 void setModifiersState( bool aShiftState, bool aCtrlState, bool aAltState );
124
128 bool hasModifier();
129
133 virtual bool ctrlClickHighlights() { return false; }
134
135 bool doSelectionMenu( COLLECTOR* aCollector );
136
137protected:
138 bool m_additive; // Items should be added to sel (instead of replacing)
139 bool m_subtractive; // Items should be removed from sel
140 bool m_exclusive_or; // Items' selection state should be toggled
141 bool m_multiple; // Multiple selection mode is active
142 bool m_skip_heuristics; // Show disambuguation menu for all items under the
143 // cursor rather than trying to narrow them down first
144 // using heuristics
145 bool m_highlight_modifier;// select highlight net on left click
146 bool m_drag_additive; // Add multiple items to selection
147 bool m_drag_subtractive; // Remove multiple from selection
148
149 bool m_canceledMenu; // Sets to true if the disambiguation menu was cancelled
150
151 wxTimer m_disambiguateTimer; // Timer to show the disambiguate menu
152
153 VECTOR2I m_originalCursor; // Location of original cursor when starting click
154};
155
156#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:89
Definition: kiid.h:49
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)
SELECTION & GetSelection()
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:536