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 PCB_TOOL_BASE TOOL_INTERACTIVE TOOL_BASE

Classes

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

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 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)
 
int Main (const TOOL_EVENT &aEvent)
 The main loop. More...
 
PCB_SELECTIONGetSelection ()
 Return the set of currently selected items. More...
 
PCB_SELECTIONRequestSelection (CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
 Return the current selection set, filtered according to aFlags and 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)
 Item selection event handler. More...
 
int SelectItem (const TOOL_EVENT &aEvent)
 
void AddItemToSel (BOARD_ITEM *aItem, bool aQuietMode=false)
 Select all items on the board. More...
 
int SelectAll (const TOOL_EVENT &aEvent)
 Multiple item selection event handler. More...
 
int SelectItems (const TOOL_EVENT &aEvent)
 Item unselection event handler. More...
 
int UnselectItem (const TOOL_EVENT &aEvent)
 
void RemoveItemFromSel (BOARD_ITEM *aItem, bool aQuietMode=false)
 Multiple item unselection event handler. More...
 
int UnselectItems (const TOOL_EVENT &aEvent)
 
void BrightenItem (BOARD_ITEM *aItem)
 
void UnbrightenItem (BOARD_ITEM *aItem)
 
void FindItem (BOARD_ITEM *aItem)
 Handle finding an item. More...
 
void select (BOARD_ITEM *aItem)
 Take necessary action mark an item as selected. More...
 
bool Selectable (const BOARD_ITEM *aItem, bool checkVisibilityOnly=false) const
 Check conditions for an item to be selected. 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...
 
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 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 ()
 
BOARDGetBoard () const
 
void EnterGroup ()
 
void ExitGroup (bool aSelectGroup=false)
 Leave the currently entered group. More...
 
PCB_GROUPGetEnteredGroup ()
 
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, upgrade any pad selection to the selection of its parent footprint. More...
 
void FilterCollectorForMarkers (GENERAL_COLLECTOR &aCollector) const
 Apply the SELECTION_FILTER_OPTIONS to a collection of items. More...
 
void FilterCollectedItems (GENERAL_COLLECTOR &aCollector, bool aMultiSelect)
 
void SetIsFootprintEditor (bool aEnabled)
 Function SetIsFootprintEditor() More...
 
bool IsFootprintEditor () const
 
virtual bool Is45Limited () const
 Should the tool use its 45° mode option? 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 Types

enum  INTERACTIVE_PLACEMENT_OPTIONS { IPO_ROTATE = 0x01, IPO_FLIP = 0x02, IPO_SINGLE_CLICK = 0x04, IPO_REPEAT = 0x08 }
 Options for placing items interactively. More...
 

Protected Member Functions

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...
 
void doInteractiveItemPlacement (const std::string &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_BASE_EDIT_FRAMEframe () const
 
BOARDboard () const
 
FOOTPRINTfootprint () const
 
const PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const PCB_SELECTIONselection () const
 
PCB_SELECTIONselection ()
 
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
 
bool m_isFootprintEditor
 
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 or aSelectAlways is true. More...
 
bool selectMultiple ()
 Handle drawing a selection box that allows one to select many items at the same time. More...
 
bool doSelectionMenu (GENERAL_COLLECTOR *aItems)
 Allow the selection of a single item from a list via pop-up menu. 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...
 
int disambiguateCursor (const TOOL_EVENT &aEvent)
 Handle disambiguation actions including displaying the menu. More...
 
int expandConnection (const TOOL_EVENT &aEvent)
 Expand the current track selection to the next boundary (junctions, pads, or all) More...
 
int selectNet (const TOOL_EVENT &aEvent)
 Select all copper connections belonging to the same net(s) as the items in the selection. More...
 
void selectConnectedTracks (BOARD_CONNECTED_ITEM &aSourceItem, STOP_CONDITION aStopCondition)
 Select connected tracks and vias. More...
 
void selectAllItemsOnNet (int aNetCode, bool aSelect=true)
 Select all items with the given net code. More...
 
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)
 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 (BOARD_ITEM *aItem)
 Take necessary action mark an item as unselected. More...
 
void highlight (BOARD_ITEM *aItem, int aHighlightMode, PCB_SELECTION *aGroup=nullptr)
 Highlight the item visually. More...
 
void unhighlight (BOARD_ITEM *aItem, int aHighlightMode, PCB_SELECTION *aGroup=nullptr)
 Unhighlight the item visually. More...
 
bool selectionContains (const VECTOR2I &aPoint) const
 
int hitTestDistance (const wxPoint &aWhere, BOARD_ITEM *aItem, int aMaxDistance) const
 
int updateSelection (const TOOL_EVENT &aEvent)
 Event handler to update the selection VIEW_ITEM. More...
 
int UpdateMenu (const TOOL_EVENT &aEvent)
 Pass the selection to a conditional menu for updating. More...
 
const GENERAL_COLLECTORS_GUIDE getCollectorsGuide () const
 
void highlightInternal (BOARD_ITEM *aItem, int aHighlightMode, bool aUsingOverlay)
 
void unhighlightInternal (BOARD_ITEM *aItem, int aHighlightMode, bool aUsingOverlay)
 

Private Attributes

PCB_BASE_FRAMEm_frame
 
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

◆ INTERACTIVE_PLACEMENT_OPTIONS

Options for placing items interactively.

Enumerator
IPO_ROTATE 

Handle the rotate action in the loop by calling the item's rotate method.

IPO_FLIP 

Handle flip action in the loop by calling the item's flip method.

IPO_SINGLE_CLICK 

Create an item immediately on placement starting, otherwise show the pencil cursor until the item is created.

IPO_REPEAT 

Allow repeat placement of the item.

Definition at line 116 of file pcb_tool_base.h.

116  {
118  IPO_ROTATE = 0x01,
119 
121  IPO_FLIP = 0x02,
122 
125  IPO_SINGLE_CLICK = 0x04,
126 
128  IPO_REPEAT = 0x08
129  };
Handle flip action in the loop by calling the item's flip method.
Allow repeat placement of the item.
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
Handle the rotate action in the loop by calling the item's rotate method.

◆ 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.

Definition at line 77 of file tool_base.h.

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

◆ 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 287 of file pcb_selection_tool.h.

288  {
297  STOP_AT_PAD,
299  STOP_NEVER
300  };
Stop at any place where more than two traces meet.
Stop when reaching a pad.

Constructor & Destructor Documentation

◆ PCB_SELECTION_TOOL()

PCB_SELECTION_TOOL::PCB_SELECTION_TOOL ( )

Definition at line 105 of file pcb_selection_tool.cpp.

105  :
106  PCB_TOOL_BASE( "pcbnew.InteractiveSelection" ),
107  m_frame( nullptr ),
109  m_enteredGroup( nullptr ),
110  m_priv( std::make_unique<PRIV>() )
111 {
112  m_filter.lockedItems = false;
113  m_filter.footprints = true;
114  m_filter.text = true;
115  m_filter.tracks = true;
116  m_filter.vias = true;
117  m_filter.pads = true;
118  m_filter.graphics = true;
119  m_filter.zones = true;
120  m_filter.keepouts = true;
121  m_filter.dimensions = true;
122  m_filter.otherItems = true;
123 }
bool otherItems
Anything not fitting one of the above categories.
PCB_BASE_FRAME * m_frame
bool text
Text (free or attached to a footprint)
bool dimensions
Dimension items.
SELECTION_FILTER_OPTIONS m_filter
bool graphics
Graphic lines, shapes, polygons.
bool footprints
Allow selecting entire footprints.
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool_base.h:77
std::unique_ptr< PRIV > m_priv
bool lockedItems
Allow selecting locked items.

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 126 of file pcb_selection_tool.cpp.

127 {
128  getView()->Remove( &m_selection );
130 
131  Disconnect( wxEVT_TIMER, wxTimerEventHandler( PCB_SELECTION_TOOL::onDisambiguationExpire ), nullptr, this );
132 }
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:350
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_GROUP m_enteredGroupOverlay
PCB_SELECTION m_selection
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, 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:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
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(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_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(), 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(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_TREE::onContextMenu(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ AddItemToSel()

void PCB_SELECTION_TOOL::AddItemToSel ( BOARD_ITEM aItem,
bool  aQuietMode = false 
)

Select all items on the board.

Definition at line 1013 of file pcb_selection_tool.cpp.

1014 {
1015  if( aItem )
1016  {
1017  select( aItem );
1018 
1019  // Inform other potentially interested tools
1020  if( !aQuietMode )
1022  }
1023 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:200
void select(BOARD_ITEM *aItem)
Take necessary action mark an item as selected.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
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(), select(), and EVENTS::SelectedEvent.

Referenced by PCB_CONTROL::DeleteItemCursor(), EDIT_TOOL::FilletTracks(), and SelectItem().

◆ 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 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 165 of file pcb_tool_base.h.

165 { return getModel<BOARD>(); }

Referenced by PCB_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), EDIT_TOOL::ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), BOARD_INSPECTION_TOOL::ClearHighlight(), EDIT_TOOL::copyToClipboard(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), MICROWAVE_TOOL::createInductorBetween(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_CONTROL::DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), BOARD_EDITOR_CONTROL::ExportNetlist(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), filterSelection(), PCB_TOOL_BASE::footprint(), GetBoard(), getCollectorsGuide(), GROUP_TOOL::Group(), ROUTER_TOOL::handleLayerSwitch(), BOARD_INSPECTION_TOOL::highlightNet(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_CONTROL::LayerNext(), PCB_CONTROL::LayerPrev(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), EDIT_TOOL::MoveExact(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), PCB_CONTROL::Paste(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PAD_TOOL::PlacePad(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), RebuildSelection(), PAD_TOOL::recombinePad(), BOARD_EDITOR_CONTROL::RepairBoard(), FOOTPRINT_EDITOR_CONTROL::RepairFootprint(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), Selectable(), selectAllItemsOnNet(), selectAllItemsOnSheet(), selectConnectedTracks(), selectionContains(), selectPoint(), PCB_CONTROL::TrackDisplayMode(), PCB_CONTROL::unfilledZoneCheck(), GROUP_TOOL::Ungroup(), ROUTER_TOOL::updateMessagePanel(), PCB_CONTROL::ViaDisplayMode(), PCB_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), BOARD_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ BrightenItem()

void PCB_SELECTION_TOOL::BrightenItem ( BOARD_ITEM aItem)

Definition at line 1065 of file pcb_selection_tool.cpp.

1066 {
1067  highlight( aItem, BRIGHTENED );
1068 }
void highlight(BOARD_ITEM *aItem, int aHighlightMode, PCB_SELECTION *aGroup=nullptr)
Highlight the item visually.
#define BRIGHTENED
item is drawn with a bright contour

References BRIGHTENED, and highlight().

Referenced by PCB_CONTROL::DeleteItemCursor().

◆ canvas()

◆ ClearSelection() [1/2]

int PCB_SELECTION_TOOL::ClearSelection ( const TOOL_EVENT aEvent)

◆ ClearSelection() [2/2]

void PCB_SELECTION_TOOL::ClearSelection ( bool  aQuietMode = false)

Item selection event handler.

Definition at line 1763 of file pcb_selection_tool.cpp.

1764 {
1765  if( m_selection.Empty() )
1766  return;
1767 
1768  while( m_selection.GetSize() )
1769  unhighlight( static_cast<BOARD_ITEM*>( m_selection.Front() ), SELECTED, &m_selection );
1770 
1771  view()->Update( &m_selection );
1772 
1773  m_selection.SetIsHover( false );
1775 
1776  // Inform other potentially interested tools
1777  if( !aQuietMode )
1778  {
1781  }
1782 }
void ClearReferencePoint()
Definition: selection.h:194
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void SetIsHover(bool aIsHover)
Definition: selection.h:69
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
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
KIGFX::PCB_VIEW * view() const
static const TOOL_EVENT ClearedEvent
Selected item had a property changed (except movement)
Definition: actions.h:202
#define SELECTED
PCB_SELECTION m_selection
static TOOL_ACTION hideDynamicRatsnest
Definition: pcb_actions.h:461
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:98
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:88
void unhighlight(BOARD_ITEM *aItem, int aHighlightMode, PCB_SELECTION *aGroup=nullptr)
Unhighlight the item visually.
EDA_ITEM * Front() const
Definition: selection.h:145

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

◆ controls()

◆ CursorSelection()

int PCB_SELECTION_TOOL::CursorSelection ( const TOOL_EVENT aEvent)

Clear current selection event handler.

Definition at line 934 of file pcb_selection_tool.cpp.

935 {
937 
938  selectCursor( false, aClientFilter );
939 
940  return 0;
941 }
void(* CLIENT_SELECTION_FILTER)(const VECTOR2I &, GENERAL_COLLECTOR &, PCB_SELECTION_TOOL *)
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
bool selectCursor(bool aForceSelect=false, CLIENT_SELECTION_FILTER aClientFilter=nullptr)
Select an item under the cursor unless there is something already selected or aSelectAlways is true.

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 923 of file pcb_selection_tool.cpp.

924 {
925  m_skip_heuristics = true;
927  m_skip_heuristics = false;
928 
929  return 0;
930 }
bool selectPoint(const VECTOR2I &aWhere, bool aOnDrag=false, bool *aSelectionCancelledFlag=nullptr, CLIENT_SELECTION_FILTER aClientFilter=nullptr)
Select an item pointed by the parameter aWhere.
VECTOR2I m_originalCursor

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

Referenced by setTransitions().

◆ displayOptions()

const PCB_DISPLAY_OPTIONS & PCB_TOOL_BASE::displayOptions ( ) const
protectedinherited

◆ doInteractiveItemPlacement()

void PCB_TOOL_BASE::doInteractiveItemPlacement ( const std::string &  aTool,
INTERACTIVE_PLACER_BASE aPlacer,
const wxString &  aCommitMessage,
int  aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT 
)
protectedinherited

Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc.

More complex interactive processes are not supported here, you should implement a customised event loop for those.

Parameters
aItemCreatorthe callable that will attempt to create the item
aCommitMessagethe message used on a successful commit

Definition at line 37 of file pcb_tool_base.cpp.

40 {
41  using namespace std::placeholders;
42  std::unique_ptr<BOARD_ITEM> newItem;
43 
44  frame()->PushTool( aTool );
45 
46  BOARD_COMMIT commit( frame() );
47 
49 
50  Activate();
51  // Must be done after Activate() so that it gets set into the correct context
52  controls()->ShowCursor( true );
53  // do not capture or auto-pan until we start placing an item
54 
55  PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() );
56 
57  // Add a VIEW_GROUP that serves as a preview for the new item
58  PCB_SELECTION preview;
59  view()->Add( &preview );
60 
61  aPlacer->m_board = board();
62  aPlacer->m_frame = frame();
63  aPlacer->m_modifiers = 0;
64 
65  auto makeNewItem =
66  [&]( VECTOR2I aPosition )
67  {
68  if( frame()->GetModel() )
69  newItem = aPlacer->CreateItem();
70 
71  if( newItem )
72  {
73  newItem->SetPosition( (wxPoint) aPosition );
74  preview.Add( newItem.get() );
75 
76  if( newItem->Type() == PCB_FOOTPRINT_T )
77  {
78  FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( newItem.get() );
79 
80  // footprints have more drawable parts
81  fp->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
82  }
83  }
84  };
85 
86  if( aOptions & IPO_SINGLE_CLICK )
87  makeNewItem( controls()->GetCursorPosition() );
88 
89  auto setCursor =
90  [&]()
91  {
92  if( !newItem )
94  else
96  };
97 
98  // Set initial cursor
99  setCursor();
100 
101  // Main loop: keep receiving events
102  while( TOOL_EVENT* evt = Wait() )
103  {
104  setCursor();
105 
106  grid.SetSnap( false ); // Interactive placement tools need to set their own item snaps
107  grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
108  VECTOR2I cursorPos = grid.BestSnapAnchor( controls()->GetMousePosition(), nullptr );
109 
110  aPlacer->m_modifiers = evt->Modifier();
111 
112  auto cleanup =
113  [&] ()
114  {
115  newItem = nullptr;
116  preview.Clear();
117  view()->Update( &preview );
118  controls()->SetAutoPan( false );
119  controls()->CaptureCursor( false );
120  controls()->ShowCursor( true );
121  };
122 
123  if( evt->IsCancelInteractive() )
124  {
125  if( aOptions & IPO_SINGLE_CLICK )
126  {
127  cleanup();
128  frame()->PopTool( aTool );
129  break;
130  }
131  else if( newItem )
132  {
133  cleanup();
134  }
135  else
136  {
137  frame()->PopTool( aTool );
138  break;
139  }
140  }
141  else if( evt->IsActivate() )
142  {
143  if( newItem )
144  cleanup();
145 
146  if( evt->IsPointEditor() )
147  {
148  // don't exit (the point editor runs in the background)
149  }
150  else if( evt->IsMoveTool() )
151  {
152  // leave ourselves on the stack so we come back after the move
153  break;
154  }
155  else
156  {
157  frame()->PopTool( aTool );
158  break;
159  }
160  }
161  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
162  {
163  if( !newItem )
164  {
165  // create the item if possible
166  makeNewItem( cursorPos );
167 
168  // no item created, so wait for another click
169  if( !newItem )
170  continue;
171 
172  controls()->CaptureCursor( true );
173  controls()->SetAutoPan( true );
174  }
175  else
176  {
177  auto oldFlags = newItem->GetFlags();
178  newItem->ClearFlags();
179 
180  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
181  {
182  newItem->SetFlags( oldFlags );
183  continue;
184  }
185 
186  preview.Clear();
187  newItem.release();
188  commit.Push( aCommitMessage );
189 
190  controls()->CaptureCursor( false );
191  controls()->SetAutoPan( false );
192  controls()->ShowCursor( true );
193 
194  if( !( aOptions & IPO_REPEAT ) )
195  break;
196 
197  if( aOptions & IPO_SINGLE_CLICK )
198  makeNewItem( controls()->GetCursorPosition() );
199 
200  setCursor();
201  }
202  }
203  else if( evt->IsClick( BUT_RIGHT ) )
204  {
206  }
207  else if( evt->IsAction( &PCB_ACTIONS::trackViaSizeChanged ) )
208  {
210  }
211  else if( newItem && evt->Category() == TC_COMMAND )
212  {
213  /*
214  * Handle any events that can affect the item as we move it around
215  */
216  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
217  {
218  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
219  newItem->Rotate( newItem->GetPosition(), rotationAngle );
220  view()->Update( &preview );
221  }
222  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
223  {
224  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
225  view()->Update( &preview );
226  }
227  else if( evt->IsAction( &PCB_ACTIONS::properties ) )
228  {
229  frame()->OnEditItemRequest( newItem.get() );
230 
231  // Notify other tools of the changes
233  }
234  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
235  {
236  preview.Clear();
237  newItem.release();
238 
239  makeNewItem( (wxPoint) cursorPos );
240  aPlacer->SnapItem( newItem.get() );
241  view()->Update( &preview );
242  }
243  else
244  {
245  evt->SetPassEvent();
246  }
247  }
248  else if( newItem && evt->IsMotion() )
249  {
250  // track the cursor
251  newItem->SetPosition( (wxPoint) cursorPos );
252  aPlacer->SnapItem( newItem.get() );
253 
254  // Show a preview of the item
255  view()->Update( &preview );
256  }
257  else
258  {
259  evt->SetPassEvent();
260  }
261  }
262 
263  view()->Remove( &preview );
265  controls()->SetAutoPan( false );
266  controls()->CaptureCursor( false );
267 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:83
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
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.
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
Handle flip action in the loop by calling the item's flip method.
BOARD * board() const
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:32
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual void OnEditItemRequest(BOARD_ITEM *aItem)=0
Install the corresponding dialog editor for the given item.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:117
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:299
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:205
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:143
PCB_BASE_EDIT_FRAME * frame() const
virtual void SnapItem(BOARD_ITEM *aItem)
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
const PCB_SELECTION & selection() const
Allow repeat placement of the item.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
Generic, UI-independent tool event.
Definition: tool_event.h:152
KIGFX::PCB_VIEW * view() const
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:57
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:105
Handle the rotate action in the loop by calling the item's rotate method.
KIGFX::VIEW_CONTROLS * controls() const
PCBNEW_SETTINGS & Settings()
void Activate()
Run the tool.
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all BOARD_ITEMs that belong to the footprint (pads, drawings,...
Definition: footprint.cpp:1298
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
PCB_BASE_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:64
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
static TOOL_ACTION refreshPreview
Definition: actions.h:106

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), ARROW, PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL_BASE::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_BASE_FRAME::GetModel(), TOOL_BASE::getView(), grid, PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, PCBNEW_SETTINGS::m_FlipLeftRight, INTERACTIVE_PLACER_BASE::m_frame, TOOL_INTERACTIVE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, TOOL_BASE::m_toolMgr, PCB_BASE_EDIT_FRAME::OnEditItemRequest(), PCB_FOOTPRINT_T, PENCIL, PLACE, INTERACTIVE_PLACER_BASE::PlaceItem(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::ProcessEvent(), PCB_ACTIONS::properties, BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, KIGFX::PCB_VIEW::Remove(), TOOL_MANAGER::RunAction(), FOOTPRINT::RunOnChildren(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, PCB_ACTIONS::trackViaSizeChanged, KIGFX::PCB_VIEW::Update(), PCB_TOOL_BASE::view(), and TOOL_INTERACTIVE::Wait().

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint(), DRAWING_TOOL::DrawVia(), and PAD_TOOL::PlacePad().

◆ doSelectionMenu()

bool PCB_SELECTION_TOOL::doSelectionMenu ( GENERAL_COLLECTOR aItems)
private

Allow the selection of a single item from a list via pop-up menu.

The items are highlighted on the canvas when hovered in the menu. The collector is trimmed to the picked item.

Returns
true if an item was picked

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

Definition at line 1839 of file pcb_selection_tool.cpp.

1840 {
1841  BOARD_ITEM* current = nullptr;
1842  PCB_SELECTION highlightGroup;
1843  bool selectAll = false;
1844  bool expandSelection = false;
1845 
1846  highlightGroup.SetLayer( LAYER_SELECT_OVERLAY );
1847  getView()->Add( &highlightGroup );
1848 
1849  do
1850  {
1852  if( expandSelection )
1853  aCollector->Combine();
1854 
1855  expandSelection = false;
1856 
1857  int limit = std::min( 9, aCollector->GetCount() );
1858  ACTION_MENU menu( true );
1859 
1860  for( int i = 0; i < limit; ++i )
1861  {
1862  wxString text;
1863  BOARD_ITEM* item = ( *aCollector )[i];
1865 
1866  wxString menuText = wxString::Format( "&%d. %s\t%d", i + 1, text, i + 1 );
1867  menu.Add( menuText, i + 1, item->GetMenuImage() );
1868  }
1869 
1870  menu.AppendSeparator();
1871  menu.Add( _( "Select &All\tA" ), limit + 1, BITMAPS::INVALID_BITMAP );
1872 
1873  if( !expandSelection && aCollector->HasAdditionalItems() )
1874  menu.Add( _( "&Expand Selection\tE" ), limit + 2, BITMAPS::INVALID_BITMAP );
1875 
1876  if( aCollector->m_MenuTitle.Length() )
1877  {
1878  menu.SetTitle( aCollector->m_MenuTitle );
1879  menu.SetIcon( BITMAPS::info );
1880  menu.DisplayTitle( true );
1881  }
1882  else
1883  {
1884  menu.DisplayTitle( false );
1885  }
1886 
1887  SetContextMenu( &menu, CMENU_NOW );
1888 
1889  while( TOOL_EVENT* evt = Wait() )
1890  {
1891  if( evt->Action() == TA_CHOICE_MENU_UPDATE )
1892  {
1893  if( selectAll )
1894  {
1895  for( int i = 0; i < aCollector->GetCount(); ++i )
1896  unhighlight( ( *aCollector )[i], BRIGHTENED, &highlightGroup );
1897  }
1898  else if( current )
1899  {
1900  unhighlight( current, BRIGHTENED, &highlightGroup );
1901  }
1902 
1903  int id = *evt->GetCommandId();
1904 
1905  // User has pointed an item, so show it in a different way
1906  if( id > 0 && id <= limit )
1907  {
1908  current = ( *aCollector )[id - 1];
1909  highlight( current, BRIGHTENED, &highlightGroup );
1910  }
1911  else
1912  {
1913  current = nullptr;
1914  }
1915 
1916  // User has pointed on the "Select All" option
1917  if( id == limit + 1 )
1918  {
1919  for( int i = 0; i < aCollector->GetCount(); ++i )
1920  highlight( ( *aCollector )[i], BRIGHTENED, &highlightGroup );
1921  selectAll = true;
1922  }
1923  else
1924  {
1925  selectAll = false;
1926  }
1927  }
1928  else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
1929  {
1930  if( selectAll )
1931  {
1932  for( int i = 0; i < aCollector->GetCount(); ++i )
1933  unhighlight( ( *aCollector )[i], BRIGHTENED, &highlightGroup );
1934  }
1935  else if( current )
1936  {
1937  unhighlight( current, BRIGHTENED, &highlightGroup );
1938  }
1939 
1940  OPT<int> id = evt->GetCommandId();
1941 
1942  // User has selected the "Select All" option
1943  if( id == limit + 1 )
1944  {
1945  selectAll = true;
1946  current = nullptr;
1947  }
1948  else if( id == limit + 2 )
1949  {
1950  expandSelection = true;
1951  selectAll = false;
1952  current = nullptr;
1953  }
1954  // User has selected an item, so this one will be returned
1955  else if( id && ( *id > 0 ) && ( *id <= limit ) )
1956  {
1957  selectAll = false;
1958  current = ( *aCollector )[*id - 1];
1959  }
1960  else
1961  {
1962  selectAll = false;
1963  current = nullptr;
1964  }
1965  }
1966  else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
1967  {
1968  break;
1969  }
1970  }
1971  } while( expandSelection );
1972 
1973  getView()->Remove( &highlightGroup );
1974 
1975  if( selectAll )
1976  {
1977  return true;
1978  }
1979  else if( current )
1980  {
1981  aCollector->Empty();
1982  aCollector->Append( current );
1983  return true;
1984  }
1985 
1986  return false;
1987 }
currently selected items overlay
Definition: layer_ids.h:215
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.
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:48
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:350
void highlight(BOARD_ITEM *aItem, int aHighlightMode, PCB_SELECTION *aGroup=nullptr)
Highlight the item visually.
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Assign a context menu and tells when it should be activated.
PCB_BASE_FRAME * m_frame
Generic, UI-independent tool event.
Definition: tool_event.h:152
#define _(s)
virtual void SetLayer(int aLayer)
Set layer used to draw the group.
Definition: view_group.h:98
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
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
virtual wxString GetSelectMenuText(EDA_UNITS aUnits) const
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: eda_item.cpp:109
virtual BITMAPS GetMenuImage() const
Return a pointer to an image to be used in menus.
Definition: eda_item.cpp:274
boost::optional< T > OPT
Definition: optional.h:7
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:320
void unhighlight(BOARD_ITEM *aItem, int aHighlightMode, PCB_SELECTION *aGroup=nullptr)
Unhighlight the item visually.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
#define BRIGHTENED
item is drawn with a bright contour

References _, KIGFX::VIEW::Add(), COLLECTOR::Append(), BRIGHTENED, CMENU_NOW, COLLECTOR::Combine(), COLLECTOR::Empty(), Format(), COLLECTOR::GetCount(), EDA_ITEM::GetMenuImage(), EDA_ITEM::GetSelectMenuText(), EDA_BASE_FRAME::GetUserUnits(), TOOL_BASE::getView(), COLLECTOR::HasAdditionalItems(), highlight(), info, INVALID_BITMAP, LAYER_SELECT_OVERLAY, m_frame, COLLECTOR::m_MenuTitle, KIGFX::VIEW::Remove(), TOOL_INTERACTIVE::SetContextMenu(), KIGFX::VIEW_GROUP::SetLayer(), TA_CHOICE_MENU_CHOICE, TA_CHOICE_MENU_CLOSED, TA_CHOICE_MENU_UPDATE, text, unhighlight(), and TOOL_INTERACTIVE::Wait().

Referenced by SelectionMenu(), and selectPoint().

◆ EnterGroup()

void PCB_SELECTION_TOOL::EnterGroup ( )

Definition at line 464 of file pcb_selection_tool.cpp.

465 {
466  wxCHECK_RET( m_selection.GetSize() == 1 && m_selection[0]->Type() == PCB_GROUP_T,
467  "EnterGroup called when selection is not a single group" );
468  PCB_GROUP* aGroup = static_cast<PCB_GROUP*>( m_selection[0] );
469 
470  if( m_enteredGroup != nullptr )
471  ExitGroup();
472 
473  ClearSelection();
474  m_enteredGroup = aGroup;
476  m_enteredGroup->RunOnChildren( [&]( BOARD_ITEM* titem )
477  {
478  select( titem );
479  } );
480 
482 }
void select(BOARD_ITEM *aItem)
Take necessary action mark an item as selected.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
KIGFX::VIEW_GROUP m_enteredGroupOverlay
PCB_SELECTION m_selection
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:57
void ExitGroup(bool aSelectGroup=false)
Leave the currently entered group.
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:88
#define ENTERED
indicates a group has been entered
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all members of the group.
Definition: pcb_group.cpp:343
int ClearSelection(const TOOL_EVENT &aEvent)

References KIGFX::VIEW_GROUP::Add(), ClearSelection(), ENTERED, ExitGroup(), SELECTION::GetSize(), m_enteredGroup, m_enteredGroupOverlay, m_selection, PCB_GROUP_T, PCB_GROUP::RunOnChildren(), select(), and EDA_ITEM::SetFlags().

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

◆ ExitGroup()

void PCB_SELECTION_TOOL::ExitGroup ( bool  aSelectGroup = false)

Leave the currently entered group.

Parameters
aSelectGroupwhen true will select the group after leaving

Definition at line 485 of file pcb_selection_tool.cpp.

486 {
487  // Only continue if there is a group entered
488  if( m_enteredGroup == nullptr )
489  return;
490 
492  ClearSelection();
493 
494  if( aSelectGroup )
496 
498  m_enteredGroup = nullptr;
499 }
void select(BOARD_ITEM *aItem)
Take necessary action mark an item as selected.
virtual void Clear()
Remove all the stored items from the group.
Definition: view_group.cpp:69
KIGFX::VIEW_GROUP m_enteredGroupOverlay
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
#define ENTERED
indicates a group has been entered
int ClearSelection(const TOOL_EVENT &aEvent)

References KIGFX::VIEW_GROUP::Clear(), EDA_ITEM::ClearFlags(), ClearSelection(), ENTERED, m_enteredGroup, m_enteredGroupOverlay, and select().

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

◆ expandConnection()

int PCB_SELECTION_TOOL::expandConnection ( const TOOL_EVENT aEvent)
private

Expand the current track selection to the next boundary (junctions, pads, or all)

Definition at line 1097 of file pcb_selection_tool.cpp.

1098 {
1099  unsigned initialCount = 0;
1100 
1101  for( const EDA_ITEM* item : m_selection.GetItems() )
1102  {
1103  if( dynamic_cast<const BOARD_CONNECTED_ITEM*>( item ) )
1104  initialCount++;
1105  }
1106 
1107  if( initialCount == 0 )
1109 
1110  for( STOP_CONDITION stopCondition : { STOP_AT_JUNCTION, STOP_AT_PAD, STOP_NEVER } )
1111  {
1112  // copy the selection, since we're going to iterate and modify
1113  std::deque<EDA_ITEM*> selectedItems = m_selection.GetItems();
1114 
1115  for( EDA_ITEM* item : selectedItems )
1116  item->ClearTempFlags();
1117 
1118  for( EDA_ITEM* item : selectedItems )
1119  {
1120  PCB_TRACK* trackItem = dynamic_cast<PCB_TRACK*>( item );
1121 
1122  // Track items marked SKIP_STRUCT have already been visited
1123  if( trackItem && !( trackItem->GetFlags() & SKIP_STRUCT ) )
1124  selectConnectedTracks( *trackItem, stopCondition );
1125  }
1126 
1127  if( m_selection.GetItems().size() > initialCount )
1128  break;
1129  }
1130 
1131  // Inform other potentially interested tools
1132  if( m_selection.Size() > 0 )
1134 
1135  return 0;
1136 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:200
Stop at any place where more than two traces meet.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
Stop when reaching a pad.
void selectConnectedTracks(BOARD_CONNECTED_ITEM &aSourceItem, STOP_CONDITION aStopCondition)
Select connected tracks and vias.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
void connectedItemFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector, PCB_SELECTION_TOOL *sTool)
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:109
PCB_SELECTION m_selection
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:154
bool selectCursor(bool aForceSelect=false, CLIENT_SELECTION_FILTER aClientFilter=nullptr)
Select an item under the cursor unless there is something already selected or aSelectAlways is true.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
int Size() const
Returns the number of selected parts.
Definition: selection.h:104
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99

References connectedItemFilter(), EDA_ITEM::GetFlags(), SELECTION::GetItems(), m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), selectConnectedTracks(), selectCursor(), EVENTS::SelectedEvent, SELECTION::Size(), SKIP_STRUCT, STOP_AT_JUNCTION, STOP_AT_PAD, and STOP_NEVER.

Referenced by setTransitions().

◆ FilterCollectedItems()

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

Definition at line 1651 of file pcb_selection_tool.cpp.

1652 {
1653  if( aCollector.GetCount() == 0 )
1654  return;
1655 
1656  std::set<BOARD_ITEM*> rejected;
1657 
1658  for( EDA_ITEM* i : aCollector )
1659  {
1660  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( i );
1661 
1662  if( !itemPassesFilter( item, aMultiSelect ) )
1663  rejected.insert( item );
1664  }
1665 
1666  for( BOARD_ITEM* item : rejected )
1667  aCollector.Remove( item );
1668 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
bool itemPassesFilter(BOARD_ITEM *aItem, bool aMultiSelect)
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99

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

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, upgrade any pad selection to the selection of its parent footprint.

Definition at line 2684 of file pcb_selection_tool.cpp.

2685 {
2686  std::set<BOARD_ITEM*> to_add;
2687 
2688  // Iterate from the back so we don't have to worry about removals.
2689  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
2690  {
2691  BOARD_ITEM* item = aCollector[i];
2692 
2693  if( !IsFootprintEditor() && item->Type() == PCB_PAD_T
2694  && !frame()->Settings().m_AllowFreePads )
2695  {
2696  if( !aCollector.HasItem( item->GetParent() ) )
2697  to_add.insert( item->GetParent() );
2698 
2699  aCollector.Remove( item );
2700  }
2701  }
2702 
2703  for( BOARD_ITEM* item : to_add )
2704  aCollector.Append( item );
2705 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PAD, a pad in a footprint
Definition: typeinfo.h:89
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:110
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:100
PCB_BASE_EDIT_FRAME * frame() const
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
bool HasItem(const EDA_ITEM *aItem) const
Tests if aItem has already been collected.
Definition: collector.h:196
PCBNEW_SETTINGS & Settings()
bool IsFootprintEditor() const
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References COLLECTOR::Append(), PCB_TOOL_BASE::frame(), COLLECTOR::GetCount(), BOARD_ITEM::GetParent(), COLLECTOR::HasItem(), PCB_TOOL_BASE::IsFootprintEditor(), PCBNEW_SETTINGS::m_AllowFreePads, PCB_PAD_T, COLLECTOR::Remove(), PCB_BASE_FRAME::Settings(), and EDA_ITEM::Type().

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

◆ 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 2614 of file pcb_selection_tool.cpp.

2616 {
2617  std::unordered_set<BOARD_ITEM*> toAdd;
2618 
2619  // Set TEMP_SELECTED on all parents which are included in the GENERAL_COLLECTOR. This
2620  // algorithm is O3n, whereas checking for the parent inclusion could potentially be On^2.
2621  for( int j = 0; j < aCollector.GetCount(); j++ )
2622  {
2623  if( aCollector[j]->GetParent() )
2624  aCollector[j]->GetParent()->ClearFlags( TEMP_SELECTED );
2625  }
2626 
2627  if( aMultiselect )
2628  {
2629  for( int j = 0; j < aCollector.GetCount(); j++ )
2630  aCollector[j]->SetFlags( TEMP_SELECTED );
2631  }
2632 
2633  for( int j = 0; j < aCollector.GetCount(); )
2634  {
2635  BOARD_ITEM* item = aCollector[j];
2636  BOARD_ITEM* parent = item->GetParent();
2637  BOARD_ITEM* start = item;
2638 
2639  if( !m_isFootprintEditor && parent && parent->Type() == PCB_FOOTPRINT_T )
2640  start = parent;
2641 
2642  // If any element is a member of a group, replace those elements with the top containing
2643  // group.
2645 
2646  if( aTop )
2647  {
2648  if( aTop != item )
2649  {
2650  toAdd.insert( aTop );
2651  aTop->SetFlags( TEMP_SELECTED );
2652 
2653  aCollector.Remove( item );
2654  continue;
2655  }
2656  }
2657  else if( m_enteredGroup
2659  {
2660  // If a group is entered, disallow selections of objects outside the group.
2661  aCollector.Remove( item );
2662  continue;
2663  }
2664 
2665  // Footprints are a bit easier as they can't be nested.
2666  if( parent && ( parent->GetFlags() & TEMP_SELECTED ) )
2667  {
2668  // Remove children of selected items
2669  aCollector.Remove( item );
2670  continue;
2671  }
2672 
2673  ++j;
2674  }
2675 
2676  for( BOARD_ITEM* item : toAdd )
2677  {
2678  if( !aCollector.HasItem( item ) )
2679  aCollector.Append( item );
2680  }
2681 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
static PCB_GROUP * TopLevelGroup(BOARD_ITEM *aItem, PCB_GROUP *aScope, bool isFootprintEditor)
Definition: pcb_group.cpp:100
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:110
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:100
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
bool HasItem(const EDA_ITEM *aItem) const
Tests if aItem has already been collected.
Definition: collector.h:196
static bool WithinScope(BOARD_ITEM *aItem, PCB_GROUP *aScope, bool isFootprintEditor)
Definition: pcb_group.cpp:108
bool m_isFootprintEditor
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:154
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
#define TEMP_SELECTED
flag indicating that the structure has already selected
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References COLLECTOR::Append(), COLLECTOR::GetCount(), EDA_ITEM::GetFlags(), BOARD_ITEM::GetParent(), COLLECTOR::HasItem(), m_enteredGroup, PCB_TOOL_BASE::m_isFootprintEditor, PCB_FOOTPRINT_T, COLLECTOR::Remove(), EDA_ITEM::SetFlags(), TEMP_SELECTED, 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(), GLOBAL_EDIT_TOOL::RemoveUnusedPads(), EDIT_TOOL::Rotate(), SelectAll(), selectMultiple(), and selectPoint().

◆ FilterCollectorForMarkers()

void PCB_SELECTION_TOOL::FilterCollectorForMarkers ( GENERAL_COLLECTOR aCollector) const

Apply the SELECTION_FILTER_OPTIONS to a collection of items.

Definition at line 2708 of file pcb_selection_tool.cpp.

2709 {
2710  // Iterate from the back so we don't have to worry about removals.
2711  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
2712  {
2713  BOARD_ITEM* item = aCollector[i];
2714 
2715  if( item->Type() == PCB_MARKER_T )
2716  aCollector.Remove( item );
2717  }
2718 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:110
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:98
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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(), and EDIT_TOOL::Rotate().

◆ 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 1619 of file pcb_selection_tool.cpp.

1620 {
1621  const BOARD& board = *getModel<BOARD>();
1622  DIALOG_FILTER_SELECTION::OPTIONS& opts = m_priv->m_filterOpts;
1623  DIALOG_FILTER_SELECTION dlg( m_frame, opts );
1624 
1625  const int cmd = dlg.ShowModal();
1626 
1627  if( cmd != wxID_OK )
1628  return 0;
1629 
1630  // copy current selection
1631  std::deque<EDA_ITEM*> selection = m_selection.GetItems();
1632 
1633  ClearSelection( true /*quiet mode*/ );
1634 
1635  // re-select items from the saved selection according to the dialog options
1636  for( EDA_ITEM* i : selection )
1637  {
1638  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( i );
1639  bool include = itemIsIncludedByFilter( *item, board, opts );
1640 
1641  if( include )
1642  select( item );
1643  }
1644 
1646 
1647  return 0;
1648 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:200
void select(BOARD_ITEM *aItem)
Take necessary action mark an item as selected.
BOARD * board() const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
Struct that will be set with the result of the user choices in the dialog.
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.
PCB_BASE_FRAME * m_frame
const PCB_SELECTION & selection() const
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:109
PCB_SELECTION m_selection
std::unique_ptr< PRIV > m_priv
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
int ClearSelection(const TOOL_EVENT &aEvent)

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

Referenced by setTransitions().

◆ FindItem()

void PCB_SELECTION_TOOL::FindItem ( BOARD_ITEM aItem)

Handle finding an item.

Does not do the actual searching, is called by the find dialog.

Parameters
aItemItem that was found and needs to be handled.

Definition at line 1522 of file pcb_selection_tool.cpp.

1523 {
1524  bool cleared = false;
1525 
1526  if( m_selection.GetSize() > 0 )
1527  {
1528  // Don't fire an event now; most of the time it will be redundant as we're about to
1529  // fire a SelectedEvent.
1530  cleared = true;
1531  ClearSelection( true /*quiet mode*/ );
1532  }
1533 
1534  if( aItem )
1535  {
1536  select( aItem );
1537  m_frame->FocusOnLocation( aItem->GetPosition() );
1538 
1539  // Inform other potentially interested tools
1541  }
1542  else if( cleared )
1543  {
1545  }
1546 
1548 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:200
void ForceRefresh()
Force a redraw.
void select(BOARD_ITEM *aItem)
Take necessary action mark an item as selected.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual wxPoint GetPosition() const
Definition: eda_item.h:251
PCB_BASE_FRAME * m_frame
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
static const TOOL_EVENT ClearedEvent
Selected item had a property changed (except movement)
Definition: actions.h:202
PCB_SELECTION m_selection
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:88
int ClearSelection(const TOOL_EVENT &aEvent)
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions.

References EVENTS::ClearedEvent, ClearSelection(), EDA_DRAW_FRAME::FocusOnLocation(), EDA_DRAW_PANEL_GAL::ForceRefresh(), PCB_BASE_FRAME::GetCanvas(), EDA_ITEM::GetPosition(), SELECTION::GetSize(), m_frame, m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), select(), and EVENTS::SelectedEvent.

Referenced by PCB_EDIT_FRAME::FindNext(), and PCB_EDIT_FRAME::ShowFindDialog().

◆ footprint()

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 160 of file pcb_tool_base.h.

161  {
162  return getEditFrame<PCB_BASE_EDIT_FRAME>();
163  }

Referenced by PCB_POINT_EDITOR::addCorner(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), ROUTER_TOOL::CustomTrackWidthDialog(), FOOTPRINT_EDITOR_CONTROL::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), ROUTER_TOOL::DpDimensionsDialog(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EditPad(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), BOARD_EDITOR_CONTROL::ExportSpecctraDSN(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), FilterCollectorForFreePads(), ROUTER_TOOL::finishInteractive(), EDIT_TOOL::Flip(), PCB_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), ROUTER_TOOL::handleLayerSwitch(), BOARD_INSPECTION_TOOL::HighlightItem(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), BOARD_EDITOR_CONTROL::ImportSpecctraSession(), ROUTER_TOOL::Init(), SCRIPTING_TOOL::Init(), Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_TOOL_BASE::Is45Limited(), PCB_PICKER_TOOL::Main(), Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MoveExact(), PCB_POINT_EDITOR::OnSelectionChange(), PCB_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), PAD_TOOL::recombinePad(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), SCRIPTING_TOOL::reloadPlugins(), EDIT_TOOL::Remove(), PCB_POINT_EDITOR::removeCorner(), RequestSelection(), PNS::TOOL_BASE::Reset(), EDIT_TOOL::Rotate(), ROUTER_TOOL::SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_POINT_EDITOR::setEditedPoint(), ROUTER_TOOL::SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), ROUTER_TOOL::switchLayerOnViaPlacement(), PCB_CONTROL::unfilledZoneCheck(), ROUTER_TOOL::updateMessagePanel(), EDIT_TOOL::updateModificationPoint(), BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ GetBoard()

BOARD* PCB_SELECTION_TOOL::GetBoard ( ) const
inline

Definition at line 184 of file pcb_selection_tool.h.

185  {
186  return board();
187  }
BOARD * board() const

References PCB_TOOL_BASE::board().

Referenced by GROUP_CONTEXT_MENU::update().

◆ getCollectorsGuide()

const GENERAL_COLLECTORS_GUIDE PCB_SELECTION_TOOL::getCollectorsGuide ( ) const
private

Definition at line 629 of file pcb_selection_tool.cpp.

630 {
631  GENERAL_COLLECTORS_GUIDE guide( board()->GetVisibleLayers(),
632  (PCB_LAYER_ID) view()->GetTopLayer(), view() );
633 
634  bool padsDisabled = !board()->IsElementVisible( LAYER_PADS );
635 
636  // account for the globals
637  guide.SetIgnoreMTextsMarkedNoShow( ! board()->IsElementVisible( LAYER_MOD_TEXT_INVISIBLE ) );
638  guide.SetIgnoreMTextsOnBack( ! board()->IsElementVisible( LAYER_MOD_TEXT ) );
639  guide.SetIgnoreMTextsOnFront( ! board()->IsElementVisible( LAYER_MOD_TEXT ) );
640  guide.SetIgnoreModulesOnBack( ! board()->IsElementVisible( LAYER_MOD_BK ) );
641  guide.SetIgnoreModulesOnFront( ! board()->IsElementVisible( LAYER_MOD_FR ) );
642  guide.SetIgnorePadsOnBack( padsDisabled || ! board()->IsElementVisible( LAYER_PAD_BK ) );
643  guide.SetIgnorePadsOnFront( padsDisabled || ! board()->IsElementVisible( LAYER_PAD_FR ) );
644  guide.SetIgnoreThroughHolePads( padsDisabled || ! board()->IsElementVisible( LAYER_PADS_TH ) );
645  guide.SetIgnoreModulesVals( ! board()->IsElementVisible( LAYER_MOD_VALUES ) );
646  guide.SetIgnoreModulesRefs( ! board()->IsElementVisible( LAYER_MOD_REFERENCES ) );
647  guide.SetIgnoreThroughVias( ! board()->IsElementVisible( LAYER_VIAS ) );
648  guide.SetIgnoreBlindBuriedVias( ! board()->IsElementVisible( LAYER_VIAS ) );
649  guide.SetIgnoreMicroVias( ! board()->IsElementVisible( LAYER_VIAS ) );
650  guide.SetIgnoreTracks( ! board()->IsElementVisible( LAYER_TRACKS ) );
651 
652  return guide;
653 }
smd pads, front layer
Definition: layer_ids.h:198
BOARD * board() const
Meta control for all pads opacity/visibility (color ignored)
Definition: layer_ids.h:226
show footprints values (when texts are visible)
Definition: layer_ids.h:206
smd pads, back layer
Definition: layer_ids.h:199
show footprints on back
Definition: layer_ids.h:205
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:189
text marked as invisible
Definition: layer_ids.h:196
show footprints on front
Definition: layer_ids.h:204
KIGFX::PCB_VIEW * view() const
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:533
show footprints references (when texts are visible)
Definition: layer_ids.h:207
multilayer pads, usually with holes
Definition: layer_ids.h:209
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:377

References PCB_TOOL_BASE::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 PCB_TOOL_BASE::view().

Referenced by selectionContains(), 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 184 of file tool_base.h.

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

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetEnteredGroup()

PCB_GROUP* PCB_SELECTION_TOOL::GetEnteredGroup ( )
inline

Definition at line 198 of file pcb_selection_tool.h.

198 { return m_enteredGroup; }

References m_enteredGroup.

Referenced by PCB_CONTROL::placeBoardItems(), and EDIT_TOOL::Remove().

◆ 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 120 of file tool_base.h.

121  {
122  return m_toolId;
123  }
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209

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

Return the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER or NULL if there is no associated tool manager.

Definition at line 143 of file tool_base.h.

144  {
145  return m_toolMgr;
146  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), LIB_TREE::onContextMenu(), ZONE_CREATE_HELPER::OnFirstPoint(), ACTION_MENU::OnMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ 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 196 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

◆ 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 133 of file tool_base.h.

134  {
135  return m_toolName;
136  }
std::string m_toolName
Definition: tool_base.h:213

References TOOL_BASE::m_toolName.

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

◆ GetSelection()

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 108 of file tool_base.h.

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

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:283
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

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(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), ROUTER_TOOL::handleCommonEvents(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), PL_EDIT_TOOL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), BOARD_EDITOR_CONTROL::PlaceTarget(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), BOARD_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), Selectable(), SelectAll(), EE_SELECTION_TOOL::SelectAll(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SCH_DRAWING_TOOLS::TwoClickPlace(), PL_SELECTION_TOOL::unhighlight(), EE_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_EDITOR_CONTROL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), 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 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:285

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

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), SCH_DRAWING_TOOLS::createSheetPin(), COMMON_TOOLS::CursorControl(), 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(), 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_DRAWING_TOOLS::GetCanvasFreeAreaPixels(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), 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(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), PCB_POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PCB_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), PL_POINT_EDITOR::setEditedPoint(), EE_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_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 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by AUTOPLACE_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), BOARD_REANNOTATE_TOOL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), PCB_PICKER_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), SYMBOL_EDITOR_PIN_TOOL::setTransitions(), SYMBOL_EDITOR_MOVE_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), ROUTER_TOOL::setTransitions(), SCRIPTING_TOOL::setTransitions(), COMMON_CONTROL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), CONVERT_TOOL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PAD_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), SCH_EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), DRC_TOOL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), PCB_CONTROL::setTransitions(), CVPCB_CONTROL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), setTransitions(), PL_SELECTION_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), and EE_SELECTION_TOOL::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
aCollectoris the collector that has a list of items to be queried.
aWhereis the selection point to consider

Definition at line 2450 of file pcb_selection_tool.cpp.

2452 {
2453  std::set<BOARD_ITEM*> preferred;
2454  std::set<BOARD_ITEM*> rejected;
2455  wxPoint where( aWhere.x, aWhere.y );
2456 
2457  PCB_LAYER_ID activeLayer = m_frame->GetActiveLayer();
2458  LSET silkLayers( 2, B_SilkS, F_SilkS );
2459 
2460  if( silkLayers[activeLayer] )
2461  {
2462  for( int i = 0; i < aCollector.GetCount(); ++i )
2463  {
2464  BOARD_ITEM* item = aCollector[i];
2465  KICAD_T type = item->Type();
2466 
2467  if( ( type == PCB_FP_TEXT_T || type == PCB_TEXT_T || type == PCB_SHAPE_T )
2468  && silkLayers[item->GetLayer()] )
2469  {
2470  preferred.insert( item );
2471  }
2472  }
2473 
2474  if( preferred.size() > 0 )
2475  {
2476  aCollector.Empty();
2477 
2478  for( BOARD_ITEM* item : preferred )
2479  aCollector.Append( item );
2480 
2481  return;
2482  }
2483  }
2484 
2485  // Prefer exact hits to sloppy ones
2486  constexpr int MAX_SLOP = 5;
2487 
2488  int pixel = (int) aCollector.GetGuide()->OnePixelInIU();
2489  int minSlop = INT_MAX;
2490 
2491  std::map<BOARD_ITEM*, int> itemsBySloppiness;
2492 
2493  for( int i = 0; i < aCollector.GetCount(); ++i )
2494  {
2495  BOARD_ITEM* item = aCollector[i];
2496  int itemSlop = hitTestDistance( where, item, MAX_SLOP * pixel );
2497 
2498  itemsBySloppiness[ item ] = itemSlop;
2499 
2500  if( itemSlop < minSlop )
2501  minSlop = itemSlop;
2502  }
2503 
2504  // Prune sloppier items
2505  if( minSlop < INT_MAX )
2506  {
2507  for( std::pair<BOARD_ITEM*, int> pair : itemsBySloppiness )
2508  {
2509  if( pair.second > minSlop + pixel )
2510  aCollector.Transfer( pair.first );
2511  }
2512  }
2513 
2514  // If the user clicked on a small item within a much larger one then it's pretty clear
2515  // they're trying to select the smaller one.
2516  constexpr double sizeRatio = 1.5;
2517 
2518  std::vector<std::pair<BOARD_ITEM*, double>> itemsByArea;
2519 
2520  for( int i = 0; i < aCollector.GetCount(); ++i )
2521  {
2522  BOARD_ITEM* item = aCollector[i];
2523  double area;
2524 
2525  if( ( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
2526  && static_cast<ZONE*>( item )->HitTestForEdge( where, MAX_SLOP * pixel / 2 ) )
2527  {
2528  // Zone borders are very specific, so make them "small"
2529  area = MAX_SLOP * SEG::Square( pixel );
2530  }
2531  else if( item->Type() == PCB_VIA_T )
2532  {
2533  // Vias rarely hide other things, and we don't want them deferring to short track
2534  // segments underneath them -- so artificially reduce their size from πr² to 1.5r².
2535  area = SEG::Square( static_cast<PCB_VIA*>( item )->GetDrill() / 2 ) * 1.5;
2536  }
2537  else
2538  {
2539  try
2540  {
2541  area = FOOTPRINT::GetCoverageArea( item, aCollector );
2542  }
2543  catch( const ClipperLib::clipperException& e )
2544  {
2545  wxLogError( "A clipper exception %s was detected.", e.what() );
2546  }
2547  }
2548 
2549  itemsByArea.emplace_back( item, area );
2550  }
2551 
2552  std::sort( itemsByArea.begin(), itemsByArea.end(),
2553  []( const std::pair<BOARD_ITEM*, double>& lhs,
2554  const std::pair<BOARD_ITEM*, double>& rhs ) -> bool
2555  {
2556  return lhs.second < rhs.second;
2557  } );
2558 
2559  bool rejecting = false;
2560 
2561  for( int i = 1; i < (int) itemsByArea.size(); ++i )
2562  {
2563  if( itemsByArea[i].second > itemsByArea[i-1].second * sizeRatio )
2564  rejecting = true;
2565 
2566  if( rejecting )
2567  rejected.insert( itemsByArea[i].first );
2568  }
2569 
2570  // Special case: if a footprint is completely covered with other features then there's no
2571  // way to select it -- so we need to leave it in the list for user disambiguation.
2572  constexpr double maxCoverRatio = 0.70;
2573 
2574  for( int i = 0; i < aCollector.GetCount(); ++i )
2575  {
2576  if( FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( aCollector[i] ) )
2577  {
2578  if( footprint->CoverageRatio( aCollector ) > maxCoverRatio )
2579  rejected.erase( footprint );
2580  }
2581  }
2582 
2583  // Hopefully we've now got what the user wanted.
2584  if( (unsigned) aCollector.GetCount() > rejected.size() ) // do not remove everything
2585  {
2586  for( BOARD_ITEM* item : rejected )
2587  aCollector.Transfer( item );
2588  }
2589 
2590  // Finally, what we are left with is a set of items of similar coverage area. We now reject
2591  // any that are not on the active layer, to reduce the number of disambiguation menus shown.
2592  // If the user wants to force-disambiguate, they can either switch layers or use the modifier
2593  // key to force the menu.
2594  if( aCollector.GetCount() > 1 )
2595  {
2596  bool haveItemOnActive = false;
2597  rejected.clear();
2598 
2599  for( int i = 0; i < aCollector.GetCount(); ++i )
2600  {
2601  if( !aCollector[i]->IsOnLayer( activeLayer ) )
2602  rejected.insert( aCollector[i] );
2603  else
2604  haveItemOnActive = true;
2605  }
2606 
2607  if( haveItemOnActive )
2608  for( BOARD_ITEM* item : rejected )
2609  aCollector.Transfer( item );
2610  }
2611 }
void Empty()
Clear the list.
Definition: collector.h:90
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:1870
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
virtual double OnePixelInIU() const =0
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
double CoverageRatio(const GENERAL_COLLECTOR &aCollector) const
Calculate the ratio of total area of the footprint pads and graphical items to the area of the footpr...
Definition: footprint.cpp:1950
static SEG::ecoord Square(int a)
Definition: seg.h:122
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
PCB_BASE_FRAME * m_frame
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:100
virtual PCB_LAYER_ID GetActiveLayer() const
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
void Transfer(int aIndex)
Move the item at aIndex (first position is 0) to the backup list.
Definition: collector.h:152
const COLLECTORS_GUIDE * GetGuide() const
Definition: collectors.h:339
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:505
FOOTPRINT * footprint() const
class ZONE, a copper pour area
Definition: typeinfo.h:105
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
int hitTestDistance(const wxPoint &aWhere, BOARD_ITEM *aItem, int aMaxDistance) const
class ZONE, managed by a footprint
Definition: typeinfo.h:94
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References COLLECTOR::Append(), B_SilkS, FOOTPRINT::CoverageRatio(), COLLECTOR::Empty(), F_SilkS, PCB_TOOL_BASE::footprint(), PCB_BASE_FRAME::GetActiveLayer(), COLLECTOR::GetCount(), FOOTPRINT::GetCoverageArea(), GENERAL_COLLECTOR::GetGuide(), BOARD_ITEM::GetLayer(), hitTestDistance(), m_frame, COLLECTORS_GUIDE::OnePixelInIU(), PCB_FP_TEXT_T, PCB_FP_ZONE_T, PCB_SHAPE_T, PCB_TEXT_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(), and selectPoint().

◆ highlight()

void PCB_SELECTION_TOOL::highlight ( BOARD_ITEM aItem,
int  aHighlightMode,
PCB_SELECTION aGroup = nullptr 
)
private

Highlight the item visually.

Parameters
aItemis an item to be be highlighted.
aHighlightModeshould be either SELECTED or BRIGHTENED
aGroupis the group to add the item to in the BRIGHTENED mode.

Definition at line 2232 of file pcb_selection_tool.cpp.

2233 {
2234  if( aGroup )
2235  aGroup->Add( aItem );
2236 
2237  highlightInternal( aItem, aMode, aGroup != nullptr );
2238  view()->Update( aItem, KIGFX::REPAINT );
2239 
2240  // Many selections are very temporal and updating the display each time just
2241  // creates noise.
2242  if( aMode == BRIGHTENED )
2244 }
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:32
void highlightInternal(BOARD_ITEM *aItem, int aHighlightMode, bool aUsingOverlay)
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
Item needs to be redrawn.
Definition: view_item.h:52
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:609
KIGFX::PCB_VIEW * view() const
Items that may change while the view stays the same (noncached)
Definition: definitions.h:50
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
#define BRIGHTENED
item is drawn with a bright contour

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

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

◆ highlightInternal()

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

Definition at line 2247 of file pcb_selection_tool.cpp.

2248 {
2249  if( aMode == SELECTED )
2250  aItem->SetSelected();
2251  else if( aMode == BRIGHTENED )
2252  aItem->SetBrightened();
2253 
2254  if( aUsingOverlay )
2255  view()->Hide( aItem, true ); // Hide the original item, so it is shown only on overlay
2256 
2257  if( aItem->Type() == PCB_FOOTPRINT_T )
2258  {
2259  static_cast<FOOTPRINT*>( aItem )->RunOnChildren(
2260  [&]( BOARD_ITEM* aChild )
2261  {
2262  highlightInternal( aChild, aMode, aUsingOverlay );
2263  } );
2264  }
2265  else if( aItem->Type() == PCB_GROUP_T )
2266  {
2267  static_cast<PCB_GROUP*>( aItem )->RunOnChildren(
2268  [&]( BOARD_ITEM* aChild )
2269  {
2270  highlightInternal( aChild, aMode, aUsingOverlay );
2271  } );
2272  }
2273 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1537
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
void highlightInternal(BOARD_ITEM *aItem, int aHighlightMode, bool aUsingOverlay)
void SetBrightened()
Definition: eda_item.h:129
void SetSelected()
Definition: eda_item.h:128
KIGFX::PCB_VIEW * view() const
#define SELECTED
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
#define BRIGHTENED
item is drawn with a bright contour

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

Referenced by highlight().

◆ hitTestDistance()

int PCB_SELECTION_TOOL::hitTestDistance ( const wxPoint &  aWhere,
BOARD_ITEM aItem,
int  aMaxDistance 
) const
private

Definition at line 2345 of file pcb_selection_tool.cpp.

2347 {
2348  BOX2D viewportD = getView()->GetViewport();
2349  BOX2I viewport( VECTOR2I( viewportD.GetPosition() ), VECTOR2I( viewportD.GetSize() ) );
2350  int distance = INT_MAX;
2351  SEG loc( aWhere, aWhere );
2352 
2353  switch( aItem->Type() )
2354  {
2355  case PCB_TEXT_T:
2356  {
2357  PCB_TEXT* text = static_cast<PCB_TEXT*>( aItem );
2358  text->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &distance );
2359  break;
2360  }
2361 
2362  case PCB_FP_TEXT_T:
2363  {
2364  FP_TEXT* text = static_cast<FP_TEXT*>( aItem );
2365  text->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &distance );
2366  break;
2367  }
2368 
2369  case PCB_ZONE_T:
2370  {
2371  ZONE* zone = static_cast<ZONE*>( aItem );
2372 
2373  // Zone borders are very specific
2374  if( zone->HitTestForEdge( aWhere, aMaxDistance / 2 ) )
2375  distance = 0;
2376  else if( zone->HitTestForEdge( aWhere, aMaxDistance ) )
2377  distance = aMaxDistance / 2;
2378  else
2379  aItem->GetEffectiveShape()->Collide( loc, aMaxDistance, &distance );
2380 
2381  break;
2382  }
2383 
2384  case PCB_FOOTPRINT_T:
2385  {
2386  FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aItem );
2387  EDA_RECT bbox = footprint->GetBoundingBox( false, false );
2388 
2389  try
2390  {
2391  footprint->GetBoundingHull().Collide( loc, aMaxDistance, &distance );
2392  }
2393  catch( const ClipperLib::clipperException& exc )
2394  {
2395  // This may be overkill and could be an assertion but we are more likely to find
2396  // any clipper errors this way.
2397  wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
2398  }
2399 
2400  // Consider footprints larger than the viewport only as a last resort
2401  if( bbox.GetHeight() > viewport.GetHeight() || bbox.GetWidth() > viewport.GetWidth() )
2402  distance = INT_MAX / 2;
2403 
2404  break;
2405  }
2406 
2407  case PCB_MARKER_T:
2408  {
2409  PCB_MARKER* marker = static_cast<PCB_MARKER*>( aItem );
2410  SHAPE_LINE_CHAIN polygon;
2411 
2412  marker->ShapeToPolygon( polygon );
2413  polygon.Move( marker->GetPos() );
2414  polygon.Collide( loc, aMaxDistance, &distance );
2415  break;
2416  }
2417 
2418  case PCB_GROUP_T:
2419  {
2420  PCB_GROUP* group = static_cast<PCB_GROUP*>( aItem );
2421 
2422  for( BOARD_ITEM* member : group->GetItems() )
2423  distance = std::min( distance, hitTestDistance( aWhere, member, aMaxDistance ) );
2424 
2425  break;
2426  }
2427 
2428  default:
2429  aItem->GetEffectiveShape()->Collide( loc, aMaxDistance, &distance );
2430  break;
2431  }
2432 
2433  return distance;
2434 }
const wxPoint & GetPos() const
Definition: marker_base.h:85
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:512
SHAPE_POLY_SET GetBoundingHull() const
Return a bounding polygon for the shapes and pads in the footprint.
Definition: footprint.cpp:847
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
void Move(const VECTOR2I &aVector) override
int GetWidth() const
Definition: eda_rect.h:109
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
FOOTPRINT * footprint() const
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
class ZONE, a copper pour area
Definition: typeinfo.h:105
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
int GetHeight() const
Definition: eda_rect.h:110
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
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.
const Vec & GetPosition() const
Definition: box2.h:177
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:40
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,...
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:98
bool HitTestForEdge(const wxPoint &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX &aCornerHit) const
Test if the given wxPoint is near a segment defined by 2 corners.
Definition: zone.cpp:443
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int hitTestDistance(const wxPoint &aWhere, BOARD_ITEM *aItem, int aMaxDistance) const
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:736
Handle the component boundary box.
Definition: eda_rect.h:42
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: board_item.cpp:169
const Vec & GetSize() const
Definition: box2.h:172
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

Referenced by GuessSelectionCandidates().

◆ 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 PCB_TOOL_BASE.

Definition at line 135 of file pcb_selection_tool.cpp.

136 {
137  auto frame = getEditFrame<PCB_BASE_FRAME>();
138 
141  {
143  return true;
144  }
145 
146  auto selectMenu = std::make_shared<SELECT_MENU>();
147  selectMenu->SetTool( this );
148  m_menu.AddSubMenu( selectMenu );
149 
150  auto& menu = m_menu.GetMenu();
151 
152  auto activeToolCondition =
153  [ frame ] ( const SELECTION& aSel )
154  {
155  return !frame->ToolStackIsEmpty();
156  };
157 
158  auto inGroupCondition =
159  [this] ( const SELECTION& )
160  {
161  return m_enteredGroup != nullptr;
162  };
163 
164  if( frame && frame->IsType( FRAME_PCB_EDITOR ) )
165  {
166  menu.AddMenu( selectMenu.get(), SELECTION_CONDITIONS::NotEmpty );
167  menu.AddSeparator( 1000 );
168  }
169 
170  // "Cancel" goes at the top of the context menu when a tool is active
171  menu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
172  menu.AddItem( PCB_ACTIONS::groupLeave, inGroupCondition, 1 );
173  menu.AddSeparator( 1 );
174 
175  if( frame )
177 
178  m_disambiguateTimer.SetOwner( this );
179  Connect( wxEVT_TIMER, wxTimerEventHandler( PCB_SELECTION_TOOL::onDisambiguationExpire ), nullptr, this );
180 
181  return true;
182 }
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Definition: pcb_group.cpp:39
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
static TOOL_ACTION groupLeave
Definition: pcb_actions.h:432
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
void onDisambiguationExpire(wxTimerEvent &aEvent)
Start the process to show our disambiguation menu once the user has kept the mouse down for the minim...
PCB_BASE_EDIT_FRAME * frame() const
bool ToolStackIsEmpty()
Definition: tools_holder.h:116
wxTimer m_disambiguateTimer
bool IsType(FRAME_T aType) const
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition: tool_menu.cpp:52

References PCB_GROUP::AddItem(), EDA_DRAW_FRAME::AddStandardSubMenus(), TOOL_MENU::AddSubMenu(), ACTIONS::cancelInteractive, PCB_TOOL_BASE::frame(), FRAME_FOOTPRINT_VIEWER, FRAME_FOOTPRINT_VIEWER_MODAL, FRAME_PCB_EDITOR, TOOL_MENU::GetMenu(), PCB_ACTIONS::groupLeave, EDA_BASE_FRAME::IsType(), SELECTION_TOOL::m_disambiguateTimer, m_enteredGroup, TOOL_INTERACTIVE::m_menu, SELECTION_CONDITIONS::NotEmpty(), onDisambiguationExpire(), and TOOLS_HOLDER::ToolStackIsEmpty().

◆ Is45Limited()

bool PCB_TOOL_BASE::Is45Limited ( ) const
virtualinherited

Should the tool use its 45° mode option?

Returns
True if set to use 45°

Definition at line 323 of file pcb_tool_base.cpp.

324 {
325  if( frame()->IsType( FRAME_PCB_EDITOR ) )
327  else
329 }
PCB_BASE_EDIT_FRAME * frame() const
PCBNEW_SETTINGS & Settings()

References PCB_TOOL_BASE::frame(), FRAME_PCB_EDITOR, PCBNEW_SETTINGS::m_FpeditUse45DegreeLimit, PCBNEW_SETTINGS::m_PcbUse45DegreeLimit, and PCB_BASE_FRAME::Settings().

Referenced by DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), and DRAWING_TOOL::DrawZone().

◆ IsFootprintEditor()

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32 {
33  return m_toolMgr->IsToolActive( m_toolId );
34 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
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(), EDIT_TOOL::isRouterActive(), 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 1671 of file pcb_selection_tool.cpp.

1672 {
1673  if( !m_filter.lockedItems )
1674  {
1675  if( aItem->IsLocked() || ( aItem->GetParent() && aItem->GetParent()->IsLocked() ) )
1676  {
1677  if( aItem->Type() == PCB_PAD_T && !aMultiSelect )
1678  {
1679  // allow a single pad to be selected -- there are a lot of operations that
1680  // require this so we allow this one inconsistency
1681  }
1682  else
1683  {
1684  return false;
1685  }
1686  }
1687  }
1688 
1689  switch( aItem->Type() )
1690  {
1691  case PCB_FOOTPRINT_T:
1692  if( !m_filter.footprints )
1693  return false;
1694 
1695  break;
1696 
1697  case PCB_PAD_T:
1698  if( !m_filter.pads )
1699  return false;
1700 
1701  break;
1702 
1703  case PCB_TRACE_T:
1704  case PCB_ARC_T:
1705  if( !m_filter.tracks )
1706  return false;
1707 
1708  break;
1709 
1710  case PCB_VIA_T:
1711  if( !m_filter.vias )
1712  return false;
1713 
1714  break;
1715 
1716  case PCB_FP_ZONE_T:
1717  case PCB_ZONE_T:
1718  {
1719  ZONE* zone = static_cast<ZONE*>( aItem );
1720 
1721  if( ( !m_filter.zones && !zone->GetIsRuleArea() )
1722  || ( !m_filter.keepouts && zone->GetIsRuleArea() ) )
1723  {
1724  return false;
1725  }
1726 
1727  break;
1728  }
1729 
1730  case PCB_FP_SHAPE_T:
1731  case PCB_SHAPE_T:
1732  case PCB_TARGET_T:
1733  if( !m_filter.graphics )
1734  return false;
1735 
1736  break;
1737 
1738  case PCB_FP_TEXT_T:
1739  case PCB_TEXT_T:
1740  if( !m_filter.text )
1741  return false;
1742 
1743  break;
1744 
1745  case PCB_DIM_ALIGNED_T:
1746  case PCB_DIM_CENTER_T:
1747  case PCB_DIM_ORTHOGONAL_T:
1748  case PCB_DIM_LEADER_T:
1749  if( !m_filter.dimensions )
1750  return false;
1751 
1752  break;
1753 
1754  default:
1755  if( !m_filter.otherItems )
1756  return false;
1757  }
1758 
1759  return true;
1760 }
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:100
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:101
bool otherItems
Anything not fitting one of the above categories.
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:733
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:102
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
class PAD, a pad in a footprint
Definition: typeinfo.h:89
virtual bool IsLocked() const
Definition: board_item.cpp:64
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
bool text
Text (free or attached to a footprint)
bool dimensions
Dimension items.
SELECTION_FILTER_OPTIONS m_filter
bool graphics
Graphic lines, shapes, polygons.
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
class ZONE, a copper pour area
Definition: typeinfo.h:105
bool footprints
Allow selecting entire footprints.
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:104
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
bool lockedItems
Allow selecting locked items.
class ZONE, managed by a footprint
Definition: typeinfo.h:94
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:103
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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, SELECTION_FILTER_OPTIONS::otherItems, SELECTION_FILTER_OPTIONS::pads, PCB_ARC_T, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_ZONE_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TARGET_T, PCB_TEXT_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 244 of file pcb_selection_tool.cpp.

245 {
246  // Main loop: keep receiving events
247  while( TOOL_EVENT* evt = Wait() )
248  {
249  MOUSE_DRAG_ACTION dragAction = m_frame->GetDragAction();
251 
252  // on left click, a selection is made, depending on modifiers ALT, SHIFT, CTRL:
253  setModifiersState( evt->Modifier( MD_SHIFT ), evt->Modifier( MD_CTRL ),
254  evt->Modifier( MD_ALT ) );
255 
256  bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or;
257  PCB_BASE_FRAME* frame = getEditFrame<PCB_BASE_FRAME>();
258  bool brd_editor = frame && frame->IsType( FRAME_PCB_EDITOR );
260 
261  // If the router tool is active, don't override
262  if( router && router->IsToolActive() && router->RoutingInProgress() )
263  {
264  evt->SetPassEvent();
265  }
266  else if( evt->IsMouseDown( BUT_LEFT ) )
267  {
268  // Avoid triggering when running under other tools
270 
271  if( m_frame->ToolStackIsEmpty() && pt_tool && !pt_tool->HasPoint() )
272  {
274  m_disambiguateTimer.StartOnce( 500 );
275  }
276  }
277  else if( evt->IsClick( BUT_LEFT ) )
278  {
279  // If there is no disambiguation, this routine is still running and will
280  // register a `click` event when released
281  if( m_disambiguateTimer.IsRunning() )
282  {
283  m_disambiguateTimer.Stop();
284 
285  // Single click? Select single object
286  if( m_highlight_modifier && brd_editor )
288  else
289  {
290  m_frame->FocusOnItem( nullptr );
291  selectPoint( evt->Position() );
292  }
293  }
294 
295  m_canceledMenu = false;
296  }
297  else if( evt->IsClick( BUT_RIGHT ) )
298  {
299  m_disambiguateTimer.Stop();
300 
301  // Right click? if there is any object - show the context menu
302  bool selectionCancelled = false;
303 
304  if( m_selection.Empty() )
305  {
306  selectPoint( evt->Position(), false, &selectionCancelled );
307  m_selection.SetIsHover( true );
308  }
309 
310  if( !selectionCancelled )
312  }
313  else if( evt->IsDblClick( BUT_LEFT ) )
314  {
315  m_disambiguateTimer.Stop();
316 
317  // Double click? Display the properties window
318  m_frame->FocusOnItem( nullptr );
319 
320  if( m_selection.Empty() )
321  selectPoint( evt->Position() );
322 
323  if( m_selection.GetSize() == 1 && m_selection[0]->Type() == PCB_GROUP_T )
324  {
325  EnterGroup();
326  }
327  else
328  {
330  }
331  }
332  else if( evt->IsDblClick( BUT_MIDDLE ) )
333  {
334  // Middle double click? Do zoom to fit or zoom to objects
335  if( evt->Modifier( MD_CTRL ) ) // Is CTRL key down?
337  else
339  }
340  else if( evt->IsDrag( BUT_LEFT ) )
341  {
342  m_disambiguateTimer.Stop();
343 
344  // Is another tool already moving a new object? Don't allow a drag start
345  if( !m_selection.Empty() && m_selection[0]->HasFlag( IS_NEW | IS_MOVING ) )
346  {
347  evt->SetPassEvent();
348  continue;
349  }
350 
351  // Drag with LMB? Select multiple objects (or at least draw a selection box)
352  // or drag them
353  m_frame->FocusOnItem( nullptr );
355 
356  if( modifier_enabled || dragAction == MOUSE_DRAG_ACTION::SELECT )
357  {
358  selectMultiple();
359  }
360  else if( m_selection.Empty() && dragAction != MOUSE_DRAG_ACTION::DRAG_ANY )
361  {
362  selectMultiple();
363  }
364  else
365  {
366  // Don't allow starting a drag from a zone filled area that isn't already selected
367  auto zoneFilledAreaFilter =
368  []( const VECTOR2I& aWhere, GENERAL_COLLECTOR& aCollector,
369  PCB_SELECTION_TOOL* aTool )
370  {
371  wxPoint location = wxPoint( aWhere );
372  int accuracy = KiROUND( 5 * aCollector.GetGuide()->OnePixelInIU() );
373  std::set<EDA_ITEM*> remove;
374 
375  for( EDA_ITEM* item : aCollector )
376  {
377  if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T )
378  {
379  ZONE* zone = static_cast<ZONE*>( item );
380 
381  if( !zone->HitTestForCorner( location, accuracy * 2 ) &&
382  !zone->HitTestForEdge( location, accuracy ) )
383  remove.insert( zone );
384  }
385  }
386 
387  for( EDA_ITEM* item : remove )
388  aCollector.Remove( item );
389  };
390 
391  // Selection is empty? try to start dragging the item under the point where drag
392  // started
393  if( m_selection.Empty() && selectCursor( false, zoneFilledAreaFilter ) )
394  m_selection.SetIsHover( true );
395 
396  // Check if dragging has started within any of selected items bounding box.
397  // We verify "HasPosition()" first to protect against edge case involving
398  // moving off menus that causes problems (issue #5250)
399  if( evt->HasPosition() && selectionContains( evt->Position() ) )
400  {
401  // Yes -> run the move tool and wait till it finishes
402  PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( m_selection.GetItem( 0 ) );
403 
404  // If there is only item in the selection and it's a track, then we need
405  // to route it.
406  bool doRouting = ( track && ( 1 == m_selection.GetSize() ) );
407 
408  if( doRouting && trackDragAction == TRACK_DRAG_ACTION::DRAG )
410  else if( doRouting && trackDragAction == TRACK_DRAG_ACTION::DRAG_FREE_ANGLE )
412  else
414  }
415  else
416  {
417  // No -> drag a selection box
418  selectMultiple();
419  }
420  }
421  }
422  else if( evt->IsCancel() )
423  {
424  m_disambiguateTimer.Stop();
425  m_frame->FocusOnItem( nullptr );
426 
427  if( m_enteredGroup )
428  ExitGroup();
429 
430  ClearSelection();
431  }
432  else
433  {
434  evt->SetPassEvent();
435  }
436 
437 
438  if( m_frame->ToolStackIsEmpty() )
439  {
440  // move cursor prediction
441  if( !modifier_enabled
442  && dragAction == MOUSE_DRAG_ACTION::DRAG_SELECTED
443  && !m_selection.Empty()
444  && evt->HasPosition()
445  && selectionContains( evt->Position() ) )
446  {
448  }
449  else
450  {
452  }
453  }
454  }
455 
456  // Shutting down; clear the selection
457  m_selection.Clear();
458  m_disambiguateTimer.Stop();
459 
460  return 0;
461 }
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:92
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:83
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 IS_NEW
New item, just created.
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
VECTOR2D GetMousePosition() const
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:135
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:117
bool m_highlight_modifier
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:134
static TOOL_ACTION zoomFitObjects
Definition: actions.h:97
TRACK_DRAG_ACTION
bool HitTestForCorner(const wxPoint &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX &aCornerHit) const
Test if the given wxPoint is near a corner.
Definition: zone.cpp:429
bool HasPoint()
Indicate the cursor is over an edit point.
void SetIsHover(bool aIsHover)
Definition: selection.h:69
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 ...
PCB_BASE_FRAME * m_frame
PCB_BASE_EDIT_FRAME * frame() const
MOUSE_DRAG_ACTION
MOUSE_DRAG_ACTION GetDragAction() const
Indicates whether a drag should draw a selection rectangle or drag selected (or unselected) objects.
Definition: tools_holder.h:135
bool selectMultiple()
Handle drawing a selection box that allows one to select many items at the same time.
#define IS_MOVING
Item being moved.
TRACK_DRAG_ACTION m_TrackDragAction
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
bool selectPoint(const VECTOR2I &aWhere, bool aOnDrag=false, bool *aSelectionCancelledFlag=nullptr, CLIENT_SELECTION_FILTER aClientFilter=nullptr)
Select an item pointed by the parameter aWhere.
Generic, UI-independent tool event.
Definition: tool_event.h:152
bool ToolStackIsEmpty()
Definition: tools_holder.h:116
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
class ZONE, a copper pour area
Definition: typeinfo.h:105
bool RoutingInProgress()
Returns whether routing is currently active.
PCB_SELECTION m_selection
wxTimer m_disambiguateTimer
void ExitGroup(bool aSelectGroup=false)
Leave the currently entered group.
void FocusOnItem(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:98
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:88
bool selectCursor(bool aForceSelect=false, CLIENT_SELECTION_FILTER aClientFilter=nullptr)
Select an item under the cursor unless there is something already selected or aSelectAlways is true.
bool HitTestForEdge(const wxPoint &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX &aCornerHit) const
Test if the given wxPoint is near a segment defined by 2 corners.
Definition: zone.cpp:443
Tool that displays edit points allowing to modify items by dragging the points.
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:451
bool IsType(FRAME_T aType) const
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.cpp:53
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
bool IsToolActive() const
Definition: tool_base.cpp:31
class ZONE, managed by a footprint
Definition: typeinfo.h:94
PCBNEW_SETTINGS & Settings()
The selection tool: currently supports:
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:73
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
static const TOOL_EVENT InhibitSelectionEditing
Definition: actions.h:211
VECTOR2I m_originalCursor
bool selectionContains(const VECTOR2I &aPoint) const
int ClearSelection(const TOOL_EVENT &aEvent)
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.

References ARROW, BUT_LEFT, BUT_MIDDLE, BUT_RIGHT, SELECTION::Clear(), ClearSelection(), DRAG, PCB_ACTIONS::drag45Degree, DRAG_ANY, DRAG_FREE_ANGLE, DRAG_SELECTED, PCB_ACTIONS::dragFreeAngle, SELECTION::Empty(), EnterGroup(), ExitGroup(), PCB_BASE_FRAME::FocusOnItem(), PCB_TOOL_BASE::frame(), FRAME_PCB_EDITOR, TOOLS_HOLDER::GetDragAction(), SELECTION::GetItem(), TOOL_MANAGER::GetMousePosition(), SELECTION::GetSize(), TOOL_MANAGER::GetTool(), 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_additive, SELECTION_TOOL::m_canceledMenu, SELECTION_TOOL::m_disambiguateTimer, m_enteredGroup, SELECTION_TOOL::m_exclusive_or, m_frame, SELECTION_TOOL::m_highlight_modifier, TOOL_INTERACTIVE::m_menu, m_nonModifiedCursor, SELECTION_TOOL::m_originalCursor, m_selection, SELECTION_TOOL::m_subtractive, 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, selectCursor(), selectionContains(), selectMultiple(), selectPoint(), SELECTION::SetIsHover(), SELECTION_TOOL::setModifiersState(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), TOOLS_HOLDER::ToolStackIsEmpty(), TOOL_INTERACTIVE::Wait(), ACTIONS::zoomFitObjects, and ACTIONS::zoomFitScreen.

Referenced by setTransitions().

◆ onDisambiguationExpire()

void PCB_SELECTION_TOOL::onDisambiguationExpire ( wxTimerEvent &  aEvent)
private

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 217 of file pcb_selection_tool.cpp.

218 {
220 }
static const TOOL_EVENT DisambiguatePoint
Definition: actions.h:215
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).

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

Referenced by Init(), and ~PCB_SELECTION_TOOL().

◆ OnIdle()

void PCB_SELECTION_TOOL::OnIdle ( wxIdleEvent &  aEvent)

Definition at line 223 of file pcb_selection_tool.cpp.

224 {
225  if( m_frame->ToolStackIsEmpty() && !m_multiple )
226  {
227  wxMouseState keyboardState = wxGetMouseState();
228 
229  setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(),
230  keyboardState.AltDown() );
231 
232  if( m_additive )
234  else if( m_subtractive )
236  else if( m_exclusive_or )
238  else
240  }
241 }
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
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 ...
PCB_BASE_FRAME * m_frame
bool ToolStackIsEmpty()
Definition: tools_holder.h:116

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 1785 of file pcb_selection_tool.cpp.

1786 {
1787  m_selection.Clear();
1788 
1789  bool enteredGroupFound = false;
1790 
1791  INSPECTOR_FUNC inspector =
1792  [&]( EDA_ITEM* item, void* testData )
1793  {
1794  if( item->IsSelected() )
1795  {
1796  EDA_ITEM* parent = item->GetParent();
1797 
1798  // Let selected parents handle their children.
1799  if( parent && parent->IsSelected() )
1800  return SEARCH_RESULT::CONTINUE;
1801 
1802  highlight( (BOARD_ITEM*) item, SELECTED, &m_selection );
1803  }
1804 
1805  if( item == m_enteredGroup )
1806  {
1807  item->SetFlags( ENTERED );
1808  enteredGroupFound = true;
1809  }
1810  else
1811  {
1812  item->ClearFlags( ENTERED );
1813  }
1814 
1815  return SEARCH_RESULT::CONTINUE;
1816  };
1817 
1820 
1821  if( !enteredGroupFound )
1822  {
1824  m_enteredGroup = nullptr;
1825  }
1826 }
static const KICAD_T FootprintItems[]
A scan list for primary footprint items.
Definition: collectors.h:293
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:83
static const KICAD_T AllBoardItems[]
A scan list for all editable board items.
Definition: collectors.h:267
BOARD * board() const
bool IsSelected() const
Definition: eda_item.h:122
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
void highlight(BOARD_ITEM *aItem, int aHighlightMode, PCB_SELECTION *aGroup=nullptr)
Highlight the item visually.
virtual void Clear()
Remove all the stored items from the group.
Definition: view_group.cpp:69
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const 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:1181
std::function< SEARCH_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:68
KIGFX::VIEW_GROUP m_enteredGroupOverlay
EDA_ITEM * GetParent() const
Definition: eda_item.h:114
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
#define SELECTED
PCB_SELECTION m_selection
bool m_isFootprintEditor
#define ENTERED
indicates a group has been entered
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99

References GENERAL_COLLECTOR::AllBoardItems, PCB_TOOL_BASE::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, PCB_TOOL_BASE::m_isFootprintEditor, m_selection, SELECTED, EDA_ITEM::SetFlags(), and BOARD::Visit().

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

◆ RemoveItemFromSel()

void PCB_SELECTION_TOOL::RemoveItemFromSel ( BOARD_ITEM aItem,
bool  aQuietMode = false 
)

Multiple item unselection event handler.

Definition at line 1050 of file pcb_selection_tool.cpp.

1051 {
1052  if( aItem )
1053  {
1054  unselect( aItem );
1055 
1056  if( !aQuietMode )
1057  {
1058  // Inform other potentially interested tools
1060  }
1061  }
1062 }
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:201
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
void unselect(BOARD_ITEM *aItem)
Take necessary action mark an item as unselected.

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

Referenced by EDIT_TOOL::Properties(), BOARD_COMMIT::Push(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow(), and UnselectItem().

◆ RequestSelection()

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

Return the current selection set, filtered according to aFlags and aClientFilter.

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

Parameters
aConfirmLockedItemsif true the user will be prompted 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 508 of file pcb_selection_tool.cpp.

510 {
511  bool selectionEmpty = m_selection.Empty();
512  m_selection.SetIsHover( selectionEmpty );
513 
514  if( selectionEmpty )
515  {
516  m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true, aClientFilter );
518  }
519 
520  if( aClientFilter )
521  {
522  enum DISPOSITION { BEFORE = 1, AFTER, BOTH };
523 
524  std::map<EDA_ITEM*, DISPOSITION> itemDispositions;
525  GENERAL_COLLECTOR collector;
526 
527  for( EDA_ITEM* item : m_selection )
528  {
529  collector.Append( item );
530  itemDispositions[ item ] = BEFORE;
531  }
532 
533  aClientFilter( VECTOR2I(), collector, this );
534 
535  for( EDA_ITEM* item : collector )
536  {
537  if( itemDispositions.count( item ) )
538  itemDispositions[ item ] = BOTH;
539  else
540  itemDispositions[ item ] = AFTER;
541  }
542 
543  // Unhighlight the BEFORE items before highlighting the AFTER items.
544  // This is so that in the case of groups, if aClientFilter replaces a selection
545  // with the enclosing group, the unhighlight of the element doesn't undo the
546  // recursive highlighting of that element by the group.
547 
548  for( std::pair<EDA_ITEM* const, DISPOSITION> itemDisposition : itemDispositions )
549  {
550  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( itemDisposition.first );
551  DISPOSITION disposition = itemDisposition.second;
552 
553  if( disposition == BEFORE )
554  unhighlight( item, SELECTED, &m_selection );
555  }
556 
557  for( std::pair<EDA_ITEM* const, DISPOSITION> itemDisposition : itemDispositions )
558  {
559  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( itemDisposition.first );
560  DISPOSITION disposition = itemDisposition.second;
561 
562  // Note that we must re-highlight even previously-highlighted items
563  // (ie: disposition BOTH) in case we removed any of their children.
564  if( disposition == AFTER || disposition == BOTH )
565  highlight( item, SELECTED, &m_selection );
566  }
567 
569  }
570 
571  if( aConfirmLockedItems )
572  {
573  std::vector<BOARD_ITEM*> lockedItems;
574 
575  for( EDA_ITEM* item : m_selection )
576  {
577  BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
578 
579  if( boardItem->Type() == PCB_GROUP_T )
580  {
581  PCB_GROUP* group = static_cast<PCB_GROUP*>( boardItem );
582  bool lockedDescendant = false;
583 
584  group->RunOnDescendants(
585  [&lockedDescendant]( BOARD_ITEM* child )
586  {
587  if( child->IsLocked() )
588  lockedDescendant = true;
589  } );
590 
591  if( lockedDescendant )
592  lockedItems.push_back( group );
593  }
594  else if( boardItem->IsLocked() )
595  {
596  lockedItems.push_back( boardItem );
597  }
598  }
599 
600  if( !lockedItems.empty() )
601  {
602  DIALOG_LOCKED_ITEMS_QUERY dlg( frame(), lockedItems.size() );
603 
604  switch( dlg.ShowModal() )
605  {
606  case wxID_OK:
607  // remove locked items from selection
608  for( BOARD_ITEM* item : lockedItems )
609  unselect( item );
610 
611  break;
612 
613  case wxID_CANCEL:
614  // cancel operation
615  ClearSelection();
616  break;
617 
618  case wxID_APPLY:
619  // continue with operation with current selection
620  break;
621  }
622  }
623  }
624 
625  return m_selection;
626 }
void ClearReferencePoint()
Definition: selection.h:194
void ForceRefresh()
Force a redraw.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void highlight(BOARD_ITEM *aItem, int aHighlightMode, PCB_SELECTION *aGroup=nullptr)
Highlight the item visually.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
virtual bool IsLocked() const
Definition: board_item.cpp:64
void SetIsHover(bool aIsHover)
Definition: selection.h:69
PCB_BASE_FRAME * m_frame
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:100
PCB_BASE_EDIT_FRAME * frame() const
#define SELECTED
PCB_SELECTION m_selection
void unselect(BOARD_ITEM *aItem)
Take necessary action mark an item as unselected.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:98
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
int ClearSelection(const TOOL_EVENT &aEvent)
void unhighlight(BOARD_ITEM *aItem, int aHighlightMode, PCB_SELECTION *aGroup=nullptr)
Unhighlight the item visually.
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:56
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

Referenced by 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::FilletTracks(), EDIT_TOOL::Flip(), ALIGN_DISTRIBUTE_TOOL::GetSelections(), GROUP_TOOL::Group(), EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), GROUP_TOOL::PickNewMember(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), GLOBAL_EDIT_TOOL::RemoveUnusedPads(), EDIT_TOOL::Rotate(), CONVERT_TOOL::SegmentToArc(), and POSITION_RELATIVE_TOOL::SelectPositionRelativeItem().

◆ 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.

Reimplemented from PCB_TOOL_BASE.

Definition at line 185 of file pcb_selection_tool.cpp.

186 {
187  m_frame = getEditFrame<PCB_BASE_FRAME>();
188 
189  if( m_enteredGroup )
190  ExitGroup();
191 
192  if( aReason == TOOL_BASE::MODEL_RELOAD )
193  {
194  // Deselect any item being currently in edit, to avoid unexpected behavior
195  // and remove pointers to the selected items from containers
196  // without changing their properties (as they are already deleted
197  // while a new board is loaded)
198  ClearSelection( true );
199 
200  getView()->GetPainter()->GetSettings()->SetHighlight( false );
201  }
202  else
203  {
204  // Restore previous properties of selected items and remove them from containers
205  ClearSelection( true );
206  }
207 
208  // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
209  view()->Remove( &m_selection );
210  view()->Add( &m_selection );
211 
214 }
Model changes (required full reload)
Definition: tool_base.h:80
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:208
PCB_BASE_FRAME * m_frame
KIGFX::VIEW_GROUP m_enteredGroupOverlay
KIGFX::PCB_VIEW * view() const
PCB_SELECTION m_selection
void ExitGroup(bool aSelectGroup=false)
Leave the currently entered group.
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
int ClearSelection(const TOOL_EVENT &aEvent)

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

◆ 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 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
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 ( BOARD_ITEM aItem)

Take necessary action mark an item as selected.

Parameters
aItemis an item to be selected.

Definition at line 2209 of file pcb_selection_tool.cpp.

2210 {
2211  if( aItem->IsSelected() )
2212  return;
2213 
2214  if( aItem->Type() == PCB_PAD_T )
2215  {
2216  FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aItem->GetParent() );
2217 
2218  if( m_selection.Contains( footprint ) )
2219  return;
2220  }
2221 
2222  highlight( aItem, SELECTED, &m_selection );
2223 }
bool IsSelected() const
Definition: eda_item.h:122
void highlight(BOARD_ITEM *aItem, int aHighlightMode, PCB_SELECTION *aGroup=nullptr)
Highlight the item visually.
class PAD, a pad in a footprint
Definition: typeinfo.h:89
bool Contains(EDA_ITEM *aItem) const
Definition: selection.cpp:62
FOOTPRINT * footprint() const
#define SELECTED
PCB_SELECTION m_selection
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References SELECTION::Contains(), PCB_TOOL_BASE::footprint(), BOARD_ITEM::GetParent(), highlight(), EDA_ITEM::IsSelected(), m_selection, PCB_PAD_T, SELECTED, and EDA_ITEM::Type().

Referenced by AddItemToSel(), EnterGroup(), ExitGroup(), filterSelection(), FindItem(), GROUP_TOOL::Group(), SelectAll(), selectAllItemsOnNet(), selectAllItemsOnSheet(), selectConnectedTracks(), SelectItems(), selectMultiple(), selectNet(), and selectPoint().

◆ Selectable()

bool PCB_SELECTION_TOOL::Selectable ( const BOARD_ITEM aItem,
bool  checkVisibilityOnly = false 
) const

Check conditions for an item to be selected.

Returns
True if the item fulfills conditions to be selected.

Definition at line 1990 of file pcb_selection_tool.cpp.

1991 {
1992  const RENDER_SETTINGS* settings = getView()->GetPainter()->GetSettings();
1993 
1994  if( settings->GetHighContrast() )
1995  {
1996  std::set<unsigned int> activeLayers = settings->GetHighContrastLayers();
1997  bool onActiveLayer = false;
1998 
1999  for( unsigned int layer : activeLayers )
2000  {
2001  // NOTE: Only checking the regular layers (not GAL meta-layers)
2002  if( layer < PCB_LAYER_ID_COUNT && aItem->IsOnLayer( ToLAYER_ID( layer ) ) )
2003  {
2004  onActiveLayer = true;
2005  break;
2006  }
2007  }
2008 
2009  if( !onActiveLayer ) // We do not want to select items that are in the background
2010  return false;
2011  }
2012 
2013  if( aItem->Type() == PCB_FOOTPRINT_T )
2014  {
2015  // In footprint editor, we do not want to select the footprint itself.
2016  if( m_isFootprintEditor )
2017  return false;
2018 
2019  // Allow selection of footprints if some part of the footprint is visible.
2020  const FOOTPRINT* footprint = static_cast<const FOOTPRINT*>( aItem );
2021 
2022  // If the footprint has no items except the reference and value fields, include the
2023  // footprint in the selections.
2024  if( footprint->GraphicalItems().empty()
2025  && footprint->Pads().empty()
2026  && footprint->Zones().empty() )
2027  return true;
2028 
2029  for( const BOARD_ITEM* item : footprint->GraphicalItems() )
2030  {
2031  if( Selectable( item, true ) )
2032  return true;
2033  }
2034 
2035  for( const PAD* pad : footprint->Pads() )
2036  {
2037  if( Selectable( pad, true ) )
2038  return true;
2039  }
2040 
2041  for( const ZONE* zone : footprint->Zones() )
2042  {
2043  if( Selectable( zone, true ) )
2044  return true;
2045  }
2046 
2047  return false;
2048  }
2049  else if( aItem->Type() == PCB_GROUP_T )
2050  {
2051  PCB_GROUP* group = const_cast<PCB_GROUP*>( static_cast<const PCB_GROUP*>( aItem ) );
2052 
2053  // Similar to logic for footprint, a group is selectable if any of its members are.
2054  // (This recurses.)
2055  for( BOARD_ITEM* item : group->GetItems() )
2056  {
2057  if( Selectable( item, true ) )
2058  return true;
2059  }
2060 
2061  return false;
2062  }
2063 
2064  const ZONE* zone = nullptr;
2065  const PCB_VIA* via = nullptr;
2066  const PAD* pad = nullptr;
2067 
2068  switch( aItem->Type() )
2069  {
2070  case PCB_ZONE_T:
2071  case PCB_FP_ZONE_T:
2072  if( !board()->IsElementVisible( LAYER_ZONES ) )
2073  return false;
2074 
2075  zone = static_cast<const ZONE*>( aItem );
2076 
2077  // A footprint zone is only selectable within the footprint editor
2078  if( zone->GetParent()
2079  && zone->GetParent()->Type() == PCB_FOOTPRINT_T
2081  && !checkVisibilityOnly )
2082  {
2083  return false;
2084  }
2085 
2086  // zones can exist on multiple layers!
2087  if( !( zone->GetLayerSet() & board()->GetVisibleLayers() ).any() )
2088  return false;
2089 
2090  break;
2091 
2092  case PCB_TRACE_T:
2093  case PCB_ARC_T:
2094  if( !board()->IsElementVisible( LAYER_TRACKS ) )
2095  return false;
2096 
2097  if( m_isFootprintEditor )
2098  {
2099  if( !view()->IsLayerVisible( aItem->GetLayer() ) )
2100  return false;
2101  }
2102  else
2103  {
2104  if( !board()->IsLayerVisible( aItem->GetLayer() ) )
2105  return false;
2106  }
2107 
2108  break;
2109 
2110  case PCB_VIA_T:
2111  if( !board()->IsElementVisible( LAYER_VIAS ) )
2112  return false;
2113 
2114  via = static_cast<const PCB_VIA*>( aItem );
2115 
2116  // For vias it is enough if only one of its layers is visible
2117  if( !( board()->GetVisibleLayers() & via->GetLayerSet() ).any() )
2118  return false;
2119 
2120  break;
2121 
2122  case PCB_FP_TEXT_T:
2123  if( m_isFootprintEditor )
2124  {
2125  if( !view()->IsLayerVisible( aItem->GetLayer() ) )
2126  return false;
2127  }
2128  else
2129  {
2130  if( !view()->IsVisible( aItem ) )
2131  return false;
2132 
2133  if( !board()->IsLayerVisible( aItem->GetLayer() ) )
2134  return false;
2135  }
2136 
2137  break;
2138 
2139  case PCB_FP_SHAPE_T:
2140  if( m_isFootprintEditor )
2141  {
2142  if( !view()->IsLayerVisible( aItem->GetLayer() ) )
2143  return false;
2144  }
2145  else
2146  {
2147  // Footprint shape selections are only allowed in footprint editor mode.
2148  if( !checkVisibilityOnly )
2149  return false;
2150 
2151  if( !board()->IsLayerVisible( aItem->GetLayer() ) )
2152  return false;
2153  }
2154 
2155  break;
2156 
2157  case PCB_PAD_T:
2158  // Multiple selection is only allowed in footprint editor mode. In pcbnew, you have to
2159  // select footprint subparts one by one, rather than with a drag selection. This is so
2160  // you can pick up items under an (unlocked) footprint without also moving the
2161  // footprint's sub-parts.
2162  if( !m_isFootprintEditor && !checkVisibilityOnly )
2163  {
2164  if( m_multiple )
2165  return false;
2166  }
2167 
2168  pad = static_cast<const PAD*>( aItem );
2169 
2170  if( pad->GetAttribute() == PAD_ATTRIB::PTH || pad->GetAttribute() == PAD_ATTRIB::NPTH )
2171  {
2172  // Check render mode (from the Items tab) first
2173  if( !board()->IsElementVisible( LAYER_PADS_TH ) )
2174  return false;
2175 
2176  // A pad's hole is visible on every layer the pad is visible on plus many layers the
2177  // pad is not visible on -- so we only need to check for any visible hole layers.
2178  if( !( board()->GetVisibleLayers() & LSET::PhysicalLayersMask() ).any() )
2179  return false;
2180  }
2181  else
2182  {
2183  // Check render mode (from the Items tab) first
2184  if( pad->IsOnLayer( F_Cu ) && !board()->IsElementVisible( LAYER_PAD_FR ) )
2185  return false;
2186  else if( pad->IsOnLayer( B_Cu ) && !board()->IsElementVisible( LAYER_PAD_BK ) )
2187  return false;
2188 
2189  if( !( pad->GetLayerSet() & board()->GetVisibleLayers() ).any() )
2190  return false;
2191  }
2192 
2193  break;
2194 
2195  // These are not selectable
2196  case PCB_NETINFO_T:
2197  case NOT_USED:
2198  case TYPE_NOT_INIT:
2199  return false;
2200 
2201  default: // Suppress warnings
2202  break;
2203  }
2204 
2205  return aItem->ViewGetLOD( aItem->GetLayer(), view() ) < view()->GetScale();
2206 }
const std::set< unsigned int > GetHighContrastLayers() const
Returns the set of currently high-contrast layers.
smd pads, front layer
Definition: layer_ids.h:198
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
BOARD * board() const
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
the 3d code uses this value
Definition: typeinfo.h:79
smd pads, back layer
Definition: layer_ids.h:199
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.cpp:295
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:481
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
class PAD, a pad in a footprint
Definition: typeinfo.h:89
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:208
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PADS & Pads()
Definition: footprint.h:169
Control for copper zone opacity/visibility (color ignored)
Definition: layer_ids.h:227
Plated through hole pad.
FP_ZONES & Zones()
Definition: footprint.h:175
like PAD_PTH, but not plated
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:189
bool IsVisible(const VIEW_ITEM *aItem) const
Return information if the item is visible (or not).
Definition: view.cpp:1556
FOOTPRINT * footprint() const
KIGFX::PCB_VIEW * view() const
bool Selectable(const BOARD_ITEM *aItem, bool checkVisibilityOnly=false) const
Check conditions for an item to be selected.
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
class ZONE, a copper pour area
Definition: typeinfo.h:105
bool m_isFootprintEditor
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
Definition: board.cpp:533
bool GetHighContrast() const
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:858
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
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:473
multilayer pads, usually with holes
Definition: layer_ids.h:209
Definition: layer_ids.h:71
class NETINFO_ITEM, a description of a net
Definition: typeinfo.h:107
class ZONE, managed by a footprint
Definition: typeinfo.h:94
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
Definition: pad.h:57
double GetScale() const
Definition: view.h:264
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:135
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:914
virtual double ViewGetLOD(int aLayer, VIEW *aView) const
Return the level of detail (LOD) of the item.
Definition: view_item.h:132
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:405

References B_Cu, PCB_TOOL_BASE::board(), F_Cu, PCB_TOOL_BASE::footprint(), KIGFX::RENDER_SETTINGS::GetHighContrast(), KIGFX::RENDER_SETTINGS::GetHighContrastLayers(), BOARD_ITEM::GetLayer(), ZONE::GetLayerSet(), KIGFX::VIEW::GetPainter(), BOARD_ITEM::GetParent(), KIGFX::VIEW::GetScale(), KIGFX::PAINTER::GetSettings(), TOOL_BASE::getView(), BOARD::GetVisibleLayers(), FOOTPRINT::GraphicalItems(), group, BOARD::IsElementVisible(), KIGFX::VIEW::IsLayerVisible(), BOARD::IsLayerVisible(), KIGFX::VIEW::IsVisible(), LAYER_PAD_BK, LAYER_PAD_FR, LAYER_PADS_TH, LAYER_TRACKS, LAYER_VIAS, LAYER_ZONES, PCB_TOOL_BASE::m_isFootprintEditor, SELECTION_TOOL::m_multiple, NOT_USED, NPTH, pad, FOOTPRINT::Pads(), PCB_ARC_T, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_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, ToLAYER_ID(), EDA_ITEM::Type(), TYPE_NOT_INIT, via, PCB_TOOL_BASE::view(), KIGFX::VIEW_ITEM::ViewGetLOD(), and FOOTPRINT::Zones().

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

◆ SelectAll()

int PCB_SELECTION_TOOL::SelectAll ( const TOOL_EVENT aEvent)

Multiple item selection event handler.

Definition at line 976 of file pcb_selection_tool.cpp.

977 {
978  KIGFX::VIEW* view = getView();
979 
980  // hold all visible items
981  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
982 
983  // Filter the view items based on the selection box
984  BOX2I selectionBox;
985 
986  // Intermediate step to allow filtering against hierarchy
987  GENERAL_COLLECTOR collection;
988 
989  selectionBox.SetMaximum();
990  view->Query( selectionBox, selectedItems ); // Get the list of selected items
991 
992  for( const KIGFX::VIEW::LAYER_ITEM_PAIR& item_pair : selectedItems )
993  {
994  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( item_pair.first );
995 
996  if( !item || !Selectable( item ) || !itemPassesFilter( item, true ) )
997  continue;
998 
999  collection.Append( item );
1000  }
1001 
1002  FilterCollectorForHierarchy( collection, true );
1003 
1004  for( EDA_ITEM* item : collection )
1005  select( static_cast<BOARD_ITEM*>( item ) );
1006 
1008 
1009  return 0;
1010 }
void ForceRefresh()
Force a redraw.
void select(BOARD_ITEM *aItem)
Take necessary action mark an item as selected.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_BASE_FRAME * m_frame
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:100
void SetMaximum()
Definition: box2.h:57
KIGFX::PCB_VIEW * view() const
bool Selectable(const BOARD_ITEM *aItem, bool checkVisibilityOnly=false) const
Check conditions for an item to be selected.
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
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.
bool itemPassesFilter(BOARD_ITEM *aItem, bool aMultiSelect)
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
Definition: view.h:73
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
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:426
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68

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

Referenced by setTransitions().

◆ selectAllItemsOnNet()

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

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 1301 of file pcb_selection_tool.cpp.

1302 {
1303  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, EOT };
1304  auto connectivity = board()->GetConnectivity();
1305 
1306  for( BOARD_CONNECTED_ITEM* item : connectivity->GetNetItems( aNetCode, types ) )
1307  {
1308  if( itemPassesFilter( item, true ) )
1309  aSelect ? select( item ) : unselect( item );
1310  }
1311 }
void select(BOARD_ITEM *aItem)
Take necessary action mark an item as selected.
BOARD * board() const
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:345
void unselect(BOARD_ITEM *aItem)
Take necessary action mark an item as unselected.
bool itemPassesFilter(BOARD_ITEM *aItem, bool aMultiSelect)
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96

References PCB_TOOL_BASE::board(), EOT, BOARD::GetConnectivity(), itemPassesFilter(), PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, select(), and unselect().

Referenced by 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 1349 of file pcb_selection_tool.cpp.

1350 {
1351  std::list<FOOTPRINT*> footprintList;
1352 
1353  // store all footprints that are on that sheet path
1354  for( FOOTPRINT* footprint : board()->Footprints() )
1355  {
1356  if( footprint == nullptr )
1357  continue;
1358 
1359  wxString footprint_path = footprint->GetPath().AsString().BeforeLast('/');
1360 
1361  if( aSheetPath.IsEmpty() )
1362  aSheetPath += '/';
1363 
1364  if( footprint_path == aSheetPath )
1365  footprintList.push_back( footprint );
1366  }
1367 
1368  // Generate a list of all pads, and of all nets they belong to.
1369  std::list<int> netcodeList;
1370  std::list<PAD*> padList;
1371 
1372  for( FOOTPRINT* footprint : footprintList )
1373  {
1374  for( PAD* pad : footprint->Pads() )
1375  {
1376  if( pad->IsConnected() )
1377  {
1378  netcodeList.push_back( pad->GetNetCode() );
1379  padList.push_back( pad );
1380  }
1381  }
1382  }
1383 
1384  // remove all duplicates
1385  netcodeList.sort();
1386  netcodeList.unique();
1387 
1388  for( PAD* pad : padList )
1390 
1391  // now we need to find all footprints that are connected to each of these nets then we need
1392  // to determine if these footprints are in the list of footprints belonging to this sheet
1393  std::list<int> removeCodeList;
1394  constexpr KICAD_T padType[] = { PCB_PAD_T, EOT };
1395 
1396  for( int netCode : netcodeList )
1397  {
1398  for( BOARD_CONNECTED_ITEM* mitem : board()->GetConnectivity()->GetNetItems( netCode,
1399  padType ) )
1400  {
1401  if( mitem->Type() == PCB_PAD_T && !alg::contains( footprintList, mitem->GetParent() ) )
1402  {
1403  // if we cannot find the footprint of the pad in the footprintList then we can
1404  // assume that that footprint is not located in the same schematic, therefore
1405  // invalidate this netcode.
1406  removeCodeList.push_back( netCode );
1407  break;
1408  }
1409  }
1410  }
1411 
1412  // remove all duplicates
1413  removeCodeList.sort();
1414  removeCodeList.unique();
1415 
1416  for( int removeCode : removeCodeList )
1417  {
1418  netcodeList.remove( removeCode );
1419  }
1420 
1421  std::list<BOARD_CONNECTED_ITEM*> localConnectionList;
1422  constexpr KICAD_T trackViaType[] = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, EOT };
1423 
1424  for( int netCode : netcodeList )
1425  {
1426  for( BOARD_CONNECTED_ITEM* item : board()->GetConnectivity()->GetNetItems( netCode,
1427  trackViaType ) )
1428  localConnectionList.push_back( item );
1429  }
1430 
1431  for( BOARD_ITEM* i : footprintList )
1432  {
1433  if( i != nullptr )
1434  select( i );
1435  }
1436 
1437  for( BOARD_CONNECTED_ITEM* i : localConnectionList )
1438  {
1439  if( i != nullptr )
1440  select( i );
1441  }
1442 }
void select(BOARD_ITEM *aItem)
Take necessary action mark an item as selected.
BOARD * board() const
const KIID_PATH & GetPath() const
Definition: footprint.h:204
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class PAD, a pad in a footprint
Definition: typeinfo.h:89
void selectConnectedTracks(BOARD_CONNECTED_ITEM &aSourceItem, STOP_CONDITION aStopCondition)
Select connected tracks and vias.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PADS & Pads()
Definition: footprint.h:169
FOOTPRINT * footprint() const
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
wxString AsString() const
Definition: kiid.cpp:310
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
Definition: pad.h:57

References KIID_PATH::AsString(), PCB_TOOL_BASE::board(), alg::contains(), EOT, PCB_TOOL_BASE::footprint(), FOOTPRINT::GetPath(), pad, FOOTPRINT::Pads(), PCB_ARC_T, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, select(), selectConnectedTracks(), and STOP_NEVER.

Referenced by selectSameSheet(), and selectSheetContents().

◆ selectConnectedTracks()

void PCB_SELECTION_TOOL::selectConnectedTracks ( BOARD_CONNECTED_ITEM aSourceItem,
STOP_CONDITION  aStopCondition 
)
private

Select connected tracks and vias.

Parameters
aStopConditionwhere to stop selecting more items

Definition at line 1139 of file pcb_selection_tool.cpp.

1141 {
1142  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, PCB_PAD_T, EOT };
1143  constexpr PCB_LAYER_ID ALL_LAYERS = UNDEFINED_LAYER;
1144 
1145  auto connectivity = board()->GetConnectivity();
1146  auto connectedItems = connectivity->GetConnectedItems( &aStartItem, types, true );
1147 
1148  std::map<wxPoint, std::vector<PCB_TRACK*>> trackMap;
1149  std::map<wxPoint, PCB_VIA*> viaMap;
1150  std::map<wxPoint, PAD*> padMap;
1151 
1152  // Build maps of connected items
1153  for( BOARD_CONNECTED_ITEM* item : connectedItems )
1154  {
1155  switch( item->Type() )
1156  {
1157  case PCB_ARC_T:
1158  case PCB_TRACE_T:
1159  {
1160  PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
1161  trackMap[ track->GetStart() ].push_back( track );
1162  trackMap[ track->GetEnd() ].push_back( track );
1163  break;
1164  }
1165 
1166  case PCB_VIA_T:
1167  {
1168  PCB_VIA* via = static_cast<PCB_VIA*>( item );
1169  viaMap[ via->GetStart() ] = via;
1170  break;
1171  }
1172 
1173  case PCB_PAD_T:
1174  {
1175  PAD* pad = static_cast<PAD*>( item );
1176  padMap[ pad->GetPosition() ] = pad;
1177  break;
1178  }
1179 
1180  default:
1181  break;
1182  }
1183 
1184  item->ClearFlags( TEMP_SELECTED );
1185  }
1186 
1187  std::vector< std::pair<wxPoint, PCB_LAYER_ID> > activePts;
1188 
1189  // Set up the initial active points
1190  switch( aStartItem.Type() )
1191  {
1192  case PCB_ARC_T:
1193  case PCB_TRACE_T:
1194  {
1195  PCB_TRACK* track = static_cast<PCB_TRACK*>( &aStartItem );
1196 
1197  activePts.push_back( { track->GetStart(), track->GetLayer() } );
1198  activePts.push_back( { track->GetEnd(), track->GetLayer() } );
1199  }
1200  break;
1201 
1202  case PCB_VIA_T:
1203  activePts.push_back( { aStartItem.GetPosition(), ALL_LAYERS } );
1204  break;
1205 
1206  case PCB_PAD_T:
1207  activePts.push_back( { aStartItem.GetPosition(), ALL_LAYERS } );
1208  break;
1209 
1210  default:
1211  break;
1212  }
1213 
1214  bool expand = true;
1215  int failSafe = 0;
1216 
1217  // Iterative push from all active points
1218  while( expand && failSafe++ < 100000 )
1219  {
1220  expand = false;
1221 
1222  for( int i = activePts.size() - 1; i >= 0; --i )
1223  {
1224  wxPoint pt = activePts[i].first;
1225  PCB_LAYER_ID layer = activePts[i].second;
1226  size_t pt_count = 0;
1227 
1228  for( PCB_TRACK* track : trackMap[pt] )
1229  {
1230  if( layer == ALL_LAYERS || layer == track->GetLayer() )
1231  pt_count++;
1232  }
1233 
1234  if( aStopCondition == STOP_AT_JUNCTION )
1235  {
1236  if( pt_count > 2
1237  || ( viaMap.count( pt ) && layer != ALL_LAYERS )
1238  || ( padMap.count( pt ) && layer != ALL_LAYERS ) )
1239  {
1240  activePts.erase( activePts.begin() + i );
1241  continue;
1242  }
1243  }
1244  else if( aStopCondition == STOP_AT_PAD )
1245  {
1246  if( padMap.count( pt ) )
1247  {
1248  activePts.erase( activePts.begin() + i );
1249  continue;
1250  }
1251  }
1252 
1253  if( padMap.count( pt ) )
1254  {
1255  PAD* pad = padMap[ pt ];
1256 
1257  if( !( pad->GetFlags() & TEMP_SELECTED ) )
1258  {
1259  pad->SetFlags( TEMP_SELECTED );
1260  activePts.push_back( { pad->GetPosition(), ALL_LAYERS } );
1261  expand = true;
1262  }
1263  }
1264 
1265  for( PCB_TRACK* track : trackMap[ pt ] )
1266  {
1267  if( layer != ALL_LAYERS && track->GetLayer() != layer )
1268  continue;
1269 
1270  if( !track->IsSelected() )
1271  {
1272  select( track );
1273 
1274  if( track->GetStart() == pt )
1275  activePts.push_back( { track->GetEnd(), track->GetLayer() } );
1276  else
1277  activePts.push_back( { track->GetStart(), track->GetLayer() } );
1278 
1279  expand = true;
1280  }
1281  }
1282 
1283  if( viaMap.count( pt ) )
1284  {
1285  PCB_VIA* via = viaMap[ pt ];
1286 
1287  if( !via->IsSelected() )
1288  {
1289  select( via );
1290  activePts.push_back( { via->GetPosition(), ALL_LAYERS } );
1291  expand = true;
1292  }
1293  }
1294 
1295  activePts.erase( activePts.begin() + i );
1296  }
1297  }
1298 }
void select(BOARD_ITEM *aItem)
Take necessary action mark an item as selected.
BOARD * board() const
bool IsSelected() const
Definition: eda_item.h:122
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
Stop at any place where more than two traces meet.
Stop when reaching a pad.
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class PAD, a pad in a footprint
Definition: typeinfo.h:89
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:345
#define TEMP_SELECTED
flag indicating that the structure has already selected
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
Definition: pad.h:57
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:142
const wxPoint & GetStart() const
Definition: pcb_track.h:108

References PCB_TOOL_BASE::board(), EOT, BOARD::GetConnectivity(), PCB_TRACK::GetEnd(), BOARD_ITEM::GetLayer(), EDA_ITEM::GetPosition(), PCB_TRACK::GetStart(), pad, PCB_ARC_T, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, select(), STOP_AT_JUNCTION, STOP_AT_PAD, TEMP_SELECTED, EDA_ITEM::Type(), UNDEFINED_LAYER, and via.

Referenced by expandConnection(), 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 or aSelectAlways is true.

Parameters
aForceSelectforces to select an item even if there is an item already selected.
aClientFilterallows the client to perform tool- or action-specific filtering.
Returns
true if eventually there is an item selected, false otherwise.

Definition at line 755 of file pcb_selection_tool.cpp.

756 {
757  if( aForceSelect || m_selection.Empty() )
758  {
759  ClearSelection( true /*quiet mode*/ );
760  selectPoint( getViewControls()->GetCursorPosition( false ), false, nullptr, aClientFilter );
761  }
762 
763  return !m_selection.Empty();
764 }
bool selectPoint(const VECTOR2I &aWhere, bool aOnDrag=false, bool *aSelectionCancelledFlag=nullptr, CLIENT_SELECTION_FILTER aClientFilter=nullptr)
Select an item pointed by the parameter aWhere.
PCB_SELECTION m_selection
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:98
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
int ClearSelection(const TOOL_EVENT &aEvent)

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

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

◆ selection() [1/2]

const PCB_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 307 of file pcb_tool_base.cpp.

308 {
310 
311  return selTool->GetSelection();
312 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
The selection tool: currently supports:

References GetSelection(), TOOL_MANAGER::GetTool(), and TOOL_BASE::m_toolMgr.

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), DRC_TOOL::CrossProbe(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), BOARD_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Drag(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), EDIT_TOOL::Duplicate(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), GROUP_TOOL::EnterGroup(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::FilletTracks(), filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), GROUP_TOOL::Group(), BOARD_INSPECTION_TOOL::highlightNet(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), EDIT_TOOL::Mirror(), BOARD_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), PCB_POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceImportedGraphics(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), BOARD_REANNOTATE_TOOL::ReannotateDuplicatesInSelection(), GROUP_TOOL::RemoveFromGroup(), GLOBAL_EDIT_TOOL::RemoveUnusedPads(), EDIT_TOOL::Rotate(), selectNet(), DRAWING_TOOL::SetAnchor(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), GROUP_TOOL::Ungroup(), PCB_CONTROL::UpdateMessagePanel(), BOARD_INSPECTION_TOOL::UpdateSelectionRatsnest(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), BOARD_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), BOARD_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

PCB_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 315 of file pcb_tool_base.cpp.

316 {
318 
319  return selTool->GetSelection();
320 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
The selection tool: currently supports:

References GetSelection(), TOOL_MANAGER::GetTool(), and TOOL_BASE::m_toolMgr.

◆ 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 box.

Definition at line 2319 of file pcb_selection_tool.cpp.

2320 {
2322  GENERAL_COLLECTOR collector;
2323 
2324  // Since we're just double-checking, we want a considerably sloppier check than the initial
2325  // selection (for which most tools use 5 pixels). So we increase this to an effective 20
2326  // pixels by artificially inflating the value of a pixel by 4X.
2327  guide.SetOnePixelInIU( guide.OnePixelInIU() * 4 );
2328 
2331  (wxPoint) aPoint, guide );
2332 
2333  for( int i = collector.GetCount() - 1; i >= 0; --i )
2334  {
2335  BOARD_ITEM* item = collector[i];
2336 
2337  if( item->IsSelected() && item->HitTest( (wxPoint) aPoint, 5 * guide.OnePixelInIU() ) )
2338  return true;
2339  }
2340 
2341  return false;
2342 }
const GENERAL_COLLECTORS_GUIDE getCollectorsGuide() const
static const KICAD_T FootprintItems[]
A scan list for primary footprint items.
Definition: collectors.h:293
void SetOnePixelInIU(double aValue)
Definition: collectors.h:571
static const KICAD_T AllBoardItems[]
A scan list for all editable board items.
Definition: collectors.h:267
BOARD * board() const
bool IsSelected() const
Definition: eda_item.h:122
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void Collect(BOARD_ITEM *aItem, const KICAD_T aScanList[], const wxPoint &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
Definition: collectors.cpp:571
double OnePixelInIU() const override
Definition: collectors.h:570
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const
Test if aPosition is inside or on the boundary of this item.
Definition: eda_item.h:224
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
bool m_isFootprintEditor
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:377

References GENERAL_COLLECTOR::AllBoardItems, PCB_TOOL_BASE::board(), GENERAL_COLLECTOR::Collect(), GENERAL_COLLECTOR::FootprintItems, getCollectorsGuide(), COLLECTOR::GetCount(), EDA_ITEM::HitTest(), EDA_ITEM::IsSelected(), PCB_TOOL_BASE::m_isFootprintEditor, GENERAL_COLLECTORS_GUIDE::OnePixelInIU(), and GENERAL_COLLECTORS_GUIDE::SetOnePixelInIU().

Referenced by Main().

◆ SelectionMenu()

int PCB_SELECTION_TOOL::SelectionMenu ( const TOOL_EVENT aEvent)

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 1829 of file pcb_selection_tool.cpp.

1830 {
1831  GENERAL_COLLECTOR* collector = aEvent.Parameter<GENERAL_COLLECTOR*>();
1832 
1833  doSelectionMenu( collector );
1834 
1835  return 0;
1836 }
bool doSelectionMenu(GENERAL_COLLECTOR *aItems)
Allow the selection of a single item from a list via pop-up menu.
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240

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

Referenced by setTransitions().

◆ SelectItem()

int PCB_SELECTION_TOOL::SelectItem ( const TOOL_EVENT aEvent)

Definition at line 969 of file pcb_selection_tool.cpp.

970 {
971  AddItemToSel( aEvent.Parameter<BOARD_ITEM*>() );
972  return 0;
973 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void AddItemToSel(BOARD_ITEM *aItem, bool aQuietMode=false)
Select all items on the board.
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432

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

Referenced by setTransitions().

◆ SelectItems()

int PCB_SELECTION_TOOL::SelectItems ( const TOOL_EVENT aEvent)

Item unselection event handler.

Definition at line 952 of file pcb_selection_tool.cpp.

953 {
954  std::vector<BOARD_ITEM*>* items = aEvent.Parameter<std::vector<BOARD_ITEM*>*>();
955 
956  if( items )
957  {
958  // Perform individual selection of each item before processing the event.
959  for( BOARD_ITEM* item : *items )
960  select( item );
961 
963  }
964 
965  return 0;
966 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:200
void select(BOARD_ITEM *aItem)
Take necessary action mark an item as selected.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432

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

Referenced by 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 780 of file pcb_selection_tool.cpp.

781 {
782  bool cancelled = false; // Was the tool cancelled while it was running?
783  m_multiple = true; // Multiple selection mode is active
784  KIGFX::VIEW* view = getView();
785 
787  view->Add( &area );
788 
789  bool anyAdded = false;
790  bool anySubtracted = false;
791 
792  while( TOOL_EVENT* evt = Wait() )
793  {
794  int width = area.GetEnd().x - area.GetOrigin().x;
795 
796  /* Selection mode depends on direction of drag-selection:
797  * Left > Right : Select objects that are fully enclosed by selection
798  * Right > Left : Select objects that are crossed by selection
799  */
800  bool windowSelection = width >= 0 ? true : false;
801 
802  if( view->IsMirroredX() )
803  windowSelection = !windowSelection;
804 
807 
808  if( evt->IsCancelInteractive() || evt->IsActivate() )
809  {
810  cancelled = true;
811  break;
812  }
813 
814  if( evt->IsDrag( BUT_LEFT ) )
815  {
817  {
818  if( m_selection.GetSize() > 0 )
819  {
820  anySubtracted = true;
821  ClearSelection( true /*quiet mode*/ );
822  }
823  }
824 
825  // Start drawing a selection box
826  area.SetOrigin( evt->DragOrigin() );
827  area.SetEnd( evt->Position() );
830  area.SetExclusiveOr( false );
831 
832  view->SetVisible( &area, true );
833  view->Update( &area );
834  getViewControls()->SetAutoPan( true );
835  }
836 
837  if( evt->IsMouseUp( BUT_LEFT ) )
838  {
839  getViewControls()->SetAutoPan( false );
840 
841  // End drawing the selection box
842  view->SetVisible( &area, false );
843 
844  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> candidates;
845  BOX2I selectionBox = area.ViewBBox();
846  view->Query( selectionBox, candidates ); // Get the list of nearby items
847 
848  int height = area.GetEnd().y - area.GetOrigin().y;
849 
850  // Construct an EDA_RECT to determine BOARD_ITEM selection
851  EDA_RECT selectionRect( (wxPoint) area.GetOrigin(), wxSize( width, height ) );
852 
853  selectionRect.Normalize();
854 
855  GENERAL_COLLECTOR collector;
856 
857  for( auto it = candidates.begin(), it_end = candidates.end(); it != it_end; ++it )
858  {
859  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first );
860 
861  if( item && Selectable( item ) && item->HitTest( selectionRect, windowSelection ) )
862  collector.Append( item );
863  }
864 
865  // Apply the stateful filter
866  FilterCollectedItems( collector, true );
867 
868  FilterCollectorForHierarchy( collector, true );
869 
870  for( EDA_ITEM* i : collector )
871  {
872  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( i );
873 
874  if( m_subtractive || ( m_exclusive_or && item->IsSelected() ) )
875  {
876  unselect( item );
877  anySubtracted = true;
878  }
879  else
880  {
881  select( item );
882  anyAdded = true;
883  }
884  }
885 
886  m_selection.SetIsHover( false );
887 
888  // Inform other potentially interested tools
889  if( anyAdded )
891  else if( anySubtracted )
893 
894  break; // Stop waiting for events
895  }
896 
897  // Allow some actions for navigation
898  for( int i = 0; allowedActions[i]; ++i )
899  {
900  if( evt->IsAction( allowedActions[i] ) )
901  {
902  evt->SetPassEvent();
903  break;
904  }
905  }
906  }