68 const wxString& layerName = b->AsString();
72 std::shared_lock<std::shared_mutex> readLock( board->
m_CachesMutex );
77 return i->second.Contains(
m_layer );
82 for(
unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
84 wxPGChoiceEntry& entry = layerMap[ii];
86 if( entry.GetText().Matches( layerName ) )
91 std::unique_lock<std::shared_mutex> writeLock( board->
m_CachesMutex );
112 const wxString& thisStr =
AsString();
113 const wxString& otherStr = b->AsString();
116 if( thisStr.IsSameAs( otherStr,
false ) )
120 if( thisStr.Matches( otherStr ) )
126 if( thisStr == wxT(
"tri_state" ) )
127 altStr = wxT(
"Tri-state" );
128 else if( thisStr == wxT(
"power_in" ) )
129 altStr = wxT(
"Power input" );
130 else if( thisStr == wxT(
"power_out" ) )
131 altStr = wxT(
"Power output" );
132 else if( thisStr == wxT(
"no_connect" ) )
133 altStr = wxT(
"Unconnected" );
135 if( !altStr.IsEmpty() )
138 if( altStr.IsSameAs( otherStr,
false ) )
142 if( altStr.Matches( otherStr ) )
168 return *(
m_item->GetEffectiveNetClass() ) == *( bValue->m_item->GetEffectiveNetClass() );
174 for(
const NETCLASS* nc :
m_item->GetEffectiveNetClass()->GetConstituentNetclasses() )
176 const wxString& ncName = nc->GetName();
178 if( b->StringIsWildcard() )
185 if( ncName.IsSameAs( b->AsString(),
false ) )
197 return *(
m_item->GetEffectiveNetClass() ) != *( bValue->m_item->GetEffectiveNetClass() );
202 bool isInConstituents =
false;
204 for(
const NETCLASS* nc :
m_item->GetEffectiveNetClass()->GetConstituentNetclasses() )
206 const wxString& ncName = nc->GetName();
212 isInConstituents =
true;
218 if( ncName.IsSameAs( b->
AsString(),
false ) )
220 isInConstituents =
true;
229 return !isInConstituents && !isFullName;
263 if( !
m_item || !bValue->m_item )
269 return *aClass == *bClass;
278 const wxString& ccName = cc->GetName();
280 if( b->StringIsWildcard() )
287 if( ccName.IsSameAs( b->AsString(),
false ) )
300 if( !
m_item || !bValue->m_item )
306 return *aClass != *bClass;
312 bool isInConstituents =
false;
316 const wxString& ccName = cc->GetName();
322 isInConstituents =
true;
328 if( ccName.IsSameAs( b->
AsString(),
false ) )
330 isInConstituents =
true;
339 return !isInConstituents && !isFullName;
367 return m_item->GetNetCode() == bValue->m_item->GetNetCode();
375 return m_item->GetNetCode() != bValue->m_item->GetNetCode();
416 std::optional<int> val = item->
Get<std::optional<int>>( it->second );
418 if( val.has_value() )
424 return new LIBEVAL::VALUE(
static_cast<double>( item->
Get<
int>( it->second ) ) );
430 std::optional<double> val = item->
Get<std::optional<double>>( it->second );
432 if( val.has_value() )
446 str = item->
Get<wxString>( it->second );
448 if( it->second->Name() == wxT(
"Pin Type" ) )
459 else if( it->second->Name() == wxT(
"Layer" )
460 || it->second->Name() == wxT(
"Layer Top" )
461 || it->second->Name() == wxT(
"Layer Bottom" ) )
463 const wxAny&
any = item->
Get( it->second );
468 else if(
any.GetAs<wxString>( &str ) )
473 const wxAny&
any = item->
Get( it->second );
475 if(
any.GetAs<wxString>( &str ) )
533 return registry.
Get( aName.Lower() );
538 const wxString& aField )
541 std::unique_ptr<PCBEXPR_VAR_REF> vref;
543 if( aVar.IsSameAs( wxT(
"null" ),
false ) )
545 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
552 if( aField.CmpNoCase( wxT(
"NetClass" ) ) == 0 )
554 if( aVar == wxT(
"A" ) )
555 return std::make_unique<PCBEXPR_NETCLASS_REF>( 0 );
556 else if( aVar == wxT(
"B" ) )
557 return std::make_unique<PCBEXPR_NETCLASS_REF>( 1 );
561 else if( aField.CmpNoCase( wxT(
"ComponentClass" ) ) == 0 )
563 if( aVar == wxT(
"A" ) )
564 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 0 );
565 else if( aVar == wxT(
"B" ) )
566 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 1 );
570 else if( aField.CmpNoCase( wxT(
"NetName" ) ) == 0 )
572 if( aVar == wxT(
"A" ) )
573 return std::make_unique<PCBEXPR_NETNAME_REF>( 0 );
574 else if( aVar == wxT(
"B" ) )
575 return std::make_unique<PCBEXPR_NETNAME_REF>( 1 );
579 else if( aField.CmpNoCase( wxT(
"Type" ) ) == 0 )
581 if( aVar == wxT(
"A" ) )
582 return std::make_unique<PCBEXPR_TYPE_REF>( 0 );
583 else if( aVar == wxT(
"B" ) )
584 return std::make_unique<PCBEXPR_TYPE_REF>( 1 );
589 if( aVar == wxT(
"A" ) || aVar == wxT(
"AB" ) )
590 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
591 else if( aVar == wxT(
"B" ) )
592 vref = std::make_unique<PCBEXPR_VAR_REF>( 1 );
593 else if( aVar == wxT(
"L" ) )
594 vref = std::make_unique<PCBEXPR_VAR_REF>( 2 );
598 if( aField.length() == 0 )
601 wxString field( aField );
602 field.Replace( wxT(
"_" ), wxT(
" " ) );
612 vref->AddAllowedClass( cls.type, prop );
621 vref->SetIsOptional();
630 vref->SetIsOptional();
643 vref->SetIsEnum(
true );
647 wxString msg = wxString::Format( wxT(
"PCBEXPR_UCODE::createVarRef: Unknown "
648 "property type %s from %s." ),
679 static const std::vector<wxString> pcbUnits = { wxT(
"mil" ), wxT(
"mm" ), wxT(
"in" ),
680 wxT(
"deg" ), wxT(
"fs" ), wxT(
"ps" ) };
689 return _(
"must be mm, in, mil, deg, fs, or ps" );
704 double v = wxAtof( aString );
721 static const std::vector<wxString> emptyUnits;
729 static const std::vector<EDA_UNITS> emptyUnits;
737 return wxAtof( aString );
771 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