Handle wildcards and "other" item for insideCourtyard DRC function.
Fixes https://gitlab.com/kicad/code/kicad/issues/4519
This commit is contained in:
parent
b2dc592bf1
commit
e88dda2c01
|
@ -80,6 +80,7 @@ static void isPlated( LIBEVAL::CONTEXT* aCtx, void* self )
|
|||
|
||||
static void insideCourtyard( LIBEVAL::CONTEXT* aCtx, void* self )
|
||||
{
|
||||
PCB_EXPR_CONTEXT* context = static_cast<PCB_EXPR_CONTEXT*>( aCtx );
|
||||
LIBEVAL::VALUE* arg = aCtx->Pop();
|
||||
LIBEVAL::VALUE* result = aCtx->AllocValue();
|
||||
|
||||
|
@ -93,15 +94,34 @@ static void insideCourtyard( LIBEVAL::CONTEXT* aCtx, void* self )
|
|||
return;
|
||||
}
|
||||
|
||||
wxString footprintRef = arg->AsString();
|
||||
PCB_EXPR_VAR_REF* vref = static_cast<PCB_EXPR_VAR_REF*>( self );
|
||||
BOARD_ITEM* item = vref ? vref->GetObject( aCtx ) : nullptr;
|
||||
MODULE* footprint = nullptr;
|
||||
|
||||
if( item )
|
||||
if( !item )
|
||||
return;
|
||||
|
||||
if( arg->AsString() == "A" )
|
||||
{
|
||||
for( MODULE* footprint : item->GetBoard()->Modules() )
|
||||
footprint = dynamic_cast<MODULE*>( context->GetItem( 0 ) );
|
||||
}
|
||||
else if( arg->AsString() == "B" )
|
||||
{
|
||||
if( footprint->GetReference() == footprintRef )
|
||||
footprint = dynamic_cast<MODULE*>( context->GetItem( 1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( MODULE* candidate : item->GetBoard()->Modules() )
|
||||
{
|
||||
if( candidate->GetReference().Matches( arg->AsString() ) )
|
||||
{
|
||||
footprint = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( footprint )
|
||||
{
|
||||
SHAPE_POLY_SET footprintCourtyard;
|
||||
|
||||
|
@ -117,10 +137,6 @@ static void insideCourtyard( LIBEVAL::CONTEXT* aCtx, void* self )
|
|||
|
||||
if( testPoly.OutlineCount() )
|
||||
result->Set( 1.0 );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue