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>
#include <math/vector2wx.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 1118 of file pcb_selection_tool.cpp.

1120{
1121 // Narrow the collection down to a single BOARD_CONNECTED_ITEM for each represented net.
1122 // All other items types are removed.
1123 std::set<int> representedNets;
1124
1125 for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
1126 {
1127 BOARD_CONNECTED_ITEM* item = dynamic_cast<BOARD_CONNECTED_ITEM*>( aCollector[i] );
1128
1129 if( !item )
1130 aCollector.Remove( i );
1131 else if ( representedNets.count( item->GetNetCode() ) )
1132 aCollector.Remove( i );
1133 else
1134 representedNets.insert( item->GetNetCode() );
1135 }
1136}
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 2070 of file pcb_selection_tool.cpp.

2072{
2073 bool include = true;
2074 const PCB_LAYER_ID layer = aItem.GetLayer();
2075
2076 // if the item needs to be checked against the options
2077 if( include )
2078 {
2079 switch( aItem.Type() )
2080 {
2081 case PCB_FOOTPRINT_T:
2082 {
2083 const FOOTPRINT& footprint = static_cast<const FOOTPRINT&>( aItem );
2084
2085 include = aFilterOptions.includeModules;
2086
2087 if( include && !aFilterOptions.includeLockedModules )
2088 include = !footprint.IsLocked();
2089
2090 break;
2091 }
2092 case PCB_TRACE_T:
2093 case PCB_ARC_T:
2094 include = aFilterOptions.includeTracks;
2095 break;
2096
2097 case PCB_VIA_T:
2098 include = aFilterOptions.includeVias;
2099 break;
2100
2101 case PCB_FP_ZONE_T:
2102 case PCB_ZONE_T:
2103 include = aFilterOptions.includeZones;
2104 break;
2105
2106 case PCB_SHAPE_T:
2107 case PCB_TARGET_T:
2108 case PCB_DIM_ALIGNED_T:
2109 case PCB_DIM_CENTER_T:
2110 case PCB_DIM_RADIAL_T:
2112 case PCB_DIM_LEADER_T:
2118 if( layer == Edge_Cuts )
2119 include = aFilterOptions.includeBoardOutlineLayer;
2120 else
2121 include = aFilterOptions.includeItemsOnTechLayers;
2122 break;
2123
2124 case PCB_FP_TEXT_T:
2125 case PCB_FP_TEXTBOX_T:
2126 case PCB_TEXT_T:
2127 case PCB_TEXTBOX_T:
2128 include = aFilterOptions.includePcbTexts;
2129 break;
2130
2131 default:
2132 // no filtering, just select it
2133 break;
2134 }
2135 }
2136
2137 return include;
2138}
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:192
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
bool IsLocked() const override
Definition: footprint.h:340
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:119
static TOOL_ACTION zoomOutCenter
Definition: actions.h:97
static TOOL_ACTION zoomIn
Definition: actions.h:94
static TOOL_ACTION cursorLeftFast
Definition: actions.h:124
static TOOL_ACTION cursorDown
Definition: actions.h:118
static TOOL_ACTION zoomOut
Definition: actions.h:95
static TOOL_ACTION cursorRightFast
Definition: actions.h:125
static TOOL_ACTION zoomCenter
Definition: actions.h:98
static TOOL_ACTION panDown
Definition: actions.h:132
static TOOL_ACTION cursorDownFast
Definition: actions.h:123
static TOOL_ACTION cursorUpFast
Definition: actions.h:122
static TOOL_ACTION panLeft
Definition: actions.h:133
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION panUp
Definition: actions.h:131
static TOOL_ACTION zoomFitObjects
Definition: actions.h:100
static TOOL_ACTION zoomInCenter
Definition: actions.h:96
static TOOL_ACTION panRight
Definition: actions.h:134
static TOOL_ACTION cursorUp
Cursor control with keyboard.
Definition: actions.h:117
static TOOL_ACTION cursorRight
Definition: actions.h:120

Definition at line 850 of file pcb_selection_tool.cpp.

Referenced by PCB_SELECTION_TOOL::selectMultiple().