diff --git a/common/gal/cairo/cairo_gal.cpp b/common/gal/cairo/cairo_gal.cpp index 7bdc60698c..05b01e22ad 100644 --- a/common/gal/cairo/cairo_gal.cpp +++ b/common/gal/cairo/cairo_gal.cpp @@ -146,8 +146,18 @@ void CAIRO_GAL_BASE::arc_angles_xform_and_normalize( double& aStartAngle, double SWAP( startAngle, >, endAngle ); // now rotate arc according to the rotation transform matrix + // Remark: + // We call angle_xform() to calculate angles according to the flip/rotation + // transform and normatize between -2M_PI and +2M_PI. + // Therefore, if aStartAngle = aEndAngle + 2*n*M_PI, the transform gives + // aEndAngle = aStartAngle + // So, if this is the case, force the aEndAngle value to draw a circle. aStartAngle = angle_xform( startAngle ); - aEndAngle = angle_xform( endAngle ); + + if( std::abs( aEndAngle - aStartAngle ) >= 2*M_PI ) // arc is a full circle + aEndAngle = aStartAngle + 2*M_PI; + else + aEndAngle = angle_xform( endAngle ); } diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index 752b6d0e41..7920d30b25 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Jon Evans - * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -315,21 +315,21 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer ) if( startAngle > endAngle ) endAngle += (2 * M_PI); - // 360-degree arcs are stored in the file with start equal to end + // In Gerber, 360-degree arcs are stored in the file with start equal to end if( arcStart == arcEnd ) { - startAngle = 0; - endAngle = 2 * M_PI; + endAngle = startAngle + 2*M_PI; } m_gal->DrawArcSegment( center, radius, startAngle, endAngle, width ); - // Arc Debugging - // m_gal->SetLineWidth( 5 ); - // m_gal->SetStrokeColor( COLOR4D( 0.0, 1.0, 0.0, 1.0 ) ); - // m_gal->DrawLine( center, aItem->GetABPosition( arcStart ) ); - // m_gal->SetStrokeColor( COLOR4D( 1.0, 0.0, 0.0, 1.0 ) ); - // m_gal->DrawLine( center, aItem->GetABPosition( arcEnd ) ); +#if 0 // Arc Debugging only + m_gal->SetLineWidth( 5 ); + m_gal->SetStrokeColor( COLOR4D( 0.0, 1.0, 0.0, 1.0 ) ); + m_gal->DrawLine( center, aItem->GetABPosition( arcStart ) ); + m_gal->SetStrokeColor( COLOR4D( 1.0, 0.0, 0.0, 1.0 ) ); + m_gal->DrawLine( center, aItem->GetABPosition( arcEnd ) ); +#endif break; }