From 25eb88636f128d3241a2bd8b6c3a83eb219cff4a Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Thu, 23 Apr 2020 16:21:29 +0200 Subject: [PATCH] eagle: handle TRESTRICT, BRESTRICT and VRESTRICT consistently --- pcbnew/eagle_plugin.cpp | 111 ++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 72 deletions(-) diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index 283ac9e6a7..6b9c64b72c 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -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 ) { wxXmlNode* child = aRules->GetChildren(); @@ -654,20 +684,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) ZONE_CONTAINER* zone = new ZONE_CONTAINER( m_board ); m_board->Add( zone, ADD_MODE::APPEND ); - if( c.layer == EAGLE_LAYER::TRESTRICT ) // front layer keepout - 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 ); - } + setKeepoutSettingsToZone( zone, c.layer ); // approximate circle as polygon with a edge every 10 degree wxPoint center( kicad_x( c.x ), kicad_y( c.y ) ); @@ -1171,7 +1188,8 @@ ZONE_CONTAINER* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode ) EPOLYGON p( aPolyNode ); PCB_LAYER_ID layer = kicad_layer( p.layer ); 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 ) return nullptr; @@ -1180,22 +1198,10 @@ ZONE_CONTAINER* EAGLE_PLUGIN::loadPolygon( wxXmlNode* aPolyNode ) zone = new ZONE_CONTAINER( m_board ); m_board->Add( zone, ADD_MODE::APPEND ); - if( p.layer == EAGLE_LAYER::TRESTRICT ) // front layer keepout - zone->SetLayer( F_Cu ); - else if( p.layer == EAGLE_LAYER::BRESTRICT ) // bottom layer keepout - zone->SetLayer( B_Cu ); - else + if( !keepout ) zone->SetLayer( layer ); - - if( keepout ) - { - zone->SetIsKeepout( true ); - zone->SetDoNotAllowVias( true ); - zone->SetDoNotAllowTracks( true ); - zone->SetDoNotAllowCopperPour( true ); - zone->SetDoNotAllowPads( true ); - zone->SetDoNotAllowFootprints( false ); - } + else + setKeepoutSettingsToZone( zone, p.layer ); // Get the first vertex and iterate 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 ); aModule->Add( zone, ADD_MODE::APPEND ); - if( r.layer == EAGLE_LAYER::TRESTRICT ) // front layer keepout - 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 ); - } + setKeepoutSettingsToZone( zone, r.layer ); 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 ); @@ -1929,20 +1922,7 @@ void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const MODULE_ZONE_CONTAINER* zone = new MODULE_ZONE_CONTAINER( aModule ); aModule->Add( zone, ADD_MODE::APPEND ); - if( p.layer == EAGLE_LAYER::TRESTRICT ) // front layer keepout - 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 ); - } + setKeepoutSettingsToZone( zone, p.layer ); SHAPE_LINE_CHAIN outline( pts ); 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 ); aModule->Add( zone, ADD_MODE::APPEND ); - if( e.layer == EAGLE_LAYER::TRESTRICT ) // front layer keepout - 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 ); - } + setKeepoutSettingsToZone( zone, e.layer ); // approximate circle as polygon with a edge every 10 degree wxPoint center( kicad_x( e.x ), kicad_y( e.y ) );