60 wxLogWarning( wxT(
"Attempting to call fromTo() with non-existent from-to cache." ) );
74#define MISSING_LAYER_ARG( f ) wxString::Format( _( "Missing layer name argument to %s." ), f )
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 ))
138 std::unique_lock<std::mutex> cacheLock( board->
m_CachesMutex );
144 for(
unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
146 wxPGChoiceEntry& entry = layerMap[ ii ];
148 if( entry.GetText().Matches( layerName ) )
173 aCtx->
Push( result );
199 if(
ZONE* zone =
dynamic_cast<ZONE*
>( aItem ) )
200 aItemShape.reset( zone->Outline()->Clone() );
205 return footprintCourtyard.
Collide( aItemShape.get() );
210 std::function<
bool(
FOOTPRINT* )> aFunc )
212 if( aArg == wxT(
"A" ) )
216 if( fp && aFunc( fp ) )
219 else if( aArg == wxT(
"B" ) )
223 if( fp && aFunc( fp ) )
228 if( fp->GetReference().Matches( aArg ) )
239#define MISSING_FP_ARG( f ) \
240 wxString::Format( _( "Missing footprint argument (A, B, or reference designator) to %s." ), f )
249 context->
Push( result );
266 [item, arg, context]() ->
double
269 std::shared_ptr<SHAPE> itemShape;
274 PTR_PTR_CACHE_KEY key = { fp, item };
275 std::unique_lock<std::mutex> cacheLock( board->
m_CachesMutex );
304 context->
Push( result );
321 [item, arg, context]() ->
double
324 std::shared_ptr<SHAPE> itemShape;
329 PTR_PTR_CACHE_KEY key = { fp, item };
330 std::unique_lock<std::mutex> cacheLock( board->
m_CachesMutex );
358 context->
Push( result );
375 [item, arg, context]() ->
double
378 std::shared_ptr<SHAPE> itemShape;
383 PTR_PTR_CACHE_KEY key = { fp, item };
384 std::unique_lock<std::mutex> cacheLock( board->
m_CachesMutex );
409 std::shared_ptr<SHAPE> shape;
446 aCtx->
ReportError(
_(
"Footprint's courtyard is not a single, closed shape." ) );
458 aCtx->
ReportError(
_(
"Footprint has no front courtyard." ) );
473 aCtx->
ReportError(
_(
"Footprint has no back courtyard." ) );
486 ZONE* zone =
static_cast<ZONE*
>( aItem );
517 return areaOutline.
Collide( shape.get() );
523 std::function<
bool(
ZONE* )> aFunc )
525 if( aArg == wxT(
"A" ) )
527 return aFunc(
dynamic_cast<ZONE*
>( aCtx->
GetItem( 0 ) ) );
529 else if( aArg == wxT(
"B" ) )
531 return aFunc(
dynamic_cast<ZONE*
>( aCtx->
GetItem( 1 ) ) );
541 if( area->m_Uuid == target )
542 return aFunc( area );
547 for(
ZONE* area : footprint->Zones() )
551 if( area->m_Uuid == target )
552 return aFunc( area );
562 if( area->GetZoneName().Matches( aArg ) )
572 for(
ZONE* area : footprint->Zones() )
575 if( area->GetZoneName().Matches( aArg ) )
588#define MISSING_AREA_ARG( f ) \
589 wxString::Format( _( "Missing rule-area argument (A, B, or rule-area name) to %s." ), f )
598 aCtx->
Push( result );
615 [item, arg, context]() ->
double
624 if( !aArea || aArea == item || aArea->GetParent() == item )
627 LSET commonLayers = aArea->GetLayerSet() & item->GetLayerSet();
629 if( !commonLayers.any() )
632 if( !aArea->GetBoundingBox().Intersects( itemBBox ) )
635 std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
638 if( aLayer != UNDEFINED_LAYER )
639 testLayers.set( aLayer );
641 testLayers = commonLayers;
643 for( PCB_LAYER_ID layer : testLayers.UIOrder() )
645 PTR_PTR_LAYER_CACHE_KEY key = { aArea, item, layer };
647 auto i = board->m_IntersectsAreaCache.find( key );
649 if( i != board->m_IntersectsAreaCache.end() && i->second )
652 bool collides = collidesWithArea( item, context, aArea );
654 board->m_IntersectsAreaCache[ key ] = collides;
678 aCtx->
Push( result );
695 [item, arg, context]() ->
double
705 if( !aArea || aArea == item || aArea->GetParent() == item )
708 if( !( aArea->GetLayerSet() & item->GetLayerSet() ).any() )
711 if( !aArea->GetBoundingBox().Intersects( itemBBox ) )
714 std::unique_lock<std::mutex> cacheLock( board->m_CachesMutex );
715 PTR_PTR_LAYER_CACHE_KEY key = { aArea, item, layer };
728 if( itemShape.IsEmpty() )
731 enclosedByArea = false;
735 itemShape.BooleanSubtract( *aArea->Outline(),
736 SHAPE_POLY_SET::PM_FAST );
738 enclosedByArea = itemShape.IsEmpty();
743 return enclosedByArea;
754#define MISSING_GROUP_ARG( f ) \
755 wxString::Format( _( "Missing group name argument to %s." ), f )
763 aCtx->
Push( result );
780 [item, arg]() ->
double
807 aCtx->
Push( result );
823 aCtx->
Push( result );
840 aCtx->
Push( result );
843 [a, b, context]() ->
double
868#define MISSING_DP_ARG( f ) \
869 wxString::Format( _( "Missing diff-pair name argument to %s." ), f )
879 aCtx->
Push( result );
893 [item, argv]() ->
double
904 wxString baseName, coupledNet;
909 if( baseName.Matches( arg ) )
912 if( baseName.EndsWith(
"_" ) && baseName.BeforeLast(
'_' ).Matches( arg ) )
930 aCtx->
Push( result );
937 wxT(
"getField()" ) ) );
947 [item, arg]() -> wxString
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 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.
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual bool IsOnLayer(PCB_LAYER_ID aLayer, bool aIncludeCourtyards=false) const
Test to see if this object is on the given layer.
BOARD_ITEM_CONTAINER * GetParent() const
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
Information pertinent to a Pcbnew printed circuit board.
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_EnclosedByAreaCache
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
FOOTPRINTS & Footprints()
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsCourtyardCache
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsFCourtyardCache
std::unordered_map< wxString, LSET > m_LayerExpressionCache
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsBCourtyardCache
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
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
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
void RegisterFunc(const wxString &funcSignature, LIBEVAL::FUNC_CALL_REF funcPtr)
void RegisterAllFunctions()
PCB_EXPR_BUILTIN_FUNCTIONS()
std::map< wxString, LIBEVAL::FUNC_CALL_REF > m_funcs
BOARD_ITEM * GetItem(int index) const
PCB_LAYER_ID GetLayer() const
int GetConstraint() const
BOARD_ITEM * GetObject(const LIBEVAL::CONTEXT *aCtx) const
A set of BOARD_ITEMs (i.e., without duplicates).
Represent a set of closed polygons.
@ ALLOW_ACUTE_CORNERS
just inflate the polygon. Acute angles create spikes
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,...
void Deflate(int aAmount, int aCircleSegmentsCount, CORNER_STRATEGY aCornerStrategy=CHAMFER_ALL_CORNERS)
SHAPE_LINE_CHAIN & Outline(int aIndex)
int OutlineCount() const
Return the number of vertices in a given outline/hole.
SHAPE_POLY_SET CloneDropTriangulation() const
Creates a new empty polygon in the set and returns its index.
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.
#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.
static void intersectsFrontCourtyardFunc(LIBEVAL::CONTEXT *aCtx, void *self)
#define MISSING_LAYER_ARG(f)
bool collidesWithCourtyard(BOARD_ITEM *aItem, std::shared_ptr< SHAPE > &aItemShape, PCB_EXPR_CONTEXT *aCtx, FOOTPRINT *aFootprint, PCB_LAYER_ID aSide)
static void intersectsBackCourtyardFunc(LIBEVAL::CONTEXT *aCtx, void *self)
bool collidesWithArea(BOARD_ITEM *aItem, PCB_EXPR_CONTEXT *aCtx, ZONE *aArea)
#define MISSING_AREA_ARG(f)
static void isCoupledDiffPairFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void isPlatedFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void existsOnLayerFunc(LIBEVAL::CONTEXT *aCtx, void *self)
#define MISSING_GROUP_ARG(f)
static void isBlindBuriedViaFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static bool searchFootprints(BOARD *aBoard, const wxString &aArg, PCB_EXPR_CONTEXT *aCtx, std::function< bool(FOOTPRINT *)> aFunc)
#define MISSING_DP_ARG(f)
static void enclosedByAreaFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void memberOfFunc(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)
bool searchAreas(BOARD *aBoard, const wxString &aArg, PCB_EXPR_CONTEXT *aCtx, std::function< bool(ZONE *)> aFunc)
static void intersectsCourtyardFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void inDiffPairFunc(LIBEVAL::CONTEXT *aCtx, void *self)
static void intersectsAreaFunc(LIBEVAL::CONTEXT *aCtx, void *self)
#define MISSING_FP_ARG(f)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
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_FP_ZONE_T
class ZONE, managed by a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint