From 4f5fca4e67c1a90b693dfe895cc5afc755204935 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Thu, 12 Oct 2023 06:09:35 +0300 Subject: [PATCH] HPGL plotting: write rects as polygons to prevent always filling. (cherry picked from commit d9c123b1ec9662ee1ab6ce42dd3acbd719e286e0) --- common/plotters/HPGL_plotter.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/common/plotters/HPGL_plotter.cpp b/common/plotters/HPGL_plotter.cpp index 24e397a4fa..09b0752929 100644 --- a/common/plotters/HPGL_plotter.cpp +++ b/common/plotters/HPGL_plotter.cpp @@ -394,22 +394,16 @@ void HPGL_PLOTTER::Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T aFill, i VECTOR2D p1_device = userToDeviceCoordinates( p1 ); VECTOR2D p2_device = userToDeviceCoordinates( p2 ); - MoveTo( p1 ); + // EA command seems to always fill the rectangle, so plot as a polygon instead + std::vector cornerList; - if( aFill == FILL_T::FILLED_SHAPE ) - { - startOrAppendItem( p1_device, wxString::Format( "RA %.0f,%.0f;", - p2_device.x, - p2_device.y ) ); - } + cornerList.emplace_back( p1.x, p1.y ); + cornerList.emplace_back( p2.x, p1.y ); + cornerList.emplace_back( p2.x, p2.y ); + cornerList.emplace_back( p1.x, p2.y ); + cornerList.emplace_back( p1.x, p1.y ); - startOrAppendItem( p1_device, wxString::Format( "EA %.0f,%.0f;", - p2_device.x, - p2_device.y ) ); - - m_current_item->loc_end = m_current_item->loc_start; - m_current_item->bbox.Merge( p2_device ); - PenFinish(); + PlotPoly( cornerList, aFill, aWidth, nullptr ); }