82 const wxString& layerName = b->AsString();
86 std::shared_lock<std::shared_mutex> readLock( board->
m_CachesMutex );
91 return i->second.Contains(
m_layer );
96 for(
unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
98 wxPGChoiceEntry& entry = layerMap[ii];
100 if( entry.GetText().Matches( layerName ) )
105 std::unique_lock<std::shared_mutex> writeLock( board->
m_CachesMutex );
126 const wxString& thisStr =
AsString();
127 const wxString& otherStr = b->AsString();
130 if( thisStr.IsSameAs( otherStr,
false ) )
134 if( thisStr.Matches( otherStr ) )
140 if( thisStr == wxT(
"tri_state" ) )
141 altStr = wxT(
"Tri-state" );
142 else if( thisStr == wxT(
"power_in" ) )
143 altStr = wxT(
"Power input" );
144 else if( thisStr == wxT(
"power_out" ) )
145 altStr = wxT(
"Power output" );
146 else if( thisStr == wxT(
"no_connect" ) )
147 altStr = wxT(
"Unconnected" );
149 if( !altStr.IsEmpty() )
152 if( altStr.IsSameAs( otherStr,
false ) )
156 if( altStr.Matches( otherStr ) )
182 return *(
m_item->GetEffectiveNetClass() ) == *( bValue->m_item->GetEffectiveNetClass() );
188 for(
const NETCLASS* nc :
m_item->GetEffectiveNetClass()->GetConstituentNetclasses() )
190 const wxString& ncName = nc->GetName();
192 if( b->StringIsWildcard() )
199 if( ncName.IsSameAs( b->AsString(),
false ) )
211 return *(
m_item->GetEffectiveNetClass() ) != *( bValue->m_item->GetEffectiveNetClass() );
216 bool isInConstituents =
false;
218 for(
const NETCLASS* nc :
m_item->GetEffectiveNetClass()->GetConstituentNetclasses() )
220 const wxString& ncName = nc->GetName();
226 isInConstituents =
true;
232 if( ncName.IsSameAs( b->
AsString(),
false ) )
234 isInConstituents =
true;
243 return !isInConstituents && !isFullName;
277 if( !
m_item || !bValue->m_item )
283 return *aClass == *bClass;
292 const wxString& ccName = cc->GetName();
294 if( b->StringIsWildcard() )
301 if( ccName.IsSameAs( b->AsString(),
false ) )
314 if( !
m_item || !bValue->m_item )
320 return *aClass != *bClass;
326 bool isInConstituents =
false;
330 const wxString& ccName = cc->GetName();
336 isInConstituents =
true;
342 if( ccName.IsSameAs( b->
AsString(),
false ) )
344 isInConstituents =
true;
353 return !isInConstituents && !isFullName;
381 return m_item->GetNetCode() == bValue->m_item->GetNetCode();
389 return m_item->GetNetCode() != bValue->m_item->GetNetCode();
412 else if( type ==
TYPE_HASH( std::optional<int> ) )
416 else if( type ==
TYPE_HASH(
long long int ) )
420 else if( type ==
TYPE_HASH( std::optional<double> ) )
511 switch( it->second.kind )
514 return new LIBEVAL::VALUE(
static_cast<double>( item->
Get<
int>( it->second.property ) ) );
518 std::optional<int> val = item->
Get<std::optional<int>>( it->second.property );
527 return new LIBEVAL::VALUE(
static_cast<double>( item->
Get<
unsigned>( it->second.property ) ) );
530 return new LIBEVAL::VALUE(
static_cast<double>( item->
Get<
long long int>( it->second.property ) ) );
536 std::optional<double> val = item->
Get<std::optional<double>>( it->second.property );
545 return new LIBEVAL::VALUE(
static_cast<double>( item->
Get<
bool>( it->second.property ) ) );
549 wxString str = item->
Get<wxString>( it->second.property );
551 if( it->second.property->Name() == wxT(
"Pin Type" ) )
567 if( it->second.property->Name() == wxT(
"Layer" ) || it->second.property->Name() == wxT(
"Layer Top" )
568 || it->second.property->Name() == wxT(
"Layer Bottom" ) )
570 const wxAny&
any = item->
Get( it->second.property );
575 else if(
any.GetAs<wxString>( &str ) )
580 const wxAny&
any = item->
Get( it->second.property );
582 if(
any.GetAs<wxString>( &str ) )
660 wxString nameLower = aName.Lower();
667 return registry.
Get( nameLower );
672 const wxString& aField )
675 std::unique_ptr<PCBEXPR_VAR_REF> vref;
677 if( aVar.IsSameAs( wxT(
"null" ),
false ) )
679 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
687 wxString baseVar = aVar;
688 std::vector<PCBEXPR_NAV_STEP> navigation;
690 if( aVar.Contains( wxT(
"." ) ) )
692 wxArrayString tokens = wxSplit( aVar,
'.' );
693 baseVar = tokens.IsEmpty() ? wxString() : tokens[0];
695 for(
size_t i = 1; i < tokens.GetCount(); ++i )
697 if( tokens[i].CmpNoCase( wxT(
"Parent" ) ) == 0 )
704 if( baseVar != wxT(
"A" ) && baseVar != wxT(
"B" ) )
708 if( !aField.IsEmpty() && ( baseVar == wxT(
"AB" ) || baseVar == wxT(
"L" ) ) )
711 if( baseVar == wxT(
"B" ) || baseVar == wxT(
"AB" ) )
715 [&navigation]( std::unique_ptr<PCBEXPR_VAR_REF> aRef ) -> std::unique_ptr<PCBEXPR_VAR_REF>
717 if( aRef && !navigation.empty() )
718 aRef->SetNavigation( navigation );
725 if( aField.CmpNoCase( wxT(
"NetClass" ) ) == 0 )
727 if( baseVar == wxT(
"A" ) )
728 return withNav( std::make_unique<PCBEXPR_NETCLASS_REF>( 0 ) );
729 else if( baseVar == wxT(
"B" ) )
730 return withNav( std::make_unique<PCBEXPR_NETCLASS_REF>( 1 ) );
734 else if( aField.CmpNoCase( wxT(
"ComponentClass" ) ) == 0 )
736 if( baseVar == wxT(
"A" ) )
737 return withNav( std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 0 ) );
738 else if( baseVar == wxT(
"B" ) )
739 return withNav( std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 1 ) );
743 else if( aField.CmpNoCase( wxT(
"NetName" ) ) == 0 )
745 if( baseVar == wxT(
"A" ) )
746 return withNav( std::make_unique<PCBEXPR_NETNAME_REF>( 0 ) );
747 else if( baseVar == wxT(
"B" ) )
748 return withNav( std::make_unique<PCBEXPR_NETNAME_REF>( 1 ) );
752 else if( aField.CmpNoCase( wxT(
"Type" ) ) == 0 )
754 if( baseVar == wxT(
"A" ) )
755 return withNav( std::make_unique<PCBEXPR_TYPE_REF>( 0 ) );
756 else if( baseVar == wxT(
"B" ) )
757 return withNav( std::make_unique<PCBEXPR_TYPE_REF>( 1 ) );
762 if( baseVar == wxT(
"A" ) || baseVar == wxT(
"AB" ) )
763 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
764 else if( baseVar == wxT(
"B" ) )
765 vref = std::make_unique<PCBEXPR_VAR_REF>( 1 );
766 else if( baseVar == wxT(
"L" ) )
767 vref = std::make_unique<PCBEXPR_VAR_REF>( 2 );
771 vref->SetNavigation( navigation );
773 if( aField.length() == 0 )
776 wxString field( aField );
777 field.Replace( wxT(
"_" ), wxT(
" " ) );
797 vref->AddAllowedClass( cls.type, prop, kind );
798 vref->SetType( expressionType );
825 static const std::vector<wxString> pcbUnits = { wxT(
"mil" ), wxT(
"mm" ), wxT(
"in" ),
826 wxT(
"deg" ), wxT(
"fs" ), wxT(
"ps" ) };
835 return _(
"must be mm, in, mil, deg, fs, or ps" );
850 double v = wxAtof( aString );
867 static const std::vector<wxString> emptyUnits;
875 static const std::vector<EDA_UNITS> emptyUnits;
883 return wxAtof( aString );
917 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
A color representation with 4 components: red, green, blue, alpha.
wxString ToCSSString() 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
static PCBEXPR_PROPERTY_KIND ClassifyProperty(const PROPERTY_BASE *aProperty)
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
std::unordered_map< TYPE_ID, MATCHED_PROPERTY > m_matchingTypes
static LIBEVAL::VAR_TYPE_T ExpressionType(PCBEXPR_PROPERTY_KIND aKind)
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
size_t TYPE_ID
Unique type identifier.
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