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 )
91 if( !arg || arg->
AsString().IsEmpty() )
100 [item, arg, aCtx]() ->
double
102 const wxString& layerName = arg->
AsString();
111 bool anyMatch =
false;
113 for(
unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
115 wxPGChoiceEntry& entry = layerMap[ ii ];
117 if( entry.GetText().Matches( layerName ))
128 aCtx->
ReportError( wxString::Format(
_(
"Unrecognized layer '%s'" ),
143 std::shared_lock<std::shared_mutex> readLock( board->
m_CachesMutex );
148 return ( item->
GetLayerSet() & i->second ).any() ? 1.0 : 0.0;
153 for(
unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
155 wxPGChoiceEntry& entry = layerMap[ ii ];
157 if( entry.GetText().Matches( layerName ) )
162 std::unique_lock<std::shared_mutex> writeLock( board->
m_CachesMutex );
166 return ( item->
GetLayerSet() & mask ).any() ? 1.0 : 0.0;
177 aCtx->
Push( result );
203 if(
ZONE* zone =
dynamic_cast<ZONE*
>( aItem ) )
204 aItemShape.reset( zone->Outline()->Clone() );
209 return footprintCourtyard.
Collide( aItemShape.get() );
214 const std::function<
bool(
FOOTPRINT* )>& aFunc )
216 if( aArg == wxT(
"A" ) )
220 if( fp && aFunc( fp ) )
223 else if( aArg == wxT(
"B" ) )
227 if( fp && aFunc( fp ) )
232 if( fp->GetReference().Matches( aArg ) )
243#define MISSING_FP_ARG( f ) \
244 wxString::Format( _( "Missing footprint argument (A, B, or reference designator) to %s." ), f )
253 context->
Push( result );
255 if( !arg || arg->
AsString().IsEmpty() )
270 [item, arg, context]() ->
double
273 std::shared_ptr<SHAPE> itemShape;
278 PTR_PTR_CACHE_KEY key = { fp, item };
282 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
284 auto i = board->m_IntersectsCourtyardCache.find( key );
286 if( i != board->m_IntersectsCourtyardCache.end() )
295 std::unique_lock<std::shared_mutex> cacheLock( board->m_CachesMutex );
296 board->m_IntersectsCourtyardCache[ key ] = res;
317 context->
Push( result );
319 if( !arg || arg->
AsString().IsEmpty() )
334 [item, arg, context]() ->
double
337 std::shared_ptr<SHAPE> itemShape;
342 PTR_PTR_CACHE_KEY key = { fp, item };
346 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
348 auto i = board->m_IntersectsFCourtyardCache.find( key );
350 if( i != board->m_IntersectsFCourtyardCache.end() )
358 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
359 board->m_IntersectsFCourtyardCache[ key ] = res;
380 context->
Push( result );
382 if( !arg || arg->
AsString().IsEmpty() )
397 [item, arg, context]() ->
double
400 std::shared_ptr<SHAPE> itemShape;
405 PTR_PTR_CACHE_KEY key = { fp, item };
409 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
411 auto i = board->m_IntersectsBCourtyardCache.find( key );
413 if( i != board->m_IntersectsBCourtyardCache.end() )
421 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
422 board->m_IntersectsBCourtyardCache[ key ] = res;
440 std::shared_ptr<SHAPE> shape;
478 aCtx->
ReportError(
_(
"Footprint's courtyard is not a single, closed shape." ) );
490 aCtx->
ReportError(
_(
"Footprint has no front courtyard." ) );
505 aCtx->
ReportError(
_(
"Footprint has no back courtyard." ) );
518 ZONE* zone =
static_cast<ZONE*
>( aItem );
549 return areaOutline.
Collide( shape.get() );
555 const std::function<
bool(
ZONE* )>& aFunc )
557 if( aArg == wxT(
"A" ) )
559 return aFunc(
dynamic_cast<ZONE*
>( aCtx->
GetItem( 0 ) ) );
561 else if( aArg == wxT(
"B" ) )
563 return aFunc(
dynamic_cast<ZONE*
>( aCtx->
GetItem( 1 ) ) );
573 if( area->m_Uuid == target )
574 return aFunc( area );
579 for(
ZONE* area : footprint->Zones() )
583 if( area->m_Uuid == target )
584 return aFunc( area );
594 if( area->GetZoneName().Matches( aArg ) )
604 for(
ZONE* area : footprint->Zones() )
607 if( area->GetZoneName().Matches( aArg ) )
620#define MISSING_AREA_ARG( f ) \
621 wxString::Format( _( "Missing rule-area argument (A, B, or rule-area name) to %s." ), f )
630 aCtx->
Push( result );
632 if( !arg || arg->
AsString().IsEmpty() )
647 [item, arg, context]() ->
double
656 if( !aArea || aArea == item || aArea->GetParent() == item )
659 LSET commonLayers = aArea->GetLayerSet() & item->GetLayerSet();
661 if( !commonLayers.any() )
664 if( !aArea->GetBoundingBox().Intersects( itemBBox ) )
669 if( aLayer != UNDEFINED_LAYER )
670 testLayers.set( aLayer );
672 testLayers = commonLayers;
674 for( PCB_LAYER_ID layer : testLayers.UIOrder() )
676 PTR_PTR_LAYER_CACHE_KEY key = { aArea, item, layer };
678 if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
680 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
682 auto i = board->m_IntersectsAreaCache.find( key );
684 if( i != board->m_IntersectsAreaCache.end() && i->second )
688 bool collides = collidesWithArea( item, context, aArea );
690 if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
692 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
693 board->m_IntersectsAreaCache[ key ] = collides;
718 aCtx->
Push( result );
720 if( !arg || arg->
AsString().IsEmpty() )
735 [item, arg, context]() ->
double
745 if( !aArea || aArea == item || aArea->GetParent() == item )
748 if( !( aArea->GetLayerSet() & item->GetLayerSet() ).any() )
751 if( !aArea->GetBoundingBox().Intersects( itemBBox ) )
754 PTR_PTR_LAYER_CACHE_KEY key = { aArea, item, layer };
758 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
760 auto i = board->m_EnclosedByAreaCache.find( key );
762 if( i != board->m_EnclosedByAreaCache.end() )
772 if( itemShape.IsEmpty() )
775 enclosedByArea = false;
779 itemShape.BooleanSubtract( *aArea->Outline(),
780 SHAPE_POLY_SET::PM_FAST );
782 enclosedByArea = itemShape.IsEmpty();
787 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
788 board->m_EnclosedByAreaCache[ key ] = enclosedByArea;
791 return enclosedByArea;
802#define MISSING_GROUP_ARG( f ) \
803 wxString::Format( _( "Missing group name argument to %s." ), f )
811 aCtx->
Push( result );
813 if( !arg || arg->
AsString().IsEmpty() )
828 [item, arg]() ->
double
848#define MISSING_SHEET_ARG( f ) \
849 wxString::Format( _( "Missing sheet name argument to %s." ), f )
857 aCtx->
Push( result );
859 if( !arg || arg->
AsString().IsEmpty() )
874 [item, arg]() ->
double
876 FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( item );
898#define MISSING_REF_ARG( f ) \
899 wxString::Format( _( "Missing footprint argument (reference designator) to %s." ), f )
907 aCtx->
Push( result );
909 if( !arg || arg->
AsString().IsEmpty() )
924 [item, arg]() ->
double
930 if( parentFP->GetReference().Matches( arg->
AsString() ) )
934 && parentFP->GetFPIDAsString().Matches( arg->
AsString() ) )
952 aCtx->
Push( result );
969 aCtx->
Push( result );
987 aCtx->
Push( result );
990 [a, b, context]() ->
double
1015#define MISSING_DP_ARG( f ) \
1016 wxString::Format( _( "Missing diff-pair name argument to %s." ), f )
1026 aCtx->
Push( result );
1028 if( !argv || argv->
AsString().IsEmpty() )
1040 [item, argv]() ->
double
1051 wxString baseName, coupledNet;
1056 if( baseName.Matches( arg ) )
1059 if( baseName.EndsWith(
"_" ) && baseName.BeforeLast(
'_' ).Matches( arg ) )
1077 aCtx->
Push( result );
1083 aCtx->
ReportError( wxString::Format(
_(
"Missing field name argument to %s." ),
1084 wxT(
"getField()" ) ) );
1094 [item, arg]() -> wxString
constexpr int ARC_LOW_DEF
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
wxString GetNetname() const
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
int GetDRCEpsilon() const
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 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.
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.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
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.
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).
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 void isBlindBuriedViaFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void memberOfSheetFunc(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)
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