80 const wxString& layerName = b->AsString();
84 std::shared_lock<std::shared_mutex> readLock( board->
m_CachesMutex );
89 return i->second.Contains(
m_layer );
94 for(
unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
96 wxPGChoiceEntry& entry = layerMap[ii];
98 if( entry.GetText().Matches( layerName ) )
103 std::unique_lock<std::shared_mutex> writeLock( board->
m_CachesMutex );
124 const wxString& thisStr =
AsString();
125 const wxString& otherStr = b->AsString();
128 if( thisStr.IsSameAs( otherStr,
false ) )
132 if( thisStr.Matches( otherStr ) )
138 if( thisStr == wxT(
"tri_state" ) )
139 altStr = wxT(
"Tri-state" );
140 else if( thisStr == wxT(
"power_in" ) )
141 altStr = wxT(
"Power input" );
142 else if( thisStr == wxT(
"power_out" ) )
143 altStr = wxT(
"Power output" );
144 else if( thisStr == wxT(
"no_connect" ) )
145 altStr = wxT(
"Unconnected" );
147 if( !altStr.IsEmpty() )
150 if( altStr.IsSameAs( otherStr,
false ) )
154 if( altStr.Matches( otherStr ) )
180 return *(
m_item->GetEffectiveNetClass() ) == *( bValue->m_item->GetEffectiveNetClass() );
186 for(
const NETCLASS* nc :
m_item->GetEffectiveNetClass()->GetConstituentNetclasses() )
188 const wxString& ncName = nc->GetName();
190 if( b->StringIsWildcard() )
197 if( ncName.IsSameAs( b->AsString(),
false ) )
209 return *(
m_item->GetEffectiveNetClass() ) != *( bValue->m_item->GetEffectiveNetClass() );
214 bool isInConstituents =
false;
216 for(
const NETCLASS* nc :
m_item->GetEffectiveNetClass()->GetConstituentNetclasses() )
218 const wxString& ncName = nc->GetName();
224 isInConstituents =
true;
230 if( ncName.IsSameAs( b->
AsString(),
false ) )
232 isInConstituents =
true;
241 return !isInConstituents && !isFullName;
275 if( !
m_item || !bValue->m_item )
281 return *aClass == *bClass;
290 const wxString& ccName = cc->GetName();
292 if( b->StringIsWildcard() )
299 if( ccName.IsSameAs( b->AsString(),
false ) )
312 if( !
m_item || !bValue->m_item )
318 return *aClass != *bClass;
324 bool isInConstituents =
false;
328 const wxString& ccName = cc->GetName();
334 isInConstituents =
true;
340 if( ccName.IsSameAs( b->
AsString(),
false ) )
342 isInConstituents =
true;
351 return !isInConstituents && !isFullName;
379 return m_item->GetNetCode() == bValue->m_item->GetNetCode();
387 return m_item->GetNetCode() != bValue->m_item->GetNetCode();
452 std::optional<int> val = item->
Get<std::optional<int>>( it->second );
454 if( val.has_value() )
460 return new LIBEVAL::VALUE(
static_cast<double>( item->
Get<
int>( it->second ) ) );
466 std::optional<double> val = item->
Get<std::optional<double>>( it->second );
468 if( val.has_value() )
482 str = item->
Get<wxString>( it->second );
484 if( it->second->Name() == wxT(
"Pin Type" ) )
495 else if( it->second->Name() == wxT(
"Layer" )
496 || it->second->Name() == wxT(
"Layer Top" )
497 || it->second->Name() == wxT(
"Layer Bottom" ) )
499 const wxAny&
any = item->
Get( it->second );
504 else if(
any.GetAs<wxString>( &str ) )
509 const wxAny&
any = item->
Get( it->second );
511 if(
any.GetAs<wxString>( &str ) )
578 wxString nameLower = aName.Lower();
585 return registry.
Get( nameLower );
590 const wxString& aField )
593 std::unique_ptr<PCBEXPR_VAR_REF> vref;
595 if( aVar.IsSameAs( wxT(
"null" ),
false ) )
597 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
605 wxString baseVar = aVar;
606 std::vector<PCBEXPR_NAV_STEP> navigation;
608 if( aVar.Contains( wxT(
"." ) ) )
610 wxArrayString tokens = wxSplit( aVar,
'.' );
611 baseVar = tokens.IsEmpty() ? wxString() : tokens[0];
613 for(
size_t i = 1; i < tokens.GetCount(); ++i )
615 if( tokens[i].CmpNoCase( wxT(
"Parent" ) ) == 0 )
623 if( baseVar != wxT(
"A" ) && baseVar != wxT(
"AB" ) && baseVar != wxT(
"B" ) )
628 [&navigation]( std::unique_ptr<PCBEXPR_VAR_REF> aRef ) -> std::unique_ptr<PCBEXPR_VAR_REF>
630 if( aRef && !navigation.empty() )
631 aRef->SetNavigation( navigation );
638 if( aField.CmpNoCase( wxT(
"NetClass" ) ) == 0 )
640 if( baseVar == wxT(
"A" ) )
641 return withNav( std::make_unique<PCBEXPR_NETCLASS_REF>( 0 ) );
642 else if( baseVar == wxT(
"B" ) )
643 return withNav( std::make_unique<PCBEXPR_NETCLASS_REF>( 1 ) );
647 else if( aField.CmpNoCase( wxT(
"ComponentClass" ) ) == 0 )
649 if( baseVar == wxT(
"A" ) )
650 return withNav( std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 0 ) );
651 else if( baseVar == wxT(
"B" ) )
652 return withNav( std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 1 ) );
656 else if( aField.CmpNoCase( wxT(
"NetName" ) ) == 0 )
658 if( baseVar == wxT(
"A" ) )
659 return withNav( std::make_unique<PCBEXPR_NETNAME_REF>( 0 ) );
660 else if( baseVar == wxT(
"B" ) )
661 return withNav( std::make_unique<PCBEXPR_NETNAME_REF>( 1 ) );
665 else if( aField.CmpNoCase( wxT(
"Type" ) ) == 0 )
667 if( baseVar == wxT(
"A" ) )
668 return withNav( std::make_unique<PCBEXPR_TYPE_REF>( 0 ) );
669 else if( baseVar == wxT(
"B" ) )
670 return withNav( std::make_unique<PCBEXPR_TYPE_REF>( 1 ) );
675 if( baseVar == wxT(
"A" ) || baseVar == wxT(
"AB" ) )
676 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
677 else if( baseVar == wxT(
"B" ) )
678 vref = std::make_unique<PCBEXPR_VAR_REF>( 1 );
679 else if( baseVar == wxT(
"L" ) )
680 vref = std::make_unique<PCBEXPR_VAR_REF>( 2 );
684 vref->SetNavigation( navigation );
686 if( aField.length() == 0 )
689 wxString field( aField );
690 field.Replace( wxT(
"_" ), wxT(
" " ) );
700 vref->AddAllowedClass( cls.type, prop );
709 vref->SetIsOptional();
718 vref->SetIsOptional();
731 vref->SetIsEnum(
true );
735 wxString msg = wxString::Format( wxT(
"PCBEXPR_UCODE::createVarRef: Unknown "
736 "property type %s from %s." ),
767 static const std::vector<wxString> pcbUnits = { wxT(
"mil" ), wxT(
"mm" ), wxT(
"in" ),
768 wxT(
"deg" ), wxT(
"fs" ), wxT(
"ps" ) };
777 return _(
"must be mm, in, mil, deg, fs, or ps" );
792 double v = wxAtof( aString );
809 static const std::vector<wxString> emptyUnits;
817 static const std::vector<EDA_UNITS> emptyUnits;
825 return wxAtof( aString );
859 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...
FOOTPRINT * GetParentFootprint() const
BOARD_ITEM_CONTAINER * GetParent() const
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.
bool IsGeometryDependent(const wxString &name) const
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
KICAD_T GetEffectiveType(const BOARD_ITEM *aItem) const
PCB_LAYER_ID GetLayer() const
std::map< const BOARD_ITEM *, KICAD_T > m_typeOverrides
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
bool m_hasGeometryDependentFunctions
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::vector< PCBEXPR_NAV_STEP > m_navigation
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.
static const long long MM
wxString result
Test unit parsing edge cases and error handling.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint