KiCad PCB EDA Suite
PCB_SELECTION_CONDITIONS Class Reference

#include <pcb_selection_conditions.h>

Inheritance diagram for PCB_SELECTION_CONDITIONS:
SELECTION_CONDITIONS

Static Public Member Functions

static bool OnlyConnectedItems (const SELECTION &aSelection)
 Test if selection contains exclusively connected items (pads, tracks, vias, zones). More...
 
static SELECTION_CONDITION SameNet (bool aAllowUnconnected=false)
 Create a functor that tests if selection contains items belonging to the same net or are unconnected if aAllowUnconnected == true. More...
 
static SELECTION_CONDITION SameLayer ()
 Creates a functor that tests if selection contains items that belong exclusively to the same layer. More...
 
static SELECTION_CONDITION OnlyGraphicShapeTypes (const std::set< SHAPE_T > aTypes)
 Create a functor that tests if the selection contains PCB_SHAPE* items of certain shapes. More...
 
static bool ShowAlways (const SELECTION &aSelection)
 The default condition function (always returns true). More...
 
static bool ShowNever (const SELECTION &aSelection)
 Always returns false. More...
 
static bool NotEmpty (const SELECTION &aSelection)
 Test if there are any items selected. More...
 
static bool Empty (const SELECTION &aSelection)
 Test if there are no items selected. More...
 
static bool Idle (const SELECTION &aSelection)
 Test if there no items selected or being edited. More...
 
static bool IdleSelection (const SELECTION &aSelection)
 Test if all selected items are not being edited. More...
 
static SELECTION_CONDITION HasType (KICAD_T aType)
 Create a functor that tests if among the selected items there is at least one of a given type. More...
 
static SELECTION_CONDITION HasTypes (const KICAD_T aTypes[])
 Create a functor that tests if among the selected items there is at least one of a given types. More...
 
static SELECTION_CONDITION OnlyType (KICAD_T aType)
 Create a functor that tests if the selected items are only of given type. More...
 
static SELECTION_CONDITION OnlyTypes (const KICAD_T aTypes[])
 Create a functor that tests if the selected items are only of given types. More...
 
static SELECTION_CONDITION Count (int aNumber)
 Create a functor that tests if the number of selected items is equal to the value given as parameter. More...
 
static SELECTION_CONDITION MoreThan (int aNumber)
 Create a functor that tests if the number of selected items is greater than the value given as parameter. More...
 
static SELECTION_CONDITION LessThan (int aNumber)
 Create a functor that tests if the number of selected items is smaller than the value given as parameter. More...
 

Static Private Member Functions

static bool sameNetFunc (const SELECTION &aSelection, bool aAllowUnconnected)
 < Helper function used by SameNet() More...
 
static bool sameLayerFunc (const SELECTION &aSelection)
 Helper function used by OnlyGraphicShapeTypes() More...
 
static bool onlyGraphicShapeTypesFunc (const SELECTION &aSelection, const std::set< SHAPE_T > aTypes)
 
static bool hasTypeFunc (const SELECTION &aSelection, KICAD_T aType)
 < Helper function used by HasType() More...
 
static bool hasTypesFunc (const SELECTION &aSelection, const KICAD_T aTypes[])
 Helper function used by OnlyType() More...
 
static bool onlyTypeFunc (const SELECTION &aSelection, KICAD_T aType)
 Helper function used by OnlyTypes() More...
 
static bool onlyTypesFunc (const SELECTION &aSelection, const KICAD_T aTypes[])
 Helper function used by Count() More...
 
static bool countFunc (const SELECTION &aSelection, int aNumber)
 Helper function used by MoreThan() More...
 
static bool moreThanFunc (const SELECTION &aSelection, int aNumber)
 Helper function used by LessThan() More...
 
static bool lessThanFunc (const SELECTION &aSelection, int aNumber)
 Helper function used by operator||. More...
 
static bool orFunc (const SELECTION_CONDITION &aConditionA, const SELECTION_CONDITION &aConditionB, const SELECTION &aSelection)
 Helper function used by operator&&. More...
 
static bool andFunc (const SELECTION_CONDITION &aConditionA, const SELECTION_CONDITION &aConditionB, const SELECTION &aSelection)
 Helper function used by operator! More...
 
static bool notFunc (const SELECTION_CONDITION &aCondition, const SELECTION &aSelection)
 Helper function used by operator||. More...
 
static bool orBoolFunc (const SELECTION_CONDITION &aConditionA, SELECTION_BOOL &aConditionB, const SELECTION &aSelection)
 Helper function used by operator&&. More...
 
static bool andBoolFunc (const SELECTION_CONDITION &aConditionA, SELECTION_BOOL &aConditionB, const SELECTION &aSelection)
 

Detailed Description

Definition at line 35 of file pcb_selection_conditions.h.

Member Function Documentation

◆ andBoolFunc()

static bool SELECTION_CONDITIONS::andBoolFunc ( const SELECTION_CONDITION aConditionA,
SELECTION_BOOL aConditionB,
const SELECTION aSelection 
)
inlinestaticprivateinherited

Definition at line 238 of file selection_conditions.h.

240 {
241 return aConditionA( aSelection ) && aConditionB( aSelection );
242 }

◆ andFunc()

static bool SELECTION_CONDITIONS::andFunc ( const SELECTION_CONDITION aConditionA,
const SELECTION_CONDITION aConditionB,
const SELECTION aSelection 
)
inlinestaticprivateinherited

Helper function used by operator!

Definition at line 218 of file selection_conditions.h.

◆ Count()

SELECTION_CONDITION SELECTION_CONDITIONS::Count ( int  aNumber)
staticinherited

Create a functor that tests if the number of selected items is equal to the value given as parameter.

Parameters
aNumberis the number of expected items.
Returns
Functor testing if the number of selected items is equal aNumber.

Definition at line 85 of file selection_conditions.cpp.

86{
87 return std::bind( &SELECTION_CONDITIONS::countFunc, _1, aNumber );
88}
static bool countFunc(const SELECTION &aSelection, int aNumber)
Helper function used by MoreThan()

References SELECTION_CONDITIONS::countFunc().

Referenced by EE_SELECTION_TOOL::Init(), SCH_EDIT_TOOL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), SYMBOL_EDITOR_PIN_TOOL::Init(), BOARD_INSPECTION_TOOL::Init(), CONVERT_TOOL::Init(), EDIT_TOOL::Init(), PAD_TOOL::Init(), and PCB_EDIT_FRAME::setupUIConditions().

◆ countFunc()

bool SELECTION_CONDITIONS::countFunc ( const SELECTION aSelection,
int  aNumber 
)
staticprivateinherited

Helper function used by MoreThan()

Definition at line 165 of file selection_conditions.cpp.

166{
167 return aSelection.Size() == aNumber;
168}
int Size() const
Returns the number of selected parts.
Definition: selection.h:104

References SELECTION::Size().

Referenced by SELECTION_CONDITIONS::Count().

◆ Empty()

bool SELECTION_CONDITIONS::Empty ( const SELECTION aSelection)
staticinherited

Test if there are no items selected.

Parameters
aSelectionis the selection to be tested.
Returns
True if there are no items selected.

Definition at line 41 of file selection_conditions.cpp.

42{
43 return aSelection.Empty();
44}
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:98

References SELECTION::Empty().

Referenced by EE_SELECTION_TOOL::Init(), and PL_SELECTION_TOOL::Init().

◆ HasType()

SELECTION_CONDITION SELECTION_CONDITIONS::HasType ( KICAD_T  aType)
staticinherited

Create a functor that tests if among the selected items there is at least one of a given type.

Parameters
aTypeis the type that is searched.
Returns
Functor testing for presence of items of a given type.

Definition at line 61 of file selection_conditions.cpp.

62{
63 return std::bind( &SELECTION_CONDITIONS::hasTypeFunc, _1, aType );
64}
static bool hasTypeFunc(const SELECTION &aSelection, KICAD_T aType)
< Helper function used by HasType()

References SELECTION_CONDITIONS::hasTypeFunc().

Referenced by PAD_TOOL::Init().

◆ hasTypeFunc()

bool SELECTION_CONDITIONS::hasTypeFunc ( const SELECTION aSelection,
KICAD_T  aType 
)
staticprivateinherited

< Helper function used by HasType()

Helper function used by HasTypes()

Definition at line 103 of file selection_conditions.cpp.

104{
105 if( aSelection.Empty() )
106 return false;
107
108 for( const EDA_ITEM* item : aSelection )
109 {
110 if( item->Type() == aType )
111 return true;
112 }
113
114 return false;
115}
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100

References SELECTION::Empty().

Referenced by SELECTION_CONDITIONS::HasType().

◆ HasTypes()

SELECTION_CONDITION SELECTION_CONDITIONS::HasTypes ( const KICAD_T  aTypes[])
staticinherited

Create a functor that tests if among the selected items there is at least one of a given types.

Parameters
aTypesis an array containing types that are searched. It has to be ended with #KICAD_T::EOT as end marker.
Returns
Functor testing for presence of items of a given types.

Definition at line 67 of file selection_conditions.cpp.

68{
69 return std::bind( &SELECTION_CONDITIONS::hasTypesFunc, _1, aTypes );
70}
static bool hasTypesFunc(const SELECTION &aSelection, const KICAD_T aTypes[])
Helper function used by OnlyType()

References SELECTION_CONDITIONS::hasTypesFunc().

Referenced by EE_SELECTION_TOOL::Init().

◆ hasTypesFunc()

bool SELECTION_CONDITIONS::hasTypesFunc ( const SELECTION aSelection,
const KICAD_T  aTypes[] 
)
staticprivateinherited

Helper function used by OnlyType()

Definition at line 118 of file selection_conditions.cpp.

119{
120 if( aSelection.Empty() )
121 return false;
122
123 for( const EDA_ITEM* item : aSelection )
124 {
125 if( item->IsType( aTypes ) )
126 return true;
127 }
128
129 return false;
130}

References SELECTION::Empty().

Referenced by SELECTION_CONDITIONS::HasTypes().

◆ Idle()

bool SELECTION_CONDITIONS::Idle ( const SELECTION aSelection)
staticinherited

Test if there no items selected or being edited.

Parameters
aSelectionis the selection to be tested.
Returns
True if there are no items being edited or no items selected.

Definition at line 47 of file selection_conditions.cpp.

48{
49 constexpr int busyMask = ( IS_NEW | IS_PASTED | IS_MOVING | IS_RESIZING | IS_DRAGGING );
50
51 return !aSelection.Front() || ( aSelection.Front()->GetEditFlags() & busyMask ) == 0;
52}
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:157
EDA_ITEM * Front() const
Definition: selection.h:182
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_NEW
New item, just created.
#define IS_DRAGGING
Item being dragged.
#define IS_MOVING
Item being moved.
#define IS_RESIZING
Item being resized.

References SELECTION::Front(), EDA_ITEM::GetEditFlags(), IS_DRAGGING, IS_MOVING, IS_NEW, IS_PASTED, and IS_RESIZING.

Referenced by EE_INSPECTION_TOOL::Init(), EE_SELECTION_TOOL::Init(), SCH_EDIT_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), SCH_EDIT_FRAME::setupUIConditions(), SYMBOL_EDIT_FRAME::setupUIConditions(), PL_EDITOR_FRAME::setupUIConditions(), FOOTPRINT_EDIT_FRAME::setupUIConditions(), and PCB_EDIT_FRAME::setupUIConditions().

◆ IdleSelection()

bool SELECTION_CONDITIONS::IdleSelection ( const SELECTION aSelection)
staticinherited

Test if all selected items are not being edited.

Parameters
aSelectionis the selection to be tested.
Returns
True if no selected items are being edited.

Definition at line 55 of file selection_conditions.cpp.

56{
57 return ( aSelection.Front() && aSelection.Front()->GetEditFlags() == 0 );
58}

References SELECTION::Front(), and EDA_ITEM::GetEditFlags().

Referenced by SCH_EDIT_TOOL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), and SYMBOL_EDITOR_MOVE_TOOL::Init().

◆ LessThan()

SELECTION_CONDITION SELECTION_CONDITIONS::LessThan ( int  aNumber)
staticinherited

Create a functor that tests if the number of selected items is smaller than the value given as parameter.

Parameters
aNumberis the number used for comparison.
Returns
Functor testing if the number of selected items is smaller than aNumber.

Definition at line 97 of file selection_conditions.cpp.

98{
99 return std::bind( &SELECTION_CONDITIONS::lessThanFunc, _1, aNumber );
100}
static bool lessThanFunc(const SELECTION &aSelection, int aNumber)
Helper function used by operator||.

References SELECTION_CONDITIONS::lessThanFunc().

Referenced by EE_SELECTION_TOOL::Init().

◆ lessThanFunc()

bool SELECTION_CONDITIONS::lessThanFunc ( const SELECTION aSelection,
int  aNumber 
)
staticprivateinherited

Helper function used by operator||.

Definition at line 177 of file selection_conditions.cpp.

178{
179 return aSelection.Size() < aNumber;
180}

References SELECTION::Size().

Referenced by SELECTION_CONDITIONS::LessThan().

◆ MoreThan()

SELECTION_CONDITION SELECTION_CONDITIONS::MoreThan ( int  aNumber)
staticinherited

Create a functor that tests if the number of selected items is greater than the value given as parameter.

Parameters
aNumberis the number used for comparison.
Returns
Functor testing if the number of selected items is greater than aNumber.

Definition at line 91 of file selection_conditions.cpp.

92{
93 return std::bind( &SELECTION_CONDITIONS::moreThanFunc, _1, aNumber );
94}
static bool moreThanFunc(const SELECTION &aSelection, int aNumber)
Helper function used by LessThan()

References SELECTION_CONDITIONS::moreThanFunc().

Referenced by EE_SELECTION_TOOL::Init(), SCH_EDIT_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), CONVERT_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), FOOTPRINT_EDIT_FRAME::setupUIConditions(), and PCB_EDIT_FRAME::setupUIConditions().

◆ moreThanFunc()

bool SELECTION_CONDITIONS::moreThanFunc ( const SELECTION aSelection,
int  aNumber 
)
staticprivateinherited

Helper function used by LessThan()

Definition at line 171 of file selection_conditions.cpp.

172{
173 return aSelection.Size() > aNumber;
174}

References SELECTION::Size().

Referenced by SELECTION_CONDITIONS::MoreThan().

◆ NotEmpty()

bool SELECTION_CONDITIONS::NotEmpty ( const SELECTION aSelection)
staticinherited

Test if there are any items selected.

Parameters
aSelectionis the selection to be tested.
Returns
True if there is at least one item selected.

Definition at line 35 of file selection_conditions.cpp.

36{
37 return !aSelection.Empty();
38}

References SELECTION::Empty().

Referenced by SCH_EDIT_TOOL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), BOARD_EDITOR_CONTROL::Init(), EDIT_TOOL::Init(), GROUP_TOOL::Init(), PCB_SELECTION_TOOL::Init(), and PL_EDITOR_FRAME::setupUIConditions().

◆ notFunc()

static bool SELECTION_CONDITIONS::notFunc ( const SELECTION_CONDITION aCondition,
const SELECTION aSelection 
)
inlinestaticprivateinherited

Helper function used by operator||.

Definition at line 225 of file selection_conditions.h.

◆ OnlyConnectedItems()

bool PCB_SELECTION_CONDITIONS::OnlyConnectedItems ( const SELECTION aSelection)
static

Test if selection contains exclusively connected items (pads, tracks, vias, zones).

Parameters
aSelectionis the selection to be tested.
Returns
True if there are only connected items connected.

Definition at line 36 of file pcb_selection_conditions.cpp.

37{
38 if( aSelection.Empty() )
39 return false;
40
41 for( const auto &item : aSelection )
42 {
43 auto type = item->Type();
44
45 if( type != PCB_PAD_T && type != PCB_VIA_T && type != PCB_TRACE_T && type != PCB_ZONE_T )
46 return false;
47 }
48
49 return true;
50}
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:104
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:114
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:89
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:103

References SELECTION::Empty(), PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, and PCB_ZONE_T.

◆ OnlyGraphicShapeTypes()

S_C PCB_SELECTION_CONDITIONS::OnlyGraphicShapeTypes ( const std::set< SHAPE_T aTypes)
static

Create a functor that tests if the selection contains PCB_SHAPE* items of certain shapes.

This implicitly includes an OnlyType( PCB_SHAPE_T ) as part of the test.

Parameters
aTypesis a list of allowed PCB_SHAPE shapes (
See also
SHAPE_T)
Returns
functor testing if selected items match the given list of allowed shapes

Definition at line 65 of file pcb_selection_conditions.cpp.

66{
67 return std::bind( &PCB_SELECTION_CONDITIONS::onlyGraphicShapeTypesFunc, _1, aTypes );
68}
static bool onlyGraphicShapeTypesFunc(const SELECTION &aSelection, const std::set< SHAPE_T > aTypes)

References onlyGraphicShapeTypesFunc().

Referenced by CONVERT_TOOL::Init().

◆ onlyGraphicShapeTypesFunc()

bool PCB_SELECTION_CONDITIONS::onlyGraphicShapeTypesFunc ( const SELECTION aSelection,
const std::set< SHAPE_T aTypes 
)
staticprivate

Definition at line 139 of file pcb_selection_conditions.cpp.

141{
142 if( aSelection.Empty() )
143 return false;
144
145 for( const EDA_ITEM* item : aSelection )
146 {
147 if( item->Type() != PCB_SHAPE_T && item->Type() != PCB_FP_SHAPE_T )
148 return false;
149
150 SHAPE_T shape = static_cast<const PCB_SHAPE*>( item )->GetShape();
151
152 if( !aTypes.count( shape ) )
153 return false;
154 }
155
156 return true;
157}
SHAPE_T
Definition: eda_shape.h:43
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:96

References SELECTION::Empty(), PCB_FP_SHAPE_T, and PCB_SHAPE_T.

Referenced by OnlyGraphicShapeTypes().

◆ OnlyType()

SELECTION_CONDITION SELECTION_CONDITIONS::OnlyType ( KICAD_T  aType)
staticinherited

Create a functor that tests if the selected items are only of given type.

Parameters
aTypeis the type that is searched.
Returns
Functor testing if selected items are exclusively of one type.

Definition at line 73 of file selection_conditions.cpp.

74{
75 return std::bind( &SELECTION_CONDITIONS::onlyTypeFunc, _1, aType );
76}
static bool onlyTypeFunc(const SELECTION &aSelection, KICAD_T aType)
Helper function used by OnlyTypes()

References SELECTION_CONDITIONS::onlyTypeFunc().

Referenced by EE_SELECTION_TOOL::Init(), SCH_EDIT_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), SCH_MOVE_TOOL::Init(), SYMBOL_EDITOR_PIN_TOOL::Init(), BOARD_EDITOR_CONTROL::Init(), CONVERT_TOOL::Init(), EDIT_TOOL::Init(), PAD_TOOL::Init(), and PCB_EDIT_FRAME::setupUIConditions().

◆ onlyTypeFunc()

bool SELECTION_CONDITIONS::onlyTypeFunc ( const SELECTION aSelection,
KICAD_T  aType 
)
staticprivateinherited

Helper function used by OnlyTypes()

Definition at line 133 of file selection_conditions.cpp.

134{
135 if( aSelection.Empty() )
136 return false;
137
138 KICAD_T types[] = { aType, EOT };
139
140 for( const EDA_ITEM* item : aSelection )
141 {
142 if( !item->IsType( types ) )
143 return false;
144 }
145
146 return true;
147}
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ EOT
search types array terminator (End Of Types)
Definition: typeinfo.h:81

References SELECTION::Empty(), and EOT.

Referenced by SELECTION_CONDITIONS::OnlyType().

◆ OnlyTypes()

SELECTION_CONDITION SELECTION_CONDITIONS::OnlyTypes ( const KICAD_T  aTypes[])
staticinherited

Create a functor that tests if the selected items are only of given types.

Parameters
aTypesis an array containing types that are searched. It has to be ended with #KICAD_T::EOT as end marker.
Returns
Functor testing if selected items are exclusively of the requested types.

Definition at line 79 of file selection_conditions.cpp.

80{
81 return std::bind( &SELECTION_CONDITIONS::onlyTypesFunc, _1, aTypes );
82}
static bool onlyTypesFunc(const SELECTION &aSelection, const KICAD_T aTypes[])
Helper function used by Count()

References SELECTION_CONDITIONS::onlyTypesFunc().

Referenced by EE_SELECTION_TOOL::Init(), SCH_EDIT_TOOL::Init(), BOARD_INSPECTION_TOOL::Init(), CONVERT_TOOL::Init(), EDIT_TOOL::Init(), EDIT_TOOL::Properties(), PCB_EDIT_FRAME::setupUIConditions(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), BOARD_EDITOR_CONTROL::ViaSizeDec(), and BOARD_EDITOR_CONTROL::ViaSizeInc().

◆ onlyTypesFunc()

bool SELECTION_CONDITIONS::onlyTypesFunc ( const SELECTION aSelection,
const KICAD_T  aTypes[] 
)
staticprivateinherited

Helper function used by Count()

Definition at line 150 of file selection_conditions.cpp.

151{
152 if( aSelection.Empty() )
153 return false;
154
155 for( const EDA_ITEM* item : aSelection )
156 {
157 if( !item->IsType( aTypes ) )
158 return false;
159 }
160
161 return true;
162}

References SELECTION::Empty().

Referenced by SELECTION_CONDITIONS::OnlyTypes().

◆ orBoolFunc()

static bool SELECTION_CONDITIONS::orBoolFunc ( const SELECTION_CONDITION aConditionA,
SELECTION_BOOL aConditionB,
const SELECTION aSelection 
)
inlinestaticprivateinherited

Helper function used by operator&&.

Definition at line 231 of file selection_conditions.h.

◆ orFunc()

static bool SELECTION_CONDITIONS::orFunc ( const SELECTION_CONDITION aConditionA,
const SELECTION_CONDITION aConditionB,
const SELECTION aSelection 
)
inlinestaticprivateinherited

Helper function used by operator&&.

Definition at line 211 of file selection_conditions.h.

◆ SameLayer()

S_C PCB_SELECTION_CONDITIONS::SameLayer ( )
static

Creates a functor that tests if selection contains items that belong exclusively to the same layer.

In case of items belonging to multiple layers, it is enough to have a single common layer with other items.

Returns
Functor testing if selected items share at least one common layer.

Definition at line 59 of file pcb_selection_conditions.cpp.

60{
61 return std::bind( &PCB_SELECTION_CONDITIONS::sameLayerFunc, _1 );
62}
static bool sameLayerFunc(const SELECTION &aSelection)
Helper function used by OnlyGraphicShapeTypes()

References sameLayerFunc().

Referenced by CONVERT_TOOL::Init().

◆ sameLayerFunc()

bool PCB_SELECTION_CONDITIONS::sameLayerFunc ( const SELECTION aSelection)
staticprivate

Helper function used by OnlyGraphicShapeTypes()

Definition at line 118 of file pcb_selection_conditions.cpp.

119{
120 if( aSelection.Empty() )
121 return false;
122
123 LSET layerSet;
124 layerSet.set();
125
126 for( const auto& i : aSelection )
127 {
128 auto item = static_cast<BOARD_ITEM*>( i );
129 layerSet &= item->GetLayerSet();
130
131 if( !layerSet.any() ) // there are no common layers left
132 return false;
133 }
134
135 return true;
136}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:53
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:529

References SELECTION::Empty().

Referenced by SameLayer().

◆ SameNet()

S_C PCB_SELECTION_CONDITIONS::SameNet ( bool  aAllowUnconnected = false)
static

Create a functor that tests if selection contains items belonging to the same net or are unconnected if aAllowUnconnected == true.

Parameters
aAllowUnconnecteddetermines if unconnected items (with no net code assigned) should be treated as connected to the same net.
Returns
Functor testing if selected items are belonging to the same net.

Definition at line 53 of file pcb_selection_conditions.cpp.

54{
55 return std::bind( &PCB_SELECTION_CONDITIONS::sameNetFunc, _1, aAllowUnconnected );
56}
static bool sameNetFunc(const SELECTION &aSelection, bool aAllowUnconnected)
< Helper function used by SameNet()

References sameNetFunc().

◆ sameNetFunc()

bool PCB_SELECTION_CONDITIONS::sameNetFunc ( const SELECTION aSelection,
bool  aAllowUnconnected 
)
staticprivate

< Helper function used by SameNet()

Helper function used by SameLayer()

Definition at line 72 of file pcb_selection_conditions.cpp.

73{
74 if( aSelection.Empty() )
75 return false;
76
77 int netcode = -1; // -1 stands for 'net code is not yet determined'
78
79 for( const auto& aitem : aSelection )
80 {
81 int current_netcode = -1;
82
83 const BOARD_CONNECTED_ITEM* item =
84 dynamic_cast<const BOARD_CONNECTED_ITEM*>( aitem );
85
86 if( item )
87 {
88 current_netcode = item->GetNetCode();
89 }
90 else
91 {
92 if( !aAllowUnconnected )
93 return false;
94 else
95 // if it is not a BOARD_CONNECTED_ITEM, treat it as if there was no net assigned
96 current_netcode = 0;
97 }
98
99 assert( current_netcode >= 0 );
100
101 if( netcode < 0 )
102 {
103 netcode = current_netcode;
104
105 if( netcode == NETINFO_LIST::UNCONNECTED && !aAllowUnconnected )
106 return false;
107 }
108 else if( netcode != current_netcode )
109 {
110 return false;
111 }
112 }
113
114 return true;
115}
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
Definition: netinfo.h:375

References SELECTION::Empty(), BOARD_CONNECTED_ITEM::GetNetCode(), and NETINFO_LIST::UNCONNECTED.

Referenced by SameNet().

◆ ShowAlways()

◆ ShowNever()

static bool SELECTION_CONDITIONS::ShowNever ( const SELECTION aSelection)
inlinestaticinherited

Always returns false.

Parameters
aSelectionis the selection to be tested.
Returns
Always false.

Definition at line 88 of file selection_conditions.h.

89 {
90 return false;
91 }

Referenced by ACTION_CONDITIONS::ACTION_CONDITIONS(), KICAD_MANAGER_FRAME::setupUIConditions(), and PL_EDITOR_FRAME::setupUIConditions().


The documentation for this class was generated from the following files: