KiCad PCB EDA Suite
PCB_SELECTION_TOOL Class Reference

The selection tool: currently supports: More...

#include <pcb_selection_tool.h>

Inheritance diagram for PCB_SELECTION_TOOL:
SELECTION_TOOL TOOL_INTERACTIVE TOOL_BASE

Classes

class  PRIV
 Private implementation of firewalled private data. More...
 

Public Types

enum  RESET_REASON { RUN , MODEL_RELOAD , GAL_SWITCH , REDRAW }
 Determine the reason of reset for a tool. More...
 

Public Member Functions

 PCB_SELECTION_TOOL ()
 
 ~PCB_SELECTION_TOOL ()
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
void OnIdle (wxIdleEvent &aEvent)
 
bool IsFootprintEditor ()
 
int Main (const TOOL_EVENT &aEvent)
 The main loop. More...
 
PCB_SELECTIONGetSelection ()
 
PCB_SELECTIONRequestSelection (CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
 Return the current selection, filtered according to aClientFilter. More...
 
int CursorSelection (const TOOL_EVENT &aEvent)
 Clear current selection event handler. More...
 
int ClearSelection (const TOOL_EVENT &aEvent)
 
void ClearSelection (bool aQuietMode=false)
 Select all items on the board. More...
 
int SelectAll (const TOOL_EVENT &aEvent)
 
void FindItem (BOARD_ITEM *aItem)
 Take necessary actions to mark an item as found. More...
 
void select (EDA_ITEM *aItem) override
 Take necessary action mark an item as selected. More...
 
bool Selectable (const BOARD_ITEM *aItem, bool checkVisibilityOnly=false) const
 
void SelectAllItemsOnNet (int aNetCode, bool aSelect=true)
 Select all items with the given net code. More...
 
void GuessSelectionCandidates (GENERAL_COLLECTOR &aCollector, const VECTOR2I &aWhere) const
 Try to guess best selection candidates in case multiple items are clicked, by doing some brain-dead heuristics. More...
 
void RebuildSelection ()
 Rebuild the selection from the EDA_ITEMs' selection flags. More...
 
SELECTION_FILTER_OPTIONSGetFilter ()
 Set up handlers for various events. More...
 
void setTransitions () override
 Zoom the screen to center and fit the current selection. More...
 
void zoomFitSelection ()
 Zoom the screen to fit the bounding box for cross probing/selection sync. More...
 
void ZoomFitCrossProbeBBox (const BOX2I &bbox)
 
void EnterGroup ()
 Enter the group at the head of the current selection. More...
 
void ExitGroup (bool aSelectGroup=false)
 Leave the currently-entered group. More...
 
PCB_GROUPGetEnteredGroup ()
 
PCB_LAYER_ID GetActiveLayer ()
 
void FilterCollectorForHierarchy (GENERAL_COLLECTOR &aCollector, bool aMultiselect) const
 In general we don't want to select both a parent and any of it's children. More...
 
void FilterCollectorForFreePads (GENERAL_COLLECTOR &aCollector) const
 Check the "allow free pads" setting and if disabled, replace any pads in the collector with their parent footprints. More...
 
void FilterCollectorForMarkers (GENERAL_COLLECTOR &aCollector) const
 Drop any PCB_MARKERs from the collector. More...
 
void FilterCollectedItems (GENERAL_COLLECTOR &aCollector, bool aMultiSelect)
 Apply the SELECTION_FITLER_OPTIONS to the collector. More...
 
int UpdateMenu (const TOOL_EVENT &aEvent)
 Update a menu's state based on the current selection. More...
 
int AddItemToSel (const TOOL_EVENT &aEvent)
 
void AddItemToSel (EDA_ITEM *aItem, bool aQuietMode=false)
 
int AddItemsToSel (const TOOL_EVENT &aEvent)
 
void AddItemsToSel (EDA_ITEMS *aList, bool aQuietMode=false)
 
int RemoveItemFromSel (const TOOL_EVENT &aEvent)
 
void RemoveItemFromSel (EDA_ITEM *aItem, bool aQuietMode=false)
 
int RemoveItemsFromSel (const TOOL_EVENT &aEvent)
 
void RemoveItemsFromSel (EDA_ITEMS *aList, bool aQuietMode=false)
 
void RemoveItemsFromSel (std::vector< KIID > *aList, bool aQuietMode=false)
 A safer version of RemoveItemsFromSel( EDA_ITEMS ) which doesn't require the items to still exist. More...
 
void BrightenItem (EDA_ITEM *aItem)
 
void UnbrightenItem (EDA_ITEM *aItem)
 
int SelectionMenu (const TOOL_EVENT &aEvent)
 Show a popup menu to trim the COLLECTOR passed as aEvent's parameter down to a single item. More...
 
void Activate ()
 Run the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Assign a context menu and tells when it should be activated. More...
 
void RunMainStack (std::function< void()> aFunc)
 Call a function using the main stack. More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Define which state (aStateFunc) to go when a certain event arrives (aConditions). More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Suspend execution of the tool until an event specified in aEventList arrives. More...
 
TOOL_TYPE GetType () const
 Return the type of the tool. More...
 
TOOL_ID GetId () const
 Return the unique identifier of the tool. More...
 
const std::string & GetName () const
 Return the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Return the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Protected Member Functions

KIGFX::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_BASE_EDIT_FRAMEframe () const
 
BOARDboard () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
virtual bool ctrlClickHighlights () override
 Determines if ctrl-click is highlight net or XOR selection. More...
 
SELECTIONselection () override
 Return a reference to the selection. More...
 
void onDisambiguationExpire (wxTimerEvent &aEvent)
 Start the process to show our disambiguation menu once the user has kept the mouse down for the minimum time. More...
 
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 of modifier keys SHIFT, CTRL, ALT and depending on the OS. More...
 
bool hasModifier ()
 True if a selection modifier is enabled, false otherwise. More...
 
bool doSelectionMenu (COLLECTOR *aCollector)
 
void attachManager (TOOL_MANAGER *aManager)
 Set the TOOL_MANAGER the tool will belong to. More...
 
KIGFX::VIEWgetView () const
 Returns the instance of #VIEW object used in the application. More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Return the instance of VIEW_CONTROLS object used in the application. More...
 
template<typename T >
T * getEditFrame () const
 Return the application window object, casted to requested user type. More...
 
template<typename T >
T * getModel () const
 Return the model object if it matches the requested type. More...
 

Protected Attributes

bool m_additive
 
bool m_subtractive
 
bool m_exclusive_or
 
bool m_multiple
 
bool m_skip_heuristics
 
bool m_highlight_modifier
 
bool m_drag_additive
 
bool m_drag_subtractive
 
bool m_canceledMenu
 
wxTimer m_disambiguateTimer
 
VECTOR2I m_originalCursor
 
TOOL_MENU m_menu
 The functions below are not yet implemented - their interface may change. More...
 
TOOL_TYPE m_type
 Unique identifier for the tool, assigned by a TOOL_MANAGER instance. More...
 
TOOL_ID m_toolId
 Name of the tool. More...
 
std::string m_toolName
 
TOOL_MANAGERm_toolMgr
 

Private Types

enum  STOP_CONDITION { STOP_AT_JUNCTION , STOP_AT_PAD , STOP_NEVER }
 

Private Member Functions

bool selectPoint (const VECTOR2I &aWhere, bool aOnDrag=false, bool *aSelectionCancelledFlag=nullptr, CLIENT_SELECTION_FILTER aClientFilter=nullptr)
 Select an item pointed by the parameter aWhere. More...
 
bool selectCursor (bool aForceSelect=false, CLIENT_SELECTION_FILTER aClientFilter=nullptr)
 Select an item under the cursor unless there is something already selected. More...
 
bool selectMultiple ()
 Handle drawing a selection box that allows one to select many items at the same time. More...
 
int disambiguateCursor (const TOOL_EVENT &aEvent)
 Handle disambiguation actions including displaying the menu. More...
 
int expandConnection (const TOOL_EVENT &aEvent)
 Expand the current connected-item selection to the next boundary (junctions, pads, or all) More...
 
int unrouteSelected (const TOOL_EVENT &aEvent)
 Unroute the selected board connected items. More...
 
int selectNet (const TOOL_EVENT &aEvent)
 Select all copper connections belonging to the same net(s) as the items in the selection. More...
 
int selectUnconnected (const TOOL_EVENT &aEvent)
 Select nearest unconnected footprints on same net as selected items. More...
 
int grabUnconnected (const TOOL_EVENT &aEvent)
 Select and move other nearest footprint unconnected on same net as selected items. More...
 
void selectAllConnectedTracks (const std::vector< BOARD_CONNECTED_ITEM * > &aStartItems, STOP_CONDITION aStopCondition)
 Select connected tracks and vias. More...
 
void selectConnections (const std::vector< BOARD_ITEM * > &aItems)
 
void selectAllItemsOnSheet (wxString &aSheetPath)
 Select all items with the given sheet timestamp/UUID name (the sheet path). More...
 
int selectSheetContents (const TOOL_EVENT &aEvent)
 Select all footprints belonging to same hierarchical sheet as the selected footprint (same sheet path). More...
 
int selectSameSheet (const TOOL_EVENT &aEvent)
 Set selection to items passed by parameter and connected nets (optionally). More...
 
int syncSelection (const TOOL_EVENT &aEvent)
 
int syncSelectionWithNets (const TOOL_EVENT &aEvent)
 
void doSyncSelection (const std::vector< BOARD_ITEM * > &aItems, bool aWithNets)
 Invoke filter dialog and modify current selection. More...
 
int filterSelection (const TOOL_EVENT &aEvent)
 Return true if the given item passes the current SELECTION_FILTER_OPTIONS. More...
 
bool itemPassesFilter (BOARD_ITEM *aItem, bool aMultiSelect)
 
void unselect (EDA_ITEM *aItem) override
 Take necessary action mark an item as unselected. More...
 
void highlight (EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
 Highlight the item visually. More...
 
void unhighlight (EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
 Unhighlight the item visually. More...
 
bool selectionContains (const VECTOR2I &aPoint) const
 
int hitTestDistance (const VECTOR2I &aWhere, BOARD_ITEM *aItem, int aMaxDistance) const
 
int updateSelection (const TOOL_EVENT &aEvent)
 Event handler to update the selection VIEW_ITEM. More...
 
const GENERAL_COLLECTORS_GUIDE getCollectorsGuide () const
 
void highlightInternal (EDA_ITEM *aItem, int aHighlightMode, bool aUsingOverlay)
 
void unhighlightInternal (EDA_ITEM *aItem, int aHighlightMode, bool aUsingOverlay)
 
void resetTransitions ()
 Clear the current transition map and restores the default one created by setTransitions(). More...
 
void goInternal (TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
 
EDA_ITEMgetModelInt () const
 
TOOLS_HOLDERgetToolHolderInt () const
 

Private Attributes

PCB_BASE_FRAMEm_frame
 
bool m_isFootprintEditor
 
PCB_SELECTION m_selection
 
SELECTION_FILTER_OPTIONS m_filter
 
KICURSOR m_nonModifiedCursor
 
PCB_GROUPm_enteredGroup
 
KIGFX::VIEW_GROUP m_enteredGroupOverlay
 
std::unique_ptr< PRIVm_priv
 

Detailed Description

The selection tool: currently supports:

  • pick single objects (click LMB)
  • add objects to existing selection (Shift+LMB)
  • draw selection box (drag LMB)
  • handles FOOTPRINTs properly (i.e. selects either FOOTPRINT or its PADs, TEXTs, etc.)
  • takes into account high-contrast & layer visibility settings
  • invokes InteractiveEdit tool when user starts to drag selected items

Definition at line 64 of file pcb_selection_tool.h.

Member Enumeration Documentation

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determine the reason of reset for a tool.

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

REDRAW 

Full drawing refresh.

Definition at line 77 of file tool_base.h.

78 {
79 RUN,
82 REDRAW
83 };
@ REDRAW
Full drawing refresh.
Definition: tool_base.h:82
@ MODEL_RELOAD
Model changes (required full reload)
Definition: tool_base.h:80
@ GAL_SWITCH
Rendering engine changes.
Definition: tool_base.h:81
@ RUN
Tool is invoked after being inactive.
Definition: tool_base.h:79

◆ STOP_CONDITION

Enumerator
STOP_AT_JUNCTION 

Stop at any place where more than two traces meet.

Because vias are also traces, this makes selection stop at a via if there is a trace on another layer as well, but a via with only one connection will be selected.

STOP_AT_PAD 

Stop when reaching a pad.

STOP_NEVER 

Select the entire net.

Definition at line 311 of file pcb_selection_tool.h.

312 {
324 };
@ STOP_AT_PAD
Stop when reaching a pad.
@ STOP_NEVER
Select the entire net.
@ STOP_AT_JUNCTION
Stop at any place where more than two traces meet.

Constructor & Destructor Documentation

◆ PCB_SELECTION_TOOL()

PCB_SELECTION_TOOL::PCB_SELECTION_TOOL ( )

Definition at line 115 of file pcb_selection_tool.cpp.

115 :
116 SELECTION_TOOL( "pcbnew.InteractiveSelection" ),
117 m_frame( nullptr ),
118 m_isFootprintEditor( false ),
120 m_enteredGroup( nullptr ),
121 m_priv( std::make_unique<PRIV>() )
122{
123 m_filter.lockedItems = false;
124 m_filter.footprints = true;
125 m_filter.text = true;
126 m_filter.tracks = true;
127 m_filter.vias = true;
128 m_filter.pads = true;
129 m_filter.graphics = true;
130 m_filter.zones = true;
131 m_filter.keepouts = true;
132 m_filter.dimensions = true;
133 m_filter.otherItems = true;
134}
std::unique_ptr< PRIV > m_priv
PCB_BASE_FRAME * m_frame
SELECTION_FILTER_OPTIONS m_filter
SELECTION_TOOL(const std::string &aName)
bool graphics
Graphic lines, shapes, polygons.
bool text
Text (free or attached to a footprint)
bool lockedItems
Allow selecting locked items.
bool footprints
Allow selecting entire footprints.
bool dimensions
Dimension items.
bool otherItems
Anything not fitting one of the above categories.

References ARROW, SELECTION_FILTER_OPTIONS::dimensions, SELECTION_FILTER_OPTIONS::footprints, SELECTION_FILTER_OPTIONS::graphics, SELECTION_FILTER_OPTIONS::keepouts, SELECTION_FILTER_OPTIONS::lockedItems, m_filter, SELECTION_FILTER_OPTIONS::otherItems, SELECTION_FILTER_OPTIONS::pads, SELECTION_FILTER_OPTIONS::text, SELECTION_FILTER_OPTIONS::tracks, SELECTION_FILTER_OPTIONS::vias, and SELECTION_FILTER_OPTIONS::zones.

◆ ~PCB_SELECTION_TOOL()

PCB_SELECTION_TOOL::~PCB_SELECTION_TOOL ( )

Definition at line 137 of file pcb_selection_tool.cpp.

138{
141
142 Disconnect( wxEVT_TIMER, wxTimerEventHandler( PCB_SELECTION_TOOL::onDisambiguationExpire ), nullptr, this );
143}
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:349
KIGFX::VIEW_GROUP m_enteredGroupOverlay
PCB_SELECTION m_selection
void onDisambiguationExpire(wxTimerEvent &aEvent)
Start the process to show our disambiguation menu once the user has kept the mouse down for the minim...
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36

References TOOL_BASE::getView(), m_enteredGroupOverlay, m_selection, SELECTION_TOOL::onDisambiguationExpire(), and KIGFX::VIEW::Remove().

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Run the tool.

After activation, the tool starts receiving events until it is finished.

Definition at line 51 of file tool_interactive.cpp.

52{
54}
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:210
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.

References TOOL_MANAGER::InvokeTool(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), SCH_EDIT_TOOL::DeleteItemCursor(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCB_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), EE_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), ROUTER_TOOL::RouteSelected(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ AddItemsToSel() [1/2]

int SELECTION_TOOL::AddItemsToSel ( const TOOL_EVENT aEvent)
inherited

Definition at line 128 of file selection_tool.cpp.

129{
130 AddItemsToSel( aEvent.Parameter<EDA_ITEMS*>(), false );
131 selection().SetIsHover( false );
132 return 0;
133}
int AddItemsToSel(const TOOL_EVENT &aEvent)
virtual SELECTION & selection()=0
Return a reference to the selection.
void SetIsHover(bool aIsHover)
Definition: selection.h:78
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:524

References SELECTION_TOOL::AddItemsToSel(), TOOL_EVENT::Parameter(), SELECTION_TOOL::selection(), and SELECTION::SetIsHover().

Referenced by SELECTION_TOOL::AddItemsToSel(), PCB_EDIT_FRAME::RebuildAndRefresh(), EE_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), and setTransitions().

◆ AddItemsToSel() [2/2]

void SELECTION_TOOL::AddItemsToSel ( EDA_ITEMS aList,
bool  aQuietMode = false 
)
inherited

Definition at line 136 of file selection_tool.cpp.

137{
138 if( aList )
139 {
140 for( EDA_ITEM* item : *aList )
141 select( item );
142
143 // Inform other potentially interested tools
144 if( !aQuietMode )
146 }
147}
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
static const TOOL_EVENT SelectedEvent
Definition: actions.h:207
virtual void select(EDA_ITEM *aItem)=0
Take necessary action mark an item as selected.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).

References TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), SELECTION_TOOL::select(), and EVENTS::SelectedEvent.

◆ AddItemToSel() [1/2]

◆ AddItemToSel() [2/2]

void SELECTION_TOOL::AddItemToSel ( EDA_ITEM aItem,
bool  aQuietMode = false 
)
inherited

Definition at line 115 of file selection_tool.cpp.

116{
117 if( aItem )
118 {
119 select( aItem );
120
121 // Inform other potentially interested tools
122 if( !aQuietMode )
124 }
125}

References TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), SELECTION_TOOL::select(), and EVENTS::SelectedEvent.

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Set the TOOL_MANAGER the tool will belong to.

Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

61{
62 m_toolMgr = aManager;
63}

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD * PCB_SELECTION_TOOL::board ( ) const
inlineprotected

◆ BrightenItem()

void SELECTION_TOOL::BrightenItem ( EDA_ITEM aItem)
inherited

Definition at line 207 of file selection_tool.cpp.

208{
209 highlight( aItem, BRIGHTENED );
210}
virtual void highlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr)=0
Highlight the item visually.
#define BRIGHTENED
item is drawn with a bright contour

References BRIGHTENED, and SELECTION_TOOL::highlight().

Referenced by SCH_EDIT_TOOL::DeleteItemCursor(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_EDIT_FRAME::DisplayCurrentSheet(), SCH_FIND_REPLACE_TOOL::FindNext(), and SCH_FIND_REPLACE_TOOL::UpdateFind().

◆ canvas()

PCB_DRAW_PANEL_GAL * PCB_SELECTION_TOOL::canvas ( ) const
inlineprotected

Definition at line 235 of file pcb_selection_tool.h.

236 {
237 return static_cast<PCB_DRAW_PANEL_GAL*>( frame()->GetCanvas() );
238 }
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_BASE_EDIT_FRAME * frame() const

References frame(), and PCB_BASE_FRAME::GetCanvas().

Referenced by FindItem().

◆ ClearSelection() [1/2]

void PCB_SELECTION_TOOL::ClearSelection ( bool  aQuietMode = false)

Select all items on the board.

Definition at line 2307 of file pcb_selection_tool.cpp.

2308{
2309 if( m_selection.Empty() )
2310 return;
2311
2312 while( m_selection.GetSize() )
2314
2315 view()->Update( &m_selection );
2316
2317 m_selection.SetIsHover( false );
2319
2320 // Inform other potentially interested tools
2321 if( !aQuietMode )
2322 {
2325 }
2326}
static const TOOL_EVENT ClearedEvent
Definition: actions.h:209
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: pcb_view.cpp:92
static TOOL_ACTION hideLocalRatsnest
Definition: pcb_actions.h:507
KIGFX::PCB_VIEW * view() const
void unhighlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
Unhighlight the item visually.
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:99
EDA_ITEM * Front() const
Definition: selection.h:208
void ClearReferencePoint()
Definition: selection.h:265
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
#define SELECTED
Item was manually selected by the user.

References EVENTS::ClearedEvent, SELECTION::ClearReferencePoint(), SELECTION::Empty(), SELECTION::Front(), SELECTION::GetSize(), PCB_ACTIONS::hideLocalRatsnest, m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), TOOL_MANAGER::RunAction(), SELECTED, SELECTION::SetIsHover(), unhighlight(), KIGFX::PCB_VIEW::Update(), and view().

◆ ClearSelection() [2/2]

◆ controls()

KIGFX::VIEW_CONTROLS * PCB_SELECTION_TOOL::controls ( ) const
inlineprotected

Definition at line 220 of file pcb_selection_tool.h.

221 {
222 return getViewControls();
223 }
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42

References TOOL_BASE::getViewControls().

◆ ctrlClickHighlights()

bool PCB_SELECTION_TOOL::ctrlClickHighlights ( )
overrideprotectedvirtual

Determines if ctrl-click is highlight net or XOR selection.

Reimplemented from SELECTION_TOOL.

Definition at line 706 of file pcb_selection_tool.cpp.

707{
709}
PCBNEW_SETTINGS * GetPcbNewSettings() const

References PCB_BASE_FRAME::GetPcbNewSettings(), PCBNEW_SETTINGS::m_CtrlClickHighlight, m_frame, and m_isFootprintEditor.

◆ CursorSelection()

int PCB_SELECTION_TOOL::CursorSelection ( const TOOL_EVENT aEvent)

Clear current selection event handler.

Definition at line 1061 of file pcb_selection_tool.cpp.

1062{
1064
1065 selectCursor( false, aClientFilter );
1066
1067 return 0;
1068}
bool selectCursor(bool aForceSelect=false, CLIENT_SELECTION_FILTER aClientFilter=nullptr)
Select an item under the cursor unless there is something already selected.
void(* CLIENT_SELECTION_FILTER)(const VECTOR2I &, GENERAL_COLLECTOR &, PCB_SELECTION_TOOL *)

References TOOL_EVENT::Parameter(), and selectCursor().

Referenced by setTransitions().

◆ disambiguateCursor()

int PCB_SELECTION_TOOL::disambiguateCursor ( const TOOL_EVENT aEvent)
private

Handle disambiguation actions including displaying the menu.

Definition at line 1045 of file pcb_selection_tool.cpp.

1046{
1047 wxMouseState keyboardState = wxGetMouseState();
1048
1049 setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(),
1050 keyboardState.AltDown() );
1051
1052 m_skip_heuristics = true;
1054 m_skip_heuristics = false;
1055
1056 return 0;
1057}
bool selectPoint(const VECTOR2I &aWhere, bool aOnDrag=false, bool *aSelectionCancelledFlag=nullptr, CLIENT_SELECTION_FILTER aClientFilter=nullptr)
Select an item pointed by the parameter aWhere.
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 ...
VECTOR2I m_originalCursor

References SELECTION_TOOL::m_canceledMenu, SELECTION_TOOL::m_originalCursor, SELECTION_TOOL::m_skip_heuristics, selectPoint(), and SELECTION_TOOL::setModifiersState().

Referenced by setTransitions().

◆ doSelectionMenu()

bool SELECTION_TOOL::doSelectionMenu ( COLLECTOR aCollector)
protectedinherited

The user has requested the full, non-limited list of selection items

Definition at line 245 of file selection_tool.cpp.

246{
247 UNITS_PROVIDER* unitsProvider = getEditFrame<EDA_DRAW_FRAME>();
248 EDA_ITEM* current = nullptr;
249 SELECTION highlightGroup;
250 bool selectAll = false;
251 bool expandSelection = false;
252
253 highlightGroup.SetLayer( LAYER_SELECT_OVERLAY );
254 getView()->Add( &highlightGroup );
255
256 do
257 {
259 if( expandSelection )
260 aCollector->Combine();
261
262 expandSelection = false;
263
264 int limit = std::min( 100, aCollector->GetCount() );
265 ACTION_MENU menu( true );
266
267 for( int i = 0; i < limit; ++i )
268 {
269 EDA_ITEM* item = ( *aCollector )[i];
270 wxString menuText;
271
272 if( i < 9 )
273 {
274#ifdef __WXMAC__
275 menuText = wxString::Format( "%s\t%d",
276 item->GetItemDescription( unitsProvider ),
277 i + 1 );
278#else
279 menuText = wxString::Format( "&%d %s\t%d",
280 i + 1,
281 item->GetItemDescription( unitsProvider ),
282 i + 1 );
283#endif
284 }
285 else
286 {
287 menuText = item->GetItemDescription( unitsProvider );
288 }
289
290 menu.Add( menuText, i + 1, item->GetMenuImage() );
291 }
292
293 menu.AppendSeparator();
294 menu.Add( _( "Select &All\tA" ), limit + 1, BITMAPS::INVALID_BITMAP );
295
296 if( !expandSelection && aCollector->HasAdditionalItems() )
297 menu.Add( _( "&Expand Selection\tE" ), limit + 2, BITMAPS::INVALID_BITMAP );
298
299 if( aCollector->m_MenuTitle.Length() )
300 {
301 menu.SetTitle( aCollector->m_MenuTitle );
302 menu.SetIcon( BITMAPS::info );
303 menu.DisplayTitle( true );
304 }
305 else
306 {
307 menu.DisplayTitle( false );
308 }
309
310 SetContextMenu( &menu, CMENU_NOW );
311
312 while( TOOL_EVENT* evt = Wait() )
313 {
314 if( evt->Action() == TA_CHOICE_MENU_UPDATE )
315 {
316 if( selectAll )
317 {
318 for( int i = 0; i < aCollector->GetCount(); ++i )
319 unhighlight( ( *aCollector )[i], BRIGHTENED, &highlightGroup );
320 }
321 else if( current )
322 {
323 unhighlight( current, BRIGHTENED, &highlightGroup );
324 }
325
326 int id = *evt->GetCommandId();
327
328 // User has pointed an item, so show it in a different way
329 if( id > 0 && id <= limit )
330 {
331 current = ( *aCollector )[id - 1];
332 highlight( current, BRIGHTENED, &highlightGroup );
333 }
334 else
335 {
336 current = nullptr;
337 }
338
339 // User has pointed on the "Select All" option
340 if( id == limit + 1 )
341 {
342 for( int i = 0; i < aCollector->GetCount(); ++i )
343 highlight( ( *aCollector )[i], BRIGHTENED, &highlightGroup );
344
345 selectAll = true;
346 }
347 else
348 {
349 selectAll = false;
350 }
351 }
352 else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
353 {
354 if( selectAll )
355 {
356 for( int i = 0; i < aCollector->GetCount(); ++i )
357 unhighlight( ( *aCollector )[i], BRIGHTENED, &highlightGroup );
358 }
359 else if( current )
360 {
361 unhighlight( current, BRIGHTENED, &highlightGroup );
362 }
363
364 std::optional<int> id = evt->GetCommandId();
365
366 // User has selected the "Select All" option
367 if( id == limit + 1 )
368 {
369 selectAll = true;
370 current = nullptr;
371 }
372 // User has selected the "Expand Selection" option
373 else if( id == limit + 2 )
374 {
375 selectAll = false;
376 current = nullptr;
377 expandSelection = true;
378 }
379 // User has selected an item, so this one will be returned
380 else if( id && ( *id > 0 ) && ( *id <= limit ) )
381 {
382 selectAll = false;
383 current = ( *aCollector )[*id - 1];
384 }
385 // User has cancelled the menu (either by <esc> or clicking out of it)
386 else
387 {
388 selectAll = false;
389 current = nullptr;
390 }
391 }
392 else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
393 {
394 break;
395 }
396
397 getView()->UpdateItems();
398 getEditFrame<EDA_DRAW_FRAME>()->GetCanvas()->Refresh();
399 }
400 } while( expandSelection );
401
402 getView()->Remove( &highlightGroup );
403
404 if( selectAll )
405 {
406 return true;
407 }
408 else if( current )
409 {
410 aCollector->Empty();
411 aCollector->Append( current );
412 return true;
413 }
414
415 return false;
416}
@ INVALID_BITMAP
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
void Empty()
Clear the list.
Definition: collector.h:89
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
wxString m_MenuTitle
Definition: collector.h:236
bool HasAdditionalItems()
Test if the collector has heuristic backup items.
Definition: collector.h:132
void Combine()
Re-combine the backup list into the main list of the collector.
Definition: collector.h:140
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:99
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const
Return a user-visible description string of this item.
Definition: eda_item.cpp:108
virtual BITMAPS GetMenuImage() const
Return a pointer to an image to be used in menus.
Definition: eda_item.cpp:269
virtual void SetLayer(int aLayer)
Set layer used to draw the group.
Definition: view_group.h:98
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:316
void UpdateItems()
Iterate through the list of items that asked for updating and updates them.
Definition: view.cpp:1401
virtual void unhighlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr)=0
Unhighlight the item visually.
Generic, UI-independent tool event.
Definition: tool_event.h:156
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Assign a context menu and tells when it should be activated.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
#define _(s)
@ LAYER_SELECT_OVERLAY
currently selected items overlay
Definition: layer_ids.h:219
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
@ CMENU_NOW
Definition: tool_event.h:148
@ TA_CHOICE_MENU_CHOICE
Definition: tool_event.h:93
@ TA_CHOICE_MENU_UPDATE
Definition: tool_event.h:89
@ TA_CHOICE_MENU_CLOSED
Definition: tool_event.h:96

References _, ACTION_MENU::Add(), KIGFX::VIEW::Add(), COLLECTOR::Append(), BRIGHTENED, CMENU_NOW, COLLECTOR::Combine(), ACTION_MENU::DisplayTitle(), COLLECTOR::Empty(), Format(), COLLECTOR::GetCount(), EDA_ITEM::GetItemDescription(), EDA_ITEM::GetMenuImage(), TOOL_BASE::getView(), COLLECTOR::HasAdditionalItems(), SELECTION_TOOL::highlight(), info, INVALID_BITMAP, LAYER_SELECT_OVERLAY, COLLECTOR::m_MenuTitle, KIGFX::VIEW::Remove(), TOOL_INTERACTIVE::SetContextMenu(), ACTION_MENU::SetIcon(), KIGFX::VIEW_GROUP::SetLayer(), ACTION_MENU::SetTitle(), TA_CHOICE_MENU_CHOICE, TA_CHOICE_MENU_CLOSED, TA_CHOICE_MENU_UPDATE, SELECTION_TOOL::unhighlight(), KIGFX::VIEW::UpdateItems(), and TOOL_INTERACTIVE::Wait().

Referenced by SELECTION_TOOL::SelectionMenu(), GERBVIEW_SELECTION_TOOL::selectPoint(), PL_SELECTION_TOOL::SelectPoint(), selectPoint(), and EE_SELECTION_TOOL::selectPoint().

◆ doSyncSelection()

void PCB_SELECTION_TOOL::doSyncSelection ( const std::vector< BOARD_ITEM * > &  aItems,
bool  aWithNets 
)
private

Invoke filter dialog and modify current selection.

Definition at line 1752 of file pcb_selection_tool.cpp.

1753{
1754 ClearSelection( true /*quiet mode*/ );
1755
1756 // Perform individual selection of each item before processing the event.
1757 for( BOARD_ITEM* item : aItems )
1758 select( item );
1759
1760 if( aWithNets )
1761 selectConnections( aItems );
1762
1764
1765 if( bbox.GetWidth() != 0 && bbox.GetHeight() != 0 )
1766 {
1768 {
1770 ZoomFitCrossProbeBBox( bbox );
1771
1772 m_frame->FocusOnLocation( bbox.Centre() );
1773 }
1774 }
1775
1777
1779
1780 if( m_selection.Size() > 0 )
1782}
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:173
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:70
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
Vec Centre() const
Definition: box2.h:70
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
void ForceRefresh()
Force a redraw.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:761
void ZoomFitCrossProbeBBox(const BOX2I &bbox)
void select(EDA_ITEM *aItem) override
Take necessary action mark an item as selected.
void selectConnections(const std::vector< BOARD_ITEM * > &aItems)
int Size() const
Returns the number of selected parts.
Definition: selection.h:115
virtual BOX2I GetBoundingBox() const
Definition: selection.cpp:133
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
Definition: app_settings.h:34
bool center_on_items
Automatically pan to cross-probed items.
Definition: app_settings.h:33

References CROSS_PROBING_SETTINGS::center_on_items, BOX2< Vec >::Centre(), ClearSelection(), EDA_DRAW_FRAME::FocusOnLocation(), EDA_DRAW_PANEL_GAL::ForceRefresh(), SELECTION::GetBoundingBox(), PCB_BASE_FRAME::GetCanvas(), BOX2< Vec >::GetHeight(), PCB_BASE_FRAME::GetPcbNewSettings(), BOX2< Vec >::GetWidth(), APP_SETTINGS_BASE::m_CrossProbing, m_frame, m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), select(), selectConnections(), EVENTS::SelectedEvent, SELECTION::Size(), KIGFX::VIEW::UpdateAllLayersColor(), view(), CROSS_PROBING_SETTINGS::zoom_to_fit, and ZoomFitCrossProbeBBox().

Referenced by syncSelection(), and syncSelectionWithNets().

◆ EnterGroup()

void PCB_SELECTION_TOOL::EnterGroup ( )

Enter the group at the head of the current selection.

Definition at line 502 of file pcb_selection_tool.cpp.

503{
504 wxCHECK_RET( m_selection.GetSize() == 1 && m_selection[0]->Type() == PCB_GROUP_T,
505 wxT( "EnterGroup called when selection is not a single group" ) );
506 PCB_GROUP* aGroup = static_cast<PCB_GROUP*>( m_selection[0] );
507
508 if( m_enteredGroup != nullptr )
509 ExitGroup();
510
512 m_enteredGroup = aGroup;
515 {
516 select( titem );
517 } );
518
520
521 view()->Hide( m_enteredGroup, true );
524}
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:139
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:57
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1550
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all members of the group.
Definition: pcb_group.cpp:407
void ExitGroup(bool aSelectGroup=false)
Leave the currently-entered group.
#define ENTERED
indicates a group has been entered
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115

References KIGFX::VIEW_GROUP::Add(), ClearSelection(), ENTERED, ExitGroup(), SELECTION::GetSize(), KIGFX::VIEW::Hide(), m_enteredGroup, m_enteredGroupOverlay, m_selection, TOOL_BASE::m_toolMgr, PCB_GROUP_T, TOOL_MANAGER::ProcessEvent(), PCB_GROUP::RunOnChildren(), select(), EVENTS::SelectedEvent, EDA_ITEM::SetFlags(), KIGFX::PCB_VIEW::Update(), and view().

Referenced by GROUP_TOOL::EnterGroup(), and Main().

◆ ExitGroup()

void PCB_SELECTION_TOOL::ExitGroup ( bool  aSelectGroup = false)

Leave the currently-entered group.

Parameters
aSelectGroup[optional] Select the group after leaving.

Definition at line 527 of file pcb_selection_tool.cpp.

528{
529 // Only continue if there is a group entered
530 if( m_enteredGroup == nullptr )
531 return;
532
534 view()->Hide( m_enteredGroup, false );
536
537 if( aSelectGroup )
538 {
541 }
542
544 m_enteredGroup = nullptr;
546}
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:141
virtual void Clear()
Remove all the stored items from the group.
Definition: view_group.cpp:69

References KIGFX::VIEW_GROUP::Clear(), EDA_ITEM::ClearFlags(), ClearSelection(), ENTERED, KIGFX::VIEW::Hide(), m_enteredGroup, m_enteredGroupOverlay, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), select(), EVENTS::SelectedEvent, KIGFX::PCB_VIEW::Update(), and view().

Referenced by EDIT_TOOL::DeleteItems(), EnterGroup(), Main(), Reset(), select(), and selectPoint().

◆ expandConnection()

int PCB_SELECTION_TOOL::expandConnection ( const TOOL_EVENT aEvent)
private

Expand the current connected-item selection to the next boundary (junctions, pads, or all)

Definition at line 1177 of file pcb_selection_tool.cpp.

1178{
1179 unsigned initialCount = 0;
1180
1181 for( const EDA_ITEM* item : m_selection.GetItems() )
1182 {
1183 if( item->Type() == PCB_FOOTPRINT_T || BOARD_CONNECTED_ITEM::ClassOf( item ) )
1184 initialCount++;
1185 }
1186
1187 if( initialCount == 0 )
1189
1190 m_frame->SetStatusText( _( "Select/Expand Connection..." ) );
1191
1192 for( STOP_CONDITION stopCondition : { STOP_AT_JUNCTION, STOP_AT_PAD, STOP_NEVER } )
1193 {
1194 std::deque<EDA_ITEM*> selectedItems = m_selection.GetItems();
1195
1196 for( EDA_ITEM* item : selectedItems )
1197 item->ClearTempFlags();
1198
1199 std::vector<BOARD_CONNECTED_ITEM*> startItems;
1200
1201 for( EDA_ITEM* item : selectedItems )
1202 {
1203 if( item->Type() == PCB_FOOTPRINT_T )
1204 {
1205 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
1206
1207 for( PAD* pad : footprint->Pads() )
1208 startItems.push_back( pad );
1209 }
1210 else if( BOARD_CONNECTED_ITEM::ClassOf( item ) )
1211 {
1212 startItems.push_back( static_cast<BOARD_CONNECTED_ITEM*>( item ) );
1213 }
1214 }
1215
1216 selectAllConnectedTracks( startItems, stopCondition );
1217
1218 if( m_selection.GetItems().size() > initialCount )
1219 break;
1220 }
1221
1222 m_frame->SetStatusText( wxEmptyString );
1223
1224 // Inform other potentially interested tools
1226
1227 return 0;
1228}
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
static bool ClassOf(const EDA_ITEM *aItem)
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
PADS & Pads()
Definition: footprint.h:170
Definition: pad.h:60
void selectAllConnectedTracks(const std::vector< BOARD_CONNECTED_ITEM * > &aStartItems, STOP_CONDITION aStopCondition)
Select connected tracks and vias.
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:120
void connectedItemFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector, PCB_SELECTION_TOOL *sTool)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86

References _, BOARD_CONNECTED_ITEM::ClassOf(), connectedItemFilter(), SELECTION::GetItems(), m_frame, m_selection, TOOL_BASE::m_toolMgr, pad, FOOTPRINT::Pads(), PCB_FOOTPRINT_T, TOOL_MANAGER::ProcessEvent(), selectAllConnectedTracks(), selectCursor(), EVENTS::SelectedEvent, STOP_AT_JUNCTION, STOP_AT_PAD, and STOP_NEVER.

Referenced by setTransitions().

◆ FilterCollectedItems()

void PCB_SELECTION_TOOL::FilterCollectedItems ( GENERAL_COLLECTOR aCollector,
bool  aMultiSelect 
)

Apply the SELECTION_FITLER_OPTIONS to the collector.

Definition at line 2173 of file pcb_selection_tool.cpp.

2174{
2175 if( aCollector.GetCount() == 0 )
2176 return;
2177
2178 std::set<BOARD_ITEM*> rejected;
2179
2180 for( EDA_ITEM* i : aCollector )
2181 {
2182 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( i );
2183
2184 if( !itemPassesFilter( item, aMultiSelect ) )
2185 rejected.insert( item );
2186 }
2187
2188 for( BOARD_ITEM* item : rejected )
2189 aCollector.Remove( item );
2190}
bool itemPassesFilter(BOARD_ITEM *aItem, bool aMultiSelect)

References COLLECTOR::GetCount(), itemPassesFilter(), and COLLECTOR::Remove().

Referenced by BOARD_INSPECTION_TOOL::highlightNet(), selectMultiple(), and selectPoint().

◆ FilterCollectorForFreePads()

void PCB_SELECTION_TOOL::FilterCollectorForFreePads ( GENERAL_COLLECTOR aCollector) const

Check the "allow free pads" setting and if disabled, replace any pads in the collector with their parent footprints.

Definition at line 3160 of file pcb_selection_tool.cpp.

3161{
3162 std::set<BOARD_ITEM*> to_add;
3163
3164 // Iterate from the back so we don't have to worry about removals.
3165 for( int i = aCollector.GetCount() - 1; i >= 0; --i )
3166 {
3167 BOARD_ITEM* item = aCollector[i];
3168
3169 if( !m_isFootprintEditor && item->Type() == PCB_PAD_T
3170 && !frame()->GetPcbNewSettings()->m_AllowFreePads )
3171 {
3172 if( !aCollector.HasItem( item->GetParent() ) )
3173 to_add.insert( item->GetParent() );
3174
3175 aCollector.Remove( item );
3176 }
3177 }
3178
3179 for( BOARD_ITEM* item : to_add )
3180 aCollector.Append( item );
3181}
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:175
bool HasItem(const EDA_ITEM *aItem) const
Tests if aItem has already been collected.
Definition: collector.h:195
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:109
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87

References COLLECTOR::Append(), frame(), COLLECTOR::GetCount(), BOARD_ITEM::GetParent(), COLLECTOR::HasItem(), m_isFootprintEditor, PCB_PAD_T, COLLECTOR::Remove(), and EDA_ITEM::Type().

Referenced by EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Drag(), EDIT_TOOL::Flip(), EDIT_TOOL::Mirror(), EDIT_TOOL::PackAndMoveFootprints(), EDIT_TOOL::Remove(), EDIT_TOOL::Rotate(), and EDIT_TOOL::Swap().

◆ FilterCollectorForHierarchy()

void PCB_SELECTION_TOOL::FilterCollectorForHierarchy ( GENERAL_COLLECTOR aCollector,
bool  aMultiselect 
) const

In general we don't want to select both a parent and any of it's children.

This includes both footprints and their items, and groups and their members.

Definition at line 3092 of file pcb_selection_tool.cpp.

3094{
3095 std::unordered_set<BOARD_ITEM*> toAdd;
3096
3097 // Set CANDIDATE on all parents which are included in the GENERAL_COLLECTOR. This
3098 // algorithm is O(3n), whereas checking for the parent inclusion could potentially be O(n^2).
3099 for( int j = 0; j < aCollector.GetCount(); j++ )
3100 {
3101 if( aCollector[j]->GetParent() )
3102 aCollector[j]->GetParent()->ClearFlags( CANDIDATE );
3103 }
3104
3105 if( aMultiselect )
3106 {
3107 for( int j = 0; j < aCollector.GetCount(); j++ )
3108 aCollector[j]->SetFlags( CANDIDATE );
3109 }
3110
3111 for( int j = 0; j < aCollector.GetCount(); )
3112 {
3113 BOARD_ITEM* item = aCollector[j];
3114 BOARD_ITEM* parent = item->GetParent();
3115 BOARD_ITEM* start = item;
3116
3117 if( !m_isFootprintEditor && parent && parent->Type() == PCB_FOOTPRINT_T )
3118 start = parent;
3119
3120 // If a group is entered, disallow selections of objects outside the group.
3122 {
3123 aCollector.Remove( item );
3124 continue;
3125 }
3126
3127 // If any element is a member of a group, replace those elements with the top containing
3128 // group.
3130 {
3131 if( top != item )
3132 {
3133 toAdd.insert( top );
3134 top->SetFlags(CANDIDATE );
3135
3136 aCollector.Remove( item );
3137 continue;
3138 }
3139 }
3140
3141 // Footprints are a bit easier as they can't be nested.
3142 if( parent && ( parent->GetFlags() & CANDIDATE ) )
3143 {
3144 // Remove children of selected items
3145 aCollector.Remove( item );
3146 continue;
3147 }
3148
3149 ++j;
3150 }
3151
3152 for( BOARD_ITEM* item : toAdd )
3153 {
3154 if( !aCollector.HasItem( item ) )
3155 aCollector.Append( item );
3156 }
3157}
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:142
static bool WithinScope(BOARD_ITEM *aItem, PCB_GROUP *aScope, bool isFootprintEditor)
Definition: pcb_group.cpp:156
static PCB_GROUP * TopLevelGroup(BOARD_ITEM *aItem, PCB_GROUP *aScope, bool isFootprintEditor)
Definition: pcb_group.cpp:150
#define CANDIDATE
flag indicating that the structure is connected

References COLLECTOR::Append(), CANDIDATE, COLLECTOR::GetCount(), EDA_ITEM::GetFlags(), BOARD_ITEM::GetParent(), COLLECTOR::HasItem(), m_enteredGroup, m_isFootprintEditor, PCB_FOOTPRINT_T, COLLECTOR::Remove(), PCB_GROUP::TopLevelGroup(), EDA_ITEM::Type(), and PCB_GROUP::WithinScope().

Referenced by EDIT_TOOL::CreateArray(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Drag(), EDIT_TOOL::Duplicate(), EDIT_TOOL::Flip(), EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), EDIT_TOOL::PackAndMoveFootprints(), POSITION_RELATIVE_TOOL::PositionRelative(), GLOBAL_EDIT_TOOL::RemoveUnusedPads(), EDIT_TOOL::Rotate(), SelectAll(), selectMultiple(), selectPoint(), and EDIT_TOOL::Swap().

◆ FilterCollectorForMarkers()

void PCB_SELECTION_TOOL::FilterCollectorForMarkers ( GENERAL_COLLECTOR aCollector) const

Drop any PCB_MARKERs from the collector.

Definition at line 3184 of file pcb_selection_tool.cpp.

3185{
3186 // Iterate from the back so we don't have to worry about removals.
3187 for( int i = aCollector.GetCount() - 1; i >= 0; --i )
3188 {
3189 BOARD_ITEM* item = aCollector[i];
3190
3191 if( item->Type() == PCB_MARKER_T )
3192 aCollector.Remove( item );
3193 }
3194}
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:104

References COLLECTOR::GetCount(), PCB_MARKER_T, COLLECTOR::Remove(), and EDA_ITEM::Type().

Referenced by EDIT_TOOL::CreateArray(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Duplicate(), EDIT_TOOL::Flip(), EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), EDIT_TOOL::PackAndMoveFootprints(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Rotate(), and EDIT_TOOL::Swap().

◆ filterSelection()

int PCB_SELECTION_TOOL::filterSelection ( const TOOL_EVENT aEvent)
private

Return true if the given item passes the current SELECTION_FILTER_OPTIONS.

Definition at line 2141 of file pcb_selection_tool.cpp.

2142{
2143 const BOARD& board = *getModel<BOARD>();
2144 DIALOG_FILTER_SELECTION::OPTIONS& opts = m_priv->m_filterOpts;
2145 DIALOG_FILTER_SELECTION dlg( m_frame, opts );
2146
2147 const int cmd = dlg.ShowModal();
2148
2149 if( cmd != wxID_OK )
2150 return 0;
2151
2152 // copy current selection
2153 std::deque<EDA_ITEM*> selection = m_selection.GetItems();
2154
2155 ClearSelection( true /*quiet mode*/ );
2156
2157 // re-select items from the saved selection according to the dialog options
2158 for( EDA_ITEM* i : selection )
2159 {
2160 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( i );
2161 bool include = itemIsIncludedByFilter( *item, board, opts );
2162
2163 if( include )
2164 select( item );
2165 }
2166
2168
2169 return 0;
2170}
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:269
SELECTION & selection() override
Return a reference to the selection.
BOARD * board() const
static bool itemIsIncludedByFilter(const BOARD_ITEM &aItem, const BOARD &aBoard, const DIALOG_FILTER_SELECTION::OPTIONS &aFilterOptions)
Determine if an item is included by the filter specified.
Struct that will be set with the result of the user choices in the dialog.

References board(), ClearSelection(), SELECTION::GetItems(), itemIsIncludedByFilter(), m_frame, m_priv, m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), select(), EVENTS::SelectedEvent, and selection().

Referenced by setTransitions().

◆ FindItem()

void PCB_SELECTION_TOOL::FindItem ( BOARD_ITEM aItem)

Take necessary actions to mark an item as found.

Parameters
aItemThe item that was found and needs to be highlighted/focused/etc.

Definition at line 1990 of file pcb_selection_tool.cpp.

1991{
1992 bool cleared = false;
1993
1994 if( m_selection.GetSize() > 0 )
1995 {
1996 // Don't fire an event now; most of the time it will be redundant as we're about to
1997 // fire a SelectedEvent.
1998 cleared = true;
1999 ClearSelection( true /*quiet mode*/ );
2000 }
2001
2002 if( aItem )
2003 {
2004 switch( aItem->Type() )
2005 {
2006 case PCB_NETINFO_T:
2007 {
2008 int netCode = static_cast<NETINFO_ITEM*>( aItem )->GetNetCode();
2009
2010 if( netCode > 0 )
2011 {
2012 SelectAllItemsOnNet( netCode, true );
2013 m_frame->FocusOnLocation( aItem->GetCenter() );
2014 }
2015 break;
2016 }
2017
2018 default:
2019 select( aItem );
2020 m_frame->FocusOnLocation( aItem->GetPosition() );
2021 }
2022
2023 // If the item has a bounding box, then zoom out if needed
2024 if( aItem->GetBoundingBox().GetHeight() > 0 && aItem->GetBoundingBox().GetWidth() > 0 )
2025 {
2026 // This adds some margin
2027 double marginFactor = 2;
2028
2029 KIGFX::PCB_VIEW* pcbView = canvas()->GetView();
2030 BOX2D screenBox = pcbView->GetViewport();
2031 VECTOR2I screenSize = screenBox.GetSize();
2032 BOX2I screenRect( screenBox.GetOrigin(), screenSize / marginFactor );
2033
2034 if( !screenRect.Contains( aItem->GetBoundingBox() ) )
2035 {
2036 double scaleX = screenSize.x / static_cast<double>( aItem->GetBoundingBox().GetWidth() );
2037 double scaleY = screenSize.y / static_cast<double>( aItem->GetBoundingBox().GetHeight() );
2038
2039 scaleX /= marginFactor;
2040 scaleY /= marginFactor;
2041
2042 double scale = scaleX > scaleY ? scaleY : scaleX;
2043
2044 if( scale < 1 ) // Don't zoom in, only zoom out
2045 {
2046 pcbView->SetScale( pcbView->GetScale() * ( scale ) );
2047
2048 //Let's refocus because there is an algorithm to avoid dialogs in there.
2049 m_frame->FocusOnLocation( aItem->GetCenter() );
2050 }
2051 }
2052 }
2053 // Inform other potentially interested tools
2055 }
2056 else if( cleared )
2057 {
2059 }
2060
2062}
virtual VECTOR2I GetCenter() const
This defaults to the center of the bounding box if not overridden.
Definition: board_item.h:105
const Vec & GetOrigin() const
Definition: box2.h:183
const Vec & GetSize() const
Definition: box2.h:179
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:249
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74
double GetScale() const
Definition: view.h:269
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:511
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:551
Handle the data for a net.
Definition: netinfo.h:67
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
PCB_DRAW_PANEL_GAL * canvas() const
void SelectAllItemsOnNet(int aNetCode, bool aSelect=true)
Select all items with the given net code.
const int scale
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
Definition: typeinfo.h:114

References canvas(), EVENTS::ClearedEvent, ClearSelection(), BOX2< Vec >::Contains(), EDA_DRAW_FRAME::FocusOnLocation(), EDA_DRAW_PANEL_GAL::ForceRefresh(), EDA_ITEM::GetBoundingBox(), PCB_BASE_FRAME::GetCanvas(), BOARD_ITEM::GetCenter(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetOrigin(), EDA_ITEM::GetPosition(), KIGFX::VIEW::GetScale(), BOX2< Vec >::GetSize(), SELECTION::GetSize(), PCB_DRAW_PANEL_GAL::GetView(), KIGFX::VIEW::GetViewport(), BOX2< Vec >::GetWidth(), m_frame, m_selection, TOOL_BASE::m_toolMgr, PCB_NETINFO_T, TOOL_MANAGER::ProcessEvent(), scale, select(), SelectAllItemsOnNet(), EVENTS::SelectedEvent, KIGFX::VIEW::SetScale(), EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PCB_EDIT_FRAME::ShowFindDialog().

◆ frame()

PCB_BASE_EDIT_FRAME * PCB_SELECTION_TOOL::frame ( ) const
inlineprotected

Definition at line 225 of file pcb_selection_tool.h.

226 {
227 return getEditFrame<PCB_BASE_EDIT_FRAME>();
228 }

Referenced by canvas(), FilterCollectorForFreePads(), Init(), Main(), and RequestSelection().

◆ GetActiveLayer()

PCB_LAYER_ID PCB_SELECTION_TOOL::GetActiveLayer ( )
inline

Definition at line 190 of file pcb_selection_tool.h.

190{ return m_frame->GetActiveLayer(); }
virtual PCB_LAYER_ID GetActiveLayer() const

References PCB_BASE_FRAME::GetActiveLayer(), and m_frame.

◆ getCollectorsGuide()

const GENERAL_COLLECTORS_GUIDE PCB_SELECTION_TOOL::getCollectorsGuide ( ) const
private

Definition at line 679 of file pcb_selection_tool.cpp.

680{
681 GENERAL_COLLECTORS_GUIDE guide( board()->GetVisibleLayers(),
682 (PCB_LAYER_ID) view()->GetTopLayer(), view() );
683
684 bool padsDisabled = !board()->IsElementVisible( LAYER_PADS );
685
686 // account for the globals
687 guide.SetIgnoreMTextsMarkedNoShow( ! board()->IsElementVisible( LAYER_MOD_TEXT_INVISIBLE ) );
688 guide.SetIgnoreMTextsOnBack( ! board()->IsElementVisible( LAYER_MOD_TEXT ) );
689 guide.SetIgnoreMTextsOnFront( ! board()->IsElementVisible( LAYER_MOD_TEXT ) );
690 guide.SetIgnoreModulesOnBack( ! board()->IsElementVisible( LAYER_MOD_BK ) );
691 guide.SetIgnoreModulesOnFront( ! board()->IsElementVisible( LAYER_MOD_FR ) );
692 guide.SetIgnorePadsOnBack( padsDisabled || ! board()->IsElementVisible( LAYER_PAD_BK ) );
693 guide.SetIgnorePadsOnFront( padsDisabled || ! board()->IsElementVisible( LAYER_PAD_FR ) );
694 guide.SetIgnoreThroughHolePads( padsDisabled || ! board()->IsElementVisible( LAYER_PADS_TH ) );
695 guide.SetIgnoreModulesVals( ! board()->IsElementVisible( LAYER_MOD_VALUES ) );
696 guide.SetIgnoreModulesRefs( ! board()->IsElementVisible( LAYER_MOD_REFERENCES ) );
697 guide.SetIgnoreThroughVias( ! board()->IsElementVisible( LAYER_VIAS ) );
698 guide.SetIgnoreBlindBuriedVias( ! board()->IsElementVisible( LAYER_VIAS ) );
699 guide.SetIgnoreMicroVias( ! board()->IsElementVisible( LAYER_VIAS ) );
700 guide.SetIgnoreTracks( ! board()->IsElementVisible( LAYER_TRACKS ) );
701
702 return guide;
703}
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:653
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:326
@ LAYER_MOD_TEXT_INVISIBLE
text marked as invisible
Definition: layer_ids.h:200
@ LAYER_PAD_FR
smd pads, front layer
Definition: layer_ids.h:202
@ LAYER_MOD_TEXT
Definition: layer_ids.h:198
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored)
Definition: layer_ids.h:230
@ LAYER_TRACKS
Definition: layer_ids.h:212
@ LAYER_MOD_FR
show footprints on front
Definition: layer_ids.h:208
@ LAYER_PAD_BK
smd pads, back layer
Definition: layer_ids.h:203
@ LAYER_MOD_VALUES
show footprints values (when texts are visible)
Definition: layer_ids.h:210
@ LAYER_PADS_TH
multilayer pads, usually with holes
Definition: layer_ids.h:213
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:193
@ LAYER_MOD_BK
show footprints on back
Definition: layer_ids.h:209
@ LAYER_MOD_REFERENCES
show footprints references (when texts are visible)
Definition: layer_ids.h:211
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59

References board(), BOARD::IsElementVisible(), LAYER_MOD_BK, LAYER_MOD_FR, LAYER_MOD_REFERENCES, LAYER_MOD_TEXT, LAYER_MOD_TEXT_INVISIBLE, LAYER_MOD_VALUES, LAYER_PAD_BK, LAYER_PAD_FR, LAYER_PADS, LAYER_PADS_TH, LAYER_TRACKS, LAYER_VIAS, GENERAL_COLLECTORS_GUIDE::SetIgnoreBlindBuriedVias(), GENERAL_COLLECTORS_GUIDE::SetIgnoreMicroVias(), GENERAL_COLLECTORS_GUIDE::SetIgnoreModulesOnBack(), GENERAL_COLLECTORS_GUIDE::SetIgnoreModulesOnFront(), GENERAL_COLLECTORS_GUIDE::SetIgnoreModulesRefs(), GENERAL_COLLECTORS_GUIDE::SetIgnoreModulesVals(), GENERAL_COLLECTORS_GUIDE::SetIgnoreMTextsMarkedNoShow(), GENERAL_COLLECTORS_GUIDE::SetIgnoreMTextsOnBack(), GENERAL_COLLECTORS_GUIDE::SetIgnoreMTextsOnFront(), GENERAL_COLLECTORS_GUIDE::SetIgnorePadsOnBack(), GENERAL_COLLECTORS_GUIDE::SetIgnorePadsOnFront(), GENERAL_COLLECTORS_GUIDE::SetIgnoreThroughHolePads(), GENERAL_COLLECTORS_GUIDE::SetIgnoreThroughVias(), GENERAL_COLLECTORS_GUIDE::SetIgnoreTracks(), and view().

Referenced by RequestSelection(), and selectPoint().

◆ getEditFrame()

template<typename T >
T * TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Return the application window object, casted to requested user type.

Definition at line 185 of file tool_base.h.

186 {
187#if !defined( QA_TEST ) // Dynamic casts give the linker a seizure in the test framework
188 wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
189#endif
190 return static_cast<T*>( getToolHolderInt() );
191 }
TOOLS_HOLDER * getToolHolderInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone(), and ZONE_CREATE_HELPER::setUniquePriority().

◆ GetEnteredGroup()

PCB_GROUP * PCB_SELECTION_TOOL::GetEnteredGroup ( )
inline
Returns
the currently-entered group.

Definition at line 188 of file pcb_selection_tool.h.

188{ return m_enteredGroup; }

References m_enteredGroup.

Referenced by EDIT_TOOL::DeleteItems(), PCB_CONTROL::placeBoardItems(), and BOARD_COMMIT::Push().

◆ GetFilter()

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Return the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 121 of file tool_base.h.

122 {
123 return m_toolId;
124 }

References TOOL_BASE::m_toolId.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::isActive(), TOOL_MANAGER::RegisterTool(), ACTION_MANAGER::RunHotKey(), TOOL_MANAGER::runTool(), TOOL_MANAGER::saveViewControls(), and TOOL_MANAGER::ShutdownTool().

◆ GetManager()

TOOL_MANAGER * TOOL_BASE::GetManager ( ) const
inlineinherited

◆ getModel()

template<typename T >
T * TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Return the model object if it matches the requested type.

Store the type of the tool.

Definition at line 197 of file tool_base.h.

References TOOL_BASE::getModelInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), and ZONE_CREATE_HELPER::createZoneFromExisting().

◆ getModelInt()

EDA_ITEM * TOOL_BASE::getModelInt ( ) const
privateinherited

Definition at line 54 of file tool_base.cpp.

55{
56 return m_toolMgr->GetModel();
57}
EDA_ITEM * GetModel() const
Definition: tool_manager.h:292

References TOOL_MANAGER::GetModel(), and TOOL_BASE::m_toolMgr.

Referenced by TOOL_BASE::getModel().

◆ GetName()

const std::string & TOOL_BASE::GetName ( void  ) const
inlineinherited

Return the name of the tool.

Tool names are expected to obey the format: application.ToolName (eg. pcbnew.InteractiveSelection).

Returns
The name of the tool.

Definition at line 134 of file tool_base.h.

135 {
136 return m_toolName;
137 }
std::string m_toolName
Definition: tool_base.h:214

References TOOL_BASE::m_toolName.

Referenced by TOOL_MANAGER::dispatchInternal(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), TOOL_MANAGER::RegisterTool(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::ShutdownTool().

◆ GetSelection()

PCB_SELECTION & PCB_SELECTION_TOOL::GetSelection ( )

◆ getToolHolderInt()

TOOLS_HOLDER * TOOL_BASE::getToolHolderInt ( ) const
privateinherited

Definition at line 48 of file tool_base.cpp.

49{
50 return m_toolMgr->GetToolHolder();
51}
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:296

References TOOL_MANAGER::GetToolHolder(), and TOOL_BASE::m_toolMgr.

Referenced by TOOL_BASE::getEditFrame().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 109 of file tool_base.h.

110 {
111 return m_type;
112 }
TOOL_TYPE m_type
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:207

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::ShutdownTool().

◆ getView()

KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Returns the instance of #VIEW object used in the application.

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

37{
38 return m_toolMgr->GetView();
39}
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:285

References TOOL_MANAGER::GetView(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), GERBVIEW_CONTROL::ClearAllLayers(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::CollectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), SCH_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), EDIT_TOOL::DeleteItems(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), EE_SELECTION_TOOL::GuessSelectionCandidates(), GuessSelectionCandidates(), ROUTER_TOOL::handleCommonEvents(), EE_SELECTION_TOOL::highlight(), PL_SELECTION_TOOL::highlight(), highlight(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::highlightNet(), PNS::TOOL_BASE::highlightNets(), hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EE_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EE_SELECTION_TOOL::Reset(), EE_TOOL_BASE< T >::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), PNS::TOOL_BASE::Reset(), BOARD_EDITOR_CONTROL::Reset(), DRAWING_TOOL::Reset(), PCB_CONTROL::Reset(), Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), Selectable(), EE_SELECTION_TOOL::SelectAll(), SelectAll(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectionContains(), selectionContains(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::selectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleERCErrors(), SCH_EDITOR_CONTROL::ToggleERCExclusions(), SCH_EDITOR_CONTROL::ToggleERCWarnings(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SCH_EDITOR_CONTROL::ToggleOPCurrents(), SCH_EDITOR_CONTROL::ToggleOPVoltages(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), EE_SELECTION_TOOL::unhighlight(), PL_SELECTION_TOOL::unhighlight(), unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), SCH_FIND_REPLACE_TOOL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< T >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), updateSelection(), PNS::TOOL_BASE::updateStartItem(), view(), PCB_TOOL_BASE::view(), PCB_VIEWER_TOOLS::view(), EE_SELECTION_TOOL::ZoomFitCrossProbeBBox(), ZoomFitCrossProbeBBox(), zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and ~PCB_SELECTION_TOOL().

◆ getViewControls()

KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited

Return the instance of VIEW_CONTROLS object used in the application.

It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.).

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

43{
44 return m_toolMgr->GetViewControls();
45}
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:287

References TOOL_MANAGER::GetViewControls(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), EE_SELECTION_TOOL::autostartEvent(), SCH_EDIT_TOOL::BreakWire(), controls(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), COMMON_TOOLS::CursorControl(), EDIT_TOOL::DeleteItems(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), EE_POINT_EDITOR::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), DRAWING_TOOL::Reset(), PCB_POINT_EDITOR::Reset(), COMMON_TOOLS::ResetLocalCoords(), ROUTER_TOOL::RouteSelected(), selectCursor(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCB_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateItem(), PL_EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Define which state (aStateFunc) to go when a certain event arrives (aConditions).

No conditions means any event.

Definition at line 147 of file tool_interactive.h.

149{
150 TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
151
152 goInternal( sptr, aConditions );
153}
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58

References TOOL_INTERACTIVE::goInternal().

Referenced by EDA_3D_CONTROLLER::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), EE_POINT_EDITOR::setTransitions(), EE_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), SCH_EDIT_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), SCH_FIND_REPLACE_TOOL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), SIMULATOR_CONTROL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SYMBOL_EDITOR_MOVE_TOOL::setTransitions(), SYMBOL_EDITOR_PIN_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), COMMON_CONTROL::setTransitions(), COMMON_TOOLS::setTransitions(), PICKER_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), PL_EDIT_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), PL_POINT_EDITOR::setTransitions(), PL_SELECTION_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), SCRIPTING_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), BOARD_REANNOTATE_TOOL::setTransitions(), CONVERT_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), DRC_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PAD_TOOL::setTransitions(), PCB_CONTROL::setTransitions(), PCB_PICKER_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), PROPERTIES_TOOL::setTransitions(), and ZONE_FILLER_TOOL::setTransitions().

◆ goInternal()

void TOOL_INTERACTIVE::goInternal ( TOOL_STATE_FUNC aState,
const TOOL_EVENT_LIST aConditions 
)
privateinherited

Definition at line 70 of file tool_interactive.cpp.

71{
72 m_toolMgr->ScheduleNextState( this, aState, aConditions );
73}
void ScheduleNextState(TOOL_BASE *aTool, TOOL_STATE_FUNC &aHandler, const TOOL_EVENT_LIST &aConditions)
Define a state transition.

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::ScheduleNextState().

Referenced by TOOL_INTERACTIVE::Go().

◆ grabUnconnected()

int PCB_SELECTION_TOOL::grabUnconnected ( const TOOL_EVENT aEvent)
private

Select and move other nearest footprint unconnected on same net as selected items.

Definition at line 1495 of file pcb_selection_tool.cpp.

1496{
1497 PCB_SELECTION originalSelection = m_selection;
1498
1499 // Get all pads
1500 std::vector<PAD*> pads;
1501
1502 for( EDA_ITEM* item : m_selection.GetItems() )
1503 {
1504 if( item->Type() == PCB_FOOTPRINT_T )
1505 {
1506 for( PAD* pad : static_cast<FOOTPRINT*>( item )->Pads() )
1507 pads.push_back( pad );
1508 }
1509 else if( item->Type() == PCB_PAD_T )
1510 {
1511 pads.push_back( static_cast<PAD*>( item ) );
1512 }
1513 }
1514
1516
1517 // Select every footprint on the end of the ratsnest for each pad in our selection
1518 std::shared_ptr<CONNECTIVITY_DATA> conn = board()->GetConnectivity();
1519
1520 for( PAD* pad : pads )
1521 {
1522 const std::vector<CN_EDGE> edges = conn->GetRatsnestForPad( pad );
1523
1524 // Need to have something unconnected to grab
1525 if( edges.size() == 0 )
1526 continue;
1527
1528 double currentDistance = DBL_MAX;
1529 FOOTPRINT* nearest = nullptr;
1530
1531 // Check every ratsnest line for the nearest one
1532 for( const CN_EDGE& edge : edges )
1533 {
1534 // Figure out if we are the source or the target node on the ratnest
1535 const CN_ANCHOR* other = edge.GetSourceNode()->Parent() == pad ? edge.GetTargetNode().get()
1536 : edge.GetSourceNode().get();
1537
1538 // We only want to grab footprints, so the ratnest has to point to a pad
1539 if( other->Parent()->Type() != PCB_PAD_T )
1540 continue;
1541
1542 if( edge.GetLength() < currentDistance )
1543 {
1544 currentDistance = edge.GetLength();
1545 nearest = static_cast<PAD*>( other->Parent() )->GetParent();
1546 }
1547 }
1548
1549 if( nearest != nullptr )
1550 select( nearest );
1551 }
1552
1554
1555 return 0;
1556}
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:430
CN_ANCHOR represents a physical location that can be connected: a pad or a track/arc/via endpoint.
BOARD_CONNECTED_ITEM * Parent() const
CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc.
static TOOL_ACTION moveIndividually
move items one-by-one
Definition: pcb_actions.h:113

References board(), ClearSelection(), BOARD::GetConnectivity(), SELECTION::GetItems(), m_selection, TOOL_BASE::m_toolMgr, PCB_ACTIONS::moveIndividually, pad, CN_ANCHOR::Parent(), PCB_FOOTPRINT_T, PCB_PAD_T, TOOL_MANAGER::RunAction(), select(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ GuessSelectionCandidates()

void PCB_SELECTION_TOOL::GuessSelectionCandidates ( GENERAL_COLLECTOR aCollector,
const VECTOR2I aWhere 
) const

Try to guess best selection candidates in case multiple items are clicked, by doing some brain-dead heuristics.

Parameters
aCollector[in, out] The collector that has a list of items to be narrowed.
aWhereThe selection point to consider.

Definition at line 2909 of file pcb_selection_tool.cpp.

2911{
2912 static const LSET silkLayers( 2, B_SilkS, F_SilkS );
2913 static const LSET courtyardLayers( 2, B_CrtYd, F_CrtYd );
2914
2915 std::set<BOARD_ITEM*> preferred;
2916 std::set<BOARD_ITEM*> rejected;
2917 VECTOR2I where( aWhere.x, aWhere.y );
2918 const RENDER_SETTINGS* settings = getView()->GetPainter()->GetSettings();
2919 PCB_LAYER_ID activeLayer = m_frame->GetActiveLayer();
2920
2921 if( silkLayers[activeLayer] )
2922 {
2923 for( int i = 0; i < aCollector.GetCount(); ++i )
2924 {
2925 BOARD_ITEM* item = aCollector[i];
2926 KICAD_T type = item->Type();
2927
2928 if( ( type == PCB_TEXT_T || type == PCB_TEXTBOX_T || type == PCB_SHAPE_T )
2929 && silkLayers[item->GetLayer()] )
2930 {
2931 preferred.insert( item );
2932 }
2933 }
2934 }
2935 else if( courtyardLayers[activeLayer] && settings->GetHighContrast() )
2936 {
2937 for( int i = 0; i < aCollector.GetCount(); ++i )
2938 {
2939 BOARD_ITEM* item = aCollector[i];
2940 KICAD_T type = item->Type();
2941
2942 if( type == PCB_FOOTPRINT_T )
2943 preferred.insert( item );
2944 }
2945 }
2946
2947 if( preferred.size() > 0 )
2948 {
2949 aCollector.Empty();
2950
2951 for( BOARD_ITEM* item : preferred )
2952 aCollector.Append( item );
2953
2954 return;
2955 }
2956
2957 // Prefer exact hits to sloppy ones
2958 constexpr int MAX_SLOP = 5;
2959
2960 int singlePixel = KiROUND( aCollector.GetGuide()->OnePixelInIU() );
2961 int maxSlop = KiROUND( MAX_SLOP * aCollector.GetGuide()->OnePixelInIU() );
2962 int minSlop = INT_MAX;
2963
2964 std::map<BOARD_ITEM*, int> itemsBySloppiness;
2965
2966 for( int i = 0; i < aCollector.GetCount(); ++i )
2967 {
2968 BOARD_ITEM* item = aCollector[i];
2969 int itemSlop = hitTestDistance( where, item, maxSlop );
2970
2971 itemsBySloppiness[ item ] = itemSlop;
2972
2973 if( itemSlop < minSlop )
2974 minSlop = itemSlop;
2975 }
2976
2977 // Prune sloppier items
2978 if( minSlop < INT_MAX )
2979 {
2980 for( std::pair<BOARD_ITEM*, int> pair : itemsBySloppiness )
2981 {
2982 if( pair.second > minSlop + singlePixel )
2983 aCollector.Transfer( pair.first );
2984 }
2985 }
2986
2987 // If the user clicked on a small item within a much larger one then it's pretty clear
2988 // they're trying to select the smaller one.
2989 constexpr double sizeRatio = 1.5;
2990
2991 std::vector<std::pair<BOARD_ITEM*, double>> itemsByArea;
2992
2993 for( int i = 0; i < aCollector.GetCount(); ++i )
2994 {
2995 BOARD_ITEM* item = aCollector[i];
2996 double area = 0.0;
2997
2998 if( ( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
2999 && static_cast<ZONE*>( item )->HitTestForEdge( where, maxSlop / 2 ) )
3000 {
3001 // Zone borders are very specific, so make them "small"
3002 area = (double) SEG::Square( singlePixel ) * MAX_SLOP;
3003 }
3004 else if( item->Type() == PCB_VIA_T )
3005 {
3006 // Vias rarely hide other things, and we don't want them deferring to short track
3007 // segments underneath them -- so artificially reduce their size from πr² to 1.5r².
3008 area = (double) SEG::Square( static_cast<PCB_VIA*>( item )->GetDrill() / 2 ) * 1.5;
3009 }
3010 else if( item->Type() == PCB_BITMAP_T )
3011 {
3012 VECTOR2D size = static_cast<const PCB_BITMAP*>( item )->GetSize();
3013 area = size.x * size.y;
3014 }
3015 else
3016 {
3017 try
3018 {
3019 area = FOOTPRINT::GetCoverageArea( item, aCollector );
3020 }
3021 catch( const ClipperLib::clipperException& e )
3022 {
3023 wxLogError( wxT( "A clipper exception %s was detected." ), e.what() );
3024 }
3025 }
3026
3027 itemsByArea.emplace_back( item, area );
3028 }
3029
3030 std::sort( itemsByArea.begin(), itemsByArea.end(),
3031 []( const std::pair<BOARD_ITEM*, double>& lhs,
3032 const std::pair<BOARD_ITEM*, double>& rhs ) -> bool
3033 {
3034 return lhs.second < rhs.second;
3035 } );
3036
3037 bool rejecting = false;
3038
3039 for( int i = 1; i < (int) itemsByArea.size(); ++i )
3040 {
3041 if( itemsByArea[i].second > itemsByArea[i-1].second * sizeRatio )
3042 rejecting = true;
3043
3044 if( rejecting )
3045 rejected.insert( itemsByArea[i].first );
3046 }
3047
3048 // Special case: if a footprint is completely covered with other features then there's no
3049 // way to select it -- so we need to leave it in the list for user disambiguation.
3050 constexpr double maxCoverRatio = 0.70;
3051
3052 for( int i = 0; i < aCollector.GetCount(); ++i )
3053 {
3054 if( FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( aCollector[i] ) )
3055 {
3056 if( footprint->CoverageRatio( aCollector ) > maxCoverRatio )
3057 rejected.erase( footprint );
3058 }
3059 }
3060
3061 // Hopefully we've now got what the user wanted.
3062 if( (unsigned) aCollector.GetCount() > rejected.size() ) // do not remove everything
3063 {
3064 for( BOARD_ITEM* item : rejected )
3065 aCollector.Transfer( item );
3066 }
3067
3068 // Finally, what we are left with is a set of items of similar coverage area. We now reject
3069 // any that are not on the active layer, to reduce the number of disambiguation menus shown.
3070 // If the user wants to force-disambiguate, they can either switch layers or use the modifier
3071 // key to force the menu.
3072 if( aCollector.GetCount() > 1 )
3073 {
3074 bool haveItemOnActive = false;
3075 rejected.clear();
3076
3077 for( int i = 0; i < aCollector.GetCount(); ++i )
3078 {
3079 if( !aCollector[i]->IsOnLayer( activeLayer ) )
3080 rejected.insert( aCollector[i] );
3081 else
3082 haveItemOnActive = true;
3083 }
3084
3085 if( haveItemOnActive )
3086 for( BOARD_ITEM* item : rejected )
3087 aCollector.Transfer( item );
3088 }
3089}
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:192
virtual double OnePixelInIU() const =0
void Transfer(int aIndex)
Move the item at aIndex (first position is 0) to the backup list.
Definition: collector.h:151
static double GetCoverageArea(const BOARD_ITEM *aItem, const GENERAL_COLLECTOR &aCollector)
Return the initial comments block or NULL if none, without transfer of ownership.
Definition: footprint.cpp:2046
const COLLECTORS_GUIDE * GetGuide() const
Definition: collectors.h:295
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
bool GetHighContrast() const
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:532
Object to handle a bitmap image that can be inserted in a PCB.
Definition: pcb_bitmap.h:42
int hitTestDistance(const VECTOR2I &aWhere, BOARD_ITEM *aItem, int aMaxDistance) const
int GetDrill() const
Function GetDrill returns the local drill setting for this PCB_VIA.
Definition: pcb_track.h:523
static SEG::ecoord Square(int a)
Definition: seg.h:123
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
bool HitTestForEdge(const VECTOR2I &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX *aCornerHit=nullptr) const
Test if the given VECTOR2I is near a segment defined by 2 corners.
Definition: zone.cpp:428
@ F_CrtYd
Definition: layer_ids.h:117
@ F_SilkS
Definition: layer_ids.h:104
@ B_CrtYd
Definition: layer_ids.h:116
@ B_SilkS
Definition: layer_ids.h:103
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
Definition: typeinfo.h:100
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
Definition: typeinfo.h:89
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

References COLLECTOR::Append(), B_CrtYd, B_SilkS, COLLECTOR::Empty(), F_CrtYd, F_SilkS, PCB_BASE_FRAME::GetActiveLayer(), COLLECTOR::GetCount(), FOOTPRINT::GetCoverageArea(), PCB_VIA::GetDrill(), GENERAL_COLLECTOR::GetGuide(), KIGFX::RENDER_SETTINGS::GetHighContrast(), BOARD_ITEM::GetLayer(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), TOOL_BASE::getView(), hitTestDistance(), ZONE::HitTestForEdge(), KiROUND(), m_frame, COLLECTORS_GUIDE::OnePixelInIU(), PCB_BITMAP_T, PCB_FOOTPRINT_T, PCB_FP_ZONE_T, PCB_SHAPE_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_VIA_T, PCB_ZONE_T, SEG::Square(), COLLECTOR::Transfer(), EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PCB_CONTROL::DeleteItemCursor(), EDIT_TOOL::Drag(), and selectPoint().

◆ hasModifier()

bool SELECTION_TOOL::hasModifier ( )
protectedinherited

◆ highlight()

void PCB_SELECTION_TOOL::highlight ( EDA_ITEM aItem,
int  aHighlightMode,
SELECTION aGroup = nullptr 
)
overrideprivatevirtual

Highlight the item visually.

Parameters
aItemThe item to be highlighted.
aHighlightModeEither SELECTED or BRIGHTENED
aGroup[optional A group to add the item to.

Implements SELECTION_TOOL.

Definition at line 2658 of file pcb_selection_tool.cpp.

2659{
2660 if( aGroup )
2661 aGroup->Add( aItem );
2662
2663 highlightInternal( aItem, aMode, aGroup != nullptr );
2664 view()->Update( aItem, KIGFX::REPAINT );
2665
2666 // Many selections are very temporal and updating the display each time just
2667 // creates noise.
2668 if( aMode == BRIGHTENED )
2670}
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:617
void highlightInternal(EDA_ITEM *aItem, int aHighlightMode, bool aUsingOverlay)
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:42
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:52
@ TARGET_OVERLAY
Items that may change while the view stays the same (noncached)
Definition: definitions.h:50

References SELECTION::Add(), BRIGHTENED, TOOL_BASE::getView(), highlightInternal(), KIGFX::VIEW::MarkTargetDirty(), KIGFX::REPAINT, KIGFX::TARGET_OVERLAY, KIGFX::PCB_VIEW::Update(), and view().

Referenced by RebuildSelection(), RequestSelection(), and select().

◆ highlightInternal()

void PCB_SELECTION_TOOL::highlightInternal ( EDA_ITEM aItem,
int  aHighlightMode,
bool  aUsingOverlay 
)
private

Definition at line 2673 of file pcb_selection_tool.cpp.

2674{
2675 if( aMode == SELECTED )
2676 aItem->SetSelected();
2677 else if( aMode == BRIGHTENED )
2678 aItem->SetBrightened();
2679
2680 if( aUsingOverlay && aMode != BRIGHTENED )
2681 view()->Hide( aItem, true ); // Hide the original item, so it is shown only on overlay
2682
2683 if( aItem->Type() == PCB_FOOTPRINT_T )
2684 {
2685 static_cast<FOOTPRINT*>( aItem )->RunOnChildren(
2686 [&]( BOARD_ITEM* aChild )
2687 {
2688 highlightInternal( aChild, aMode, aUsingOverlay );
2689 } );
2690 }
2691 else if( aItem->Type() == PCB_GROUP_T )
2692 {
2693 static_cast<PCB_GROUP*>( aItem )->RunOnChildren(
2694 [&]( BOARD_ITEM* aChild )
2695 {
2696 highlightInternal( aChild, aMode, aUsingOverlay );
2697 } );
2698 }
2699}
void SetSelected()
Definition: eda_item.h:115
void SetBrightened()
Definition: eda_item.h:116

References BRIGHTENED, KIGFX::VIEW::Hide(), highlightInternal(), PCB_FOOTPRINT_T, PCB_GROUP_T, SELECTED, EDA_ITEM::SetBrightened(), EDA_ITEM::SetSelected(), EDA_ITEM::Type(), and view().

Referenced by highlight(), and highlightInternal().

◆ hitTestDistance()

int PCB_SELECTION_TOOL::hitTestDistance ( const VECTOR2I aWhere,
BOARD_ITEM aItem,
int  aMaxDistance 
) const
private
Returns
the distance from wWhere to aItem, up to and including aMaxDistance.

Definition at line 2790 of file pcb_selection_tool.cpp.

2792{
2793 BOX2D viewportD = getView()->GetViewport();
2794 BOX2I viewport( VECTOR2I( viewportD.GetPosition() ), VECTOR2I( viewportD.GetSize() ) );
2795 int distance = INT_MAX;
2796 SEG loc( aWhere, aWhere );
2797
2798 switch( aItem->Type() )
2799 {
2800 case PCB_TEXT_T:
2801 {
2802 PCB_TEXT* text = static_cast<PCB_TEXT*>( aItem );
2803 text->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &distance );
2804 break;
2805 }
2806
2807 case PCB_TEXTBOX_T:
2808 {
2809 PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( aItem );
2810 textbox->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &distance );
2811 break;
2812 }
2813
2814 case PCB_FP_TEXT_T:
2815 {
2816 FP_TEXT* text = static_cast<FP_TEXT*>( aItem );
2817 text->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &distance );
2818 break;
2819 }
2820
2821 case PCB_FP_TEXTBOX_T:
2822 {
2823 FP_TEXTBOX* textbox = static_cast<FP_TEXTBOX*>( aItem );
2824 textbox->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &distance );
2825 break;
2826 }
2827
2828 case PCB_ZONE_T:
2829 {
2830 ZONE* zone = static_cast<ZONE*>( aItem );
2831
2832 // Zone borders are very specific
2833 if( zone->HitTestForEdge( aWhere, aMaxDistance / 2 ) )
2834 distance = 0;
2835 else if( zone->HitTestForEdge( aWhere, aMaxDistance ) )
2836 distance = aMaxDistance / 2;
2837 else
2838 aItem->GetEffectiveShape()->Collide( loc, aMaxDistance, &distance );
2839
2840 break;
2841 }
2842
2843 case PCB_FOOTPRINT_T:
2844 {
2845 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aItem );
2846 BOX2I bbox = footprint->GetBoundingBox( false, false );
2847
2848 try
2849 {
2850 footprint->GetBoundingHull().Collide( loc, aMaxDistance, &distance );
2851 }
2852 catch( const ClipperLib::clipperException& exc )
2853 {
2854 // This may be overkill and could be an assertion but we are more likely to find
2855 // any clipper errors this way.
2856 wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
2857 }
2858
2859 // Consider footprints larger than the viewport only as a last resort
2860 if( bbox.GetHeight() > viewport.GetHeight() || bbox.GetWidth() > viewport.GetWidth() )
2861 distance = INT_MAX / 2;
2862
2863 break;
2864 }
2865
2866 case PCB_MARKER_T:
2867 {
2868 PCB_MARKER* marker = static_cast<PCB_MARKER*>( aItem );
2869 SHAPE_LINE_CHAIN polygon;
2870
2871 marker->ShapeToPolygon( polygon );
2872 polygon.Move( marker->GetPos() );
2873 polygon.Collide( loc, aMaxDistance, &distance );
2874 break;
2875 }
2876
2877 case PCB_GROUP_T:
2878 {
2879 PCB_GROUP* group = static_cast<PCB_GROUP*>( aItem );
2880
2881 for( BOARD_ITEM* member : group->GetItems() )
2882 distance = std::min( distance, hitTestDistance( aWhere, member, aMaxDistance ) );
2883
2884 break;
2885 }
2886
2887 default:
2888 aItem->GetEffectiveShape()->Collide( loc, aMaxDistance, &distance );
2889 break;
2890 }
2891
2892 return distance;
2893}
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: board_item.cpp:219
const Vec & GetPosition() const
Definition: box2.h:184
std::shared_ptr< SHAPE_COMPOUND > GetEffectiveTextShape(bool aTriangulate=true, bool aUseTextRotation=true) const
build a list of segments (SHAPE_SEGMENT) to describe a text shape.
Definition: eda_text.cpp:855
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
Definition: footprint.cpp:944
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:806
const VECTOR2I & GetPos() const
Definition: marker_base.h:87
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
Definition: seg.h:42
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void Move(const VECTOR2I &aVector) override
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if point aP lies closer to us than aClearance.
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590

References SHAPE_POLY_SET::Collide(), SHAPE_LINE_CHAIN::Collide(), distance(), FOOTPRINT::GetBoundingBox(), FOOTPRINT::GetBoundingHull(), BOARD_ITEM::GetEffectiveShape(), EDA_TEXT::GetEffectiveTextShape(), BOX2< Vec >::GetHeight(), MARKER_BASE::GetPos(), BOX2< Vec >::GetPosition(), BOX2< Vec >::GetSize(), TOOL_BASE::getView(), KIGFX::VIEW::GetViewport(), BOX2< Vec >::GetWidth(), group, hitTestDistance(), ZONE::HitTestForEdge(), SHAPE_LINE_CHAIN::Move(), PCB_FOOTPRINT_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_GROUP_T, PCB_MARKER_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_ZONE_T, MARKER_BASE::ShapeToPolygon(), text, and EDA_ITEM::Type().

Referenced by GuessSelectionCandidates(), and hitTestDistance().

◆ Init()

bool PCB_SELECTION_TOOL::Init ( )
overridevirtual

Init() is called once upon a registration of the tool.

Returns
True if the initialization went fine, false - otherwise.

Reimplemented from TOOL_BASE.

Definition at line 146 of file pcb_selection_tool.cpp.

147{
148 PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
149
152 {
154 return true;
155 }
156
157 std::shared_ptr<SELECT_MENU> selectMenu = std::make_shared<SELECT_MENU>();
158 selectMenu->SetTool( this );
159 m_menu.RegisterSubMenu( selectMenu );
160
161 auto& menu = m_menu.GetMenu();
162
163 auto activeToolCondition =
164 [ frame ] ( const SELECTION& aSel )
165 {
166 return !frame->ToolStackIsEmpty();
167 };
168
169 auto haveHighlight =
170 [&]( const SELECTION& sel )
171 {
173
174 return !cfg->GetHighlightNetCodes().empty();
175 };
176
177 auto groupEnterCondition =
179
180 auto inGroupCondition =
181 [this] ( const SELECTION& )
182 {
183 return m_enteredGroup != nullptr;
184 };
185
187 {
188 menu.AddMenu( selectMenu.get(), SELECTION_CONDITIONS::NotEmpty );
189 menu.AddSeparator( 1000 );
190 }
191
192 // "Cancel" goes at the top of the context menu when a tool is active
193 menu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
194 menu.AddItem( PCB_ACTIONS::groupEnter, groupEnterCondition, 1 );
195 menu.AddItem( PCB_ACTIONS::groupLeave, inGroupCondition, 1 );
196 menu.AddItem( PCB_ACTIONS::clearHighlight, haveHighlight, 1 );
197
198 menu.AddSeparator( 1 );
199
200 if( frame )
202
203 m_disambiguateTimer.SetOwner( this );
204 Connect( wxEVT_TIMER, wxTimerEventHandler( PCB_SELECTION_TOOL::onDisambiguationExpire ), nullptr, this );
205
206 return true;
207}
static TOOL_ACTION cancelInteractive
Definition: actions.h:63
bool IsType(FRAME_T aType) const
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
static TOOL_ACTION groupLeave
Definition: pcb_actions.h:478
static TOOL_ACTION clearHighlight
Definition: pcb_actions.h:496
static TOOL_ACTION groupEnter
Definition: pcb_actions.h:477
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:80
static SELECTION_CONDITION HasType(KICAD_T aType)
Create a functor that tests if among the selected items there is at least one of a given type.
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static SELECTION_CONDITION Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
wxTimer m_disambiguateTimer
bool ToolStackIsEmpty()
Definition: tools_holder.h:128
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
void RegisterSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition: tool_menu.cpp:50
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ FRAME_FOOTPRINT_VIEWER_MODAL
Definition: frame_type.h:43
@ FRAME_FOOTPRINT_VIEWER
Definition: frame_type.h:42

References PCB_GROUP::AddItem(), EDA_DRAW_FRAME::AddStandardSubMenus(), ACTIONS::cancelInteractive, PCB_ACTIONS::clearHighlight, SELECTION_CONDITIONS::Count(), frame(), FRAME_FOOTPRINT_VIEWER, FRAME_FOOTPRINT_VIEWER_MODAL, FRAME_PCB_EDITOR, KIGFX::RENDER_SETTINGS::GetHighlightNetCodes(), TOOL_MENU::GetMenu(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), TOOL_MANAGER::GetView(), PCB_ACTIONS::groupEnter, PCB_ACTIONS::groupLeave, SELECTION_CONDITIONS::HasType(), EDA_BASE_FRAME::IsType(), SELECTION_TOOL::m_disambiguateTimer, m_enteredGroup, TOOL_INTERACTIVE::m_menu, TOOL_BASE::m_toolMgr, SELECTION_CONDITIONS::NotEmpty(), SELECTION_TOOL::onDisambiguationExpire(), PCB_GROUP_T, TOOL_MENU::RegisterSubMenu(), and TOOLS_HOLDER::ToolStackIsEmpty().

◆ IsFootprintEditor()

bool PCB_SELECTION_TOOL::IsFootprintEditor ( )
inline

Definition at line 78 of file pcb_selection_tool.h.

79 {
81 }

References m_isFootprintEditor.

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32{
34}
bool IsToolActive(TOOL_ID aId) const
Return true if a tool with given id is active (executing)

References TOOL_MANAGER::IsToolActive(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by EDIT_TOOL::Drag(), ROUTER_TOOL::handleLayerSwitch(), Main(), BOARD_EDITOR_CONTROL::TrackWidthDec(), and BOARD_EDITOR_CONTROL::TrackWidthInc().

◆ itemPassesFilter()

bool PCB_SELECTION_TOOL::itemPassesFilter ( BOARD_ITEM aItem,
bool  aMultiSelect 
)
private

Definition at line 2193 of file pcb_selection_tool.cpp.

2194{
2195 if( !m_filter.lockedItems )
2196 {
2197 if( aItem->IsLocked() || ( aItem->GetParent() && aItem->GetParent()->IsLocked() ) )
2198 {
2199 if( aItem->Type() == PCB_PAD_T && !aMultiSelect )
2200 {
2201 // allow a single pad to be selected -- there are a lot of operations that
2202 // require this so we allow this one inconsistency
2203 }
2204 else
2205 {
2206 return false;
2207 }
2208 }
2209 }
2210
2211 switch( aItem->Type() )
2212 {
2213 case PCB_FOOTPRINT_T:
2214 if( !m_filter.footprints )
2215 return false;
2216
2217 break;
2218
2219 case PCB_PAD_T:
2220 if( !m_filter.pads )
2221 return false;
2222
2223 break;
2224
2225 case PCB_TRACE_T:
2226 case PCB_ARC_T:
2227 if( !m_filter.tracks )
2228 return false;
2229
2230 break;
2231
2232 case PCB_VIA_T:
2233 if( !m_filter.vias )
2234 return false;
2235
2236 break;
2237
2238 case PCB_FP_ZONE_T:
2239 case PCB_ZONE_T:
2240 {
2241 ZONE* zone = static_cast<ZONE*>( aItem );
2242
2243 if( ( !m_filter.zones && !zone->GetIsRuleArea() )
2244 || ( !m_filter.keepouts && zone->GetIsRuleArea() ) )
2245 {
2246 return false;
2247 }
2248
2249 break;
2250 }
2251
2252 case PCB_FP_SHAPE_T:
2253 case PCB_SHAPE_T:
2254 case PCB_TARGET_T:
2255 if( !m_filter.graphics )
2256 return false;
2257
2258 break;
2259
2260 case PCB_BITMAP_T:
2261 // a bitmap living in a footprint must not be selected inside the board editor
2262 if( !m_filter.graphics )
2263 return false;
2264
2265 if( !m_isFootprintEditor )
2266 {
2267 if( dynamic_cast<FOOTPRINT*>( aItem->GetParent() ) )
2268 return false;
2269 }
2270
2271
2272 break;
2273
2274 case PCB_FP_TEXT_T:
2275 case PCB_FP_TEXTBOX_T:
2276 case PCB_TEXT_T:
2277 case PCB_TEXTBOX_T:
2278 if( !m_filter.text )
2279 return false;
2280
2281 break;
2282
2283 case PCB_DIM_ALIGNED_T:
2284 case PCB_DIM_CENTER_T:
2285 case PCB_DIM_RADIAL_T:
2287 case PCB_DIM_LEADER_T:
2293 if( !m_filter.dimensions )
2294 return false;
2295
2296 break;
2297
2298 default:
2299 if( !m_filter.otherItems )
2300 return false;
2301 }
2302
2303 return true;
2304}
virtual bool IsLocked() const
Definition: board_item.cpp:71
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:703
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:95
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:110
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:107
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:108
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:97
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:111
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:99
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:96
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:106
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:98
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:109

References SELECTION_FILTER_OPTIONS::dimensions, SELECTION_FILTER_OPTIONS::footprints, ZONE::GetIsRuleArea(), BOARD_ITEM::GetParent(), SELECTION_FILTER_OPTIONS::graphics, BOARD_ITEM::IsLocked(), SELECTION_FILTER_OPTIONS::keepouts, SELECTION_FILTER_OPTIONS::lockedItems, m_filter, m_isFootprintEditor, SELECTION_FILTER_OPTIONS::otherItems, SELECTION_FILTER_OPTIONS::pads, PCB_ARC_T, PCB_BITMAP_T, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_DIM_RADIAL_T, PCB_FOOTPRINT_T, PCB_FP_DIM_ALIGNED_T, PCB_FP_DIM_CENTER_T, PCB_FP_DIM_LEADER_T, PCB_FP_DIM_ORTHOGONAL_T, PCB_FP_DIM_RADIAL_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_FP_ZONE_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, SELECTION_FILTER_OPTIONS::text, SELECTION_FILTER_OPTIONS::tracks, EDA_ITEM::Type(), SELECTION_FILTER_OPTIONS::vias, and SELECTION_FILTER_OPTIONS::zones.

Referenced by FilterCollectedItems(), SelectAll(), and SelectAllItemsOnNet().

◆ Main()

int PCB_SELECTION_TOOL::Main ( const TOOL_EVENT aEvent)

The main loop.

Definition at line 264 of file pcb_selection_tool.cpp.

265{
266 // Main loop: keep receiving events
267 while( TOOL_EVENT* evt = Wait() )
268 {
271
272 // on left click, a selection is made, depending on modifiers ALT, SHIFT, CTRL:
273 setModifiersState( evt->Modifier( MD_SHIFT ), evt->Modifier( MD_CTRL ),
274 evt->Modifier( MD_ALT ) );
275
276 PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
277 bool brd_editor = frame && frame->IsType( FRAME_PCB_EDITOR );
279
280 // If the router tool is active, don't override
281 if( router && router->IsToolActive() && router->RoutingInProgress() )
282 {
283 evt->SetPassEvent();
284 }
285 else if( evt->IsMouseDown( BUT_LEFT ) )
286 {
287 // Avoid triggering when running under other tools
289
290 if( m_frame->ToolStackIsEmpty() && pt_tool && !pt_tool->HasPoint() )
291 {
293 m_disambiguateTimer.StartOnce( 500 );
294 }
295 }
296 else if( evt->IsClick( BUT_LEFT ) )
297 {
298 // If there is no disambiguation, this routine is still running and will
299 // register a `click` event when released
300 if( m_disambiguateTimer.IsRunning() )
301 {
302 m_disambiguateTimer.Stop();
303
304 // Single click? Select single object
305 if( m_highlight_modifier && brd_editor )
306 {
308 }
309 else
310 {
311 m_frame->FocusOnItem( nullptr );
312 selectPoint( evt->Position() );
313 }
314 }
315
316 m_canceledMenu = false;
317 }
318 else if( evt->IsClick( BUT_RIGHT ) )
319 {
320 m_disambiguateTimer.Stop();
321
322 // Right click? if there is any object - show the context menu
323 bool selectionCancelled = false;
324
325 if( m_selection.Empty() )
326 {
327 selectPoint( evt->Position(), false, &selectionCancelled );
328 m_selection.SetIsHover( true );
329 }
330
331 if( !selectionCancelled )
333 }
334 else if( evt->IsDblClick( BUT_LEFT ) )
335 {
336 m_disambiguateTimer.Stop();
337
338 // Double click? Display the properties window
339 m_frame->FocusOnItem( nullptr );
340
341 if( m_selection.Empty() )
342 selectPoint( evt->Position() );
343
344 if( m_selection.GetSize() == 1 && m_selection[0]->Type() == PCB_GROUP_T )
345 EnterGroup();
346 else
348 }
349 else if( evt->IsDblClick( BUT_MIDDLE ) )
350 {
351 // Middle double click? Do zoom to fit or zoom to objects
352 if( evt->Modifier( MD_CTRL ) ) // Is CTRL key down?
354 else
356 }
357 else if( evt->IsDrag( BUT_LEFT ) )
358 {
359 m_disambiguateTimer.Stop();
360
361 // Is another tool already moving a new object? Don't allow a drag start
362 if( !m_selection.Empty() && m_selection[0]->HasFlag( IS_NEW | IS_MOVING ) )
363 {
364 evt->SetPassEvent();
365 continue;
366 }
367
368 // Drag with LMB? Select multiple objects (or at least draw a selection box)
369 // or drag them
370 m_frame->FocusOnItem( nullptr );
372
373 if( hasModifier() || dragAction == MOUSE_DRAG_ACTION::SELECT )
374 {
376 }
377 else if( m_selection.Empty() && dragAction != MOUSE_DRAG_ACTION::DRAG_ANY )
378 {
380 }
381 else
382 {
383 // Don't allow starting a drag from a zone filled area that isn't already selected
384 auto zoneFilledAreaFilter =
385 []( const VECTOR2I& aWhere, GENERAL_COLLECTOR& aCollector,
386 PCB_SELECTION_TOOL* aTool )
387 {
388 int accuracy = KiROUND( 5 * aCollector.GetGuide()->OnePixelInIU() );
389 std::set<EDA_ITEM*> remove;
390
391 for( EDA_ITEM* item : aCollector )
392 {
393 if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
394 {
395 ZONE* zone = static_cast<ZONE*>( item );
396
397 if( !zone->HitTestForCorner( aWhere, accuracy * 2 )
398 && !zone->HitTestForEdge( aWhere, accuracy ) )
399 {
400 remove.insert( zone );
401 }
402 }
403 }
404
405 for( EDA_ITEM* item : remove )
406 aCollector.Remove( item );
407 };
408
409 // See if we can drag before falling back to selectMultiple()
410 bool doDrag = false;
411
412 if( evt->HasPosition() )
413 {
414 if( m_selection.Empty()
415 && selectPoint( evt->DragOrigin(), false, nullptr, zoneFilledAreaFilter ) )
416 {
417 m_selection.SetIsHover( true );
418 doDrag = true;
419 }
420 // Check if dragging has started within any of selected items bounding box.
421 else if( selectionContains( evt->DragOrigin() ) )
422 {
423 doDrag = true;
424 }
425 }
426
427 if( doDrag )
428 {
429 bool haveTrack = m_selection.GetSize() == 1
430 && dynamic_cast<PCB_TRACK*>( m_selection.GetItem( 0 ) );
431
432 if( haveTrack && trackDragAction == TRACK_DRAG_ACTION::DRAG )
434 else if( haveTrack && trackDragAction == TRACK_DRAG_ACTION::DRAG_FREE_ANGLE )
436 else
438 }
439 else
440 {
441 // Otherwise drag a selection box
443 }
444 }
445 }
446 else if( evt->IsCancel() )
447 {
448 m_disambiguateTimer.Stop();
449 m_frame->FocusOnItem( nullptr );
450
451 if( !GetSelection().Empty() )
452 {
454 }
455 else if( evt->FirstResponder() == this && evt->GetCommandId() == (int) WXK_ESCAPE )
456 {
457 if( m_enteredGroup )
458 {
459 ExitGroup();
460 }
461 else
462 {
464
466 controller->ClearHighlight( *evt );
467 }
468 }
469 }
470 else
471 {
472 evt->SetPassEvent();
473 }
474
475
477 {
478 // move cursor prediction
479 if( !hasModifier()
480 && dragAction == MOUSE_DRAG_ACTION::DRAG_SELECTED
481 && !m_selection.Empty()
482 && evt->HasPosition()
483 && selectionContains( evt->Position() ) )
484 {
486 }
487 else
488 {
490 }
491 }
492 }
493
494 // Shutting down; clear the selection
496 m_disambiguateTimer.Stop();
497
498 return 0;
499}
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION zoomFitObjects
Definition: actions.h:100
Tool for pcb inspection.
int ClearHighlight(const TOOL_EVENT &aEvent)
Perform the appropriate action in response to an Eeschema cross-probe.
static const TOOL_EVENT InhibitSelectionEditing
Definition: actions.h:220
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:204
TRACK_DRAG_ACTION m_TrackDragAction
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:166
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:497
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:149
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:167
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:110
void FocusOnItem(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Tool that displays edit points allowing to modify items by dragging the points.
bool HasPoint()
Indicate the cursor is over an edit point.
The selection tool: currently supports:
bool selectionContains(const VECTOR2I &aPoint) const
void EnterGroup()
Enter the group at the head of the current selection.
PCB_SELECTION & GetSelection()
bool selectMultiple()
Handle drawing a selection box that allows one to select many items at the same time.
bool RoutingInProgress()
Returns whether routing is currently active.
bool hasModifier()
True if a selection modifier is enabled, false otherwise.
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.cpp:75
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:92
MOUSE_DRAG_ACTION GetDragAction() const
Indicates whether a drag should draw a selection rectangle or drag selected (or unselected) objects.
Definition: tools_holder.h:147
bool IsToolActive() const
Definition: tool_base.cpp:31
VECTOR2D GetMousePosition() const
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:57
bool HitTestForCorner(const VECTOR2I &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX *aCornerHit=nullptr) const
Test if the given VECTOR2I is near a corner.
Definition: zone.cpp:421
MOUSE_DRAG_ACTION
#define IS_NEW
New item, just created.
#define IS_MOVING
Item being moved.
TRACK_DRAG_ACTION
@ MD_ALT
Definition: tool_event.h:140
@ MD_CTRL
Definition: tool_event.h:139
@ MD_SHIFT
Definition: tool_event.h:138
@ BUT_MIDDLE
Definition: tool_event.h:129
@ BUT_LEFT
Definition: tool_event.h:127
@ BUT_RIGHT
Definition: tool_event.h:128

References ARROW, BUT_LEFT, BUT_MIDDLE, BUT_RIGHT, SELECTION::Clear(), BOARD_INSPECTION_TOOL::ClearHighlight(), ClearSelection(), DRAG, PCB_ACTIONS::drag45Degree, DRAG_ANY, DRAG_FREE_ANGLE, DRAG_SELECTED, PCB_ACTIONS::dragFreeAngle, SELECTION::Empty(), EnterGroup(), ExitGroup(), PCB_BASE_FRAME::FocusOnItem(), frame(), FRAME_PCB_EDITOR, TOOLS_HOLDER::GetDragAction(), SELECTION::GetItem(), TOOL_MANAGER::GetMousePosition(), PCB_BASE_FRAME::GetPcbNewSettings(), GetSelection(), SELECTION::GetSize(), TOOL_MANAGER::GetTool(), SELECTION_TOOL::hasModifier(), PCB_POINT_EDITOR::HasPoint(), PCB_ACTIONS::highlightNet, ZONE::HitTestForCorner(), ZONE::HitTestForEdge(), EVENTS::InhibitSelectionEditing, IS_MOVING, IS_NEW, TOOL_BASE::IsToolActive(), EDA_BASE_FRAME::IsType(), KiROUND(), SELECTION_TOOL::m_canceledMenu, SELECTION_TOOL::m_disambiguateTimer, m_enteredGroup, PCBNEW_SETTINGS::m_ESCClearsNetHighlight, m_frame, SELECTION_TOOL::m_highlight_modifier, TOOL_INTERACTIVE::m_menu, m_nonModifiedCursor, SELECTION_TOOL::m_originalCursor, m_selection, TOOL_BASE::m_toolMgr, PCBNEW_SETTINGS::m_TrackDragAction, MD_ALT, MD_CTRL, MD_SHIFT, PCB_ACTIONS::move, MOVING, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_ZONE_T, TOOL_MANAGER::ProcessEvent(), PCB_ACTIONS::properties, ROUTER_TOOL::RoutingInProgress(), TOOL_MANAGER::RunAction(), SELECT, selectionContains(), selectMultiple(), selectPoint(), SELECTION::SetIsHover(), SELECTION_TOOL::setModifiersState(), TOOL_MENU::ShowContextMenu(), TOOLS_HOLDER::ToolStackIsEmpty(), TOOL_INTERACTIVE::Wait(), ACTIONS::zoomFitObjects, and ACTIONS::zoomFitScreen.

Referenced by setTransitions().

◆ onDisambiguationExpire()

void SELECTION_TOOL::onDisambiguationExpire ( wxTimerEvent &  aEvent)
protectedinherited

Start the process to show our disambiguation menu once the user has kept the mouse down for the minimum time.

Parameters
aEvent

Definition at line 219 of file selection_tool.cpp.

220{
221 // If there is a multiple selection then it's more likely that we're seeing a paused drag
222 // than a long-click.
223 if( selection().GetSize() >= 2 && !hasModifier() )
224 return;
225
226 // If another tool has since started running then we don't want to interrupt
227 if( !getEditFrame<EDA_DRAW_FRAME>()->ToolStackIsEmpty() )
228 return;
229
231}
static const TOOL_EVENT DisambiguatePoint
Definition: actions.h:224

References EVENTS::DisambiguatePoint, SELECTION_TOOL::hasModifier(), TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), and SELECTION_TOOL::selection().

Referenced by EE_SELECTION_TOOL::Init(), PL_SELECTION_TOOL::Init(), Init(), and ~PCB_SELECTION_TOOL().

◆ OnIdle()

void PCB_SELECTION_TOOL::OnIdle ( wxIdleEvent &  aEvent)

Definition at line 243 of file pcb_selection_tool.cpp.

244{
246 {
247 wxMouseState keyboardState = wxGetMouseState();
248
249 setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(),
250 keyboardState.AltDown() );
251
252 if( m_additive )
254 else if( m_subtractive )
256 else if( m_exclusive_or )
258 else
260 }
261}
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.

References ADD, PCB_BASE_FRAME::GetCanvas(), SELECTION_TOOL::m_additive, SELECTION_TOOL::m_exclusive_or, m_frame, SELECTION_TOOL::m_multiple, m_nonModifiedCursor, SELECTION_TOOL::m_subtractive, EDA_DRAW_PANEL_GAL::SetCurrentCursor(), SELECTION_TOOL::setModifiersState(), SUBTRACT, TOOLS_HOLDER::ToolStackIsEmpty(), and XOR.

Referenced by PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME().

◆ RebuildSelection()

void PCB_SELECTION_TOOL::RebuildSelection ( )

Rebuild the selection from the EDA_ITEMs' selection flags.

Commonly called after rolling back an undo state to make sure there aren't any stale pointers.

Definition at line 2329 of file pcb_selection_tool.cpp.

2330{
2332
2333 bool enteredGroupFound = false;
2334
2335 INSPECTOR_FUNC inspector =
2336 [&]( EDA_ITEM* item, void* testData )
2337 {
2338 if( item->IsSelected() )
2339 {
2340 EDA_ITEM* parent = item->GetParent();
2341
2342 // Let selected parents handle their children.
2343 if( parent && parent->IsSelected() )
2345
2346 highlight( item, SELECTED, &m_selection );
2347 }
2348
2349 if( item == m_enteredGroup )
2350 {
2351 item->SetFlags( ENTERED );
2352 enteredGroupFound = true;
2353 }
2354 else
2355 {
2356 item->ClearFlags( ENTERED );
2357 }
2358
2360 };
2361
2364
2365 if( !enteredGroupFound )
2366 {
2368 m_enteredGroup = nullptr;
2369 }
2370}
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: board.cpp:1352
bool IsSelected() const
Definition: eda_item.h:106
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
static const std::vector< KICAD_T > AllBoardItems
A scan list for all editable board items.
Definition: collectors.h:224
static const std::vector< KICAD_T > FootprintItems
A scan list for primary footprint items.
Definition: collectors.h:250
void highlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
Highlight the item visually.
std::function< INSPECT_RESULT(EDA_ITEM *aItem, void *aTestData) > INSPECTOR_FUNC
Used to inspect and possibly collect the (search) results of iterating over a list or tree of KICAD_T...
Definition: eda_item.h:75

References GENERAL_COLLECTOR::AllBoardItems, board(), KIGFX::VIEW_GROUP::Clear(), SELECTION::Clear(), EDA_ITEM::ClearFlags(), CONTINUE, ENTERED, GENERAL_COLLECTOR::FootprintItems, EDA_ITEM::GetParent(), highlight(), EDA_ITEM::IsSelected(), m_enteredGroup, m_enteredGroupOverlay, m_isFootprintEditor, m_selection, SELECTED, EDA_ITEM::SetFlags(), and BOARD::Visit().

Referenced by EDIT_TOOL::doMoveSelection(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), and BOARD_COMMIT::Revert().

◆ RemoveItemFromSel() [1/2]

◆ RemoveItemFromSel() [2/2]

void SELECTION_TOOL::RemoveItemFromSel ( EDA_ITEM aItem,
bool  aQuietMode = false 
)
inherited

Definition at line 158 of file selection_tool.cpp.

159{
160 if( aItem )
161 {
162 unselect( aItem );
163
164 // Inform other potentially interested tools
165 if( !aQuietMode )
167 }
168}
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:208
virtual void unselect(EDA_ITEM *aItem)=0
Take necessary action mark an item as unselected.

References TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), SELECTION_TOOL::unselect(), and EVENTS::UnselectedEvent.

◆ RemoveItemsFromSel() [1/3]

int SELECTION_TOOL::RemoveItemsFromSel ( const TOOL_EVENT aEvent)
inherited

◆ RemoveItemsFromSel() [2/3]

void SELECTION_TOOL::RemoveItemsFromSel ( EDA_ITEMS aList,
bool  aQuietMode = false 
)
inherited

Definition at line 179 of file selection_tool.cpp.

180{
181 if( aList )
182 {
183 for( EDA_ITEM* item : *aList )
184 unselect( item );
185
186 // Inform other potentially interested tools
187 if( !aQuietMode )
189 }
190}

References TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), SELECTION_TOOL::unselect(), and EVENTS::UnselectedEvent.

◆ RemoveItemsFromSel() [3/3]

void SELECTION_TOOL::RemoveItemsFromSel ( std::vector< KIID > *  aList,
bool  aQuietMode = false 
)
inherited

A safer version of RemoveItemsFromSel( EDA_ITEMS ) which doesn't require the items to still exist.

Definition at line 193 of file selection_tool.cpp.

194{
195 EDA_ITEMS removeItems;
196
197 for( EDA_ITEM* item : selection() )
198 {
199 if( alg::contains( *aList, item->m_Uuid ) )
200 removeItems.push_back( item );
201 }
202
203 RemoveItemsFromSel( &removeItems, aQuietMode );
204}
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99

References alg::contains(), SELECTION_TOOL::RemoveItemsFromSel(), and SELECTION_TOOL::selection().

◆ RequestSelection()

PCB_SELECTION & PCB_SELECTION_TOOL::RequestSelection ( CLIENT_SELECTION_FILTER  aClientFilter,
bool  aConfirmLockedItems = false 
)

Return the current selection, filtered according to aClientFilter.

If the set is empty, performs the legacy-style hover selection.

Parameters
aClientFilterA callback to allow tool- or action-specific filtering.
aConfirmLockedItems[optional] Signals that the user shall be asked if they want to drop locked items from the selection or override the locks. Select a single item under cursor event handler.

Definition at line 555 of file pcb_selection_tool.cpp.

557{
558 bool selectionEmpty = m_selection.Empty();
559 m_selection.SetIsHover( selectionEmpty );
560
561 if( selectionEmpty )
562 {
563 m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true, aClientFilter );
565 }
566
567 if( aClientFilter )
568 {
569 enum DISPOSITION { BEFORE = 1, AFTER, BOTH };
570
571 std::map<EDA_ITEM*, DISPOSITION> itemDispositions;
573 GENERAL_COLLECTOR collector;
574
575 collector.SetGuide( &guide );
576
577 for( EDA_ITEM* item : m_selection )
578 {
579 collector.Append( item );
580 itemDispositions[ item ] = BEFORE;
581 }
582
583 aClientFilter( VECTOR2I(), collector, this );
584
585 for( EDA_ITEM* item : collector )
586 {
587 if( itemDispositions.count( item ) )
588 itemDispositions[ item ] = BOTH;
589 else
590 itemDispositions[ item ] = AFTER;
591 }
592
593 // Unhighlight the BEFORE items before highlighting the AFTER items.
594 // This is so that in the case of groups, if aClientFilter replaces a selection
595 // with the enclosing group, the unhighlight of the element doesn't undo the
596 // recursive highlighting of that element by the group.
597
598 for( std::pair<EDA_ITEM* const, DISPOSITION> itemDisposition : itemDispositions )
599 {
600 EDA_ITEM* item = itemDisposition.first;
601 DISPOSITION disposition = itemDisposition.second;
602
603 if( disposition == BEFORE )
605 }
606
607 for( std::pair<EDA_ITEM* const, DISPOSITION> itemDisposition : itemDispositions )
608 {
609 EDA_ITEM* item = itemDisposition.first;
610 DISPOSITION disposition = itemDisposition.second;
611
612 // Note that we must re-highlight even previously-highlighted items
613 // (ie: disposition BOTH) in case we removed any of their children.
614 if( disposition == AFTER || disposition == BOTH )
615 highlight( item, SELECTED, &m_selection );
616 }
617
619 }
620
621 if( aConfirmLockedItems )
622 {
623 std::vector<BOARD_ITEM*> lockedItems;
624
625 for( EDA_ITEM* item : m_selection )
626 {
627 BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
628
629 if( boardItem->Type() == PCB_GROUP_T )
630 {
631 PCB_GROUP* group = static_cast<PCB_GROUP*>( boardItem );
632 bool lockedDescendant = false;
633
634 group->RunOnDescendants(
635 [&lockedDescendant]( BOARD_ITEM* child )
636 {
637 if( child->IsLocked() )
638 lockedDescendant = true;
639 } );
640
641 if( lockedDescendant )
642 lockedItems.push_back( group );
643 }
644 else if( boardItem->IsLocked() )
645 {
646 lockedItems.push_back( boardItem );
647 }
648 }
649
650 if( !lockedItems.empty() )
651 {
652 DIALOG_LOCKED_ITEMS_QUERY dlg( frame(), (int) lockedItems.size() );
653
654 switch( dlg.ShowModal() )
655 {
656 case wxID_OK:
657 // remove locked items from selection
658 for( BOARD_ITEM* item : lockedItems )
659 unselect( item );
660
661 break;
662
663 case wxID_CANCEL:
664 // cancel operation
666 break;
667
668 case wxID_APPLY:
669 // continue with operation with current selection
670 break;
671 }
672 }
673 }
674
675 return m_selection;
676}
void SetGuide(const COLLECTORS_GUIDE *aGuide)
Record which COLLECTORS_GUIDE to use.
Definition: collectors.h:293
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:56
const GENERAL_COLLECTORS_GUIDE getCollectorsGuide() const
void unselect(EDA_ITEM *aItem) override
Take necessary action mark an item as unselected.

References COLLECTOR::Append(), SELECTION::ClearReferencePoint(), ClearSelection(), SELECTION::Empty(), EDA_DRAW_PANEL_GAL::ForceRefresh(), frame(), PCB_BASE_FRAME::GetCanvas(), getCollectorsGuide(), group, highlight(), BOARD_ITEM::IsLocked(), m_frame, m_selection, TOOL_BASE::m_toolMgr, PCB_GROUP_T, TOOL_MANAGER::RunAction(), SELECTED, PCB_ACTIONS::selectionCursor, GENERAL_COLLECTOR::SetGuide(), SELECTION::SetIsHover(), DIALOG_LOCKED_ITEMS_QUERY::ShowModal(), EDA_ITEM::Type(), unhighlight(), and unselect().

Referenced by BOARD_EDITOR_CONTROL::AssignNetclass(), EDIT_TOOL::ChangeTrackWidth(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), CONVERT_TOOL::CreateLines(), CONVERT_TOOL::CreatePolys(), ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally(), ALIGN_DISTRIBUTE_TOOL::DistributeVertically(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Drag(), EDIT_TOOL::Duplicate(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::FilletLines(), EDIT_TOOL::FilletTracks(), EDIT_TOOL::Flip(), ALIGN_DISTRIBUTE_TOOL::GetSelections(), GROUP_TOOL::Group(), EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), EDIT_TOOL::PackAndMoveFootprints(), GROUP_TOOL::PickNewMember(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), GLOBAL_EDIT_TOOL::RemoveUnusedPads(), EDIT_TOOL::Rotate(), CONVERT_TOOL::SegmentToArc(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), and EDIT_TOOL::Swap().

◆ Reset()

void PCB_SELECTION_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

Bring the tool to a known, initial state.

If the tool claimed anything from the model or the view, it must release it when its reset.

Parameters
aReasoncontains information about the reason of tool reset.

Implements TOOL_BASE.

Definition at line 210 of file pcb_selection_tool.cpp.

211{
212 m_frame = getEditFrame<PCB_BASE_FRAME>();
214
215 if( m_enteredGroup )
216 ExitGroup();
217
218 if( aReason == TOOL_BASE::MODEL_RELOAD )
219 {
220 // Deselect any item being currently in edit, to avoid unexpected behavior
221 // and remove pointers to the selected items from containers
222 // without changing their properties (as they are already deleted
223 // while a new board is loaded)
224 ClearSelection( true );
225
226 getView()->GetPainter()->GetSettings()->SetHighlight( false );
227 }
228 else if ( aReason != TOOL_BASE::REDRAW )
229 {
230 // Restore previous properties of selected items and remove them from containers
231 ClearSelection( true );
232 }
233
234 // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
235 view()->Remove( &m_selection );
236 view()->Add( &m_selection );
237
240}
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41

References KIGFX::PCB_VIEW::Add(), ClearSelection(), ExitGroup(), FRAME_FOOTPRINT_EDITOR, KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), TOOL_BASE::getView(), EDA_BASE_FRAME::IsType(), m_enteredGroup, m_enteredGroupOverlay, m_frame, m_isFootprintEditor, m_selection, TOOL_BASE::MODEL_RELOAD, TOOL_BASE::REDRAW, KIGFX::PCB_VIEW::Remove(), KIGFX::RENDER_SETTINGS::SetHighlight(), and view().

◆ resetTransitions()

void TOOL_INTERACTIVE::resetTransitions ( )
privateinherited

Clear the current transition map and restores the default one created by setTransitions().

Definition at line 63 of file tool_interactive.cpp.

64{
67}
virtual void setTransitions()=0
This method is meant to be overridden in order to specify handlers for events.
void ClearTransitions(TOOL_BASE *aTool)
Clear the state transition map for a tool.

References TOOL_MANAGER::ClearTransitions(), TOOL_BASE::m_toolMgr, and TOOL_INTERACTIVE::setTransitions().

◆ RunMainStack()

void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Call a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

88{
89 m_toolMgr->RunMainStack( this, std::move( aFunc ) );
90}
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::RunMainStack().

Referenced by DRAWING_TOOL::PlaceText().

◆ select()

void PCB_SELECTION_TOOL::select ( EDA_ITEM aItem)
overridevirtual

Take necessary action mark an item as selected.

Parameters
aItemThe item to be selected.

Implements SELECTION_TOOL.

Definition at line 2628 of file pcb_selection_tool.cpp.

2629{
2630 if( aItem->IsSelected() )
2631 return;
2632
2633 if( aItem->Type() == PCB_PAD_T )
2634 {
2635 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aItem->GetParent() );
2636
2637 if( m_selection.Contains( footprint ) )
2638 return;
2639 }
2640
2641 if( m_enteredGroup &&
2642 !PCB_GROUP::WithinScope( static_cast<BOARD_ITEM*>( aItem ), m_enteredGroup,
2644 {
2645 ExitGroup();
2646 }
2647
2648 highlight( aItem, SELECTED, &m_selection );
2649}
bool Contains(EDA_ITEM *aItem) const
Definition: selection.cpp:84

References SELECTION::Contains(), ExitGroup(), EDA_ITEM::GetParent(), highlight(), EDA_ITEM::IsSelected(), m_enteredGroup, m_isFootprintEditor, m_selection, PCB_PAD_T, SELECTED, EDA_ITEM::Type(), and PCB_GROUP::WithinScope().

Referenced by doSyncSelection(), EnterGroup(), ExitGroup(), filterSelection(), FindItem(), grabUnconnected(), GROUP_TOOL::Group(), SelectAll(), selectAllConnectedTracks(), SelectAllItemsOnNet(), selectAllItemsOnSheet(), selectConnections(), selectMultiple(), selectNet(), selectPoint(), selectUnconnected(), and unrouteSelected().

◆ Selectable()

bool PCB_SELECTION_TOOL::Selectable ( const BOARD_ITEM aItem,
bool  checkVisibilityOnly = false 
) const
Returns
true if an item fulfills conditions to be selected.

Definition at line 2373 of file pcb_selection_tool.cpp.

2374{
2375 const RENDER_SETTINGS* settings = getView()->GetPainter()->GetSettings();
2376
2377 auto visibleLayers =
2378 [&]()
2379 {
2381 {
2382 LSET set;
2383
2384 for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
2385 set.set( layer, view()->IsLayerVisible( layer ) );
2386
2387 return set;
2388 }
2389 else
2390 {
2391 return board()->GetVisibleLayers();
2392 }
2393 };
2394
2395 if( settings->GetHighContrast() )
2396 {
2397 const std::set<int> activeLayers = settings->GetHighContrastLayers();
2398 bool onActiveLayer = false;
2399
2400 for( int layer : activeLayers )
2401 {
2402 // NOTE: Only checking the regular layers (not GAL meta-layers)
2403 if( layer < PCB_LAYER_ID_COUNT && aItem->IsOnLayer( ToLAYER_ID( layer ), true ) )
2404 {
2405 onActiveLayer = true;
2406 break;
2407 }
2408 }
2409
2410 if( !onActiveLayer ) // We do not want to select items that are in the background
2411 return false;
2412 }
2413
2414 if( aItem->Type() == PCB_FOOTPRINT_T )
2415 {
2416 // In footprint editor, we do not want to select the footprint itself.
2418 return false;
2419
2420 // Allow selection of footprints if some part of the footprint is visible.
2421 const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( aItem );
2422 LSET boardSide = footprint->IsFlipped() ? LSET::BackMask() : LSET::FrontMask();
2423
2424 if( !( visibleLayers() & boardSide ).any() && !m_skip_heuristics )
2425 return false;
2426
2427 // If the footprint has no items except the reference and value fields, include the
2428 // footprint in the selections.
2429 if( footprint->GraphicalItems().empty()
2430 && footprint->Pads().empty()
2431 && footprint->Zones().empty() )
2432 {
2433 return true;
2434 }
2435
2436 for( const BOARD_ITEM* item : footprint->GraphicalItems() )
2437 {
2438 if( Selectable( item, true ) )
2439 return true;
2440 }
2441
2442 for( const PAD* pad : footprint->Pads() )
2443 {
2444 if( Selectable( pad, true ) )
2445 return true;
2446 }
2447
2448 for( const ZONE* zone : footprint->Zones() )
2449 {
2450 if( Selectable( zone, true ) )
2451 return true;
2452 }
2453
2454 return false;
2455 }
2456 else if( aItem->Type() == PCB_GROUP_T )
2457 {
2458 PCB_GROUP* group = const_cast<PCB_GROUP*>( static_cast<const PCB_GROUP*>( aItem ) );
2459
2460 // Similar to logic for footprint, a group is selectable if any of its members are.
2461 // (This recurses.)
2462 for( BOARD_ITEM* item : group->GetItems() )
2463 {
2464 if( Selectable( item, true ) )
2465 return true;
2466 }
2467
2468 return false;
2469 }
2470
2471 const ZONE* zone = nullptr;
2472 const PCB_VIA* via = nullptr;
2473 const PAD* pad = nullptr;
2474 const FP_TEXT* text = nullptr;
2475
2476 switch( aItem->Type() )
2477 {
2478 case PCB_ZONE_T:
2479 case PCB_FP_ZONE_T:
2481 return false;
2482
2483 zone = static_cast<const ZONE*>( aItem );
2484
2485 // A footprint zone is only selectable within the footprint editor
2486 if( zone->GetParent()
2487 && zone->GetParent()->Type() == PCB_FOOTPRINT_T
2489 && !checkVisibilityOnly )
2490 {
2491 return false;
2492 }
2493
2494 // zones can exist on multiple layers!
2495 if( !( zone->GetLayerSet() & visibleLayers() ).any() )
2496 return false;
2497
2498 break;
2499
2500 case PCB_TRACE_T:
2501 case PCB_ARC_T:
2503 return false;
2504
2506 {
2507 if( !view()->IsLayerVisible( aItem->GetLayer() ) )
2508 return false;
2509 }
2510 else
2511 {
2512 if( !board()->IsLayerVisible( aItem->GetLayer() ) )
2513 return false;
2514 }
2515
2516 break;
2517
2518 case PCB_VIA_T:
2519 if( !board()->IsElementVisible( LAYER_VIAS ) )
2520 return false;
2521
2522 via = static_cast<const PCB_VIA*>( aItem );
2523
2524 // For vias it is enough if only one of its layers is visible
2525 if( !( visibleLayers() & via->GetLayerSet() ).any() )
2526 return false;
2527
2528 break;
2529
2530 case PCB_FP_TEXT_T:
2532 {
2533 text = static_cast<const FP_TEXT*>( aItem );
2534
2535 if( !text->IsVisible() && !view()->IsLayerVisible( LAYER_MOD_TEXT_INVISIBLE ) )
2536 return false;
2537
2538 if( !view()->IsLayerVisible( aItem->GetLayer() ) )
2539 return false;
2540 }
2541 else
2542 {
2543 if( !view()->IsVisible( aItem ) )
2544 return false;
2545
2546 if( !board()->IsLayerVisible( aItem->GetLayer() ) )
2547 return false;
2548
2549 int controlLayer = UNDEFINED_LAYER;
2550
2551 switch( static_cast<const FP_TEXT*>( aItem )->GetType() )
2552 {
2553 case FP_TEXT::TEXT_is_REFERENCE: controlLayer = LAYER_MOD_REFERENCES; break;
2554 case FP_TEXT::TEXT_is_VALUE: controlLayer = LAYER_MOD_VALUES; break;
2555 case FP_TEXT::TEXT_is_DIVERS: controlLayer = LAYER_MOD_TEXT; break;
2556 }
2557
2558 if( controlLayer == UNDEFINED_LAYER )
2559 return false;
2560
2561 if( !view()->IsLayerVisible( controlLayer ) )
2562 return false;
2563 }
2564
2565 break;
2566
2567 case PCB_FP_SHAPE_T:
2568 case PCB_FP_TEXTBOX_T:
2570 {
2571 if( !view()->IsLayerVisible( aItem->GetLayer() ) )
2572 return false;
2573 }
2574 else
2575 {
2576 // Footprint shape selections are only allowed in footprint editor mode.
2577 if( !checkVisibilityOnly )
2578 return false;
2579
2580 if( !board()->IsLayerVisible( aItem->GetLayer() ) )
2581 return false;
2582 }
2583
2584 break;
2585
2586 case PCB_PAD_T:
2587 pad = static_cast<const PAD*>( aItem );
2588
2589 if( pad->GetAttribute() == PAD_ATTRIB::PTH || pad->GetAttribute() == PAD_ATTRIB::NPTH )
2590 {
2591 // Check render mode (from the Items tab) first
2593 return false;
2594
2595 // A pad's hole is visible on every layer the pad is visible on plus many layers the
2596 // pad is not visible on -- so we only need to check for any visible hole layers.
2597 if( !( visibleLayers() & LSET::PhysicalLayersMask() ).any() )
2598 return false;
2599 }
2600 else
2601 {
2602 // Check render mode (from the Items tab) first
2603 if( pad->IsOnLayer( F_Cu ) && !board()->IsElementVisible( LAYER_PAD_FR ) )
2604 return false;
2605 else if( pad->IsOnLayer( B_Cu ) && !board()->IsElementVisible( LAYER_PAD_BK ) )
2606 return false;
2607
2608 if( !( pad->GetLayerSet() & visibleLayers() ).any() )
2609 return false;
2610 }
2611
2612 break;
2613
2614 // These are not selectable
2615 case PCB_NETINFO_T:
2616 case NOT_USED:
2617 case TYPE_NOT_INIT:
2618 return false;
2619
2620 default: // Suppress warnings
2621 break;
2622 }
2623
2624 return true;
2625}
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:601
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.cpp:593
bool IsFlipped() const
Definition: footprint.h:324
FP_ZONES & Zones()
Definition: footprint.h:176
DRAWINGS & GraphicalItems()
Definition: footprint.h:173
@ TEXT_is_REFERENCE
Definition: fp_text.h:49
@ TEXT_is_DIVERS
Definition: fp_text.h:51
@ TEXT_is_VALUE
Definition: fp_text.h:50
TEXT_TYPE GetType() const
Definition: fp_text.h:120
const std::set< int > GetHighContrastLayers() const
Returns the set of currently high-contrast layers.
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:410
bool IsVisible(const VIEW_ITEM *aItem) const
Return information if the item is visible (or not).
Definition: view.cpp:1569
static LSET AllLayersMask()
Definition: lset.cpp:808
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:870
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Definition: lset.cpp:902
bool Selectable(const BOARD_ITEM *aItem, bool checkVisibilityOnly=false) const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.h:122
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored)
Definition: layer_ids.h:231
@ B_Cu
Definition: layer_ids.h:95
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ F_Cu
Definition: layer_ids.h:64
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:932
@ NPTH
like PAD_PTH, but not plated
@ PTH
Plated through hole pad.
@ TYPE_NOT_INIT
Definition: typeinfo.h:81
@ NOT_USED
the 3d code uses this value
Definition: typeinfo.h:79

References LSET::AllLayersMask(), B_Cu, LSET::BackMask(), board(), F_Cu, LSET::FrontMask(), KIGFX::RENDER_SETTINGS::GetHighContrast(), KIGFX::RENDER_SETTINGS::GetHighContrastLayers(), BOARD_ITEM::GetLayer(), ZONE::GetLayerSet(), KIGFX::VIEW::GetPainter(), BOARD_ITEM::GetParent(), KIGFX::PAINTER::GetSettings(), FP_TEXT::GetType(), TOOL_BASE::getView(), BOARD::GetVisibleLayers(), FOOTPRINT::GraphicalItems(), group, BOARD::IsElementVisible(), FOOTPRINT::IsFlipped(), KIGFX::VIEW::IsLayerVisible(), BOARD::IsLayerVisible(), KIGFX::VIEW::IsVisible(), LAYER_MOD_REFERENCES, LAYER_MOD_TEXT, LAYER_MOD_TEXT_INVISIBLE, LAYER_MOD_VALUES, LAYER_PAD_BK, LAYER_PAD_FR, LAYER_PADS_TH, LAYER_TRACKS, LAYER_VIAS, LAYER_ZONES, m_isFootprintEditor, SELECTION_TOOL::m_skip_heuristics, NOT_USED, NPTH, pad, FOOTPRINT::Pads(), PCB_ARC_T, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_NETINFO_T, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, LSET::PhysicalLayersMask(), PTH, Selectable(), LSET::Seq(), text, FP_TEXT::TEXT_is_DIVERS, FP_TEXT::TEXT_is_REFERENCE, FP_TEXT::TEXT_is_VALUE, ToLAYER_ID(), EDA_ITEM::Type(), TYPE_NOT_INIT, UNDEFINED_LAYER, via, view(), and FOOTPRINT::Zones().

Referenced by PCB_CONTROL::DeleteItemCursor(), Selectable(), SelectAll(), selectMultiple(), and selectPoint().

◆ SelectAll()

int PCB_SELECTION_TOOL::SelectAll ( const TOOL_EVENT aEvent)

Definition at line 1079 of file pcb_selection_tool.cpp.

1080{
1082
1083 // hold all visible items
1084 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
1085
1086 // Filter the view items based on the selection box
1087 BOX2I selectionBox;
1088
1089 // Intermediate step to allow filtering against hierarchy
1090 GENERAL_COLLECTOR collection;
1091
1092 selectionBox.SetMaximum();
1093 view->Query( selectionBox, selectedItems ); // Get the list of selected items
1094
1095 for( const KIGFX::VIEW::LAYER_ITEM_PAIR& item_pair : selectedItems )
1096 {
1097 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( item_pair.first );
1098
1099 if( !item || !Selectable( item ) || !itemPassesFilter( item, true ) )
1100 continue;
1101
1102 collection.Append( item );
1103 }
1104
1105 FilterCollectorForHierarchy( collection, true );
1106
1107 for( EDA_ITEM* item : collection )
1108 select( item );
1109
1111
1113
1114 return 0;
1115}
void SetMaximum()
Definition: box2.h:63
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
virtual int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Find all visible items that touch or are within the rectangle aRect.
Definition: view.cpp:425
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
Definition: view.h:73
void FilterCollectorForHierarchy(GENERAL_COLLECTOR &aCollector, bool aMultiselect) const
In general we don't want to select both a parent and any of it's children.

References COLLECTOR::Append(), FilterCollectorForHierarchy(), EDA_DRAW_PANEL_GAL::ForceRefresh(), PCB_BASE_FRAME::GetCanvas(), TOOL_BASE::getView(), itemPassesFilter(), m_frame, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), KIGFX::VIEW::Query(), select(), Selectable(), EVENTS::SelectedEvent, BOX2< Vec >::SetMaximum(), and view().

Referenced by setTransitions().

◆ selectAllConnectedTracks()

void PCB_SELECTION_TOOL::selectAllConnectedTracks ( const std::vector< BOARD_CONNECTED_ITEM * > &  aStartItems,
STOP_CONDITION  aStopCondition 
)
private

Select connected tracks and vias.

Parameters
aStopConditionIndicates where to stop selecting more items.

Definition at line 1231 of file pcb_selection_tool.cpp.

1233{
1234 const LSET allCuMask = LSET::AllCuMask();
1235
1236 PROF_TIMER refreshTimer;
1237 double refreshIntervalMs = 500; // Refresh display with this interval to indicate progress
1238 int lastSelectionSize = (int) m_selection.GetSize();
1239
1240 auto connectivity = board()->GetConnectivity();
1241
1242 std::map<VECTOR2I, std::vector<PCB_TRACK*>> trackMap;
1243 std::map<VECTOR2I, PCB_VIA*> viaMap;
1244 std::map<VECTOR2I, PAD*> padMap;
1245 std::set<PAD*> startPadSet;
1246 std::vector<BOARD_CONNECTED_ITEM*> cleanupItems;
1247 std::vector<std::pair<VECTOR2I, LSET>> activePts;
1248
1249 for( BOARD_CONNECTED_ITEM* startItem : aStartItems )
1250 {
1251 // Track starting pads
1252 if( startItem->Type() == PCB_PAD_T )
1253 startPadSet.insert( static_cast<PAD*>( startItem ) );
1254 }
1255
1256 for( BOARD_CONNECTED_ITEM* startItem : aStartItems )
1257 {
1258 if( startItem->HasFlag( SKIP_STRUCT ) ) // Skip already visited items
1259 continue;
1260
1261 auto connectedItems = connectivity->GetConnectedItems( startItem,
1263
1264 // Build maps of connected items
1265 for( BOARD_CONNECTED_ITEM* item : connectedItems )
1266 {
1267 switch( item->Type() )
1268 {
1269 case PCB_ARC_T:
1270 case PCB_TRACE_T:
1271 {
1272 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
1273 trackMap[track->GetStart()].push_back( track );
1274 trackMap[track->GetEnd()].push_back( track );
1275 break;
1276 }
1277
1278 case PCB_VIA_T:
1279 {
1280 PCB_VIA* via = static_cast<PCB_VIA*>( item );
1281 viaMap[via->GetStart()] = via;
1282 break;
1283 }
1284
1285 case PCB_PAD_T:
1286 {
1287 PAD* pad = static_cast<PAD*>( item );
1288 padMap[pad->GetPosition()] = pad;
1289 break;
1290 }
1291
1292 default:
1293 break;
1294 }
1295 }
1296
1297 // Set up the initial active points
1298 switch( startItem->Type() )
1299 {
1300 case PCB_ARC_T:
1301 case PCB_TRACE_T:
1302 {
1303 PCB_TRACK* track = static_cast<PCB_TRACK*>( startItem );
1304
1305 activePts.push_back( { track->GetStart(), track->GetLayerSet() } );
1306 activePts.push_back( { track->GetEnd(), track->GetLayerSet() } );
1307 break;
1308 }
1309
1310 case PCB_VIA_T:
1311 activePts.push_back( { startItem->GetPosition(), startItem->GetLayerSet() } );
1312 break;
1313
1314 case PCB_PAD_T:
1315 activePts.push_back( { startItem->GetPosition(), startItem->GetLayerSet() } );
1316 break;
1317
1318 default:
1319 break;
1320 }
1321
1322 bool expand = true;
1323 int failSafe = 0;
1324
1325 // Iterative push from all active points
1326 while( expand && failSafe++ < 100000 )
1327 {
1328 expand = false;
1329
1330 for( int i = (int) activePts.size() - 1; i >= 0; --i )
1331 {
1332 VECTOR2I pt = activePts[i].first;
1333 LSET layerSetCu = activePts[i].second & allCuMask;
1334
1335 auto viaIt = viaMap.find( pt );
1336 auto padIt = padMap.find( pt );
1337
1338 bool gotVia = ( viaIt != viaMap.end() )
1339 && ( layerSetCu & ( viaIt->second->GetLayerSet() ) ).any();
1340
1341 bool gotPad = ( padIt != padMap.end() )
1342 && ( layerSetCu & ( padIt->second->GetLayerSet() ) ).any();
1343
1344 bool gotNonStartPad =
1345 gotPad && ( startPadSet.find( padIt->second ) == startPadSet.end() );
1346
1347 if( aStopCondition == STOP_AT_JUNCTION )
1348 {
1349 size_t pt_count = 0;
1350
1351 for( PCB_TRACK* track : trackMap[pt] )
1352 {
1353 if( track->GetStart() != track->GetEnd()
1354 && layerSetCu.Contains( track->GetLayer() ) )
1355 {
1356 pt_count++;
1357 }
1358 }
1359
1360 if( pt_count > 2 || gotVia || gotNonStartPad )
1361 {
1362 activePts.erase( activePts.begin() + i );
1363 continue;
1364 }
1365 }
1366 else if( aStopCondition == STOP_AT_PAD )
1367 {
1368 if( gotNonStartPad )
1369 {
1370 activePts.erase( activePts.begin() + i );
1371 continue;
1372 }
1373 }
1374
1375 if( gotPad )
1376 {
1377 PAD* pad = padIt->second;
1378
1379 if( !pad->HasFlag( SKIP_STRUCT ) )
1380 {
1381 pad->SetFlags( SKIP_STRUCT );
1382 cleanupItems.push_back( pad );
1383
1384 activePts.push_back( { pad->GetPosition(), pad->GetLayerSet() } );
1385 expand = true;
1386 }
1387 }
1388
1389 for( PCB_TRACK* track : trackMap[pt] )
1390 {
1391 if( !layerSetCu.Contains( track->GetLayer() ) )
1392 continue;
1393
1394 if( !track->IsSelected() )
1395 select( track );
1396
1397 if( !track->HasFlag( SKIP_STRUCT ) )
1398 {
1399 track->SetFlags( SKIP_STRUCT );
1400 cleanupItems.push_back( track );
1401
1402 if( track->GetStart() == pt )
1403 activePts.push_back( { track->GetEnd(), track->GetLayerSet() } );
1404 else
1405 activePts.push_back( { track->GetStart(), track->GetLayerSet() } );
1406
1407 expand = true;
1408 }
1409 }
1410
1411 if( viaMap.count( pt ) )
1412 {
1413 PCB_VIA* via = viaMap[pt];
1414
1415 if( !via->IsSelected() )
1416 select( via );
1417
1418 if( !via->HasFlag( SKIP_STRUCT ) )
1419 {
1420 via->SetFlags( SKIP_STRUCT );
1421 cleanupItems.push_back( via );
1422
1423 activePts.push_back( { via->GetPosition(), via->GetLayerSet() } );
1424 expand = true;
1425 }
1426 }
1427
1428 activePts.erase( activePts.begin() + i );
1429 }
1430
1431 // Refresh display for the feel of progress
1432 if( refreshTimer.msecs() >= refreshIntervalMs )
1433 {
1434 if( m_selection.Size() != lastSelectionSize )
1435 {
1437 lastSelectionSize = m_selection.Size();
1438 }
1439
1440 refreshTimer.Start();
1441 }
1442 }
1443 }
1444
1445 for( BOARD_CONNECTED_ITEM* item : cleanupItems )
1446 item->ClearFlags( SKIP_STRUCT );
1447}
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:197
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:143
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
Definition: layer_ids.h:602
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
const VECTOR2I & GetStart() const
Definition: pcb_track.h:114
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:111
A small class to help profiling.
Definition: profile.h:47
void Start()
Start or restart the counter.
Definition: profile.h:75
double msecs(bool aSinceLast=false)
Definition: profile.h:147
#define SKIP_STRUCT
flag indicating that the structure should be ignored

References LSET::AllCuMask(), board(), LSET::Contains(), EDA_DRAW_PANEL_GAL::ForceRefresh(), PCB_BASE_FRAME::GetCanvas(), BOARD::GetConnectivity(), PCB_TRACK::GetEnd(), BOARD_ITEM::GetLayerSet(), SELECTION::GetSize(), PCB_TRACK::GetStart(), m_frame, m_selection, PROF_TIMER::msecs(), pad, PCB_ARC_T, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, select(), SELECTION::Size(), SKIP_STRUCT, PROF_TIMER::Start(), STOP_AT_JUNCTION, STOP_AT_PAD, and via.

Referenced by expandConnection(), selectConnections(), and unrouteSelected().

◆ SelectAllItemsOnNet()

void PCB_SELECTION_TOOL::SelectAllItemsOnNet ( int  aNetCode,
bool  aSelect = true 
)

Select all items with the given net code.

Parameters
aNetCodeis the target net to select
aSelectis true to add the items to the selection, false to remove them (deselect)

Definition at line 1559 of file pcb_selection_tool.cpp.

1560{
1561 std::shared_ptr<CONNECTIVITY_DATA> conn = board()->GetConnectivity();
1562
1563 for( BOARD_ITEM* item : conn->GetNetItems( aNetCode, { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) )
1564 {
1565 if( itemPassesFilter( item, true ) )
1566 aSelect ? select( item ) : unselect( item );
1567 }
1568}

References board(), BOARD::GetConnectivity(), itemPassesFilter(), select(), and unselect().

Referenced by BOARD_EDITOR_CONTROL::AssignNetclass(), FindItem(), and selectNet().

◆ selectAllItemsOnSheet()

void PCB_SELECTION_TOOL::selectAllItemsOnSheet ( wxString &  aSheetPath)
private

Select all items with the given sheet timestamp/UUID name (the sheet path).

The path of the root sheet is "/". Select all footprints belonging to same sheet, from Eeschema using cross-probing.

Definition at line 1615 of file pcb_selection_tool.cpp.

1616{
1617 std::vector<BOARD_ITEM*> footprints;
1618
1619 // store all footprints that are on that sheet path
1620 for( FOOTPRINT* footprint : board()->Footprints() )
1621 {
1622 if( footprint == nullptr )
1623 continue;
1624
1625 wxString footprint_path = footprint->GetPath().AsString().BeforeLast( '/' );
1626
1627 if( footprint_path.IsEmpty() )
1628 footprint_path += '/';
1629
1630 if( footprint_path == aSheetPath )
1631 footprints.push_back( footprint );
1632 }
1633
1634 for( BOARD_ITEM* i : footprints )
1635 {
1636 if( i != nullptr )
1637 select( i );
1638 }
1639
1640 selectConnections( footprints );
1641}

References board(), select(), and selectConnections().

Referenced by selectSameSheet(), and selectSheetContents().

◆ selectConnections()

void PCB_SELECTION_TOOL::selectConnections ( const std::vector< BOARD_ITEM * > &  aItems)
private

Definition at line 1644 of file pcb_selection_tool.cpp.

1645{
1646 // Generate a list of all pads, and of all nets they belong to.
1647 std::list<int> netcodeList;
1648 std::vector<BOARD_CONNECTED_ITEM*> padList;
1649
1650 for( BOARD_ITEM* item : aItems )
1651 {
1652 switch( item->Type() )
1653 {
1654 case PCB_FOOTPRINT_T:
1655 {
1656 for( PAD* pad : static_cast<FOOTPRINT*>( item )->Pads() )
1657 {
1658 if( pad->IsConnected() )
1659 {
1660 netcodeList.push_back( pad->GetNetCode() );
1661 padList.push_back( pad );
1662 }
1663 }
1664
1665 break;
1666 }
1667
1668 case PCB_PAD_T:
1669 {
1670 PAD* pad = static_cast<PAD*>( item );
1671
1672 if( pad->IsConnected() )
1673 {
1674 netcodeList.push_back( pad->GetNetCode() );
1675 padList.push_back( pad );
1676 }
1677
1678 break;
1679 }
1680
1681 default:
1682 break;
1683 }
1684 }
1685
1686 // Sort for binary search
1687 std::sort( padList.begin(), padList.end() );
1688
1689 // remove all duplicates
1690 netcodeList.sort();
1691 netcodeList.unique();
1692
1694
1695 // now we need to find all footprints that are connected to each of these nets then we need
1696 // to determine if these footprints are in the list of footprints
1697 std::vector<int> removeCodeList;
1698 std::shared_ptr<CONNECTIVITY_DATA> conn = board()->GetConnectivity();
1699
1700 for( int netCode : netcodeList )
1701 {
1702 for( BOARD_CONNECTED_ITEM* pad : conn->GetNetItems( netCode, { PCB_PAD_T } ) )
1703 {
1704 if( !std::binary_search( padList.begin(), padList.end(), pad ) )
1705 {
1706 // if we cannot find the pad in the padList then we can assume that that pad
1707 // should not be used, therefore invalidate this netcode.
1708 removeCodeList.push_back( netCode );
1709 break;
1710 }
1711 }
1712 }
1713
1714 for( int removeCode : removeCodeList )
1715 netcodeList.remove( removeCode );
1716
1717 std::unordered_set<BOARD_ITEM*> localConnectionList;
1718
1719 for( int netCode : netcodeList )
1720 {
1721 for( BOARD_ITEM* item : conn->GetNetItems( netCode, { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) )
1722 localConnectionList.insert( item );
1723 }
1724
1725 for( BOARD_ITEM* item : localConnectionList )
1726 select( item );
1727}

References board(), BOARD::GetConnectivity(), pad, PCB_FOOTPRINT_T, PCB_PAD_T, select(), selectAllConnectedTracks(), and STOP_AT_PAD.

Referenced by doSyncSelection(), and selectAllItemsOnSheet().

◆ selectCursor()

bool PCB_SELECTION_TOOL::selectCursor ( bool  aForceSelect = false,
CLIENT_SELECTION_FILTER  aClientFilter = nullptr 
)
private

Select an item under the cursor unless there is something already selected.

Parameters
aForceSelect[optional] Forces an item to be selected even if there is already a selection.
aClientFilterA callback to allow tool- or action-specific filtering.
Returns
whether or not the selection is empty.

Definition at line 837 of file pcb_selection_tool.cpp.

838{
839 if( aForceSelect || m_selection.Empty() )
840 {
841 ClearSelection( true /*quiet mode*/ );
842 selectPoint( getViewControls()->GetCursorPosition( false ), false, nullptr, aClientFilter );
843 }
844
845 return !m_selection.Empty();
846}

References ClearSelection(), SELECTION::Empty(), TOOL_BASE::getViewControls(), m_selection, and selectPoint().

Referenced by CursorSelection(), expandConnection(), and selectNet().

◆ selection()

SELECTION & PCB_SELECTION_TOOL::selection ( )
inlineoverrideprotectedvirtual

Return a reference to the selection.

Implements SELECTION_TOOL.

Definition at line 242 of file pcb_selection_tool.h.

242{ return m_selection; }

References m_selection.

Referenced by filterSelection(), and selectNet().

◆ selectionContains()

bool PCB_SELECTION_TOOL::selectionContains ( const VECTOR2I aPoint) const
private
Returns
true if the given point is contained in any of selected items' bounding boxes.

Definition at line 2745 of file pcb_selection_tool.cpp.

2746{
2747 const unsigned GRIP_MARGIN = 20;
2748 int margin = KiROUND( getView()->ToWorld( GRIP_MARGIN ) );
2749
2750 // Check if the point is located close to any of the currently selected items
2751 for( EDA_ITEM* item : m_selection )
2752 {
2753 BOX2I itemBox = item->ViewBBox();
2754 itemBox.Inflate( margin ); // Give some margin for gripping an item
2755
2756 if( itemBox.Contains( aPoint ) )
2757 {
2758 if( item->HitTest( aPoint, margin ) )
2759 return true;
2760
2761 bool found = false;
2762
2763 std::function<void( PCB_GROUP* )> checkGroup;
2764 checkGroup = [&]( PCB_GROUP* aGroup )
2765 {
2766 aGroup->RunOnChildren(
2767 [&]( BOARD_ITEM* aItem )
2768 {
2769 if( PCB_GROUP* group = dyn_cast<PCB_GROUP*>( aItem ) )
2770 checkGroup( group );
2771 else if( aItem->HitTest( aPoint, margin ) )
2772 found = true;
2773 } );
2774 };
2775
2776 if( PCB_GROUP* group = dyn_cast<PCB_GROUP*>( item ) )
2777 {
2778 checkGroup( group );
2779
2780 if( found )
2781 return true;
2782 }
2783 }
2784 }
2785
2786 return false;
2787}
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
virtual bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Test if aPosition is inside or on the boundary of this item.
Definition: eda_item.h:222

References BOX2< Vec >::Contains(), TOOL_BASE::getView(), group, EDA_ITEM::HitTest(), BOX2< Vec >::Inflate(), KiROUND(), and m_selection.

Referenced by Main().

◆ SelectionMenu()

int SELECTION_TOOL::SelectionMenu ( const TOOL_EVENT aEvent)
inherited

Show a popup menu to trim the COLLECTOR passed as aEvent's parameter down to a single item.

Note
This routine does not modify the selection.

Definition at line 234 of file selection_tool.cpp.

235{
236 COLLECTOR* collector = aEvent.Parameter<COLLECTOR*>();
237
238 if( !doSelectionMenu( collector ) )
239 collector->m_MenuCancelled = true;
240
241 return 0;
242}
An abstract class that will find and hold all the objects according to an inspection done by the Insp...
Definition: collector.h:48
bool m_MenuCancelled
Definition: collector.h:237
bool doSelectionMenu(COLLECTOR *aCollector)

References SELECTION_TOOL::doSelectionMenu(), COLLECTOR::m_MenuCancelled, and TOOL_EVENT::Parameter().

Referenced by EE_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), and setTransitions().

◆ selectMultiple()

bool PCB_SELECTION_TOOL::selectMultiple ( )
private

Handle drawing a selection box that allows one to select many items at the same time.

Returns
true if the function was canceled (i.e. CancelEvent was received).

Definition at line 862 of file pcb_selection_tool.cpp.

863{
864 bool cancelled = false; // Was the tool cancelled while it was running?
865 m_multiple = true; // Multiple selection mode is active
867
869 view->Add( &area );
870
871 bool anyAdded = false;
872 bool anySubtracted = false;
873
874 while( TOOL_EVENT* evt = Wait() )
875 {
876 int width = area.GetEnd().x - area.GetOrigin().x;
877
878 /* Selection mode depends on direction of drag-selection:
879 * Left > Right : Select objects that are fully enclosed by selection
880 * Right > Left : Select objects that are crossed by selection
881 */
882 bool greedySelection = width >= 0 ? false : true;
883
884 if( view->IsMirroredX() )
885 greedySelection = !greedySelection;
886
889
890 if( evt->IsCancelInteractive() || evt->IsActivate() )
891 {
892 cancelled = true;
893 break;
894 }
895
896 if( evt->IsDrag( BUT_LEFT ) )
897 {
899 {
900 if( m_selection.GetSize() > 0 )
901 {
902 anySubtracted = true;
903 ClearSelection( true /*quiet mode*/ );
904 }
905 }
906
907 // Start drawing a selection box
908 area.SetOrigin( evt->DragOrigin() );
909 area.SetEnd( evt->Position() );
912 area.SetExclusiveOr( false );
913
914 view->SetVisible( &area, true );
915 view->Update( &area );
916 getViewControls()->SetAutoPan( true );
917 }
918
919 if( evt->IsMouseUp( BUT_LEFT ) )
920 {
921 getViewControls()->SetAutoPan( false );
922
923 // End drawing the selection box
924 view->SetVisible( &area, false );
925
926 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> candidates;
927 BOX2I selectionBox = area.ViewBBox();
928 view->Query( selectionBox, candidates ); // Get the list of nearby items
929
930 int height = area.GetEnd().y - area.GetOrigin().y;
931
932 // Construct a BOX2I to determine BOARD_ITEM selection
933 BOX2I selectionRect( area.GetOrigin(), VECTOR2I( width, height ) );
934
935 selectionRect.Normalize();
936
937 GENERAL_COLLECTOR collector;
938 GENERAL_COLLECTOR padsCollector;
939 std::set<BOARD_ITEM*> group_items;
940
941 for( PCB_GROUP* group : board()->Groups() )
942 {
943 // The currently entered group does not get limited
944 if( m_enteredGroup == group )
945 continue;
946
947 std::unordered_set<BOARD_ITEM*>& newset = group->GetItems();
948
949 // If we are not greedy and have selected the whole group, add just one item
950 // to allow it to be promoted to the group later
951 if( !greedySelection && selectionRect.Contains( group->GetBoundingBox() )
952 && newset.size() )
953 {
954 for( BOARD_ITEM* group_item : newset )
955 {
956 if( Selectable( group_item ) )
957 collector.Append( *newset.begin() );
958 }
959 }
960
961 for( BOARD_ITEM* group_item : newset )
962 group_items.emplace( group_item );
963 }
964
965 for( const KIGFX::VIEW::LAYER_ITEM_PAIR& candidate : candidates )
966 {
967 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( candidate.first );
968
969 if( item && Selectable( item ) && item->HitTest( selectionRect, !greedySelection )
970 && ( greedySelection || !group_items.count( item ) ) )
971 {
972 if( item->Type() == PCB_PAD_T && !m_isFootprintEditor )
973 padsCollector.Append( item );
974 else
975 collector.Append( item );
976 }
977 }
978
979 // Apply the stateful filter
980 FilterCollectedItems( collector, true );
981
982 FilterCollectorForHierarchy( collector, true );
983
984 // If we selected nothing but pads, allow them to be selected
985 if( collector.GetCount() == 0 )
986 {
987 collector = padsCollector;
988 FilterCollectedItems( collector, true );
989 FilterCollectorForHierarchy( collector, true );
990 }
991
992 for( EDA_ITEM* i : collector )
993 {
994 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( i );
995
996 if( m_subtractive || ( m_exclusive_or && item->IsSelected() ) )
997 {
998 unselect( item );
999 anySubtracted = true;
1000 }
1001 else
1002 {
1003 select( item );
1004 anyAdded = true;
1005 }
1006 }
1007
1008 m_selection.SetIsHover( false );
1009
1010 // Inform other potentially interested tools
1011 if( anyAdded )
1013 else if( anySubtracted )
1015
1016 break; // Stop waiting for events
1017 }
1018
1019 // Allow some actions for navigation
1020 for( int i = 0; allowedActions[i]; ++i )
1021 {
1022 if( evt->IsAction( allowedActions[i] ) )
1023 {
1024 evt->SetPassEvent();
1025 break;
1026 }
1027 }
1028 }
1029
1030 getViewControls()->SetAutoPan( false );
1031
1032 // Stop drawing the selection box
1033 view->Remove( &area );
1034 m_multiple = false; // Multiple selection mode is inactive
1035
1036 if( !cancelled )
1038
1040
1041 return cancelled;
1042}
static const TOOL_EVENT UninhibitSelectionEditing
Used to inform tool that it should display the disambiguation menu.
Definition: actions.h:221
Represent a selection area (currently a rectangle) in a VIEW, drawn corner-to-corner between two poin...
void SetSubtractive(bool aSubtractive)
void SetAdditive(bool aAdditive)
void SetOrigin(const VECTOR2I &aOrigin)
const BOX2I ViewBBox() const override
Set the origin of the rectangle (the fixed corner)
void SetExclusiveOr(bool aExclusiveOr)
void SetEnd(const VECTOR2I &aEnd)
Set the current end of the rectangle (the corner that moves with the cursor.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:243
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition: view.cpp:1529
void FilterCollectedItems(GENERAL_COLLECTOR &aCollector, bool aMultiSelect)
Apply the SELECTION_FITLER_OPTIONS to the collector.
const TOOL_ACTION * allowedActions[]

References KIGFX::PCB_VIEW::Add(), allowedActions, COLLECTOR::Append(), board(), BUT_LEFT, SELECTION::ClearReferencePoint(), ClearSelection(), BOX2< Vec >::Contains(), FilterCollectedItems(), FilterCollectorForHierarchy(), PCB_BASE_FRAME::GetCanvas(), COLLECTOR::GetCount(), KIGFX::PREVIEW::SELECTION_AREA::GetEnd(), KIGFX::PREVIEW::SELECTION_AREA::GetOrigin(), SELECTION::GetSize(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), group, EDA_ITEM::HitTest(), KIGFX::VIEW::IsMirroredX(), EDA_ITEM::IsSelected(), SELECTION_TOOL::m_drag_additive, SELECTION_TOOL::m_drag_subtractive, m_enteredGroup, SELECTION_TOOL::m_exclusive_or, m_frame, m_isFootprintEditor, SELECTION_TOOL::m_multiple, m_selection, SELECTION_TOOL::m_subtractive, TOOL_BASE::m_toolMgr, BOX2< Vec >::Normalize(), PCB_PAD_T, TOOL_MANAGER::ProcessEvent(), KIGFX::VIEW::Query(), KIGFX::PCB_VIEW::Remove(), select(), SELECT_LASSO, SELECT_WINDOW, Selectable(), EVENTS::SelectedEvent, KIGFX::PREVIEW::SELECTION_AREA::SetAdditive(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::PREVIEW::SELECTION_AREA::SetEnd(), KIGFX::PREVIEW::SELECTION_AREA::SetExclusiveOr(), SELECTION::SetIsHover(), KIGFX::PREVIEW::SELECTION_AREA::SetOrigin(), KIGFX::PREVIEW::SELECTION_AREA::SetSubtractive(), KIGFX::VIEW::SetVisible(), EDA_ITEM::Type(), EVENTS::UninhibitSelectionEditing, unselect(), EVENTS::UnselectedEvent, KIGFX::PCB_VIEW::Update(), view(), KIGFX::PREVIEW::SELECTION_AREA::ViewBBox(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Main().

◆ selectNet()

int PCB_SELECTION_TOOL::selectNet ( const TOOL_EVENT aEvent)
private

Select all copper connections belonging to the same net(s) as the items in the selection.

Definition at line 1571 of file pcb_selection_tool.cpp.

1572{
1573 bool select = aEvent.IsAction( &PCB_ACTIONS::selectNet );
1574
1575 // If we've been passed an argument, just select that netcode1
1576 int netcode = (int) aEvent.Parameter<intptr_t>();
1577
1578 if( netcode > 0 )
1579 {
1580 SelectAllItemsOnNet( netcode, select );
1581
1582 // Inform other potentially interested tools
1583 if( m_selection.Size() > 0 )
1585 else
1587
1588 return 0;
1589 }
1590
1591 if( !selectCursor() )
1592 return 0;
1593
1594 // copy the selection, since we're going to iterate and modify
1596
1597 for( EDA_ITEM* i : selection )
1598 {
1599 BOARD_CONNECTED_ITEM* connItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( i );
1600
1601 if( connItem )
1602 SelectAllItemsOnNet( connItem->GetNetCode(), select );
1603 }
1604
1605 // Inform other potentially interested tools
1606 if( m_selection.Size() > 0 )
1608 else
1610
1611 return 0;
1612}
static TOOL_ACTION selectNet
Select all connections belonging to a single net.
Definition: pcb_actions.h:86
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:81

References SELECTION::GetItems(), BOARD_CONNECTED_ITEM::GetNetCode(), TOOL_EVENT::IsAction(), m_selection, TOOL_BASE::m_toolMgr, TOOL_EVENT::Parameter(), TOOL_MANAGER::ProcessEvent(), select(), SelectAllItemsOnNet(), selectCursor(), EVENTS::SelectedEvent, selection(), PCB_ACTIONS::selectNet, SELECTION::Size(), and EVENTS::UnselectedEvent.

Referenced by setTransitions().

◆ selectPoint()

bool PCB_SELECTION_TOOL::selectPoint ( const VECTOR2I aWhere,
bool  aOnDrag = false,
bool *  aSelectionCancelledFlag = nullptr,
CLIENT_SELECTION_FILTER  aClientFilter = nullptr 
)
private

Select an item pointed by the parameter aWhere.

If there is more than one item at that place, there is a menu displayed that allows one to choose the item.

Parameters
aWhereis the place where the item should be selected.
aOnDragindicates whether a drag operation is being performed.
aSelectionCancelledFlagallows the function to inform its caller that a selection was canceled (for instance, by clicking outside of the disambiguation menu).
aClientFiltera callback to allow tool- or action-specific filtering.
Returns
whether or not the selection is empty.

Definition at line 712 of file pcb_selection_tool.cpp.

715{
717 GENERAL_COLLECTOR collector;
718 const PCB_DISPLAY_OPTIONS& displayOpts = m_frame->GetDisplayOptions();
719
721
723 ExitGroup();
724
727 aWhere, guide );
728
729 // Remove unselectable items
730 for( int i = collector.GetCount() - 1; i >= 0; --i )
731 {
732 if( !Selectable( collector[ i ] ) || ( aOnDrag && collector[i]->IsLocked() ) )
733 collector.Remove( i );
734 }
735
737
738 // Allow the client to do tool- or action-specific filtering to see if we can get down
739 // to a single item
740 if( aClientFilter )
741 aClientFilter( aWhere, collector, this );
742
743 FilterCollectorForHierarchy( collector, false );
744
745 // Apply the stateful filter
746 FilterCollectedItems( collector, false );
747
748 // For subtracting, we only want items that are selected
749 if( m_subtractive )
750 {
751 for( int i = collector.GetCount() - 1; i >= 0; --i )
752 {
753 if( !collector[i]->IsSelected() )
754 collector.Remove( i );
755 }
756 }
757
758 // Apply some ugly heuristics to avoid disambiguation menus whenever possible
759 if( collector.GetCount() > 1 && !m_skip_heuristics )
760 {
761 try
762 {
763 GuessSelectionCandidates( collector, aWhere );
764 }
765 catch( const ClipperLib::clipperException& exc )
766 {
767 wxLogWarning( wxS( "Exception \"%s\" occurred attemption to guess selection "
768 "candidates." ), exc.what() );
769 return false;
770 }
771 }
772
773 // If still more than one item we're going to have to ask the user.
774 if( collector.GetCount() > 1 )
775 {
776 if( aOnDrag )
778
779 if( !doSelectionMenu( &collector ) )
780 {
781 if( aSelectionCancelledFlag )
782 *aSelectionCancelledFlag = true;
783
784 return false;
785 }
786 }
787
788 int addedCount = 0;
789 bool anySubtracted = false;
790
792 {
793 if( m_selection.GetSize() > 0 )
794 {
795 ClearSelection( true /*quiet mode*/ );
796 anySubtracted = true;
797 }
798 }
799
800 if( collector.GetCount() > 0 )
801 {
802 for( int i = 0; i < collector.GetCount(); ++i )
803 {
804 if( m_subtractive || ( m_exclusive_or && collector[i]->IsSelected() ) )
805 {
806 unselect( collector[i] );
807 anySubtracted = true;
808 }
809 else
810 {
811 select( collector[i] );
812 addedCount++;
813 }
814 }
815 }
816
817 if( addedCount == 1 )
818 {
820 return true;
821 }
822 else if( addedCount > 1 )
823 {
825 return true;
826 }
827 else if( anySubtracted )
828 {
830 return true;
831 }
832
833 return false;
834}
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:206
void SetIgnoreZoneFills(bool ignore)
Definition: collectors.h:480
void Collect(BOARD_ITEM *aItem, const std::vector< KICAD_T > &aScanList, const VECTOR2I &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
Definition: collectors.cpp:596
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
ZONE_DISPLAY_MODE m_ZoneDisplayMode
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_group.cpp:276
void GuessSelectionCandidates(GENERAL_COLLECTOR &aCollector, const VECTOR2I &aWhere) const
Try to guess best selection candidates in case multiple items are clicked, by doing some brain-dead h...
@ TA_MOUSE_UP
Definition: tool_event.h:64
@ TC_ANY
Definition: tool_event.h:55

References GENERAL_COLLECTOR::AllBoardItems, board(), BUT_LEFT, SELECTION::ClearReferencePoint(), ClearSelection(), GENERAL_COLLECTOR::Collect(), BOX2< Vec >::Contains(), SELECTION_TOOL::doSelectionMenu(), ExitGroup(), FilterCollectedItems(), FilterCollectorForHierarchy(), GENERAL_COLLECTOR::FootprintItems, PCB_GROUP::GetBoundingBox(), getCollectorsGuide(), COLLECTOR::GetCount(), PCB_BASE_FRAME::GetDisplayOptions(), SELECTION::GetSize(), GuessSelectionCandidates(), SELECTION_TOOL::m_additive, m_enteredGroup, SELECTION_TOOL::m_exclusive_or, m_frame, m_isFootprintEditor, m_selection, SELECTION_TOOL::m_skip_heuristics, SELECTION_TOOL::m_subtractive, TOOL_BASE::m_toolMgr, PCB_DISPLAY_OPTIONS::m_ZoneDisplayMode, EVENTS::PointSelectedEvent, TOOL_MANAGER::ProcessEvent(), COLLECTOR::Remove(), select(), Selectable(), EVENTS::SelectedEvent, GENERAL_COLLECTORS_GUIDE::SetIgnoreZoneFills(), SHOW_FILLED, TA_MOUSE_UP, TC_ANY, unselect(), EVENTS::UnselectedEvent, and TOOL_INTERACTIVE::Wait().

Referenced by disambiguateCursor(), Main(), and selectCursor().

◆ selectSameSheet()

int PCB_SELECTION_TOOL::selectSameSheet ( const TOOL_EVENT aEvent)
private

Set selection to items passed by parameter and connected nets (optionally).

Zooms to fit, if enabled

Definition at line 1801 of file pcb_selection_tool.cpp.

1802{
1803 // this function currently only supports footprints since they are only on one sheet.
1804 EDA_ITEM* item = m_selection.Front();
1805
1806 if( !item )
1807 return 0;
1808
1809 if( item->Type() != PCB_FOOTPRINT_T )
1810 return 0;
1811
1812 FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( item );
1813
1814 if( !footprint || footprint->GetPath().empty() )
1815 return 0;
1816
1817 ClearSelection( true /*quiet mode*/ );
1818
1819 // get the sheet path only.
1820 wxString sheetPath = footprint->GetPath().AsString().BeforeLast( '/' );
1821
1822 if( sheetPath.IsEmpty() )
1823 sheetPath += '/';
1824
1825 selectAllItemsOnSheet( sheetPath );
1826
1827 // Inform other potentially interested tools
1828 if( m_selection.Size() > 0 )
1830
1831 return 0;
1832}
const KIID_PATH & GetPath() const
Definition: footprint.h:224
wxString AsString() const
Definition: kiid.cpp:359
void selectAllItemsOnSheet(wxString &aSheetPath)
Select all items with the given sheet timestamp/UUID name (the sheet path).

References KIID_PATH::AsString(), ClearSelection(), SELECTION::Front(), FOOTPRINT::GetPath(), m_selection, TOOL_BASE::m_toolMgr, PCB_FOOTPRINT_T, TOOL_MANAGER::ProcessEvent(), selectAllItemsOnSheet(), EVENTS::SelectedEvent, SELECTION::Size(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ selectSheetContents()

int PCB_SELECTION_TOOL::selectSheetContents ( const TOOL_EVENT aEvent)
private

Select all footprints belonging to same hierarchical sheet as the selected footprint (same sheet path).

Definition at line 1785 of file pcb_selection_tool.cpp.

1786{
1787 ClearSelection( true /*quiet mode*/ );
1788 wxString sheetPath = *aEvent.Parameter<wxString*>();
1789
1790 selectAllItemsOnSheet( sheetPath );
1791
1793
1794 if( m_selection.Size() > 0 )
1796
1797 return 0;
1798}
void zoomFitSelection()
Zoom the screen to fit the bounding box for cross probing/selection sync.

References ClearSelection(), m_selection, TOOL_BASE::m_toolMgr, TOOL_EVENT::Parameter(), TOOL_MANAGER::ProcessEvent(), selectAllItemsOnSheet(), EVENTS::SelectedEvent, SELECTION::Size(), and zoomFitSelection().

Referenced by setTransitions().

◆ selectUnconnected()

int PCB_SELECTION_TOOL::selectUnconnected ( const TOOL_EVENT aEvent)
private

Select nearest unconnected footprints on same net as selected items.

Definition at line 1450 of file pcb_selection_tool.cpp.

1451{
1452 // Get all pads
1453 std::vector<PAD*> pads;
1454
1455 for( EDA_ITEM* item : m_selection.GetItems() )
1456 {
1457 if( item->Type() == PCB_FOOTPRINT_T )
1458 {
1459 for( PAD* pad : static_cast<FOOTPRINT*>( item )->Pads() )
1460 pads.push_back( pad );
1461 }
1462 else if( item->Type() == PCB_PAD_T )
1463 {
1464 pads.push_back( static_cast<PAD*>( item ) );
1465 }
1466 }
1467
1468 // Select every footprint on the end of the ratsnest for each pad in our selection
1469 std::shared_ptr<CONNECTIVITY_DATA> conn = board()->GetConnectivity();
1470
1471 for( PAD* pad : pads )
1472 {
1473 for( const CN_EDGE& edge : conn->GetRatsnestForPad( pad ) )
1474 {
1475 BOARD_CONNECTED_ITEM* sourceParent = edge.GetSourceNode()->Parent();
1476 BOARD_CONNECTED_ITEM* targetParent = edge.GetTargetNode()->Parent();
1477
1478 if( sourceParent == pad )
1479 {
1480 if( targetParent->Type() == PCB_PAD_T )
1481 select( static_cast<PAD*>( targetParent )->GetParent() );
1482 }
1483 else if( targetParent == pad )
1484 {
1485 if( sourceParent->Type() == PCB_PAD_T )
1486 select( static_cast<PAD*>( sourceParent )->GetParent() );
1487 }
1488 }
1489 }
1490
1491 return 0;
1492}

References board(), BOARD::GetConnectivity(), SELECTION::GetItems(), m_selection, pad, PCB_FOOTPRINT_T, PCB_PAD_T, select(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ SetContextMenu()

void TOOL_INTERACTIVE::SetContextMenu ( ACTION_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Assign a context menu and tells when it should be activated.

Parameters
aMenuis the menu to be assigned.
aTriggerdetermines conditions upon which the context menu is activated.

Definition at line 76 of file tool_interactive.cpp.

77{
78 if( aMenu )
79 aMenu->SetTool( this );
80 else
81 aTrigger = CMENU_OFF;
82
83 m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
84}
void SetTool(TOOL_INTERACTIVE *aTool)
Set a tool that is the creator of the menu.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Set behavior of the tool's context popup menu.
@ CMENU_OFF
Definition: tool_event.h:149

References CMENU_OFF, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ScheduleContextMenu(), and ACTION_MENU::SetTool().

Referenced by SELECTION_TOOL::doSelectionMenu(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ setModifiersState()

void SELECTION_TOOL::setModifiersState ( bool  aShiftState,
bool  aCtrlState,
bool  aAltState 
)
protectedinherited

Set the configuration of m_additive, m_subtractive, m_exclusive_or, m_skip_heuristics from the state of modifier keys SHIFT, CTRL, ALT and depending on the OS.

Definition at line 48 of file selection_tool.cpp.

49{
50 // Set the configuration of m_additive, m_subtractive, m_exclusive_or from the state of
51 // modifier keys SHIFT and CTRL
52
53 // ALT key cannot be used on MSW because of a conflict with the system menu
54
55 m_subtractive = aCtrlState && aShiftState;
56 m_additive = !aCtrlState && aShiftState;
57
59 {
60 m_exclusive_or = false;
61 m_highlight_modifier = aCtrlState && !aShiftState;
62 }
63 else
64 {
65 m_exclusive_or = aCtrlState && !aShiftState;
67 }
68
69 // Drag is more forgiving and allows either Ctrl+Drag or Shift+Drag to add to the selection
70 // Note, however that we cannot provide disambiguation at the same time as the box selection
71 m_drag_additive = ( aCtrlState || aShiftState ) && !aAltState;
72 m_drag_subtractive = aCtrlState && aShiftState && !aAltState;
73
74 // While the ALT key has some conflicts under MSW (and some flavors of Linux WMs), it remains
75 // useful for users who only use tap-click rather than holding the button. We disable it for
76 // windows because it flashes the disambiguation menu without showing data
77#ifndef __WINDOWS__
78 m_skip_heuristics = aAltState;
79#else
80 m_skip_heuristics = false;
81#endif
82
83}
virtual bool ctrlClickHighlights()
Determines if ctrl-click is highlight net or XOR selection.

References SELECTION_TOOL::ctrlClickHighlights(), SELECTION_TOOL::m_additive, SELECTION_TOOL::m_drag_additive, SELECTION_TOOL::m_drag_subtractive, SELECTION_TOOL::m_exclusive_or, SELECTION_TOOL::m_highlight_modifier, SELECTION_TOOL::m_skip_heuristics, and SELECTION_TOOL::m_subtractive.

Referenced by EE_SELECTION_TOOL::disambiguateCursor(), PL_SELECTION_TOOL::disambiguateCursor(), disambiguateCursor(), EE_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), Main(), EE_SELECTION_TOOL::OnIdle(), and OnIdle().

◆ setTransitions()

void PCB_SELECTION_TOOL::setTransitions ( )
overridevirtual

Zoom the screen to center and fit the current selection.

Implements TOOL_INTERACTIVE.

Definition at line 3206 of file pcb_selection_tool.cpp.

3207{
3209
3213
3219
3235
3237
3239}
static TOOL_ACTION updateMenu
Definition: actions.h:172
static TOOL_ACTION selectAll
Definition: actions.h:71
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:214
static const TOOL_EVENT SelectedItemsMoved
Used to inform tools that the selection should temporarily be non-editable.
Definition: actions.h:217
static TOOL_ACTION unrouteSelected
Removes all tracks from the selected items to the first pad.
Definition: pcb_actions.h:83
static TOOL_ACTION grabUnconnected
Select and move nearest unconnected footprint from ratsnest of selection.
Definition: pcb_actions.h:95
static TOOL_ACTION filterSelection
Filter the items in the current selection (invokes dialog)
Definition: pcb_actions.h:107
static TOOL_ACTION unselectItem
Definition: pcb_actions.h:63
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
static TOOL_ACTION selectOnSheetFromEeschema
Select all components on sheet from Eeschema crossprobing.
Definition: pcb_actions.h:98
static TOOL_ACTION selectConnection
Select tracks between junctions or expands an existing selection to pads or the entire connection.
Definition: pcb_actions.h:80
static TOOL_ACTION unselectItems
Definition: pcb_actions.h:67
static TOOL_ACTION selectUnconnected
Select unconnected footprints from ratsnest of selection.
Definition: pcb_actions.h:92
static TOOL_ACTION syncSelection
Sets selection to specified items, zooms to fit, if enabled.
Definition: pcb_actions.h:70
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition: pcb_actions.h:62
static TOOL_ACTION selectSameSheet
Select all components on the same sheet as the selected footprint.
Definition: pcb_actions.h:101
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: pcb_actions.h:53
static TOOL_ACTION syncSelectionWithNets
Sets selection to specified items with connected nets, zooms to fit, if enabled.
Definition: pcb_actions.h:73
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
Definition: pcb_actions.h:66
static TOOL_ACTION deselectNet
Remove all connections belonging to a single net from the active selection.
Definition: pcb_actions.h:89
static TOOL_ACTION selectionMenu
Run a selection menu to select from a list of items.
Definition: pcb_actions.h:76
int syncSelectionWithNets(const TOOL_EVENT &aEvent)
int syncSelection(const TOOL_EVENT &aEvent)
int selectNet(const TOOL_EVENT &aEvent)
Select all copper connections belonging to the same net(s) as the items in the selection.
int filterSelection(const TOOL_EVENT &aEvent)
Return true if the given item passes the current SELECTION_FILTER_OPTIONS.
int disambiguateCursor(const TOOL_EVENT &aEvent)
Handle disambiguation actions including displaying the menu.
int unrouteSelected(const TOOL_EVENT &aEvent)
Unroute the selected board connected items.
int grabUnconnected(const TOOL_EVENT &aEvent)
Select and move other nearest footprint unconnected on same net as selected items.
int expandConnection(const TOOL_EVENT &aEvent)
Expand the current connected-item selection to the next boundary (junctions, pads,...
int selectUnconnected(const TOOL_EVENT &aEvent)
Select nearest unconnected footprints on same net as selected items.
int selectSheetContents(const TOOL_EVENT &aEvent)
Select all footprints belonging to same hierarchical sheet as the selected footprint (same sheet path...
int selectSameSheet(const TOOL_EVENT &aEvent)
Set selection to items passed by parameter and connected nets (optionally).
int CursorSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
int Main(const TOOL_EVENT &aEvent)
The main loop.
int updateSelection(const TOOL_EVENT &aEvent)
Event handler to update the selection VIEW_ITEM.
int SelectAll(const TOOL_EVENT &aEvent)
int UpdateMenu(const TOOL_EVENT &aEvent)
Update a menu's state based on the current selection.
int SelectionMenu(const TOOL_EVENT &aEvent)
Show a popup menu to trim the COLLECTOR passed as aEvent's parameter down to a single item.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).

References SELECTION_TOOL::AddItemsToSel(), SELECTION_TOOL::AddItemToSel(), ClearSelection(), CursorSelection(), PCB_ACTIONS::deselectNet, disambiguateCursor(), EVENTS::DisambiguatePoint, expandConnection(), PCB_ACTIONS::filterSelection, filterSelection(), TOOL_INTERACTIVE::Go(), PCB_ACTIONS::grabUnconnected, grabUnconnected(), Main(), SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemsFromSel(), ACTIONS::selectAll, SelectAll(), PCB_ACTIONS::selectConnection, EVENTS::SelectedItemsModified, EVENTS::SelectedItemsMoved, PCB_ACTIONS::selectionActivate, PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionCursor, SELECTION_TOOL::SelectionMenu(), PCB_ACTIONS::selectionMenu, PCB_ACTIONS::selectItem, PCB_ACTIONS::selectItems, PCB_ACTIONS::selectNet, selectNet(), PCB_ACTIONS::selectOnSheetFromEeschema, PCB_ACTIONS::selectSameSheet, selectSameSheet(), selectSheetContents(), PCB_ACTIONS::selectUnconnected, selectUnconnected(), PCB_ACTIONS::syncSelection, syncSelection(), PCB_ACTIONS::syncSelectionWithNets, syncSelectionWithNets(), PCB_ACTIONS::unrouteSelected, unrouteSelected(), PCB_ACTIONS::unselectItem, PCB_ACTIONS::unselectItems, ACTIONS::updateMenu, SELECTION_TOOL::UpdateMenu(), and updateSelection().

◆ syncSelection()

int PCB_SELECTION_TOOL::syncSelection ( const TOOL_EVENT aEvent)
private

Definition at line 1730 of file pcb_selection_tool.cpp.

1731{
1732 std::vector<BOARD_ITEM*>* items = aEvent.Parameter<std::vector<BOARD_ITEM*>*>();
1733
1734 if( items )
1735 doSyncSelection( *items, false );
1736
1737 return 0;
1738}
void doSyncSelection(const std::vector< BOARD_ITEM * > &aItems, bool aWithNets)
Invoke filter dialog and modify current selection.

References doSyncSelection(), and TOOL_EVENT::Parameter().

Referenced by setTransitions().

◆ syncSelectionWithNets()

int PCB_SELECTION_TOOL::syncSelectionWithNets ( const TOOL_EVENT aEvent)
private

Definition at line 1741 of file pcb_selection_tool.cpp.

1742{
1743 std::vector<BOARD_ITEM*>* items = aEvent.Parameter<std::vector<BOARD_ITEM*>*>();
1744
1745 if( items )
1746 doSyncSelection( *items, true );
1747
1748 return 0;
1749}

References doSyncSelection(), and TOOL_EVENT::Parameter().

Referenced by setTransitions().

◆ UnbrightenItem()

◆ unhighlight()

void PCB_SELECTION_TOOL::unhighlight ( EDA_ITEM aItem,
int  aHighlightMode,
SELECTION aGroup = nullptr 
)
overrideprivatevirtual

Unhighlight the item visually.

Parameters
aItemThe item to be highlighted.
aHighlightModeEither SELECTED or BRIGHTENED
aGroup[optional] A group to remove the item from.

Implements SELECTION_TOOL.

Definition at line