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 ) )
173 const wxString& ncName = nc->GetName();
175 if( b->StringIsWildcard() )
182 if( ncName.IsSameAs( b->AsString(),
false ) )
199 bool isInConstituents =
false;
203 const wxString& ncName = nc->GetName();
209 isInConstituents =
true;
215 if( ncName.IsSameAs( b->
AsString(),
false ) )
217 isInConstituents =
true;
226 return !isInConstituents && !isFullName;
260 if( !
m_item || !bValue->m_item )
266 return *aClass == *bClass;
275 const wxString& ccName = cc->
GetName();
277 if( b->StringIsWildcard() )
284 if( ccName.IsSameAs( b->AsString(),
false ) )
297 if( !
m_item || !bValue->m_item )
303 return *aClass != *bClass;
309 bool isInConstituents =
false;
313 const wxString& ccName = cc->
GetName();
319 isInConstituents =
true;
325 if( ccName.IsSameAs( b->
AsString(),
false ) )
327 isInConstituents =
true;
336 return !isInConstituents && !isFullName;
413 auto val = item->
Get<std::optional<int>>( it->second );
415 if( val.has_value() )
421 return new LIBEVAL::VALUE(
static_cast<double>( item->
Get<
int>( it->second ) ) );
427 auto val = item->
Get<std::optional<double>>( it->second );
429 if( val.has_value() )
443 str = item->
Get<wxString>( it->second );
445 if( it->second->Name() == wxT(
"Pin Type" ) )
452 const wxAny& any = item->
Get( it->second );
455 if( it->second->Name() == wxT(
"Layer" )
456 || it->second->Name() == wxT(
"Layer Top" )
457 || it->second->Name() == wxT(
"Layer Bottom" ) )
461 else if( any.GetAs<wxString>( &str ) )
466 if( any.GetAs<wxString>( &str ) )
525 return registry.
Get( aName.Lower() );
530 const wxString& aField )
533 std::unique_ptr<PCBEXPR_VAR_REF> vref;
535 if( aVar.IsSameAs( wxT(
"null" ),
false ) )
537 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
544 if( aField.CmpNoCase( wxT(
"NetClass" ) ) == 0 )
546 if( aVar == wxT(
"A" ) )
547 return std::make_unique<PCBEXPR_NETCLASS_REF>( 0 );
548 else if( aVar == wxT(
"B" ) )
549 return std::make_unique<PCBEXPR_NETCLASS_REF>( 1 );
553 else if( aField.CmpNoCase( wxT(
"ComponentClass" ) ) == 0 )
555 if( aVar == wxT(
"A" ) )
556 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 0 );
557 else if( aVar == wxT(
"B" ) )
558 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 1 );
562 else if( aField.CmpNoCase( wxT(
"NetName" ) ) == 0 )
564 if( aVar == wxT(
"A" ) )
565 return std::make_unique<PCBEXPR_NETNAME_REF>( 0 );
566 else if( aVar == wxT(
"B" ) )
567 return std::make_unique<PCBEXPR_NETNAME_REF>( 1 );
571 else if( aField.CmpNoCase( wxT(
"Type" ) ) == 0 )
573 if( aVar == wxT(
"A" ) )
574 return std::make_unique<PCBEXPR_TYPE_REF>( 0 );
575 else if( aVar == wxT(
"B" ) )
576 return std::make_unique<PCBEXPR_TYPE_REF>( 1 );
581 if( aVar == wxT(
"A" ) || aVar == wxT(
"AB" ) )
582 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
583 else if( aVar == wxT(
"B" ) )
584 vref = std::make_unique<PCBEXPR_VAR_REF>( 1 );
585 else if( aVar == wxT(
"L" ) )
586 vref = std::make_unique<PCBEXPR_VAR_REF>( 2 );
590 if( aField.length() == 0 )
593 wxString field( aField );
594 field.Replace( wxT(
"_" ), wxT(
" " ) );
604 vref->AddAllowedClass( cls.type, prop );
613 vref->SetIsOptional();
622 vref->SetIsOptional();
635 vref->SetIsEnum(
true );
639 wxString msg = wxString::Format( wxT(
"PCBEXPR_UCODE::createVarRef: Unknown "
640 "property type %s from %s." ),
671 static const std::vector<wxString> pcbUnits = { wxT(
"mil" ), wxT(
"mm" ), wxT(
"in" ),
672 wxT(
"deg" ), wxT(
"fs" ), wxT(
"ps" ) };
681 return _(
"must be mm, in, mil, deg, fs, or ps" );
687 static const std::vector<EDA_UNITS> pcbUnits = { EDA_UNITS::MILS, EDA_UNITS::MM, EDA_UNITS::INCH,
688 EDA_UNITS::DEGREES, EDA_UNITS::FS, EDA_UNITS::PS };
696 double v = wxAtof( aString );
713 static const std::vector<wxString> emptyUnits;
721 static const std::vector<EDA_UNITS> emptyUnits;
729 return wxAtof( aString );
746 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.
const wxString & GetName() const
Fetches the full name of this component class.
const std::vector< COMPONENT_CLASS * > & GetConstituentClasses() const
Fetches a vector of the constituent classes for this (effective) 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
bool StringIsWildcard() const
static VALUE * MakeNullValue()
virtual bool NotEqualTo(CONTEXT *aCtx, const VALUE *b) const
virtual double AsDouble() const
EDA_UNITS GetUnits() 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 GetName() const
Gets the name of this (maybe aggregate) netclass in a format for internal usage or for export to exte...
const std::vector< NETCLASS * > & GetConstituentNetclasses() const
Gets the netclasses which make up this netclass.
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
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.
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.
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint