KiCad PCB EDA Suite
EDA_3D_CONDITIONS Class Reference

#include <eda_3d_conditions.h>

Inheritance diagram for EDA_3D_CONDITIONS:
SELECTION_CONDITIONS

Public Member Functions

 EDA_3D_CONDITIONS (BOARD_ADAPTER *aAdapter)
 Define conditions for a 3D viewer frame. More...
 
SELECTION_CONDITION GridSize (GRID3D_TYPE aGridSize)
 Creates a functor that tests the current grid size. More...
 

Static Public Member Functions

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 (std::vector< 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 OnlyTypes (std::vector< 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 gridSizeFunction (const SELECTION &aSelection, BOARD_ADAPTER *aAdapter, GRID3D_TYPE aGridSize)
 < Helper function used by GridDize() More...
 
static bool hasTypeFunc (const SELECTION &aSelection, KICAD_T aType)
 < Helper function used by HasType() More...
 
static bool hasTypesFunc (const SELECTION &aSelection, std::vector< KICAD_T > aTypes)
 Helper function used by OnlyTypes() More...
 
static bool onlyTypesFunc (const SELECTION &aSelection, std::vector< 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)
 

Private Attributes

BOARD_ADAPTERm_adapter
 

Detailed Description

Definition at line 35 of file eda_3d_conditions.h.

Constructor & Destructor Documentation

◆ EDA_3D_CONDITIONS()

EDA_3D_CONDITIONS::EDA_3D_CONDITIONS ( BOARD_ADAPTER aAdapter)
inline

Define conditions for a 3D viewer frame.

Parameters
aAdapteris the board adapter to query for information.

Definition at line 43 of file eda_3d_conditions.h.

43 :
44 m_adapter( aAdapter )
45 {}
BOARD_ADAPTER * m_adapter

Member Function Documentation

◆ andBoolFunc()

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

Definition at line 201 of file selection_conditions.h.

203 {
204 return aConditionA( aSelection ) && aConditionB( aSelection );
205 }

◆ 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 181 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 79 of file selection_conditions.cpp.

80{
81 return std::bind( &SELECTION_CONDITIONS::countFunc, _1, aNumber );
82}
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(), 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 142 of file selection_conditions.cpp.

143{
144 return aSelection.Size() == aNumber;
145}
int Size() const
Returns the number of selected parts.
Definition: selection.h:113

References SELECTION::Size().

Referenced by SELECTION_CONDITIONS::Count().

◆ Empty()

bool SELECTION_CONDITIONS::Empty ( const SELECTION aSelection)
staticinherited

Test 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:107

References SELECTION::Empty().

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

◆ GridSize()

SELECTION_CONDITION EDA_3D_CONDITIONS::GridSize ( GRID3D_TYPE  aGridSize)

Creates a functor that tests the current grid size.

Parameters
aAdapteris the board adapter the setting is in
aGridSizeis the grid size to test for.
Returns
Functor testing if the flag is set.

Definition at line 33 of file eda_3d_conditions.cpp.

34{
35 return std::bind( &EDA_3D_CONDITIONS::gridSizeFunction, _1, m_adapter, aGridSize );
36}
static bool gridSizeFunction(const SELECTION &aSelection, BOARD_ADAPTER *aAdapter, GRID3D_TYPE aGridSize)
< Helper function used by GridDize()

References gridSizeFunction(), and m_adapter.

◆ gridSizeFunction()

bool EDA_3D_CONDITIONS::gridSizeFunction ( const SELECTION aSelection,
BOARD_ADAPTER aAdapter,
GRID3D_TYPE  aGridSize 
)
staticprivate

< Helper function used by GridDize()

The board adapter to read the 3D viewer state from

Definition at line 39 of file eda_3d_conditions.cpp.

42{
43 return aAdapter->m_Cfg->m_Render.grid_type == aGridSize;
44}
EDA_3D_VIEWER_SETTINGS * m_Cfg

References EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::grid_type, BOARD_ADAPTER::m_Cfg, and EDA_3D_VIEWER_SETTINGS::m_Render.

Referenced by GridSize().

◆ 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 EDIT_TOOL::Init(), and 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 97 of file selection_conditions.cpp.

98{
99 if( aSelection.Empty() )
100 return false;
101
102 for( const EDA_ITEM* item : aSelection )
103 {
104 if( item->Type() == aType )
105 return true;
106 }
107
108 return false;
109}
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85

References SELECTION::Empty().

Referenced by SELECTION_CONDITIONS::HasType().

◆ HasTypes()

SELECTION_CONDITION SELECTION_CONDITIONS::HasTypes ( std::vector< 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.
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, std::vector< KICAD_T > aTypes)
Helper function used by OnlyTypes()

References SELECTION_CONDITIONS::hasTypesFunc().

Referenced by EE_SELECTION_TOOL::Init(), and PCB_EDIT_FRAME::setupUIConditions().

◆ hasTypesFunc()

bool SELECTION_CONDITIONS::hasTypesFunc ( const SELECTION aSelection,
std::vector< KICAD_T aTypes 
)
staticprivateinherited

Helper function used by OnlyTypes()

Definition at line 112 of file selection_conditions.cpp.

113{
114 if( aSelection.Empty() )
115 return false;
116
117 for( const EDA_ITEM* item : aSelection )
118 {
119 if( item->IsType( aTypes ) )
120 return true;
121 }
122
123 return false;
124}

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.

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:147
EDA_ITEM * Front() const
Definition: selection.h:200
#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.

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 91 of file selection_conditions.cpp.

92{
93 return std::bind( &SELECTION_CONDITIONS::lessThanFunc, _1, aNumber );
94}
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 154 of file selection_conditions.cpp.

155{
156 return aSelection.Size() < aNumber;
157}

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 85 of file selection_conditions.cpp.

86{
87 return std::bind( &SELECTION_CONDITIONS::moreThanFunc, _1, aNumber );
88}
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(), EDIT_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 148 of file selection_conditions.cpp.

149{
150 return aSelection.Size() > aNumber;
151}

References SELECTION::Size().

Referenced by SELECTION_CONDITIONS::MoreThan().

◆ NotEmpty()

bool SELECTION_CONDITIONS::NotEmpty ( const SELECTION aSelection)
staticinherited

◆ notFunc()

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

Helper function used by operator||.

Definition at line 188 of file selection_conditions.h.

◆ OnlyTypes()

SELECTION_CONDITION SELECTION_CONDITIONS::OnlyTypes ( std::vector< 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.
Returns
Functor testing if selected items are exclusively of the requested types.

Definition at line 73 of file selection_conditions.cpp.

74{
75 return std::bind( &SELECTION_CONDITIONS::onlyTypesFunc, _1, aTypes );
76}
static bool onlyTypesFunc(const SELECTION &aSelection, std::vector< KICAD_T > aTypes)
Helper function used by Count()

References SELECTION_CONDITIONS::onlyTypesFunc().

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(), BOARD_INSPECTION_TOOL::Init(), CONVERT_TOOL::Init(), EDIT_TOOL::Init(), PAD_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,
std::vector< KICAD_T aTypes 
)
staticprivateinherited

Helper function used by Count()

Definition at line 127 of file selection_conditions.cpp.

128{
129 if( aSelection.Empty() )
130 return false;
131
132 for( const EDA_ITEM* item : aSelection )
133 {
134 if( !item->IsType( aTypes ) )
135 return false;
136 }
137
138 return true;
139}

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 194 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 174 of file selection_conditions.h.

◆ ShowAlways()

◆ ShowNever()

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

Always returns false.

Definition at line 79 of file selection_conditions.h.

79{ return false; }

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

Member Data Documentation

◆ m_adapter

BOARD_ADAPTER* EDA_3D_CONDITIONS::m_adapter
private

Definition at line 62 of file eda_3d_conditions.h.

Referenced by GridSize().


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