7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 18:23:45 +00:00

pcbnew: file format support for placement rule areas

Added:
- "placement" tag to denote placement Rule Areas
- "expr" tag for providing the filtering expression
This commit is contained in:
Tomasz Wlostowski 2023-12-31 13:20:01 +01:00
parent 05fc8199dc
commit cb4b26b39b
2 changed files with 44 additions and 8 deletions

View File

@ -2437,6 +2437,8 @@ void PCB_IO_KICAD_SEXPR::format( const ZONE* aZone, int aNestLevel ) const
m_out->Print( 0, " (hatch %s %s)\n", hatch.c_str(),
formatInternalUnits( aZone->GetBorderHatchPitch() ).c_str() );
if( aZone->GetAssignedPriority() > 0 )
m_out->Print( aNestLevel+1, "(priority %d)\n", aZone->GetAssignedPriority() );
@ -2494,14 +2496,27 @@ void PCB_IO_KICAD_SEXPR::format( const ZONE* aZone, int aNestLevel ) const
if( aZone->GetIsRuleArea() )
{
m_out->Print( aNestLevel + 1,
"(keepout (tracks %s) (vias %s) (pads %s) (copperpour %s) "
"(footprints %s))\n",
aZone->GetDoNotAllowTracks() ? "not_allowed" : "allowed",
aZone->GetDoNotAllowVias() ? "not_allowed" : "allowed",
aZone->GetDoNotAllowPads() ? "not_allowed" : "allowed",
aZone->GetDoNotAllowCopperPour() ? "not_allowed" : "allowed",
aZone->GetDoNotAllowFootprints() ? "not_allowed" : "allowed" );
switch( aZone->GetRuleAreaType() )
{
case RULE_AREA_TYPE::KEEPOUT:
m_out->Print( aNestLevel + 1,
"(keepout (tracks %s) (vias %s) (pads %s) (copperpour %s) "
"(footprints %s))\n",
aZone->GetDoNotAllowTracks() ? "not_allowed" : "allowed",
aZone->GetDoNotAllowVias() ? "not_allowed" : "allowed",
aZone->GetDoNotAllowPads() ? "not_allowed" : "allowed",
aZone->GetDoNotAllowCopperPour() ? "not_allowed" : "allowed",
aZone->GetDoNotAllowFootprints() ? "not_allowed" : "allowed" );
break;
case RULE_AREA_TYPE::PLACEMENT:
m_out->Print( aNestLevel + 1,
"(placement (expr %s))", m_out->Quotew( aZone->GetRuleAreaExpression() ).c_str() );
break;
default:
break;
}
}
m_out->Print( aNestLevel + 1, "(fill" );

View File

@ -6272,9 +6272,30 @@ ZONE* PCB_IO_KICAD_SEXPR_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent )
break;
case T_placement:
zone->SetIsRuleArea( true );
zone->SetRuleAreaType( RULE_AREA_TYPE::PLACEMENT );
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{
if( token == T_LEFT )
token = NextTok();
if( token == T_expr )
{
token = NextTok();
zone->SetRuleAreaExpression( FromUTF8() );
}
NeedRIGHT();
}
break;
case T_keepout:
// "keepout" now means rule area, but the file token stays the same
zone->SetIsRuleArea( true );
zone->SetRuleAreaType( RULE_AREA_TYPE::KEEPOUT );
// Initialize these two because their tokens won't appear in older files:
zone->SetDoNotAllowPads( false );