From 5a910e9ee3ec0661c94d8577a4e721a7f4fc9ca3 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 18 Sep 2018 22:52:48 +0100 Subject: [PATCH] Make sure filled polygons are closed when rendering. --- eeschema/sch_painter.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index c36765a7d3..4960652320 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -416,10 +416,17 @@ void SCH_PAINTER::draw( LIB_POLYLINE *aLine, int aLayer ) defaultColors( aLine ); + const std::vector& pts = aLine->GetPolyPoints(); std::deque vtx; - for( auto p : aLine->GetPolyPoints() ) - vtx.push_back ( mapCoords( p ) ); + for( auto p : pts ) + vtx.push_back( mapCoords( p ) ); + + // Make sure a filled polygon is closed. We appear to have both types out in the wild: + // while most are closed (cf op-amp bodies, diodes, etc.), there are some that are inferred + // by their fill to be closed (cf arrowheads on potentiometers, optocoupler LEDs, etc.). + if( aLine->GetFillMode() != NO_FILL && pts.back() != pts.front() ) + vtx.push_back( mapCoords( pts.front() ) ); m_gal->DrawPolygon( vtx ); }