From 9e656fe5eb8e924c60fada40659f7a2edff7a071 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 10 Apr 2020 15:57:02 +0200 Subject: [PATCH] Gerbview: fix incorrect rendering of oval vertical standard aperture with hole. Fix also incorrect display of dcode size in toolbal: was Y size X size. Now is X size Y size, as expected. --- gerbview/dcode.cpp | 11 ++++------- gerbview/rs274x.cpp | 8 +++++--- gerbview/toolbars_gerber.cpp | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp index 36f84932ac..ec28e9bb12 100644 --- a/gerbview/dcode.cpp +++ b/gerbview/dcode.cpp @@ -224,14 +224,14 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, int delta = (m_Size.x - m_Size.y) / 2; start.x -= delta; end.x += delta; - radius = m_Size.y; + radius = m_Size.y; // Width in fact } - else // horizontal oval + else // vertical oval { int delta = (m_Size.y - m_Size.x) / 2; start.y -= delta; end.y += delta; - radius = m_Size.x; + radius = m_Size.x; // Width in fact } start = aParent->GetABPosition( start ); @@ -375,10 +375,7 @@ void D_CODE::ConvertShapeToPolygon() m_Polygon.Append( VECTOR2I( initialpos ) ); // close outline if( m_Size.y > m_Size.x ) // vertical oval, rotate polygon. - { - for( auto it = m_Polygon.Iterate( 0 ); it; ++it ) - it->Rotate( -M_PI / 2 ); - } + m_Polygon.Rotate( -M_PI / 2 ); addHoleToPolygon( &m_Polygon, m_DrillShape, m_Drill, initialpos ); } diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp index 2fc0464831..5c57a83221 100644 --- a/gerbview/rs274x.cpp +++ b/gerbview/rs274x.cpp @@ -687,6 +687,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff, aText += 2; // skip "C," for example + // First parameter is the size X: dcode->m_Size.x = KiROUND( ReadDouble( aText ) * conv_scale ); dcode->m_Size.y = dcode->m_Size.x; @@ -726,7 +727,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff, while( *aText == ' ' ) aText++; - if( *aText == 'X' ) + if( *aText == 'X' ) // Second parameter: size Y { aText++; dcode->m_Size.y = @@ -736,7 +737,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff, while( *aText == ' ' ) aText++; - if( *aText == 'X' ) + if( *aText == 'X' ) // third parameter: drill size (or drill size X) { aText++; dcode->m_Drill.x = KiROUND( ReadDouble( aText ) * conv_scale ); @@ -747,13 +748,14 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff, while( *aText == ' ' ) aText++; - if( *aText == 'X' ) + if( *aText == 'X' ) // fourth parameter: drill size Y { aText++; dcode->m_Drill.y = KiROUND( ReadDouble( aText ) * conv_scale ); dcode->m_DrillShape = APT_DEF_RECT_HOLE; } + dcode->m_Defined = true; break; diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 18ce07b59c..52bbba771f 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -289,7 +289,7 @@ void GERBVIEW_FRAME::updateDCodeSelectBox() msg.Printf( "tool %d [%.3fx%.3f %s] %s", dcode->m_Num_Dcode, - dcode->m_Size.y / scale, dcode->m_Size.x / scale, + dcode->m_Size.x / scale, dcode->m_Size.y / scale, units, D_CODE::ShowApertureType( dcode->m_Shape ) );