KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcbexpr_functions.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24
25#include <cstdio>
26#include <memory>
27#include <mutex>
28#include <wx/log.h>
29#include <board.h>
31#include <drc/drc_rtree.h>
32#include <drc/drc_engine.h>
33#include <pcb_track.h>
34#include <pcb_group.h>
36#include <pcbexpr_evaluator.h>
40
41
42bool fromToFunc( LIBEVAL::CONTEXT* aCtx, void* self )
43{
44 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
45 BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
46 LIBEVAL::VALUE* result = aCtx->AllocValue();
47
48 LIBEVAL::VALUE* argTo = aCtx->Pop();
49 LIBEVAL::VALUE* argFrom = aCtx->Pop();
50
51 result->Set(0.0);
52 aCtx->Push( result );
53
54 if(!item)
55 return false;
56
57 auto ftCache = item->GetBoard()->GetConnectivity()->GetFromToCache();
58
59 if( !ftCache )
60 {
61 wxLogWarning( wxT( "Attempting to call fromTo() with non-existent from-to cache." ) );
62 return true;
63 }
64
65 if( ftCache->IsOnFromToPath( static_cast<BOARD_CONNECTED_ITEM*>( item ),
66 argFrom->AsString(), argTo->AsString() ) )
67 {
68 result->Set(1.0);
69 }
70
71 return true;
72}
73
74
75#define MISSING_LAYER_ARG( f ) wxString::Format( _( "Missing layer name argument to %s." ), f )
76
77static void existsOnLayerFunc( LIBEVAL::CONTEXT* aCtx, void *self )
78{
79 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
80 BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
81
82 LIBEVAL::VALUE* arg = aCtx->Pop();
83 LIBEVAL::VALUE* result = aCtx->AllocValue();
84
85 result->Set( 0.0 );
86 aCtx->Push( result );
87
88 if( !item )
89 return;
90
91 if( !arg || arg->AsString().IsEmpty() )
92 {
93 if( aCtx->HasErrorCallback() )
94 aCtx->ReportError( MISSING_LAYER_ARG( wxT( "existsOnLayer()" ) ) );
95
96 return;
97 }
98
99 result->SetDeferredEval(
100 [item, arg, aCtx]() -> double
101 {
102 const wxString& layerName = arg->AsString();
103 wxPGChoices& layerMap = ENUM_MAP<PCB_LAYER_ID>::Instance().Choices();
104
105 if( aCtx->HasErrorCallback())
106 {
107 /*
108 * Interpreted version
109 */
110
111 bool anyMatch = false;
112
113 for( unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
114 {
115 wxPGChoiceEntry& entry = layerMap[ ii ];
116
117 if( entry.GetText().Matches( layerName ))
118 {
119 anyMatch = true;
120
121 if( item->IsOnLayer( ToLAYER_ID( entry.GetValue() ) ) )
122 return 1.0;
123 }
124 }
125
126 if( !anyMatch )
127 {
128 aCtx->ReportError( wxString::Format( _( "Unrecognized layer '%s'" ),
129 layerName ) );
130 }
131
132 return 0.0;
133 }
134 else
135 {
136 /*
137 * Compiled version
138 */
139
140 BOARD* board = item->GetBoard();
141
142 {
143 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
144
145 auto i = board->m_LayerExpressionCache.find( layerName );
146
147 if( i != board->m_LayerExpressionCache.end() )
148 return ( item->GetLayerSet() & i->second ).any() ? 1.0 : 0.0;
149 }
150
151 LSET mask;
152
153 for( unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
154 {
155 wxPGChoiceEntry& entry = layerMap[ ii ];
156
157 if( entry.GetText().Matches( layerName ) )
158 mask.set( ToLAYER_ID( entry.GetValue() ) );
159 }
160
161 {
162 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
163 board->m_LayerExpressionCache[ layerName ] = mask;
164 }
165
166 return ( item->GetLayerSet() & mask ).any() ? 1.0 : 0.0;
167 }
168 } );
169}
170
171
172static void isPlatedFunc( LIBEVAL::CONTEXT* aCtx, void* self )
173{
174 LIBEVAL::VALUE* result = aCtx->AllocValue();
175
176 result->Set( 0.0 );
177 aCtx->Push( result );
178
179 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
180 BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
181
182 if( !item )
183 return;
184
185 if( item->Type() == PCB_PAD_T && static_cast<PAD*>( item )->GetAttribute() == PAD_ATTRIB::PTH )
186 result->Set( 1.0 );
187 else if( item->Type() == PCB_VIA_T )
188 result->Set( 1.0 );
189}
190
191
192bool collidesWithCourtyard( BOARD_ITEM* aItem, std::shared_ptr<SHAPE>& aItemShape,
193 PCBEXPR_CONTEXT* aCtx, FOOTPRINT* aFootprint, PCB_LAYER_ID aSide )
194{
195 SHAPE_POLY_SET footprintCourtyard;
196
197 footprintCourtyard = aFootprint->GetCourtyard( aSide );
198
199 if( !aItemShape )
200 {
201 // Since rules are used for zone filling we can't rely on the filled shapes.
202 // Use the zone outline instead.
203 if( ZONE* zone = dynamic_cast<ZONE*>( aItem ) )
204 aItemShape.reset( zone->Outline()->Clone() );
205 else
206 aItemShape = aItem->GetEffectiveShape( aCtx->GetLayer() );
207 }
208
209 return footprintCourtyard.Collide( aItemShape.get() );
210};
211
212
213static bool searchFootprints( BOARD* aBoard, const wxString& aArg, PCBEXPR_CONTEXT* aCtx,
214 const std::function<bool( FOOTPRINT* )>& aFunc )
215{
216 if( aArg == wxT( "A" ) )
217 {
218 FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( aCtx->GetItem( 0 ) );
219
220 if( fp && aFunc( fp ) )
221 return true;
222 }
223 else if( aArg == wxT( "B" ) )
224 {
225 FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( aCtx->GetItem( 1 ) );
226
227 if( fp && aFunc( fp ) )
228 return true;
229 }
230 else for( FOOTPRINT* fp : aBoard->Footprints() )
231 {
232 if( fp->GetReference().Matches( aArg ) )
233 {
234 if( aFunc( fp ) )
235 return true;
236 }
237 else if( aArg.Contains( ':' )
238 && fp->GetFPIDAsString().Matches( aArg ) )
239 {
240 if( aFunc( fp ) )
241 return true;
242 }
243 }
244
245 return false;
246}
247
248
249#define MISSING_FP_ARG( f ) \
250 wxString::Format( _( "Missing footprint argument (A, B, or reference designator) to %s." ), f )
251
252static void intersectsCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
253{
254 PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
255 LIBEVAL::VALUE* arg = context->Pop();
256 LIBEVAL::VALUE* result = context->AllocValue();
257
258 result->Set( 0.0 );
259 context->Push( result );
260
261 if( !arg || arg->AsString().IsEmpty() )
262 {
263 if( context->HasErrorCallback() )
264 context->ReportError( MISSING_FP_ARG( wxT( "intersectsCourtyard()" ) ) );
265
266 return;
267 }
268
269 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
270 BOARD_ITEM* item = vref ? vref->GetObject( context ) : nullptr;
271
272 if( !item )
273 return;
274
275 result->SetDeferredEval(
276 [item, arg, context]() -> double
277 {
278 BOARD* board = item->GetBoard();
279 std::shared_ptr<SHAPE> itemShape;
280
281 if( searchFootprints( board, arg->AsString(), context,
282 [&]( FOOTPRINT* fp )
283 {
284 PTR_PTR_CACHE_KEY key = { fp, item };
285
286 if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
287 {
288 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
289
290 auto i = board->m_IntersectsCourtyardCache.find( key );
291
292 if( i != board->m_IntersectsCourtyardCache.end() )
293 return i->second;
294 }
295
296 bool res = collidesWithCourtyard( item, itemShape, context, fp, F_Cu )
297 || collidesWithCourtyard( item, itemShape, context, fp, B_Cu );
298
299 if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
300 {
301 std::unique_lock<std::shared_mutex> cacheLock( board->m_CachesMutex );
302 board->m_IntersectsCourtyardCache[ key ] = res;
303 }
304
305 return res;
306 } ) )
307 {
308 return 1.0;
309 }
310
311 return 0.0;
312 } );
313}
314
315
316static void intersectsFrontCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
317{
318 PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
319 LIBEVAL::VALUE* arg = context->Pop();
320 LIBEVAL::VALUE* result = context->AllocValue();
321
322 result->Set( 0.0 );
323 context->Push( result );
324
325 if( !arg || arg->AsString().IsEmpty() )
326 {
327 if( context->HasErrorCallback() )
328 context->ReportError( MISSING_FP_ARG( wxT( "intersectsFrontCourtyard()" ) ) );
329
330 return;
331 }
332
333 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
334 BOARD_ITEM* item = vref ? vref->GetObject( context ) : nullptr;
335
336 if( !item )
337 return;
338
339 result->SetDeferredEval(
340 [item, arg, context]() -> double
341 {
342 BOARD* board = item->GetBoard();
343 std::shared_ptr<SHAPE> itemShape;
344
345 if( searchFootprints( board, arg->AsString(), context,
346 [&]( FOOTPRINT* fp )
347 {
348 PTR_PTR_CACHE_KEY key = { fp, item };
349
350 if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
351 {
352 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
353
354 auto i = board->m_IntersectsFCourtyardCache.find( key );
355
356 if( i != board->m_IntersectsFCourtyardCache.end() )
357 return i->second;
358 }
359
360 bool res = collidesWithCourtyard( item, itemShape, context, fp, F_Cu );
361
362 if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
363 {
364 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
365 board->m_IntersectsFCourtyardCache[ key ] = res;
366 }
367
368 return res;
369 } ) )
370 {
371 return 1.0;
372 }
373
374 return 0.0;
375 } );
376}
377
378
379static void intersectsBackCourtyardFunc( LIBEVAL::CONTEXT* aCtx, void* self )
380{
381 PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
382 LIBEVAL::VALUE* arg = context->Pop();
383 LIBEVAL::VALUE* result = context->AllocValue();
384
385 result->Set( 0.0 );
386 context->Push( result );
387
388 if( !arg || arg->AsString().IsEmpty() )
389 {
390 if( context->HasErrorCallback() )
391 context->ReportError( MISSING_FP_ARG( wxT( "intersectsBackCourtyard()" ) ) );
392
393 return;
394 }
395
396 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
397 BOARD_ITEM* item = vref ? vref->GetObject( context ) : nullptr;
398
399 if( !item )
400 return;
401
402 result->SetDeferredEval(
403 [item, arg, context]() -> double
404 {
405 BOARD* board = item->GetBoard();
406 std::shared_ptr<SHAPE> itemShape;
407
408 if( searchFootprints( board, arg->AsString(), context,
409 [&]( FOOTPRINT* fp )
410 {
411 PTR_PTR_CACHE_KEY key = { fp, item };
412
413 if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
414 {
415 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
416
417 auto i = board->m_IntersectsBCourtyardCache.find( key );
418
419 if( i != board->m_IntersectsBCourtyardCache.end() )
420 return i->second;
421 }
422
423 bool res = collidesWithCourtyard( item, itemShape, context, fp, B_Cu );
424
425 if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
426 {
427 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
428 board->m_IntersectsBCourtyardCache[ key ] = res;
429 }
430
431 return res;
432 } ) )
433 {
434 return 1.0;
435 }
436
437 return 0.0;
438 } );
439}
440
441
442bool collidesWithArea( BOARD_ITEM* aItem, PCBEXPR_CONTEXT* aCtx, ZONE* aArea )
443{
444 BOARD* board = aArea->GetBoard();
445 BOX2I areaBBox = aArea->GetBoundingBox();
446 std::shared_ptr<SHAPE> shape;
447
448 // Collisions include touching, so we need to deflate outline by enough to exclude it.
449 // This is particularly important for detecting copper fills as they will be exactly
450 // touching along the entire exclusion border.
451 SHAPE_POLY_SET areaOutline = aArea->Outline()->CloneDropTriangulation();
452 areaOutline.ClearArcs();
453 areaOutline.Deflate( board->GetDesignSettings().GetDRCEpsilon(),
455
456 if( aItem->GetFlags() & HOLE_PROXY )
457 {
458 if( aItem->Type() == PCB_PAD_T )
459 {
460 return areaOutline.Collide( aItem->GetEffectiveHoleShape().get() );
461 }
462 else if( aItem->Type() == PCB_VIA_T )
463 {
464 LSET overlap = aItem->GetLayerSet() & aArea->GetLayerSet();
465
467 if( overlap.any() )
468 {
469 if( aCtx->GetLayer() == UNDEFINED_LAYER || overlap.Contains( aCtx->GetLayer() ) )
470 return areaOutline.Collide( aItem->GetEffectiveHoleShape().get() );
471 }
472 }
473
474 return false;
475 }
476
477 if( aItem->Type() == PCB_FOOTPRINT_T )
478 {
479 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aItem );
480
481 if( ( footprint->GetFlags() & MALFORMED_COURTYARDS ) != 0 )
482 {
483 if( aCtx->HasErrorCallback() )
484 aCtx->ReportError( _( "Footprint's courtyard is not a single, closed shape." ) );
485
486 return false;
487 }
488
489 if( ( aArea->GetLayerSet() & LSET::FrontMask() ).any() )
490 {
491 const SHAPE_POLY_SET& courtyard = footprint->GetCourtyard( F_CrtYd );
492
493 if( courtyard.OutlineCount() == 0 )
494 {
495 if( aCtx->HasErrorCallback() )
496 aCtx->ReportError( _( "Footprint has no front courtyard." ) );
497 }
498 else if( areaOutline.Collide( &courtyard.Outline( 0 ) ) )
499 {
500 return true;
501 }
502 }
503
504 if( ( aArea->GetLayerSet() & LSET::BackMask() ).any() )
505 {
506 const SHAPE_POLY_SET& courtyard = footprint->GetCourtyard( B_CrtYd );
507
508 if( courtyard.OutlineCount() == 0 )
509 {
510 if( aCtx->HasErrorCallback() )
511 aCtx->ReportError( _( "Footprint has no back courtyard." ) );
512 }
513 else if( areaOutline.Collide( &courtyard.Outline( 0 ) ) )
514 {
515 return true;
516 }
517 }
518
519 return false;
520 }
521
522 if( aItem->Type() == PCB_ZONE_T )
523 {
524 ZONE* zone = static_cast<ZONE*>( aItem );
525
526 if( !zone->IsFilled() )
527 return false;
528
529 DRC_RTREE* zoneRTree = board->m_CopperZoneRTreeCache[ zone ].get();
530
531 if( zoneRTree )
532 {
533 for( PCB_LAYER_ID layer : aArea->GetLayerSet().Seq() )
534 {
535 if( aCtx->GetLayer() == layer || aCtx->GetLayer() == UNDEFINED_LAYER )
536 {
537 if( zoneRTree->QueryColliding( areaBBox, &areaOutline, layer ) )
538 return true;
539 }
540 }
541 }
542
543 return false;
544 }
545 else
546 {
547 PCB_LAYER_ID layer = aCtx->GetLayer();
548
549 if( layer != UNDEFINED_LAYER && !( aArea->GetLayerSet().Contains( layer ) ) )
550 return false;
551
552 if( !shape )
553 shape = aItem->GetEffectiveShape( layer );
554
555 return areaOutline.Collide( shape.get() );
556 }
557}
558
559
560bool searchAreas( BOARD* aBoard, const wxString& aArg, PCBEXPR_CONTEXT* aCtx,
561 const std::function<bool( ZONE* )>& aFunc )
562{
563 if( aArg == wxT( "A" ) )
564 {
565 return aFunc( dynamic_cast<ZONE*>( aCtx->GetItem( 0 ) ) );
566 }
567 else if( aArg == wxT( "B" ) )
568 {
569 return aFunc( dynamic_cast<ZONE*>( aCtx->GetItem( 1 ) ) );
570 }
571 else if( KIID::SniffTest( aArg ) )
572 {
573 KIID target( aArg );
574
575 for( ZONE* area : aBoard->Zones() )
576 {
577 // Only a single zone can match the UUID; exit once we find a match whether
578 // "inside" or not
579 if( area->m_Uuid == target )
580 return aFunc( area );
581 }
582
583 for( FOOTPRINT* footprint : aBoard->Footprints() )
584 {
585 for( ZONE* area : footprint->Zones() )
586 {
587 // Only a single zone can match the UUID; exit once we find a match
588 // whether "inside" or not
589 if( area->m_Uuid == target )
590 return aFunc( area );
591 }
592 }
593
594 return false;
595 }
596 else // Match on zone name
597 {
598 for( ZONE* area : aBoard->Zones() )
599 {
600 if( area->GetZoneName().Matches( aArg ) )
601 {
602 // Many zones can match the name; exit only when we find an "inside"
603 if( aFunc( area ) )
604 return true;
605 }
606 }
607
608 for( FOOTPRINT* footprint : aBoard->Footprints() )
609 {
610 for( ZONE* area : footprint->Zones() )
611 {
612 // Many zones can match the name; exit only when we find an "inside"
613 if( area->GetZoneName().Matches( aArg ) )
614 {
615 if( aFunc( area ) )
616 return true;
617 }
618 }
619 }
620
621 return false;
622 }
623}
624
625
626#define MISSING_AREA_ARG( f ) \
627 wxString::Format( _( "Missing rule-area argument (A, B, or rule-area name) to %s." ), f )
628
629static void intersectsAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
630{
631 PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
632 LIBEVAL::VALUE* arg = aCtx->Pop();
633 LIBEVAL::VALUE* result = aCtx->AllocValue();
634
635 result->Set( 0.0 );
636 aCtx->Push( result );
637
638 if( !arg || arg->AsString().IsEmpty() )
639 {
640 if( aCtx->HasErrorCallback() )
641 aCtx->ReportError( MISSING_AREA_ARG( wxT( "intersectsArea()" ) ) );
642
643 return;
644 }
645
646 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
647 BOARD_ITEM* item = vref ? vref->GetObject( context ) : nullptr;
648
649 if( !item )
650 return;
651
652 result->SetDeferredEval(
653 [item, arg, context]() -> double
654 {
655 BOARD* board = item->GetBoard();
656 PCB_LAYER_ID aLayer = context->GetLayer();
657 BOX2I itemBBox = item->GetBoundingBox();
658
659 if( searchAreas( board, arg->AsString(), context,
660 [&]( ZONE* aArea )
661 {
662 if( !aArea || aArea == item || aArea->GetParent() == item )
663 return false;
664
665 LSET commonLayers = aArea->GetLayerSet() & item->GetLayerSet();
666
667 if( !commonLayers.any() )
668 return false;
669
670 if( !aArea->GetBoundingBox().Intersects( itemBBox ) )
671 return false;
672
673 LSET testLayers;
674
675 if( aLayer != UNDEFINED_LAYER )
676 testLayers.set( aLayer );
677 else
678 testLayers = commonLayers;
679
680 for( PCB_LAYER_ID layer : testLayers.UIOrder() )
681 {
682 PTR_PTR_LAYER_CACHE_KEY key = { aArea, item, layer };
683
684 if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
685 {
686 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
687
688 auto i = board->m_IntersectsAreaCache.find( key );
689
690 if( i != board->m_IntersectsAreaCache.end() && i->second )
691 return true;
692 }
693
694 bool collides = collidesWithArea( item, context, aArea );
695
696 if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
697 {
698 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
699 board->m_IntersectsAreaCache[ key ] = collides;
700 }
701
702 if( collides )
703 return true;
704 }
705
706 return false;
707 } ) )
708 {
709 return 1.0;
710 }
711
712 return 0.0;
713 } );
714}
715
716
717static void enclosedByAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
718{
719 PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
720 LIBEVAL::VALUE* arg = aCtx->Pop();
721 LIBEVAL::VALUE* result = aCtx->AllocValue();
722
723 result->Set( 0.0 );
724 aCtx->Push( result );
725
726 if( !arg || arg->AsString().IsEmpty() )
727 {
728 if( aCtx->HasErrorCallback() )
729 aCtx->ReportError( MISSING_AREA_ARG( wxT( "enclosedByArea()" ) ) );
730
731 return;
732 }
733
734 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
735 BOARD_ITEM* item = vref ? vref->GetObject( context ) : nullptr;
736
737 if( !item )
738 return;
739
740 result->SetDeferredEval(
741 [item, arg, context]() -> double
742 {
743 BOARD* board = item->GetBoard();
744 int maxError = board->GetDesignSettings().m_MaxError;
745 PCB_LAYER_ID layer = context->GetLayer();
746 BOX2I itemBBox = item->GetBoundingBox();
747
748 if( searchAreas( board, arg->AsString(), context,
749 [&]( ZONE* aArea )
750 {
751 if( !aArea || aArea == item || aArea->GetParent() == item )
752 return false;
753
754 if( !( aArea->GetLayerSet() & item->GetLayerSet() ).any() )
755 return false;
756
757 if( !aArea->GetBoundingBox().Intersects( itemBBox ) )
758 return false;
759
760 PTR_PTR_LAYER_CACHE_KEY key = { aArea, item, layer };
761
762 if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
763 {
764 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
765
766 auto i = board->m_EnclosedByAreaCache.find( key );
767
768 if( i != board->m_EnclosedByAreaCache.end() )
769 return i->second;
770 }
771
772 SHAPE_POLY_SET itemShape;
773 bool enclosedByArea;
774
775 item->TransformShapeToPolygon( itemShape, layer, 0, maxError,
777
778 if( itemShape.IsEmpty() )
779 {
780 // If it's already empty then our test will have no meaning.
781 enclosedByArea = false;
782 }
783 else
784 {
785 itemShape.BooleanSubtract( *aArea->Outline(),
786 SHAPE_POLY_SET::PM_FAST );
787
788 enclosedByArea = itemShape.IsEmpty();
789 }
790
791 if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 )
792 {
793 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
794 board->m_EnclosedByAreaCache[ key ] = enclosedByArea;
795 }
796
797 return enclosedByArea;
798 } ) )
799 {
800 return 1.0;
801 }
802
803 return 0.0;
804 } );
805}
806
807
808#define MISSING_GROUP_ARG( f ) \
809 wxString::Format( _( "Missing group name argument to %s." ), f )
810
811static void memberOfGroupFunc( LIBEVAL::CONTEXT* aCtx, void* self )
812{
813 LIBEVAL::VALUE* arg = aCtx->Pop();
814 LIBEVAL::VALUE* result = aCtx->AllocValue();
815
816 result->Set( 0.0 );
817 aCtx->Push( result );
818
819 if( !arg || arg->AsString().IsEmpty() )
820 {
821 if( aCtx->HasErrorCallback() )
822 aCtx->ReportError( MISSING_GROUP_ARG( wxT( "memberOfGroup()" ) ) );
823
824 return;
825 }
826
827 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
828 BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
829
830 if( !item )
831 return;
832
833 result->SetDeferredEval(
834 [item, arg]() -> double
835 {
836 PCB_GROUP* group = item->GetParentGroup();
837
838 if( !group && item->GetParent() && item->GetParent()->Type() == PCB_FOOTPRINT_T )
839 group = item->GetParent()->GetParentGroup();
840
841 while( group )
842 {
843 if( group->GetName().Matches( arg->AsString() ) )
844 return 1.0;
845
846 group = group->GetParentGroup();
847 }
848
849 return 0.0;
850 } );
851}
852
853
854#define MISSING_SHEET_ARG( f ) \
855 wxString::Format( _( "Missing sheet name argument to %s." ), f )
856
857static void memberOfSheetFunc( LIBEVAL::CONTEXT* aCtx, void* self )
858{
859 LIBEVAL::VALUE* arg = aCtx->Pop();
860 LIBEVAL::VALUE* result = aCtx->AllocValue();
861
862 result->Set( 0.0 );
863 aCtx->Push( result );
864
865 if( !arg || arg->AsString().IsEmpty() )
866 {
867 if( aCtx->HasErrorCallback() )
868 aCtx->ReportError( MISSING_SHEET_ARG( wxT( "memberOfSheet()" ) ) );
869
870 return;
871 }
872
873 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
874 BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
875
876 if( !item )
877 return;
878
879 result->SetDeferredEval(
880 [item, arg]() -> double
881 {
882 FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( item );
883
884 if( !fp )
885 fp = item->GetParentFootprint();
886
887 if( !fp )
888 return 0.0;
889
890 if( fp->GetSheetname().Matches( arg->AsString() ) )
891 return 1.0;
892
893 if( ( arg->AsString().Matches( wxT( "/" ) ) || arg->AsString().IsEmpty() )
894 && fp->GetSheetname() == wxT( "Root" ) )
895 {
896 return 1.0;
897 }
898
899 return 0.0;
900 } );
901}
902
903
904#define MISSING_REF_ARG( f ) \
905 wxString::Format( _( "Missing footprint argument (reference designator) to %s." ), f )
906
907static void memberOfFootprintFunc( LIBEVAL::CONTEXT* aCtx, void* self )
908{
909 LIBEVAL::VALUE* arg = aCtx->Pop();
910 LIBEVAL::VALUE* result = aCtx->AllocValue();
911
912 result->Set( 0.0 );
913 aCtx->Push( result );
914
915 if( !arg || arg->AsString().IsEmpty() )
916 {
917 if( aCtx->HasErrorCallback() )
918 aCtx->ReportError( MISSING_REF_ARG( wxT( "memberOfFootprint()" ) ) );
919
920 return;
921 }
922
923 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
924 BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
925
926 if( !item )
927 return;
928
929 result->SetDeferredEval(
930 [item, arg]() -> double
931 {
932 ;
933
934 if( FOOTPRINT* parentFP = item->GetParentFootprint() )
935 {
936 if( parentFP->GetReference().Matches( arg->AsString() ) )
937 return 1.0;
938
939 if( arg->AsString().Contains( ':' )
940 && parentFP->GetFPIDAsString().Matches( arg->AsString() ) )
941 {
942 return 1.0;
943 }
944 }
945
946 return 0.0;
947 } );
948}
949
950
951static void isMicroVia( LIBEVAL::CONTEXT* aCtx, void* self )
952{
953 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
954 BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
955 LIBEVAL::VALUE* result = aCtx->AllocValue();
956
957 result->Set( 0.0 );
958 aCtx->Push( result );
959
960 if( item && item->Type() == PCB_VIA_T
961 && static_cast<PCB_VIA*>( item )->GetViaType() == VIATYPE::MICROVIA )
962 {
963 result->Set ( 1.0 );
964 }
965}
966
967
968static void isBlindBuriedViaFunc( LIBEVAL::CONTEXT* aCtx, void* self )
969{
970 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
971 BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
972 LIBEVAL::VALUE* result = aCtx->AllocValue();
973
974 result->Set( 0.0 );
975 aCtx->Push( result );
976
977 if( item && item->Type() == PCB_VIA_T
978 && static_cast<PCB_VIA*>( item )->GetViaType() == VIATYPE::BLIND_BURIED )
979 {
980 result->Set ( 1.0 );
981 }
982}
983
984
985static void isCoupledDiffPairFunc( LIBEVAL::CONTEXT* aCtx, void* self )
986{
987 PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
988 BOARD_CONNECTED_ITEM* a = dynamic_cast<BOARD_CONNECTED_ITEM*>( context->GetItem( 0 ) );
989 BOARD_CONNECTED_ITEM* b = dynamic_cast<BOARD_CONNECTED_ITEM*>( context->GetItem( 1 ) );
990 LIBEVAL::VALUE* result = aCtx->AllocValue();
991
992 result->Set( 0.0 );
993 aCtx->Push( result );
994
995 result->SetDeferredEval(
996 [a, b, context]() -> double
997 {
998 NETINFO_ITEM* netinfo = a ? a->GetNet() : nullptr;
999
1000 if( !netinfo )
1001 return 0.0;
1002
1003 wxString coupledNet;
1004 wxString dummy;
1005
1006 if( !DRC_ENGINE::MatchDpSuffix( netinfo->GetNetname(), coupledNet, dummy ) )
1007 return 0.0;
1008
1011 {
1012 // DRC engine evaluates these singly, so we won't have a B item
1013 return 1.0;
1014 }
1015
1016 return b && b->GetNetname() == coupledNet;
1017 } );
1018}
1019
1020
1021#define MISSING_DP_ARG( f ) \
1022 wxString::Format( _( "Missing diff-pair name argument to %s." ), f )
1023
1024static void inDiffPairFunc( LIBEVAL::CONTEXT* aCtx, void* self )
1025{
1026 LIBEVAL::VALUE* argv = aCtx->Pop();
1027 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
1028 BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
1029 LIBEVAL::VALUE* result = aCtx->AllocValue();
1030
1031 result->Set( 0.0 );
1032 aCtx->Push( result );
1033
1034 if( !argv || argv->AsString().IsEmpty() )
1035 {
1036 if( aCtx->HasErrorCallback() )
1037 aCtx->ReportError( MISSING_DP_ARG( wxT( "inDiffPair()" ) ) );
1038
1039 return;
1040 }
1041
1042 if( !item || !item->GetBoard() )
1043 return;
1044
1045 result->SetDeferredEval(
1046 [item, argv]() -> double
1047 {
1048 if( item && item->IsConnected() )
1049 {
1050 NETINFO_ITEM* netinfo = static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNet();
1051
1052 if( !netinfo )
1053 return 0.0;
1054
1055 wxString refName = netinfo->GetNetname();
1056 wxString arg = argv->AsString();
1057 wxString baseName, coupledNet;
1058 int polarity = DRC_ENGINE::MatchDpSuffix( refName, coupledNet, baseName );
1059
1060 if( polarity != 0 && item->GetBoard()->FindNet( coupledNet ) )
1061 {
1062 if( baseName.Matches( arg ) )
1063 return 1.0;
1064
1065 if( baseName.EndsWith( "_" ) && baseName.BeforeLast( '_' ).Matches( arg ) )
1066 return 1.0;
1067 }
1068 }
1069
1070 return 0.0;
1071 } );
1072}
1073
1074
1075static void getFieldFunc( LIBEVAL::CONTEXT* aCtx, void* self )
1076{
1077 LIBEVAL::VALUE* arg = aCtx->Pop();
1078 PCBEXPR_VAR_REF* vref = static_cast<PCBEXPR_VAR_REF*>( self );
1079 BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
1080 LIBEVAL::VALUE* result = aCtx->AllocValue();
1081
1082 result->Set( "" );
1083 aCtx->Push( result );
1084
1085 if( !arg )
1086 {
1087 if( aCtx->HasErrorCallback() )
1088 {
1089 aCtx->ReportError( wxString::Format( _( "Missing field name argument to %s." ),
1090 wxT( "getField()" ) ) );
1091 }
1092
1093 return;
1094 }
1095
1096 if( !item || !item->GetBoard() )
1097 return;
1098
1099 result->SetDeferredEval(
1100 [item, arg]() -> wxString
1101 {
1102 if( item && item->Type() == PCB_FOOTPRINT_T )
1103 {
1104 FOOTPRINT* fp = static_cast<FOOTPRINT*>( item );
1105
1106 PCB_FIELD* field = fp->GetFieldByName( arg->AsString() );
1107
1108 if( field )
1109 return field->GetText();
1110 }
1111
1112 return "";
1113 } );
1114}
1115
1116
1118{
1120}
1121
1122
1124{
1125 m_funcs.clear();
1126
1127 RegisterFunc( wxT( "existsOnLayer('x')" ), existsOnLayerFunc );
1128
1129 RegisterFunc( wxT( "isPlated()" ), isPlatedFunc );
1130
1131 RegisterFunc( wxT( "insideCourtyard('x') DEPRECATED" ), intersectsCourtyardFunc );
1132 RegisterFunc( wxT( "insideFrontCourtyard('x') DEPRECATED" ), intersectsFrontCourtyardFunc );
1133 RegisterFunc( wxT( "insideBackCourtyard('x') DEPRECATED" ), intersectsBackCourtyardFunc );
1134 RegisterFunc( wxT( "intersectsCourtyard('x')" ), intersectsCourtyardFunc );
1135 RegisterFunc( wxT( "intersectsFrontCourtyard('x')" ), intersectsFrontCourtyardFunc );
1136 RegisterFunc( wxT( "intersectsBackCourtyard('x')" ), intersectsBackCourtyardFunc );
1137
1138 RegisterFunc( wxT( "insideArea('x') DEPRECATED" ), intersectsAreaFunc );
1139 RegisterFunc( wxT( "intersectsArea('x')" ), intersectsAreaFunc );
1140 RegisterFunc( wxT( "enclosedByArea('x')" ), enclosedByAreaFunc );
1141
1142 RegisterFunc( wxT( "isMicroVia()" ), isMicroVia );
1143 RegisterFunc( wxT( "isBlindBuriedVia()" ), isBlindBuriedViaFunc );
1144
1145 RegisterFunc( wxT( "memberOf('x') DEPRECATED" ), memberOfGroupFunc );
1146 RegisterFunc( wxT( "memberOfGroup('x')" ), memberOfGroupFunc );
1147 RegisterFunc( wxT( "memberOfFootprint('x')" ), memberOfFootprintFunc );
1148 RegisterFunc( wxT( "memberOfSheet('x')" ), memberOfSheetFunc );
1149
1150 RegisterFunc( wxT( "fromTo('x','y')" ), fromToFunc );
1151 RegisterFunc( wxT( "isCoupledDiffPair()" ), isCoupledDiffPairFunc );
1152 RegisterFunc( wxT( "inDiffPair('x')" ), inDiffPairFunc );
1153
1154 RegisterFunc( wxT( "getField('x')" ), getFieldFunc );
1155}
1156
1157
constexpr int ARC_LOW_DEF
Definition: base_units.h:119
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
virtual bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition: board_item.h:134
PCB_GROUP * GetParentGroup() const
Definition: board_item.h:91
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.
Definition: board_item.cpp:205
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:291
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.
Definition: board_item.cpp:228
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:46
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:248
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:231
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:204
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
Definition: board_item.cpp:238
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:282
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1803
const ZONES & Zones() const
Definition: board.h:327
const FOOTPRINTS & Footprints() const
Definition: board.h:323
std::unordered_map< wxString, LSET > m_LayerExpressionCache
Definition: board.h:1266
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
Definition: board.h:1267
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:794
std::shared_mutex m_CachesMutex
Definition: board.h:1260
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:460
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.
Definition: drc_rtree.h:48
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.
Definition: drc_rtree.h:214
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:129
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
static ENUM_MAP< T > & Instance()
Definition: property.h:663
PCB_FIELD * GetFieldByName(const wxString &aFieldName)
Return a field in this symbol.
Definition: footprint.cpp:538
wxString GetSheetname() const
Definition: footprint.h:252
const SHAPE_POLY_SET & GetCourtyard(PCB_LAYER_ID aLayer) const
Used in DRC to test the courtyard area (a complex polygon).
Definition: footprint.cpp:2812
Definition: kiid.h:49
static bool SniffTest(const wxString &aCandidate)
Returns true if a string has the correct formatting to be a KIID.
Definition: kiid.cpp:179
void ReportError(const wxString &aErrorMsg)
void Push(VALUE *v)
void Set(double aValue)
virtual const wxString & AsString() const
void SetDeferredEval(std::function< double()> aLambda)
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:575
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:418
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
Definition: layer_ids.h:647
static LSET FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
Definition: lset.cpp:985
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Definition: lset.cpp:992
Handle the data for a net.
Definition: netinfo.h:56
const wxString & GetNetname() const
Definition: netinfo.h:114
Definition: pad.h:53
void RegisterFunc(const wxString &funcSignature, LIBEVAL::FUNC_CALL_REF funcPtr)
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).
Definition: pcb_group.h:51
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.
Definition: zone.h:72
const BOX2I GetBoundingBox() const override
Definition: zone.cpp:343
bool IsFilled() const
Definition: zone.h:260
SHAPE_POLY_SET * Outline()
Definition: zone.h:336
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.h:129
@ ALLOW_ACUTE_CORNERS
just inflate the polygon. Acute angles create spikes
@ LENGTH_CONSTRAINT
Definition: drc_rule.h:64
@ SKEW_CONSTRAINT
Definition: drc_rule.h:65
#define _(s)
#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
@ ERROR_OUTSIDE
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ F_CrtYd
Definition: layer_ids.h:117
@ B_Cu
Definition: layer_ids.h:95
@ B_CrtYd
Definition: layer_ids.h:116
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:64
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:1022
@ PTH
Plated through hole pad.
Class to handle a set of BOARD_ITEMs.
@ BLIND_BURIED
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
VECTOR3I res
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:107
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87