From e7e1d5140e42a5ead2670c8095c0fcb652801f97 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 17 Jul 2020 11:26:35 +0200 Subject: [PATCH] Pcbnew, DRAWSEGMENT plot function: add missing plot code for S_RECT shape. Fixes #4905 https://gitlab.com/kicad/code/kicad/issues/4905 --- pcbnew/plot_brditems_plotter.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 7fcce01007..63fc8bf879 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -810,6 +810,10 @@ void BRDITEMS_PLOTTER::PlotDrawSegment( DRAWSEGMENT* aSeg ) switch( aSeg->GetShape() ) { + case S_SEGMENT: + m_plotter->ThickSegment( start, end, thickness, GetPlotMode(), &gbr_metadata ); + break; + case S_CIRCLE: radius = KiROUND( GetLineLength( end, start ) ); m_plotter->ThickCircle( start, radius * 2, thickness, GetPlotMode(), &gbr_metadata ); @@ -863,7 +867,32 @@ void BRDITEMS_PLOTTER::PlotDrawSegment( DRAWSEGMENT* aSeg ) } break; + case S_RECT: + { + std::vector pts; + aSeg->GetRectCorners( &pts ); + + if( aSeg->GetWidth() > 0 ) + { + m_plotter->ThickSegment( pts[0], pts[1], thickness, GetPlotMode(), &gbr_metadata ); + m_plotter->ThickSegment( pts[1], pts[2], thickness, GetPlotMode(), &gbr_metadata ); + m_plotter->ThickSegment( pts[2], pts[3], thickness, GetPlotMode(), &gbr_metadata ); + m_plotter->ThickSegment( pts[3], pts[0], thickness, GetPlotMode(), &gbr_metadata ); + } + else + { + SHAPE_LINE_CHAIN poly; + + for( const wxPoint& pt : pts ) + poly.Append( pt ); + + m_plotter->PlotPoly( poly, FILLED_SHAPE, -1, &gbr_metadata ); + } + } + break; + default: + wxASSERT_MSG( false, "Unhandled DRAWSEGMENT shape" ); m_plotter->ThickSegment( start, end, thickness, GetPlotMode(), &gbr_metadata ); } }