70 const wxString& layerName = b->AsString();
74 std::shared_lock<std::shared_mutex> readLock( board->
m_CachesMutex );
79 return i->second.Contains(
m_layer );
84 for(
unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
86 wxPGChoiceEntry& entry = layerMap[ii];
88 if( entry.GetText().Matches( layerName ) )
93 std::unique_lock<std::shared_mutex> writeLock( board->
m_CachesMutex );
114 const wxString& thisStr =
AsString();
115 const wxString& otherStr = b->AsString();
118 if( thisStr.IsSameAs( otherStr,
false ) )
122 if( thisStr.Matches( otherStr ) )
128 if( thisStr == wxT(
"tri_state" ) )
129 altStr = wxT(
"Tri-state" );
130 else if( thisStr == wxT(
"power_in" ) )
131 altStr = wxT(
"Power input" );
132 else if( thisStr == wxT(
"power_out" ) )
133 altStr = wxT(
"Power output" );
134 else if( thisStr == wxT(
"no_connect" ) )
135 altStr = wxT(
"Unconnected" );
137 if( !altStr.IsEmpty() )
140 if( altStr.IsSameAs( otherStr,
false ) )
144 if( altStr.Matches( otherStr ) )
170 return *(
m_item->GetEffectiveNetClass() ) == *( bValue->m_item->GetEffectiveNetClass() );
176 for(
const NETCLASS* nc :
m_item->GetEffectiveNetClass()->GetConstituentNetclasses() )
178 const wxString& ncName = nc->GetName();
180 if( b->StringIsWildcard() )
187 if( ncName.IsSameAs( b->AsString(),
false ) )
199 return *(
m_item->GetEffectiveNetClass() ) != *( bValue->m_item->GetEffectiveNetClass() );
204 bool isInConstituents =
false;
206 for(
const NETCLASS* nc :
m_item->GetEffectiveNetClass()->GetConstituentNetclasses() )
208 const wxString& ncName = nc->GetName();
214 isInConstituents =
true;
220 if( ncName.IsSameAs( b->
AsString(),
false ) )
222 isInConstituents =
true;
231 return !isInConstituents && !isFullName;
265 if( !
m_item || !bValue->m_item )
271 return *aClass == *bClass;
280 const wxString& ccName = cc->GetName();
282 if( b->StringIsWildcard() )
289 if( ccName.IsSameAs( b->AsString(),
false ) )
302 if( !
m_item || !bValue->m_item )
308 return *aClass != *bClass;
314 bool isInConstituents =
false;
318 const wxString& ccName = cc->GetName();
324 isInConstituents =
true;
330 if( ccName.IsSameAs( b->
AsString(),
false ) )
332 isInConstituents =
true;
341 return !isInConstituents && !isFullName;
369 return m_item->GetNetCode() == bValue->m_item->GetNetCode();
377 return m_item->GetNetCode() != bValue->m_item->GetNetCode();
418 std::optional<int> val = item->
Get<std::optional<int>>( it->second );
420 if( val.has_value() )
426 return new LIBEVAL::VALUE(
static_cast<double>( item->
Get<
int>( it->second ) ) );
432 std::optional<double> val = item->
Get<std::optional<double>>( it->second );
434 if( val.has_value() )
448 str = item->
Get<wxString>( it->second );
450 if( it->second->Name() == wxT(
"Pin Type" ) )
461 else if( it->second->Name() == wxT(
"Layer" )
462 || it->second->Name() == wxT(
"Layer Top" )
463 || it->second->Name() == wxT(
"Layer Bottom" ) )
465 const wxAny&
any = item->
Get( it->second );
470 else if(
any.GetAs<wxString>( &str ) )
475 const wxAny&
any = item->
Get( it->second );
477 if(
any.GetAs<wxString>( &str ) )
535 return registry.
Get( aName.Lower() );
540 const wxString& aField )
543 std::unique_ptr<PCBEXPR_VAR_REF> vref;
545 if( aVar.IsSameAs( wxT(
"null" ),
false ) )
547 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
554 if( aField.CmpNoCase( wxT(
"NetClass" ) ) == 0 )
556 if( aVar == wxT(
"A" ) )
557 return std::make_unique<PCBEXPR_NETCLASS_REF>( 0 );
558 else if( aVar == wxT(
"B" ) )
559 return std::make_unique<PCBEXPR_NETCLASS_REF>( 1 );
563 else if( aField.CmpNoCase( wxT(
"ComponentClass" ) ) == 0 )
565 if( aVar == wxT(
"A" ) )
566 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 0 );
567 else if( aVar == wxT(
"B" ) )
568 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 1 );
572 else if( aField.CmpNoCase( wxT(
"NetName" ) ) == 0 )
574 if( aVar == wxT(
"A" ) )
575 return std::make_unique<PCBEXPR_NETNAME_REF>( 0 );
576 else if( aVar == wxT(
"B" ) )
577 return std::make_unique<PCBEXPR_NETNAME_REF>( 1 );
581 else if( aField.CmpNoCase( wxT(
"Type" ) ) == 0 )
583 if( aVar == wxT(
"A" ) )
584 return std::make_unique<PCBEXPR_TYPE_REF>( 0 );
585 else if( aVar == wxT(
"B" ) )
586 return std::make_unique<PCBEXPR_TYPE_REF>( 1 );
591 if( aVar == wxT(
"A" ) || aVar == wxT(
"AB" ) )
592 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
593 else if( aVar == wxT(
"B" ) )
594 vref = std::make_unique<PCBEXPR_VAR_REF>( 1 );
595 else if( aVar == wxT(
"L" ) )
596 vref = std::make_unique<PCBEXPR_VAR_REF>( 2 );
600 if( aField.length() == 0 )
603 wxString field( aField );
604 field.Replace( wxT(
"_" ), wxT(
" " ) );
614 vref->AddAllowedClass( cls.type, prop );
623 vref->SetIsOptional();
632 vref->SetIsOptional();
645 vref->SetIsEnum(
true );
649 wxString msg = wxString::Format( wxT(
"PCBEXPR_UCODE::createVarRef: Unknown "
650 "property type %s from %s." ),
681 static const std::vector<wxString> pcbUnits = { wxT(
"mil" ), wxT(
"mm" ), wxT(
"in" ),
682 wxT(
"deg" ), wxT(
"fs" ), wxT(
"ps" ) };
691 return _(
"must be mm, in, mil, deg, fs, or ps" );
706 double v = wxAtof( aString );
723 static const std::vector<wxString> emptyUnits;
731 static const std::vector<EDA_UNITS> emptyUnits;
739 return wxAtof( aString );
773 if( !
m_compiler.Compile( aExpr.ToUTF8().data(), &ucode, &preflightContext ) )
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
BASE_SET & set(size_t pos)
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
PCB_LAYER_ID GetLayerID(const wxString &aLayerName) const
Return the ID of a layer.
std::unordered_map< wxString, LSET > m_LayerExpressionCache
std::shared_mutex m_CachesMutex
A lightweight representation of a component class.
KICAD_T Type() const
Returns the type of object.
static ENUM_MAP< T > & Instance()
wxAny Get(PROPERTY_BASE *aProperty) const
std::unique_ptr< UNIT_RESOLVER > m_unitResolver
VALUE * Run(CONTEXT *ctx)
virtual const wxString & AsString() const
bool StringIsWildcard() const
static VALUE * MakeNullValue()
virtual bool NotEqualTo(CONTEXT *aCtx, const VALUE *b) const
VAR_TYPE_T GetType() const
virtual bool EqualTo(CONTEXT *aCtx, const VALUE *b) const
LSET is a set of PCB_LAYER_IDs.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
A collection of nets and the parameters used to route or test these nets.
LIBEVAL::FUNC_CALL_REF Get(const wxString &name)
static PCBEXPR_BUILTIN_FUNCTIONS & Instance()
PCBEXPR_COMPILER(LIBEVAL::UNIT_RESOLVER *aUnitResolver)
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
bool NotEqualTo(LIBEVAL::CONTEXT *aCtx, const LIBEVAL::VALUE *b) const override
const wxString & AsString() const override
PCBEXPR_COMPONENT_CLASS_VALUE(BOARD_ITEM *aItem)
bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
PCB_LAYER_ID GetLayer() const
BOARD_ITEM * GetItem(int index) const
LIBEVAL::ERROR_STATUS m_errorStatus
PCBEXPR_EVALUATOR(LIBEVAL::UNIT_RESOLVER *aUnitResolver)
PCBEXPR_COMPILER m_compiler
bool Evaluate(const wxString &aExpr)
PCBEXPR_LAYER_VALUE(PCB_LAYER_ID aLayer)
virtual bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
BOARD_CONNECTED_ITEM * m_item
PCBEXPR_NETCLASS_VALUE(BOARD_CONNECTED_ITEM *aItem)
const wxString & AsString() const override
bool NotEqualTo(LIBEVAL::CONTEXT *aCtx, const LIBEVAL::VALUE *b) const override
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
BOARD_CONNECTED_ITEM * m_item
PCBEXPR_NET_VALUE(BOARD_CONNECTED_ITEM *aItem)
bool NotEqualTo(LIBEVAL::CONTEXT *aCtx, const LIBEVAL::VALUE *b) const override
const wxString & AsString() const override
bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
PCBEXPR_PINTYPE_VALUE(const wxString &aPinTypeName)
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
virtual std::unique_ptr< LIBEVAL::VAR_REF > CreateVarRef(const wxString &aVar, const wxString &aField) override
virtual LIBEVAL::FUNC_CALL_REF CreateFuncCall(const wxString &aName) override
const std::vector< wxString > & GetSupportedUnits() const override
const std::vector< EDA_UNITS > & GetSupportedUnitsTypes() const override
double Convert(const wxString &aString, int unitId) const override
double Convert(const wxString &aString, int unitId) const override
const std::vector< EDA_UNITS > & GetSupportedUnitsTypes() const override
wxString GetSupportedUnitsMessage() const override
const std::vector< wxString > & GetSupportedUnits() const override
std::unordered_map< TYPE_ID, PROPERTY_BASE * > m_matchingTypes
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
LIBEVAL::VAR_TYPE_T m_type
BOARD_ITEM * GetObject(const LIBEVAL::CONTEXT *aCtx) const
virtual size_t TypeHash() const =0
Return type-id of the property type.
virtual bool HasChoices() const
Return true if this PROPERTY has a limited set of possible values.
Provide class metadata.Helper macro to map type hashes to names.
CLASSES_INFO GetAllClasses()
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
bool IsOfType(TYPE_ID aDerived, TYPE_ID aBase) const
Return true if aDerived is inherited from aBase.
A type-safe container of any type.
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Convert aTextValue to a double.
std::function< void(CONTEXT *, void *)> FUNC_CALL_REF
bool WildCompareString(const wxString &pattern, const wxString &string_to_tst, bool case_sensitive)
Compare a string against wild card (* and ?) pattern using the usual rules.
wxString result
Test unit parsing edge cases and error handling.
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint