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

Function Documentation

◆ connectedItemFilter()

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

Definition at line 1060 of file pcb_selection_tool.cpp.

1062 {
1063  // Narrow the collection down to a single BOARD_CONNECTED_ITEM for each represented net.
1064  // All other items types are removed.
1065  std::set<int> representedNets;
1066 
1067  for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
1068  {
1069  BOARD_CONNECTED_ITEM* item = dynamic_cast<BOARD_CONNECTED_ITEM*>( aCollector[i] );
1070  if( !item )
1071  aCollector.Remove( i );
1072  else if ( representedNets.count( item->GetNetCode() ) )
1073  aCollector.Remove( i );
1074  else
1075  representedNets.insert( item->GetNetCode() );
1076  }
1077 }
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 1531 of file pcb_selection_tool.cpp.

1533 {
1534  bool include = true;
1535  const PCB_LAYER_ID layer = aItem.GetLayer();
1536 
1537  // if the item needs to be checked against the options
1538  if( include )
1539  {
1540  switch( aItem.Type() )
1541  {
1542  case PCB_FOOTPRINT_T:
1543  {
1544  const FOOTPRINT& footprint = static_cast<const FOOTPRINT&>( aItem );
1545 
1546  include = aFilterOptions.includeModules;
1547 
1548  if( include && !aFilterOptions.includeLockedModules )
1549  include = !footprint.IsLocked();
1550 
1551  break;
1552  }
1553  case PCB_TRACE_T:
1554  case PCB_ARC_T:
1555  include = aFilterOptions.includeTracks;
1556  break;
1557 
1558  case PCB_VIA_T:
1559  include = aFilterOptions.includeVias;
1560  break;
1561 
1562  case PCB_FP_ZONE_T:
1563  case PCB_ZONE_T:
1564  include = aFilterOptions.includeZones;
1565  break;
1566 
1567  case PCB_SHAPE_T:
1568  case PCB_TARGET_T:
1569  case PCB_DIM_ALIGNED_T:
1570  case PCB_DIM_CENTER_T:
1571  case PCB_DIM_ORTHOGONAL_T:
1572  case PCB_DIM_LEADER_T:
1573  if( layer == Edge_Cuts )
1574  include = aFilterOptions.includeBoardOutlineLayer;
1575  else
1576  include = aFilterOptions.includeItemsOnTechLayers;
1577  break;
1578 
1579  case PCB_FP_TEXT_T:
1580  case PCB_TEXT_T:
1581  include = aFilterOptions.includePcbTexts;
1582  break;
1583 
1584  default:
1585  // no filtering, just select it
1586  break;
1587  }
1588  }
1589 
1590  return include;
1591 }
bool IsLocked() const override
Definition: footprint.h:293
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:142
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().