65 const wxString& layerName = b->AsString();
69 std::shared_lock<std::shared_mutex> readLock( board->
m_CachesMutex );
74 return i->second.Contains(
m_layer );
79 for(
unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
81 wxPGChoiceEntry& entry = layerMap[ii];
83 if( entry.GetText().Matches( layerName ) )
88 std::unique_lock<std::shared_mutex> writeLock( board->
m_CachesMutex );
109 const wxString& thisStr =
AsString();
110 const wxString& otherStr = b->AsString();
113 if( thisStr.IsSameAs( otherStr,
false ) )
117 if( thisStr.Matches( otherStr ) )
123 if( thisStr == wxT(
"tri_state" ) )
124 altStr = wxT(
"Tri-state" );
125 else if( thisStr == wxT(
"power_in" ) )
126 altStr = wxT(
"Power input" );
127 else if( thisStr == wxT(
"power_out" ) )
128 altStr = wxT(
"Power output" );
129 else if( thisStr == wxT(
"no_connect" ) )
130 altStr = wxT(
"Unconnected" );
132 if( !altStr.IsEmpty() )
135 if( altStr.IsSameAs( otherStr,
false ) )
139 if( altStr.Matches( otherStr ) )
168 == *( bValue->m_item->GetEffectiveNetClass() );
187 != *( bValue->m_item->GetEffectiveNetClass() );
192 const bool isInConstituents =
196 return !isInConstituents && !isFullName;
230 if( !
m_item || !bValue->m_item )
236 return *aClass == *bClass;
255 if( !
m_item || !bValue->m_item )
261 return *aClass != *bClass;
266 const bool isInConstituents =
270 return !isInConstituents && !isFullName;
347 auto val = item->
Get<std::optional<int>>( it->second );
349 if( val.has_value() )
355 return new LIBEVAL::VALUE(
static_cast<double>( item->
Get<
int>( it->second ) ) );
361 auto val = item->
Get<std::optional<double>>( it->second );
363 if( val.has_value() )
377 str = item->
Get<wxString>( it->second );
379 if( it->second->Name() == wxT(
"Pin Type" ) )
386 const wxAny& any = item->
Get( it->second );
389 if( it->second->Name() == wxT(
"Layer" )
390 || it->second->Name() == wxT(
"Layer Top" )
391 || it->second->Name() == wxT(
"Layer Bottom" ) )
395 else if( any.GetAs<wxString>( &str ) )
400 if( any.GetAs<wxString>( &str ) )
459 return registry.
Get( aName.Lower() );
464 const wxString& aField )
467 std::unique_ptr<PCBEXPR_VAR_REF> vref;
469 if( aVar.IsSameAs( wxT(
"null" ),
false ) )
471 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
478 if( aField.CmpNoCase( wxT(
"NetClass" ) ) == 0 )
480 if( aVar == wxT(
"A" ) )
481 return std::make_unique<PCBEXPR_NETCLASS_REF>( 0 );
482 else if( aVar == wxT(
"B" ) )
483 return std::make_unique<PCBEXPR_NETCLASS_REF>( 1 );
487 else if( aField.CmpNoCase( wxT(
"ComponentClass" ) ) == 0 )
489 if( aVar == wxT(
"A" ) )
490 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 0 );
491 else if( aVar == wxT(
"B" ) )
492 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 1 );
496 else if( aField.CmpNoCase( wxT(
"NetName" ) ) == 0 )
498 if( aVar == wxT(
"A" ) )
499 return std::make_unique<PCBEXPR_NETNAME_REF>( 0 );
500 else if( aVar == wxT(
"B" ) )
501 return std::make_unique<PCBEXPR_NETNAME_REF>( 1 );
505 else if( aField.CmpNoCase( wxT(
"Type" ) ) == 0 )
507 if( aVar == wxT(
"A" ) )
508 return std::make_unique<PCBEXPR_TYPE_REF>( 0 );
509 else if( aVar == wxT(
"B" ) )
510 return std::make_unique<PCBEXPR_TYPE_REF>( 1 );
515 if( aVar == wxT(
"A" ) || aVar == wxT(
"AB" ) )
516 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
517 else if( aVar == wxT(
"B" ) )
518 vref = std::make_unique<PCBEXPR_VAR_REF>( 1 );
519 else if( aVar == wxT(
"L" ) )
520 vref = std::make_unique<PCBEXPR_VAR_REF>( 2 );
524 if( aField.length() == 0 )
527 wxString field( aField );
528 field.Replace( wxT(
"_" ), wxT(
" " ) );
538 vref->AddAllowedClass( cls.type, prop );
547 vref->SetIsOptional();
556 vref->SetIsOptional();
569 vref->SetIsEnum(
true );
573 wxString msg = wxString::Format( wxT(
"PCBEXPR_UCODE::createVarRef: Unknown "
574 "property type %s from %s." ),
605 static const std::vector<wxString> pcbUnits = { wxT(
"mil" ), wxT(
"mm" ), wxT(
"in" ),
614 return _(
"must be mm, in, mil, or deg" );
620 double v = wxAtof( aString );
634 static const std::vector<wxString> emptyUnits;
642 return wxAtof( aString );
658 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
A lightweight representation of a component class.
bool ContainsClassName(const wxString &className) const
Determines if this (effective) component class contains a specific constituent class.
const wxString & GetName() const
Fetches the full name of this 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
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.
bool ContainsNetclassWithName(const wxString &netclass) const
Determines if the given netclass name is a constituent of this (maybe aggregate) netclass.
const wxString GetName() const
Gets the name of this (maybe aggregate) netclass in a format for internal usage or for export to exte...
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)
Convert aTextValue to a double.
std::function< void(CONTEXT *, void *)> FUNC_CALL_REF
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint