From 8a17fb8d19b130dd72598ba3d4311acfb38d16b7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 26 Jan 2022 09:57:43 +0100 Subject: [PATCH] SCH_SEXPR_PARSER::parseArc(): fix a very annoying issue: each time the lib or sch files are saved and reopened, 180 deg arcs were flipped. This fix is a workaround, but avoid flipped arcs after saving/reopening these files. --- .../sch_plugins/kicad/sch_sexpr_parser.cpp | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 0ff2d2f796..07c479225d 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -985,20 +985,31 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseArc() { arc->SetCenter( CalcArcCenter( arc->GetStart(), midPoint, arc->GetEnd() ) ); - /** +#if 1 // This code will be removed if the current code in Eeschema is modified to allow + // full support of arcs >= 180 deg without issue. + // For now the arcs are just modified to be < 180 degrees to do not break + // some other functions ( Draw, Plot, HitTest) + + /* * Current file format stores start-mid-end and so doesn't care about winding. We * store start-end with an implied winding internally though, so we need to swap the * ends if they don't match what we're expecting. + * This issue is only for 180 deg arcs, because 180 deg are a limit to handle arcs in + * previous versions of Kicad */ - EDA_ANGLE arc_start, arc_end; + EDA_ANGLE arc_start, arc_end, arc_angle; arc->CalcArcAngles( arc_start, arc_end ); + arc_angle = arc_end - arc_start; - if( arc_start < arc_end ) + // So a workaround is to slightly change the arc angle to + // avoid it == 180 deg after correction + if( arc_angle == ANGLE_180 ) { - VECTOR2I temp = arc->GetStart(); - arc->SetStart( arc->GetEnd() ); - arc->SetEnd( temp ); + VECTOR2I new_center = CalcArcCenter( arc->GetStart(), arc->GetEnd(), + EDA_ANGLE( 179.5, DEGREES_T ) ); + arc->SetCenter( new_center ); } +#endif } else if( hasAngles ) {