KiCad PCB EDA Suite
pcb_selection_tool.cpp File Reference
#include <limits>
#include <cmath>
#include <functional>
#include <core/kicad_algo.h>
#include <board.h>
#include <board_design_settings.h>
#include <board_item.h>
#include <clipper.hpp>
#include <pcb_bitmap.h>
#include <pcb_track.h>
#include <footprint.h>
#include <pad.h>
#include <pcb_group.h>
#include <pcb_shape.h>
#include <pcb_text.h>
#include <pcb_textbox.h>
#include <fp_textbox.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 <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 <tools/board_inspection_tool.h>
#include <connectivity/connectivity_data.h>
#include <ratsnest/ratsnest_data.h>
#include <footprint_viewer_frame.h>
#include <wx/event.h>
#include <wx/timer.h>
#include <wx/log.h>
#include <profile.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 1085 of file pcb_selection_tool.cpp.

1087{
1088 // Narrow the collection down to a single BOARD_CONNECTED_ITEM for each represented net.
1089 // All other items types are removed.
1090 std::set<int> representedNets;
1091
1092 for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
1093 {
1094 BOARD_CONNECTED_ITEM* item = dynamic_cast<BOARD_CONNECTED_ITEM*>( aCollector[i] );
1095
1096 if( !item )
1097 aCollector.Remove( i );
1098 else if ( representedNets.count( item->GetNetCode() ) )
1099 aCollector.Remove( i );
1100 else
1101 representedNets.insert( item->GetNetCode() );
1102 }
1103}
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:109

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

2034{
2035 bool include = true;
2036 const PCB_LAYER_ID layer = aItem.GetLayer();
2037
2038 // if the item needs to be checked against the options
2039 if( include )
2040 {
2041 switch( aItem.Type() )
2042 {
2043 case PCB_FOOTPRINT_T:
2044 {
2045 const FOOTPRINT& footprint = static_cast<const FOOTPRINT&>( aItem );
2046
2047 include = aFilterOptions.includeModules;
2048
2049 if( include && !aFilterOptions.includeLockedModules )
2050 include = !footprint.IsLocked();
2051
2052 break;
2053 }
2054 case PCB_TRACE_T:
2055 case PCB_ARC_T:
2056 include = aFilterOptions.includeTracks;
2057 break;
2058
2059 case PCB_VIA_T:
2060 include = aFilterOptions.includeVias;
2061 break;
2062
2063 case PCB_FP_ZONE_T:
2064 case PCB_ZONE_T:
2065 include = aFilterOptions.includeZones;
2066 break;
2067
2068 case PCB_SHAPE_T:
2069 case PCB_TARGET_T:
2070 case PCB_DIM_ALIGNED_T:
2071 case PCB_DIM_CENTER_T:
2072 case PCB_DIM_RADIAL_T:
2074 case PCB_DIM_LEADER_T:
2080 if( layer == Edge_Cuts )
2081 include = aFilterOptions.includeBoardOutlineLayer;
2082 else
2083 include = aFilterOptions.includeItemsOnTechLayers;
2084 break;
2085
2086 case PCB_FP_TEXT_T:
2087 case PCB_FP_TEXTBOX_T:
2088 case PCB_TEXT_T:
2089 case PCB_TEXTBOX_T:
2090 include = aFilterOptions.includePcbTexts;
2091 break;
2092
2093 default:
2094 // no filtering, just select it
2095 break;
2096 }
2097 }
2098
2099 return include;
2100}
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:180
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
bool IsLocked() const override
Definition: footprint.h:331
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ Edge_Cuts
Definition: layer_ids.h:113
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:95
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:110
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:107
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:108
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:97
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:111
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:99
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:96
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:106
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
Definition: typeinfo.h:100
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:98
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:109

References 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_DIM_RADIAL_T, PCB_FOOTPRINT_T, PCB_FP_DIM_ALIGNED_T, PCB_FP_DIM_CENTER_T, PCB_FP_DIM_LEADER_T, PCB_FP_DIM_ORTHOGONAL_T, PCB_FP_DIM_RADIAL_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_FP_ZONE_T, PCB_SHAPE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TEXTBOX_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 cursorLeft
Definition: actions.h:118
static TOOL_ACTION zoomOutCenter
Definition: actions.h:96
static TOOL_ACTION zoomIn
Definition: actions.h:93
static TOOL_ACTION cursorLeftFast
Definition: actions.h:123
static TOOL_ACTION cursorDown
Definition: actions.h:117
static TOOL_ACTION zoomOut
Definition: actions.h:94
static TOOL_ACTION cursorRightFast
Definition: actions.h:124
static TOOL_ACTION zoomCenter
Definition: actions.h:97
static TOOL_ACTION panDown
Definition: actions.h:131
static TOOL_ACTION cursorDownFast
Definition: actions.h:122
static TOOL_ACTION cursorUpFast
Definition: actions.h:121
static TOOL_ACTION panLeft
Definition: actions.h:132
static TOOL_ACTION zoomFitScreen
Definition: actions.h:98
static TOOL_ACTION panUp
Definition: actions.h:130
static TOOL_ACTION zoomFitObjects
Definition: actions.h:99
static TOOL_ACTION zoomInCenter
Definition: actions.h:95
static TOOL_ACTION panRight
Definition: actions.h:133
static TOOL_ACTION cursorUp
Cursor control with keyboard.
Definition: actions.h:116
static TOOL_ACTION cursorRight
Definition: actions.h:119

Definition at line 833 of file pcb_selection_tool.cpp.

Referenced by PCB_SELECTION_TOOL::selectMultiple().