eagle: handle TRESTRICT, BRESTRICT and VRESTRICT consistently

This commit is contained in:
Thomas Pointhuber 2020-04-23 16:21:29 +02:00 committed by Ian McInerney
parent 23cc51a53f
commit 25eb88636f
1 changed files with 39 additions and 72 deletions

View File

@ -115,6 +115,36 @@ static wxString makeKey( const wxString& aFirst, const wxString& aSecond )
} }
static void setKeepoutSettingsToZone( ZONE_CONTAINER* aZone, LAYER_NUM aLayer )
{
if( aLayer == EAGLE_LAYER::TRESTRICT || aLayer == EAGLE_LAYER::BRESTRICT )
{
aZone->SetIsKeepout( true );
aZone->SetDoNotAllowVias( true );
aZone->SetDoNotAllowTracks( true );
aZone->SetDoNotAllowCopperPour( true );
aZone->SetDoNotAllowPads( true );
aZone->SetDoNotAllowFootprints( false );
if( aLayer == EAGLE_LAYER::TRESTRICT ) // front layer keepout
aZone->SetLayer( F_Cu );
else // bottom layer keepout
aZone->SetLayer( B_Cu );
}
else if( aLayer == EAGLE_LAYER::VRESTRICT )
{
aZone->SetIsKeepout( true );
aZone->SetDoNotAllowVias( true );
aZone->SetDoNotAllowTracks( false );
aZone->SetDoNotAllowCopperPour( false );
aZone->SetDoNotAllowPads( false );
aZone->SetDoNotAllowFootprints( false );
aZone->SetLayerSet( LSET::AllCuMask() );
}
}
void ERULES::parse( wxXmlNode* aRules ) void ERULES::parse( wxXmlNode* aRules )
{ {
wxXmlNode* child = aRules->GetChildren(); wxXmlNode* child = aRules->GetChildren();
@ -654,20 +684,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
ZONE_CONTAINER* zone = new ZONE_CONTAINER( m_board ); ZONE_CONTAINER* zone = new ZONE_CONTAINER( m_board );
m_board->Add( zone, ADD_MODE::APPEND ); m_board->Add( zone, ADD_MODE::APPEND );
if( c.layer == EAGLE_LAYER::TRESTRICT ) // front layer keepout setKeepoutSettingsToZone( zone, c.layer );
zone->SetLayer( F_Cu );
else if( c.layer == EAGLE_LAYER::BRESTRICT ) // bottom layer keepout
zone->SetLayer( B_Cu );
else if( c.layer == EAGLE_LAYER::VRESTRICT ) // all layers
zone->SetLayerSet( LSET::AllCuMask() );
zone->SetIsKeepout( true );
zone->SetDoNotAllowVias( true );
if( c.layer == EAGLE_LAYER::TRESTRICT || c.layer == EAGLE_LAYER::BRESTRICT )
{
zone->SetDoNotAllowTracks( true );
zone->SetDoNotAllowCopperPour( true );
}
// approximate circle as polygon with a edge every 10 degree // approximate circle as polygon with a edge every 10 degree
wxPoint center( kicad_x( c.x ), kicad_y( c.y ) ); wxPoint center( kicad_x( c.x ), kicad_y( c.y ) );
@ -1171,7 +1188,8 @@ ZONE_CONTAINER* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode )
EPOLYGON p( aPolyNode ); EPOLYGON p( aPolyNode );
PCB_LAYER_ID layer = kicad_layer( p.layer ); PCB_LAYER_ID layer = kicad_layer( p.layer );
ZONE_CONTAINER* zone = nullptr; ZONE_CONTAINER* zone = nullptr;
bool keepout = ( p.layer == EAGLE_LAYER::TRESTRICT || p.layer == EAGLE_LAYER::BRESTRICT ); bool keepout = ( p.layer == EAGLE_LAYER::TRESTRICT || p.layer == EAGLE_LAYER::BRESTRICT
|| p.layer == EAGLE_LAYER::VRESTRICT );
if( !IsCopperLayer( layer ) && !keepout ) if( !IsCopperLayer( layer ) && !keepout )
return nullptr; return nullptr;
@ -1180,22 +1198,10 @@ ZONE_CONTAINER* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode )
zone = new ZONE_CONTAINER( m_board ); zone = new ZONE_CONTAINER( m_board );
m_board->Add( zone, ADD_MODE::APPEND ); m_board->Add( zone, ADD_MODE::APPEND );
if( p.layer == EAGLE_LAYER::TRESTRICT ) // front layer keepout if( !keepout )
zone->SetLayer( F_Cu );
else if( p.layer == EAGLE_LAYER::BRESTRICT ) // bottom layer keepout
zone->SetLayer( B_Cu );
else
zone->SetLayer( layer ); zone->SetLayer( layer );
else
if( keepout ) setKeepoutSettingsToZone( zone, p.layer );
{
zone->SetIsKeepout( true );
zone->SetDoNotAllowVias( true );
zone->SetDoNotAllowTracks( true );
zone->SetDoNotAllowCopperPour( true );
zone->SetDoNotAllowPads( true );
zone->SetDoNotAllowFootprints( false );
}
// Get the first vertex and iterate // Get the first vertex and iterate
wxXmlNode* vertex = aPolyNode->GetChildren(); wxXmlNode* vertex = aPolyNode->GetChildren();
@ -1796,20 +1802,7 @@ void EAGLE_PLUGIN::packageRectangle( MODULE* aModule, wxXmlNode* aTree ) const
MODULE_ZONE_CONTAINER* zone = new MODULE_ZONE_CONTAINER( aModule ); MODULE_ZONE_CONTAINER* zone = new MODULE_ZONE_CONTAINER( aModule );
aModule->Add( zone, ADD_MODE::APPEND ); aModule->Add( zone, ADD_MODE::APPEND );
if( r.layer == EAGLE_LAYER::TRESTRICT ) // front layer keepout setKeepoutSettingsToZone( zone, r.layer );
zone->SetLayer( F_Cu );
else if( r.layer == EAGLE_LAYER::BRESTRICT ) // bottom layer keepout
zone->SetLayer( B_Cu );
else if( r.layer == EAGLE_LAYER::VRESTRICT ) // all layers
zone->SetLayerSet( LSET::AllCuMask() );
zone->SetIsKeepout( true );
zone->SetDoNotAllowVias( true );
if( r.layer == EAGLE_LAYER::TRESTRICT || r.layer == EAGLE_LAYER::BRESTRICT )
{
zone->SetDoNotAllowTracks( true );
zone->SetDoNotAllowCopperPour( true );
}
const int outlineIdx = -1; // this is the id of the copper zone main outline const int outlineIdx = -1; // this is the id of the copper zone main outline
zone->AppendCorner( wxPoint( kicad_x( r.x1 ), kicad_y( r.y1 ) ), outlineIdx ); zone->AppendCorner( wxPoint( kicad_x( r.x1 ), kicad_y( r.y1 ) ), outlineIdx );
@ -1929,20 +1922,7 @@ void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const
MODULE_ZONE_CONTAINER* zone = new MODULE_ZONE_CONTAINER( aModule ); MODULE_ZONE_CONTAINER* zone = new MODULE_ZONE_CONTAINER( aModule );
aModule->Add( zone, ADD_MODE::APPEND ); aModule->Add( zone, ADD_MODE::APPEND );
if( p.layer == EAGLE_LAYER::TRESTRICT ) // front layer keepout setKeepoutSettingsToZone( zone, p.layer );
zone->SetLayer( F_Cu );
else if( p.layer == EAGLE_LAYER::BRESTRICT ) // bottom layer keepout
zone->SetLayer( B_Cu );
else if( p.layer == EAGLE_LAYER::VRESTRICT ) // all layers
zone->SetLayerSet( LSET::AllCuMask() );
zone->SetIsKeepout( true );
zone->SetDoNotAllowVias( true );
if( p.layer == EAGLE_LAYER::TRESTRICT || p.layer == EAGLE_LAYER::BRESTRICT )
{
zone->SetDoNotAllowTracks( true );
zone->SetDoNotAllowCopperPour( true );
}
SHAPE_LINE_CHAIN outline( pts ); SHAPE_LINE_CHAIN outline( pts );
outline.SetClosed( true ); outline.SetClosed( true );
@ -1983,20 +1963,7 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const
MODULE_ZONE_CONTAINER* zone = new MODULE_ZONE_CONTAINER( aModule ); MODULE_ZONE_CONTAINER* zone = new MODULE_ZONE_CONTAINER( aModule );
aModule->Add( zone, ADD_MODE::APPEND ); aModule->Add( zone, ADD_MODE::APPEND );
if( e.layer == EAGLE_LAYER::TRESTRICT ) // front layer keepout setKeepoutSettingsToZone( zone, e.layer );
zone->SetLayer( F_Cu );
else if( e.layer == EAGLE_LAYER::BRESTRICT ) // bottom layer keepout
zone->SetLayer( B_Cu );
else if( e.layer == EAGLE_LAYER::VRESTRICT ) // all layers
zone->SetLayerSet( LSET::AllCuMask() );
zone->SetIsKeepout( true );
zone->SetDoNotAllowVias( true );
if( e.layer == EAGLE_LAYER::TRESTRICT || e.layer == EAGLE_LAYER::BRESTRICT )
{
zone->SetDoNotAllowTracks( true );
zone->SetDoNotAllowCopperPour( true );
}
// approximate circle as polygon with a edge every 10 degree // approximate circle as polygon with a edge every 10 degree
wxPoint center( kicad_x( e.x ), kicad_y( e.y ) ); wxPoint center( kicad_x( e.x ), kicad_y( e.y ) );