61 wxLogWarning( wxT(
"Attempting to call fromTo() with non-existent from-to cache." ) );
75#define MISSING_LAYER_ARG( f ) wxString::Format( _( "Missing layer name argument to %s." ), f )
90 if( !arg || arg->
AsString().IsEmpty() )
99 [item, arg, aCtx]() ->
double
101 const wxString& layerName = arg->
AsString();
110 bool anyMatch =
false;
112 for(
unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
114 wxPGChoiceEntry& entry = layerMap[ ii ];
116 if( entry.GetText().Matches( layerName ))
127 aCtx->
ReportError( wxString::Format(
_(
"Unrecognized layer '%s'" ),
142 std::shared_lock<std::shared_mutex> readLock( board->
m_CachesMutex );
147 return ( item->
GetLayerSet() & i->second ).any() ? 1.0 : 0.0;
152 for(
unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
154 wxPGChoiceEntry& entry = layerMap[ ii ];
156 if( entry.GetText().Matches( layerName ) )
161 std::unique_lock<std::shared_mutex> writeLock( board->
m_CachesMutex );
165 return ( item->
GetLayerSet() & mask ).any() ? 1.0 : 0.0;
176 aCtx->
Push( result );
202 if(
ZONE* zone =
dynamic_cast<ZONE*
>( aItem ) )
203 aItemShape.reset( zone->Outline()->Clone() );
208 return footprintCourtyard.
Collide( aItemShape.get() );
222 if( aSelector.Upper().StartsWith( wxT(
"${CLASS:" ) ) && aSelector.EndsWith(
'}' ) )
224 wxString
name = aSelector.Mid( 8, aSelector.Length() - 9 );
235 else if( aSelector.Contains(
':' ) && aFp->
GetFPIDAsString().Matches( aSelector ) )
245 const std::function<
bool(
FOOTPRINT* )>& aFunc )
247 if( aArg == wxT(
"A" ) )
251 if( fp && aFunc( fp ) )
254 else if( aArg == wxT(
"B" ) )
258 if( fp && aFunc( fp ) )
271#define MISSING_FP_ARG( f ) \
272 wxString::Format( _( "Missing footprint argument (A, B, or reference designator) to %s." ), f )
281 context->
Push( result );
283 if( !arg || arg->
AsString().IsEmpty() )
298 [item, arg, context]() ->
double
301 std::shared_ptr<SHAPE> itemShape;
306 PTR_PTR_CACHE_KEY key = { fp, item };
310 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
312 auto i = board->m_IntersectsCourtyardCache.find( key );
314 if( i != board->m_IntersectsCourtyardCache.end() )
323 std::unique_lock<std::shared_mutex> cacheLock( board->m_CachesMutex );
324 board->m_IntersectsCourtyardCache[ key ] = res;
345 context->
Push( result );
347 if( !arg || arg->
AsString().IsEmpty() )
362 [item, arg, context]() ->
double
365 std::shared_ptr<SHAPE> itemShape;
370 PTR_PTR_CACHE_KEY key = { fp, item };
374 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
376 auto i = board->m_IntersectsFCourtyardCache.find( key );
378 if( i != board->m_IntersectsFCourtyardCache.end() )
386 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
387 board->m_IntersectsFCourtyardCache[ key ] = res;
408 context->
Push( result );
410 if( !arg || arg->
AsString().IsEmpty() )
425 [item, arg, context]() ->
double
428 std::shared_ptr<SHAPE> itemShape;
433 PTR_PTR_CACHE_KEY key = { fp, item };
437 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
439 auto i = board->m_IntersectsBCourtyardCache.find( key );
441 if( i != board->m_IntersectsBCourtyardCache.end() )
449 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
450 board->m_IntersectsBCourtyardCache[ key ] = res;
468 std::shared_ptr<SHAPE> shape;
506 aCtx->
ReportError(
_(
"Footprint's courtyard is not a single, closed shape." ) );
518 aCtx->
ReportError(
_(
"Footprint has no front courtyard." ) );
533 aCtx->
ReportError(
_(
"Footprint has no back courtyard." ) );
546 ZONE* zone =
static_cast<ZONE*
>( aItem );
555 for(
size_t ii = 0; ii < aArea->
GetLayerSet().size(); ++ii )
582 return areaOutline.
Collide( shape.get() );
588 const std::function<
bool(
ZONE* )>& aFunc )
590 if( aArg == wxT(
"A" ) )
592 return aFunc(
dynamic_cast<ZONE*
>( aCtx->
GetItem( 0 ) ) );
594 else if( aArg == wxT(
"B" ) )
596 return aFunc(
dynamic_cast<ZONE*
>( aCtx->
GetItem( 1 ) ) );
606 if( area->m_Uuid == target )
607 return aFunc( area );
612 for(
ZONE* area : footprint->Zones() )
616 if( area->m_Uuid == target )
617 return aFunc( area );
627 if( area->GetZoneName().Matches( aArg ) )
637 for(
ZONE* area : footprint->Zones() )
640 if( area->GetZoneName().Matches( aArg ) )
678#define MISSING_AREA_ARG( f ) \
679 wxString::Format( _( "Missing rule-area argument (A, B, or rule-area name) to %s." ), f )
688 aCtx->
Push( result );
690 if( !arg || arg->
AsString().IsEmpty() )
705 [item, arg, context]() ->
double
714 if( !aArea || aArea == item || aArea->GetParent() == item )
717 SCOPED_LAYERSET scopedLayerSet( aArea );
719 if( context->GetConstraint() == SILK_CLEARANCE_CONSTRAINT )
722 if( ( aArea->IsOnLayer( F_SilkS ) && IsFrontLayer( aLayer ) )
723 || ( aArea->IsOnLayer( B_SilkS ) && IsBackLayer( aLayer ) ) )
725 scopedLayerSet.Add( aLayer );
731 if( !commonLayers.any() )
740 testLayers.
set( aLayer );
742 testLayers = commonLayers;
746 PTR_PTR_LAYER_CACHE_KEY key = { aArea, item, layer };
750 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
752 auto i = board->m_IntersectsAreaCache.find( key );
754 if( i != board->m_IntersectsAreaCache.end() && i->second )
762 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
763 board->m_IntersectsAreaCache[ key ] = collides;
788 aCtx->
Push( result );
790 if( !arg || arg->
AsString().IsEmpty() )
805 [item, arg, context]() ->
double
815 if( !aArea || aArea == item || aArea->GetParent() == item )
818 if( item->Type() != PCB_FOOTPRINT_T )
820 if( !( aArea->GetLayerSet() & item->GetLayerSet() ).any() )
831 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
833 auto i = board->m_EnclosedByAreaCache.find( key );
835 if( i != board->m_EnclosedByAreaCache.end() )
844 itemShape = *static_cast<ZONE*>( item )->Outline();
848 FOOTPRINT* fp = static_cast<FOOTPRINT*>( item );
850 for( PCB_LAYER_ID testLayer : aArea->GetLayerSet() )
852 fp->TransformPadsToPolySet( itemShape, testLayer, 0,
853 maxError, ERROR_OUTSIDE );
854 fp->TransformFPShapesToPolySet( itemShape, testLayer, 0,
855 maxError, ERROR_OUTSIDE );
864 if( itemShape.IsEmpty() )
867 enclosedByArea = false;
871 itemShape.BooleanSubtract( *aArea->Outline() );
873 enclosedByArea = itemShape.IsEmpty();
878 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
879 board->m_EnclosedByAreaCache[ key ] = enclosedByArea;
882 return enclosedByArea;
893#define MISSING_GROUP_ARG( f ) \
894 wxString::Format( _( "Missing group name argument to %s." ), f )
902 aCtx->
Push( result );
904 if( !arg || arg->
AsString().IsEmpty() )
919 [item, arg]() ->
double
939#define MISSING_SHEET_ARG( f ) \
940 wxString::Format( _( "Missing sheet name argument to %s." ), f )
948 aCtx->
Push( result );
950 if( !arg || arg->
AsString().IsEmpty() )
965 [item, arg]() ->
double
978 if( sheetName.EndsWith( wxT(
"/") ) )
979 sheetName.RemoveLast();
980 if( refName.EndsWith( wxT(
"/") ) )
981 refName.RemoveLast();
983 if( sheetName.Matches( refName ) )
986 if( ( refName.Matches( wxT(
"/" ) ) || refName.IsEmpty() )
987 && sheetName.IsEmpty() )
997#define MISSING_REF_ARG( f ) \
998 wxString::Format( _( "Missing footprint argument (reference designator) to %s." ), f )
1006 aCtx->
Push( result );
1008 if( !arg || arg->
AsString().IsEmpty() )
1023 [item, arg]() ->
double
1043 aCtx->
Push( result );
1048 result->
Set ( 1.0 );
1060 aCtx->
Push( result );
1065 result->
Set ( 1.0 );
1078 aCtx->
Push( result );
1081 [a, b, context]() ->
double
1088 wxString coupledNet;
1106#define MISSING_DP_ARG( f ) \
1107 wxString::Format( _( "Missing diff-pair name argument to %s." ), f )
1117 aCtx->
Push( result );
1119 if( !argv || argv->
AsString().IsEmpty() )
1131 [item, argv]() ->
double
1142 wxString baseName, coupledNet;
1147 if( baseName.Matches( arg ) )
1150 if( baseName.EndsWith(
"_" ) && baseName.BeforeLast(
'_' ).Matches( arg ) )
1168 aCtx->
Push( result );
1174 aCtx->
ReportError( wxString::Format(
_(
"Missing field name argument to %s." ),
1175 wxT(
"getField()" ) ) );
1185 [item, arg]() -> wxString
1208 aCtx->
Push( result );
1210 if( !arg || arg->
AsString().IsEmpty() )
1213 aCtx->
ReportError(
_(
"Missing netclass name argument to hasNetclass()" ) );
1225 [item, arg]() ->
double
1246 aCtx->
Push( result );
1248 if( !arg || arg->
AsString().IsEmpty() )
1252 _(
"Missing component class name argument to hasComponentClass()" ) );
1264 [item, arg]() ->
double
constexpr int ARC_LOW_DEF
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
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
int GetDRCEpsilon() const
Return an epsilon which accounts for rounding errors, etc.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
PCB_GROUP * GetParentGroup() const
virtual void SetLayerSet(const LSET &aLayers)
virtual void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const
Convert the item shape to a closed polygon.
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
BOARD_ITEM_CONTAINER * GetParent() const
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
Information pertinent to a Pcbnew printed circuit board.
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
const ZONES & Zones() const
const FOOTPRINTS & Footprints() const
std::unordered_map< wxString, LSET > m_LayerExpressionCache
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
std::shared_mutex m_CachesMutex
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
constexpr bool Intersects(const BOX2< Vec > &aRect) const
bool ContainsClassName(const wxString &className) const
Determines if this (effective) component class contains a specific sub-class.
static int MatchDpSuffix(const wxString &aNetName, wxString &aComplementNet, wxString &aBaseDpName)
Check if the given net is a diff pair, returning its polarity and complement if so.
Implement an R-tree for fast spatial and layer indexing of connectable items.
int QueryColliding(BOARD_ITEM *aRefItem, PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer, std::function< bool(BOARD_ITEM *)> aFilter=nullptr, std::function< bool(BOARD_ITEM *)> aVisitor=nullptr, int aClearance=0) const
This is a fast test which essentially does bounding-box overlap given a worst-case clearance.
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
KICAD_T Type() const
Returns the type of object.
EDA_ITEM_FLAGS GetFlags() const
virtual const wxString & GetText() const
Return the string associated with the text object.
static ENUM_MAP< T > & Instance()
static bool SniffTest(const wxString &aCandidate)
Returns true if a string has the correct formatting to be a KIID.
void ReportError(const wxString &aErrorMsg)
virtual const wxString & AsString() const
void SetDeferredEval(std::function< double()> aLambda)
LSET is a set of PCB_LAYER_IDs.
static LSET FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
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 ContainsNetclassWithName(const wxString &netclass) const
Determines if the given netclass name is a constituent of this (maybe aggregate) netclass.
Handle the data for a net.
const wxString & GetNetname() const
PCBEXPR_BUILTIN_FUNCTIONS()
void RegisterFunc(const wxString &funcSignature, LIBEVAL::FUNC_CALL_REF funcPtr)
void RegisterAllFunctions()
std::map< wxString, LIBEVAL::FUNC_CALL_REF > m_funcs
int GetConstraint() const
PCB_LAYER_ID GetLayer() const
BOARD_ITEM * GetItem(int index) const
BOARD_ITEM * GetObject(const LIBEVAL::CONTEXT *aCtx) const
A set of BOARD_ITEMs (i.e., without duplicates).
void Add(PCB_LAYER_ID aLayer)
SCOPED_LAYERSET(BOARD_ITEM *aItem)
Represent a set of closed polygons.
void ClearArcs()
Removes all arc references from all the outlines and holes in the polyset.
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
void Deflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError)
int OutlineCount() const
Return the number of outlines in the set.
SHAPE_POLY_SET CloneDropTriangulation() const
Handle a list of polygons defining a copper zone.
const BOX2I GetBoundingBox() const override
SHAPE_POLY_SET * Outline()
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
@ ALLOW_ACUTE_CORNERS
just inflate the polygon. Acute angles create spikes
#define ROUTER_TRANSIENT
transient items that should NOT be cached
#define HOLE_PROXY
Indicates the BOARD_ITEM is a proxy for its hole.
#define MALFORMED_COURTYARDS
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
@ PTH
Plated through hole pad.
Class to handle a set of BOARD_ITEMs.
static void intersectsFrontCourtyardFunc(LIBEVAL::CONTEXT *aCtx, void *self)
#define MISSING_SHEET_ARG(f)
bool collidesWithCourtyard(BOARD_ITEM *aItem, std::shared_ptr< SHAPE > &aItemShape, PCBEXPR_CONTEXT *aCtx, FOOTPRINT *aFootprint, PCB_LAYER_ID aSide)
#define MISSING_LAYER_ARG(f)
static void intersectsBackCourtyardFunc(LIBEVAL::CONTEXT *aCtx, void *self)
bool collidesWithArea(BOARD_ITEM *aItem, PCBEXPR_CONTEXT *aCtx, ZONE *aArea)
static void memberOfGroupFunc(LIBEVAL::CONTEXT *aCtx, void *self)
#define MISSING_AREA_ARG(f)
static void isCoupledDiffPairFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void isPlatedFunc(LIBEVAL::CONTEXT *aCtx, void *self)
bool searchAreas(BOARD *aBoard, const wxString &aArg, PCBEXPR_CONTEXT *aCtx, const std::function< bool(ZONE *)> &aFunc)
static void existsOnLayerFunc(LIBEVAL::CONTEXT *aCtx, void *self)
#define MISSING_GROUP_ARG(f)
static bool testFootprintSelector(FOOTPRINT *aFp, const wxString &aSelector)
static void isBlindBuriedViaFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void memberOfSheetFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void hasComponentClassFunc(LIBEVAL::CONTEXT *aCtx, void *self)
#define MISSING_REF_ARG(f)
#define MISSING_DP_ARG(f)
static void enclosedByAreaFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void memberOfFootprintFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void isMicroVia(LIBEVAL::CONTEXT *aCtx, void *self)
static void getFieldFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void hasNetclassFunc(LIBEVAL::CONTEXT *aCtx, void *self)
bool fromToFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void intersectsCourtyardFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static bool searchFootprints(BOARD *aBoard, const wxString &aArg, PCBEXPR_CONTEXT *aCtx, const std::function< bool(FOOTPRINT *)> &aFunc)
static void inDiffPairFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void intersectsAreaFunc(LIBEVAL::CONTEXT *aCtx, void *self)
#define MISSING_FP_ARG(f)
std::vector< FAB_LAYER_COLOR > dummy
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint