KiCad PCB EDA Suite
pcb_selection_tool.cpp File Reference
#include <limits>
#include <functional>
#include <core/kicad_algo.h>
#include <board.h>
#include <board_design_settings.h>
#include <board_item.h>
#include <clipper.hpp>
#include <pcb_track.h>
#include <footprint.h>
#include <pad.h>
#include <pcb_group.h>
#include <pcb_shape.h>
#include <pcb_text.h>
#include <pcb_marker.h>
#include <zone.h>
#include <collectors.h>
#include <dialog_filter_selection.h>
#include <dialogs/dialog_locked_items_query.h>
#include <class_draw_panel_gal.h>
#include <view/view_controls.h>
#include <preview_items/selection_area.h>
#include <painter.h>
#include <router/router_tool.h>
#include <bitmaps.h>
#include <pcbnew_settings.h>
#include <tool/tool_event.h>
#include <tool/tool_manager.h>
#include <tools/tool_event_utils.h>
#include <tools/pcb_point_editor.h>
#include <tools/pcb_selection_tool.h>
#include <tools/pcb_actions.h>
#include <connectivity/connectivity_data.h>
#include <footprint_viewer_frame.h>
#include <id.h>
#include <wx/event.h>
#include <wx/timer.h>
#include <wx/log.h>

Go to the source code of this file.

Classes

class  SELECT_MENU
 
class  PCB_SELECTION_TOOL::PRIV
 Private implementation of firewalled private data. More...
 

Functions

void connectedItemFilter (const VECTOR2I &, GENERAL_COLLECTOR &aCollector, PCB_SELECTION_TOOL *sTool)
 
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. More...
 

Variables

const TOOL_ACTIONallowedActions []
 

Function Documentation

◆ connectedItemFilter()

void connectedItemFilter ( const VECTOR2I ,
GENERAL_COLLECTOR aCollector,
PCB_SELECTION_TOOL sTool 
)

Definition at line 1082 of file pcb_selection_tool.cpp.

1084 {
1085  // Narrow the collection down to a single BOARD_CONNECTED_ITEM for each represented net.
1086  // All other items types are removed.
1087  std::set<int> representedNets;
1088 
1089  for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
1090  {
1091  BOARD_CONNECTED_ITEM* item = dynamic_cast<BOARD_CONNECTED_ITEM*>( aCollector[i] );
1092  if( !item )
1093  aCollector.Remove( i );
1094  else if ( representedNets.count( item->GetNetCode() ) )
1095  aCollector.Remove( i );
1096  else
1097  representedNets.insert( item->GetNetCode() );
1098  }
1099 }
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
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

References COLLECTOR::GetCount(), BOARD_CONNECTED_ITEM::GetNetCode(), and COLLECTOR::Remove().

Referenced by PCB_SELECTION_TOOL::expandConnection().

◆ itemIsIncludedByFilter()

static bool itemIsIncludedByFilter ( const BOARD_ITEM aItem,
const BOARD aBoard,
const DIALOG_FILTER_SELECTION::OPTIONS aFilterOptions 
)
static

Determine if an item is included by the filter specified.

Returns
true if aItem should be selected by this filter (i..e not filtered out)

Definition at line 1558 of file pcb_selection_tool.cpp.

1560 {
1561  bool include = true;
1562  const PCB_LAYER_ID layer = aItem.GetLayer();
1563 
1564  // if the item needs to be checked against the options
1565  if( include )
1566  {
1567  switch( aItem.Type() )
1568  {
1569  case PCB_FOOTPRINT_T:
1570  {
1571  const FOOTPRINT& footprint = static_cast<const FOOTPRINT&>( aItem );
1572 
1573  include = aFilterOptions.includeModules;
1574 
1575  if( include && !aFilterOptions.includeLockedModules )
1576  include = !footprint.IsLocked();
1577 
1578  break;
1579  }
1580  case PCB_TRACE_T:
1581  case PCB_ARC_T:
1582  include = aFilterOptions.includeTracks;
1583  break;
1584 
1585  case PCB_VIA_T:
1586  include = aFilterOptions.includeVias;
1587  break;
1588 
1589  case PCB_FP_ZONE_T:
1590  case PCB_ZONE_T:
1591  include = aFilterOptions.includeZones;
1592  break;
1593 
1594  case PCB_SHAPE_T:
1595  case PCB_TARGET_T:
1596  case PCB_DIM_ALIGNED_T:
1597  case PCB_DIM_CENTER_T:
1598  case PCB_DIM_ORTHOGONAL_T:
1599  case PCB_DIM_LEADER_T:
1600  if( layer == Edge_Cuts )
1601  include = aFilterOptions.includeBoardOutlineLayer;
1602  else
1603  include = aFilterOptions.includeItemsOnTechLayers;
1604  break;
1605 
1606  case PCB_FP_TEXT_T:
1607  case PCB_TEXT_T:
1608  include = aFilterOptions.includePcbTexts;
1609  break;
1610 
1611  default:
1612  // no filtering, just select it
1613  break;
1614  }
1615  }
1616 
1617  return include;
1618 }
bool IsLocked() const override
Definition: footprint.h:294
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
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
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 PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
class ZONE, a copper pour area
Definition: typeinfo.h:105
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:104
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
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
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:143
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References Edge_Cuts, BOARD_ITEM::GetLayer(), DIALOG_FILTER_SELECTION::OPTIONS::includeBoardOutlineLayer, DIALOG_FILTER_SELECTION::OPTIONS::includeItemsOnTechLayers, DIALOG_FILTER_SELECTION::OPTIONS::includeLockedModules, DIALOG_FILTER_SELECTION::OPTIONS::includeModules, DIALOG_FILTER_SELECTION::OPTIONS::includePcbTexts, DIALOG_FILTER_SELECTION::OPTIONS::includeTracks, DIALOG_FILTER_SELECTION::OPTIONS::includeVias, DIALOG_FILTER_SELECTION::OPTIONS::includeZones, FOOTPRINT::IsLocked(), PCB_ARC_T, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_FOOTPRINT_T, PCB_FP_TEXT_T, PCB_FP_ZONE_T, PCB_SHAPE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, and EDA_ITEM::Type().

Referenced by PCB_SELECTION_TOOL::filterSelection().

Variable Documentation

◆ allowedActions

const TOOL_ACTION* allowedActions[]
Initial value:
static TOOL_ACTION zoomInCenter
Definition: actions.h:93
static TOOL_ACTION cursorRight
Definition: actions.h:116
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
static TOOL_ACTION cursorRightFast
Definition: actions.h:121
static TOOL_ACTION zoomFitObjects
Definition: actions.h:97
static TOOL_ACTION panLeft
Definition: actions.h:129
static TOOL_ACTION zoomOutCenter
Definition: actions.h:94
static TOOL_ACTION panDown
Definition: actions.h:128
static TOOL_ACTION cursorUpFast
Definition: actions.h:118
static TOOL_ACTION cursorDownFast
Definition: actions.h:119
static TOOL_ACTION cursorLeft
Definition: actions.h:115
static TOOL_ACTION panRight
Definition: actions.h:130
static TOOL_ACTION cursorLeftFast
Definition: actions.h:120
static TOOL_ACTION zoomCenter
Definition: actions.h:95
static TOOL_ACTION cursorUp
Cursor control with keyboard.
Definition: actions.h:113
static TOOL_ACTION panUp
Definition: actions.h:127
static TOOL_ACTION zoomIn
Definition: actions.h:91
static TOOL_ACTION zoomOut
Definition: actions.h:92
static TOOL_ACTION cursorDown
Definition: actions.h:114

Definition at line 768 of file pcb_selection_tool.cpp.

Referenced by PCB_SELECTION_TOOL::selectMultiple().