Don't require keepout zones to be named.

insideArea() now takes A, B, a UUID or a zone name.  (Only the UUID
is new.)
This commit is contained in:
Jeff Young 2020-10-25 20:53:24 +00:00
parent be0de8d151
commit 8c93fc76ae
3 changed files with 62 additions and 6 deletions

View File

@ -111,6 +111,9 @@ bool KIID::SniffTest( const wxString& aCandidate )
if( c >= 'A' && c <= 'F' )
continue;
if( c == '-' )
continue;
return false;
}

View File

@ -377,18 +377,21 @@ void DRC_ENGINE::loadImplicitRules()
for( ZONE_CONTAINER* zone : keepoutZones )
{
if( zone->GetZoneName().IsEmpty() )
zone->SetZoneName( KIID().AsString() );
wxString name = zone->GetZoneName();
if( KIID::SniffTest( name ) ) // Synthetic name; don't show to user
if( name.IsEmpty() )
{
rule = createImplicitRule( _( "keepout area" ) );
name = zone->m_Uuid.AsString();
}
else
{
rule = createImplicitRule( wxString::Format( _( "keepout area '%s'" ), name ) );
}
rule->m_Condition = new DRC_RULE_CONDITION( wxString::Format( "A.insideArea('%s')",
zone->GetZoneName() ) );
name ) );
if( zone->GetDoNotAllowTracks() )
addKeepoutConstraint( DRC_DISALLOW_TRACKS );

View File

@ -305,12 +305,46 @@ static void insideArea( LIBEVAL::CONTEXT* aCtx, void* self )
if( insideZone( dynamic_cast<ZONE_CONTAINER*>( context->GetItem( 1 ) ) ) )
result->Set( 1.0 );
}
else
else if( KIID::SniffTest( arg->AsString() ) )
{
KIID target( arg->AsString() );
for( ZONE_CONTAINER* candidate : item->GetBoard()->Zones() )
{
// Only a single zone can match the UUID; exit once we find a match whether
// "inside" or not
if( candidate->m_Uuid == target )
{
if( insideZone( candidate ) )
result->Set( 1.0 );
return;
}
}
for( MODULE* module : item->GetBoard()->Modules() )
{
for( ZONE_CONTAINER* candidate : module->Zones() )
{
// Only a single zone can match the UUID; exit once we find a match whether
// "inside" or not
if( candidate->m_Uuid == target )
{
if( insideZone( candidate ) )
result->Set( 1.0 );
return;
}
}
}
}
else // Match on zone name
{
for( ZONE_CONTAINER* candidate : item->GetBoard()->Zones() )
{
if( candidate->GetZoneName().Matches( arg->AsString() ) )
{
// Many zones can match the name; exit only when we find an "inside"
if( insideZone( candidate ) )
{
result->Set( 1.0 );
@ -318,6 +352,22 @@ static void insideArea( LIBEVAL::CONTEXT* aCtx, void* self )
}
}
}
for( MODULE* module : item->GetBoard()->Modules() )
{
for( ZONE_CONTAINER* candidate : module->Zones() )
{
// Many zones can match the name; exit only when we find an "inside"
if( candidate->GetZoneName().Matches( arg->AsString() ) )
{
if( insideZone( candidate ) )
{
result->Set( 1.0 );
return;
}
}
}
}
}
}