64 const wxString& layerName = b->AsString();
68 std::shared_lock<std::shared_mutex> readLock( board->
m_CachesMutex );
73 return i->second.Contains(
m_layer );
78 for(
unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
80 wxPGChoiceEntry& entry = layerMap[ii];
82 if( entry.GetText().Matches( layerName ) )
87 std::unique_lock<std::shared_mutex> writeLock( board->
m_CachesMutex );
108 const wxString& thisStr =
AsString();
109 const wxString& otherStr = b->AsString();
111 if( thisStr.IsSameAs( otherStr,
false ) )
115 if( thisStr == wxT(
"tri_state" ) )
116 return otherStr.IsSameAs( wxT(
"Tri-state" ),
false );
118 if( thisStr == wxT(
"power_in" ) )
119 return otherStr.IsSameAs( wxT(
"Power input" ),
false );
121 if( thisStr == wxT(
"power_out" ) )
122 return otherStr.IsSameAs( wxT(
"Power output" ),
false );
124 if( thisStr == wxT(
"no_connect" ) )
125 return otherStr.IsSameAs( wxT(
"Unconnected" ),
false );
151 == *( bValue->m_item->GetEffectiveNetClass() );
194 if( !
m_item || !bValue->m_item )
202 return aClass == bClass;
215 if( !
m_item || !bValue->m_item )
223 return aClass != bClass;
302 auto val = item->
Get<std::optional<int>>( it->second );
304 if( val.has_value() )
310 return new LIBEVAL::VALUE(
static_cast<double>( item->
Get<
int>( it->second ) ) );
318 str = item->
Get<wxString>( it->second );
320 if( it->second->Name() == wxT(
"Pin Type" ) )
327 const wxAny& any = item->
Get( it->second );
330 if( it->second->Name() == wxT(
"Layer" )
331 || it->second->Name() == wxT(
"Layer Top" )
332 || it->second->Name() == wxT(
"Layer Bottom" ) )
336 else if( any.GetAs<wxString>( &str ) )
341 if( any.GetAs<wxString>( &str ) )
400 return registry.
Get( aName.Lower() );
405 const wxString& aField )
408 std::unique_ptr<PCBEXPR_VAR_REF> vref;
410 if( aVar.IsSameAs( wxT(
"null" ),
false ) )
412 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
419 if( aField.CmpNoCase( wxT(
"NetClass" ) ) == 0 )
421 if( aVar == wxT(
"A" ) )
422 return std::make_unique<PCBEXPR_NETCLASS_REF>( 0 );
423 else if( aVar == wxT(
"B" ) )
424 return std::make_unique<PCBEXPR_NETCLASS_REF>( 1 );
428 else if( aField.CmpNoCase( wxT(
"ComponentClass" ) ) == 0 )
430 if( aVar == wxT(
"A" ) )
431 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 0 );
432 else if( aVar == wxT(
"B" ) )
433 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 1 );
437 else if( aField.CmpNoCase( wxT(
"NetName" ) ) == 0 )
439 if( aVar == wxT(
"A" ) )
440 return std::make_unique<PCBEXPR_NETNAME_REF>( 0 );
441 else if( aVar == wxT(
"B" ) )
442 return std::make_unique<PCBEXPR_NETNAME_REF>( 1 );
446 else if( aField.CmpNoCase( wxT(
"Type" ) ) == 0 )
448 if( aVar == wxT(
"A" ) )
449 return std::make_unique<PCBEXPR_TYPE_REF>( 0 );
450 else if( aVar == wxT(
"B" ) )
451 return std::make_unique<PCBEXPR_TYPE_REF>( 1 );
456 if( aVar == wxT(
"A" ) || aVar == wxT(
"AB" ) )
457 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
458 else if( aVar == wxT(
"B" ) )
459 vref = std::make_unique<PCBEXPR_VAR_REF>( 1 );
460 else if( aVar == wxT(
"L" ) )
461 vref = std::make_unique<PCBEXPR_VAR_REF>( 2 );
465 if( aField.length() == 0 )
470 wxString field( aField );
471 field.Replace( wxT(
"_" ), wxT(
" " ) );
481 vref->AddAllowedClass( cls.type, prop );
490 vref->SetIsOptional();
503 vref->SetIsEnum(
true );
507 wxFAIL_MSG( wxT(
"PCBEXPR_UCODE::createVarRef: Unknown property type." ) );
535 static const std::vector<wxString> pcbUnits = { wxT(
"mil" ), wxT(
"mm" ), wxT(
"in" ) };
543 return _(
"must be mm, in, or mil" );
549 double v = wxAtof( aString );
563 static const std::vector<wxString> emptyUnits;
571 return wxAtof( aString );
587 m_compiler( aUnitResolver ),
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,...
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
wxString GetNetname() const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
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
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
bool Compile(const wxString &aString, UCODE *aCode, CONTEXT *aPreflightContext)
VALUE * Run(CONTEXT *ctx)
virtual const wxString & AsString() const
static VALUE * MakeNullValue()
virtual bool NotEqualTo(CONTEXT *aCtx, const VALUE *b) const
virtual double AsDouble() 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.
const wxString GetVariableSubstitutionName() const
Gets the name of this (maybe aggregate) netclass in a format for label variable substitutions.
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
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
double Convert(const wxString &aString, int unitId) const override
double Convert(const wxString &aString, int unitId) 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.
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)
Function DoubleValueFromString converts aTextValue to a double.
std::function< void(CONTEXT *, void *)> FUNC_CALL_REF
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint