From 7b9dc1b9f0003900a0f7271b9207919e67090f29 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 22 Jun 2022 16:44:35 -0700 Subject: [PATCH] Fix Eeschema Arc plotting The start/end point plotting is not reliable for eeschema. We need to preconvert to angles to get the correct winding as the default plotter conversion in the PLOTTER class makes pcbnew-based assumptions Fixes https://gitlab.com/kicad/code/kicad/issues/11885 --- common/plotters/plotter.cpp | 39 ------------------------------------- eeschema/lib_shape.cpp | 8 +++++++- eeschema/sch_shape.cpp | 19 +++++++++++++++--- 3 files changed, 23 insertions(+), 43 deletions(-) diff --git a/common/plotters/plotter.cpp b/common/plotters/plotter.cpp index 658cd27581..b51236dbaa 100644 --- a/common/plotters/plotter.cpp +++ b/common/plotters/plotter.cpp @@ -154,44 +154,6 @@ void PLOTTER::Arc( const VECTOR2I& aCenter, const VECTOR2I& aStart, const VECTOR EDA_ANGLE endAngle( aEnd - aCenter ); int radius = ( aStart - aCenter ).EuclideanNorm(); - #if 0 - // Approximate arc by segments: - int numSegs = GetArcToSegmentCount( radius, aMaxError, FULL_CIRCLE ); - EDA_ANGLE delta = ANGLE_360 / std::max( 8, numSegs ); - VECTOR2I start( aStart ); - VECTOR2I end( aEnd ); - VECTOR2I pt; - - if( startAngle > endAngle ) - { - if( endAngle < ANGLE_0 ) - endAngle.Normalize(); - else - startAngle = startAngle.Normalize() - ANGLE_360; - } - - SetCurrentLineWidth( aWidth ); - MoveTo( start ); - - for( EDA_ANGLE ii = delta; startAngle + ii < endAngle; ii += delta ) - { - pt = start; - RotatePoint( pt, aCenter, -ii ); - - LineTo( pt ); - } - - if( aFill == FILL_T::NO_FILL ) - { - FinishTo( end ); - } - else - { - LineTo( end ); - FinishTo( aCenter ); - } - - #else if( startAngle > endAngle ) { if( endAngle < ANGLE_0 ) @@ -208,7 +170,6 @@ void PLOTTER::Arc( const VECTOR2I& aCenter, const VECTOR2I& aStart, const VECTOR } Arc( aCenter, startAngle, endAngle, radius, aFill, aWidth ); - #endif } diff --git a/eeschema/lib_shape.cpp b/eeschema/lib_shape.cpp index e12f536e7e..d43f873d5e 100644 --- a/eeschema/lib_shape.cpp +++ b/eeschema/lib_shape.cpp @@ -224,7 +224,13 @@ void LIB_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffs switch( GetShape() ) { case SHAPE_T::ARC: - aPlotter->Arc( center, start, end, fill, penWidth, ARC_HIGH_DEF ); + { + EDA_ANGLE t1, t2; + + CalcArcAngles( t1, t2 ); + aTransform.MapAngles( &t1, &t2 ); + aPlotter->Arc( center, -t2, -t1, GetRadius(), fill, penWidth ); + } break; case SHAPE_T::CIRCLE: diff --git a/eeschema/sch_shape.cpp b/eeschema/sch_shape.cpp index c1a729cf7f..c818acffdd 100644 --- a/eeschema/sch_shape.cpp +++ b/eeschema/sch_shape.cpp @@ -137,7 +137,14 @@ void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground ) const switch( GetShape() ) { case SHAPE_T::ARC: - aPlotter->Arc( getCenter(), GetStart(), GetEnd(), m_fill, 0, ARC_HIGH_DEF ); + { + EDA_ANGLE start; + EDA_ANGLE end; + CalcArcAngles( start, end ); + + aPlotter->Arc( getCenter(), -end, -start, GetRadius(), m_fill, 0 ); + } + break; case SHAPE_T::CIRCLE: @@ -174,8 +181,14 @@ void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground ) const switch( GetShape() ) { case SHAPE_T::ARC: - aPlotter->Arc( getCenter(), GetStart(), GetEnd(), FILL_T::NO_FILL, pen_size, - ARC_HIGH_DEF ); + { + EDA_ANGLE start; + EDA_ANGLE end; + CalcArcAngles( start, end ); + + aPlotter->Arc( getCenter(), -end, -start, GetRadius(), FILL_T::NO_FILL, pen_size ); + } + break; case SHAPE_T::CIRCLE: