eagle: add support for tRestrict, bRestrict and vRestrict on circle

Fixes #1869
https://gitlab.com/kicad/code/kicad/-/issues/1869
This commit is contained in:
Thomas Pointhuber 2020-04-01 11:22:32 +02:00 committed by Ian McInerney
parent 22860b6e7a
commit 23cc51a53f
1 changed files with 139 additions and 38 deletions

View File

@ -644,6 +644,58 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
m_xpath->push( "circle" );
ECIRCLE c( gr );
int width = c.width.ToPcbUnits();
int radius = c.radius.ToPcbUnits();
if( c.layer == EAGLE_LAYER::TRESTRICT || c.layer == EAGLE_LAYER::BRESTRICT
|| c.layer == EAGLE_LAYER::VRESTRICT )
{
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 );
}
// approximate circle as polygon with a edge every 10 degree
wxPoint center( kicad_x( c.x ), kicad_y( c.y ) );
int outlineRadius = radius + ( width / 2 );
for( int angle = 0; angle < 360; angle += 10 )
{
wxPoint rotatedPoint( outlineRadius, 0 );
RotatePoint( &rotatedPoint, angle * 10. );
zone->AppendCorner( center + rotatedPoint, -1 );
}
if( width > 0 )
{
zone->NewHole();
int innerRadius = radius - ( width / 2 );
for( int angle = 0; angle < 360; angle += 10 )
{
wxPoint rotatedPoint( innerRadius, 0 );
RotatePoint( &rotatedPoint, angle * 10. );
zone->AppendCorner( center + rotatedPoint, 0 );
}
}
zone->SetHatch( ZONE_HATCH_STYLE::DIAGONAL_EDGE,
ZONE_CONTAINER::GetDefaultHatchPitch(), true );
}
else
{
PCB_LAYER_ID layer = kicad_layer( c.layer );
if( layer != UNDEFINED_LAYER ) // unsupported layer
@ -651,9 +703,6 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board );
m_board->Add( dseg, ADD_MODE::APPEND );
int width = c.width.ToPcbUnits();
int radius = c.radius.ToPcbUnits();
// with == 0 means filled circle
if( width <= 0 )
{
@ -667,6 +716,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
dseg->SetEnd( wxPoint( kicad_x( c.x ) + radius, kicad_y( c.y ) ) );
dseg->SetWidth( width );
}
}
m_xpath->pop();
}
else if( grName == "rectangle" )
@ -1923,11 +1973,61 @@ void EAGLE_PLUGIN::packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const
void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const
{
ECIRCLE e( aTree );
PCB_LAYER_ID layer = kicad_layer( e.layer );
EDGE_MODULE* gr = new EDGE_MODULE( aModule, S_CIRCLE );
int width = e.width.ToPcbUnits();
int radius = e.radius.ToPcbUnits();
if( e.layer == EAGLE_LAYER::TRESTRICT || e.layer == EAGLE_LAYER::BRESTRICT
|| e.layer == EAGLE_LAYER::VRESTRICT )
{
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 );
}
// approximate circle as polygon with a edge every 10 degree
wxPoint center( kicad_x( e.x ), kicad_y( e.y ) );
int outlineRadius = radius + ( width / 2 );
for( int angle = 0; angle < 360; angle += 10 )
{
wxPoint rotatedPoint( outlineRadius, 0 );
RotatePoint( &rotatedPoint, angle * 10. );
zone->AppendCorner( center + rotatedPoint, -1 );
}
if( width > 0 )
{
zone->NewHole();
int innerRadius = radius - ( width / 2 );
for( int angle = 0; angle < 360; angle += 10 )
{
wxPoint rotatedPoint( innerRadius, 0 );
RotatePoint( &rotatedPoint, angle * 10. );
zone->AppendCorner( center + rotatedPoint, 0 );
}
}
zone->SetHatch(
ZONE_HATCH_STYLE::DIAGONAL_EDGE, ZONE_CONTAINER::GetDefaultHatchPitch(), true );
}
else
{
PCB_LAYER_ID layer = kicad_layer( e.layer );
EDGE_MODULE* gr = new EDGE_MODULE( aModule, S_CIRCLE );
// with == 0 means filled circle
if( width <= 0 )
{
@ -1938,7 +2038,7 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const
aModule->Add( gr );
gr->SetWidth( width );
switch ( (int) layer )
switch( (int) layer )
{
case UNDEFINED_LAYER:
layer = Cmts_User;
@ -1951,6 +2051,7 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const
gr->SetStart0( wxPoint( kicad_x( e.x ), kicad_y( e.y ) ) );
gr->SetEnd0( wxPoint( kicad_x( e.x ) + radius, kicad_y( e.y ) ) );
gr->SetDrawCoord();
}
}