From 87ebd34ea274696cee4bc5bdc7c285d464914694 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 31 Jul 2020 10:54:53 +0200 Subject: [PATCH] Optimize drawings for degenerated oval pads (in fact circle) and for round pad holes --- pcbnew/class_pad.cpp | 21 +++++++++++---------- pcbnew/pcb_painter.cpp | 9 +++++++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index ac00162b5b..db27a580fe 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -228,7 +228,7 @@ std::shared_ptr D_PAD::GetEffectiveShape( PCB_LAYER_ID aLayer ) const if( m_shapesDirty ) BuildEffectiveShapes(); - + for( auto s : m_effectiveShapes ) shape->AddShape( s->Clone() ); // fixme: use COMPOUND everywhere @@ -277,15 +277,16 @@ void D_PAD::BuildEffectiveShapes() const break; case PAD_SHAPE_OVAL: - { - wxSize half_size = m_Size / 2; - int half_width = std::min( half_size.x, half_size.y ); - wxPoint half_len( half_size.x - half_width, half_size.y - half_width ); - - RotatePoint( &half_len, m_Orient ); - - add( new SHAPE_SEGMENT( shapePos - half_len, shapePos + half_len, half_width * 2 ) ); - } + if( m_Size.x == m_Size.y ) // the oval pad is in fact a circle + add( new SHAPE_CIRCLE( shapePos, m_Size.x / 2 ) ); + else + { + wxSize half_size = m_Size / 2; + int half_width = std::min( half_size.x, half_size.y ); + wxPoint half_len( half_size.x - half_width, half_size.y - half_width ); + RotatePoint( &half_len, m_Orient ); + add( new SHAPE_SEGMENT( shapePos - half_len, shapePos + half_len, half_width * 2 ) ); + } break; case PAD_SHAPE_RECT: diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 1c03d6bdc8..f0048cb5eb 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -812,7 +812,11 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES ) { const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape(); - m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() ); + + if( seg->GetSeg().A == seg->GetSeg().B ) // Circular hole + m_gal->DrawCircle( seg->GetSeg().A, seg->GetWidth()/2 ); + else + m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() ); } else { @@ -879,7 +883,8 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) m_gal->SetStrokeColor( color ); int clearance = aPad->GetClearance(); - const std::shared_ptr shapes = std::dynamic_pointer_cast( aPad->GetEffectiveShape() ); + const std::shared_ptr shapes = + std::dynamic_pointer_cast( aPad->GetEffectiveShape() ); if( shapes && shapes->Size() == 1 && shapes->Shapes()[0]->Type() == SH_SEGMENT ) {