From 9fe00bb808d9dfb100de8e307fe9e4a71ed56a66 Mon Sep 17 00:00:00 2001
From: Jeff Young <jeff@rokeby.ie>
Date: Tue, 6 Jun 2023 12:30:35 +0100
Subject: [PATCH] Cleanup.  No (intentional) functional changes.

---
 common/gbr_metadata.cpp                      |   6 +-
 include/gbr_metadata.h                       |   4 +-
 pcbnew/exporters/gen_drill_report_files.cpp  |   2 +-
 pcbnew/exporters/gerber_placefile_writer.cpp |  64 +++---
 pcbnew/pcb_track.cpp                         |  29 +--
 pcbnew/pcb_track.h                           |  65 +++---
 pcbnew/pcbplot.h                             |  35 ++--
 pcbnew/plot_board_layers.cpp                 |  15 +-
 pcbnew/plot_brditems_plotter.cpp             | 208 ++++++++-----------
 9 files changed, 180 insertions(+), 248 deletions(-)

diff --git a/common/gbr_metadata.cpp b/common/gbr_metadata.cpp
index 7a2bdf2c1a..132d5aaaac 100644
--- a/common/gbr_metadata.cpp
+++ b/common/gbr_metadata.cpp
@@ -279,18 +279,18 @@ std::string GBR_APERTURE_METADATA::FormatAttribute( GBR_APERTURE_ATTRIB aAttribu
         attribute_string = "TA.AperFunction,ComponentMain";
         break;
 
-    case GBR_APERTURE_ATTRIB_PAD1_POSITION:     // print info associated to a component
+    case GBR_APERTURE_ATTRIB_PAD1_POS:     // print info associated to a component
                                                 // flashed shape at pad 1 position
                                                 // (pad 1 is also pad A1 or pad AA1)
                                                 // in placement files
         attribute_string = "TA.AperFunction,ComponentPin";
         break;
 
-    case GBR_APERTURE_ATTRIB_PADOTHER_POSITION: // print info associated to a component
+    case GBR_APERTURE_ATTRIB_PADOTHER_POS: // print info associated to a component
                                                 // flashed shape at pads position (all but pad 1)
                                                 // in placement files
                                                 // Currently: (could be changed later) same as
-                                                // GBR_APERTURE_ATTRIB_PADOTHER_POSITION
+                                                // GBR_APERTURE_ATTRIB_PADOTHER_POS
         attribute_string = "TA.AperFunction,ComponentPin";
         break;
 
diff --git a/include/gbr_metadata.h b/include/gbr_metadata.h
index be99309c52..a540d86140 100644
--- a/include/gbr_metadata.h
+++ b/include/gbr_metadata.h
@@ -146,10 +146,10 @@ public:
         GBR_APERTURE_ATTRIB_CMP_POSITION,
 
         ///< aperture used for flashed pin 1 (or A1 or AA1) position in placement files.
-        GBR_APERTURE_ATTRIB_PAD1_POSITION,
+        GBR_APERTURE_ATTRIB_PAD1_POS,
 
         ///< aperture used for flashed pads position in placement files.
-        GBR_APERTURE_ATTRIB_PADOTHER_POSITION,
+        GBR_APERTURE_ATTRIB_PADOTHER_POS,
 
         ///< aperture used to draw component physical body outline without pins in placement files.
         GBR_APERTURE_ATTRIB_CMP_BODY,
diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp
index a9516685f8..4e85370d17 100644
--- a/pcbnew/exporters/gen_drill_report_files.cpp
+++ b/pcbnew/exporters/gen_drill_report_files.cpp
@@ -225,7 +225,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_
             {
             PCB_SHAPE dummy_shape( *static_cast<PCB_SHAPE*>( item ) );
             dummy_shape.SetLayer( Dwgs_User );
-            itemplotter.PlotPcbShape( &dummy_shape );
+            itemplotter.PlotShape( &dummy_shape );
             }
             break;
 
diff --git a/pcbnew/exporters/gerber_placefile_writer.cpp b/pcbnew/exporters/gerber_placefile_writer.cpp
index 6880e3c234..d20bdd0a4e 100644
--- a/pcbnew/exporters/gerber_placefile_writer.cpp
+++ b/pcbnew/exporters/gerber_placefile_writer.cpp
@@ -31,11 +31,7 @@
 #include <string_utils.h>
 #include <locale_io.h>
 #include <macros.h>
-
-#include <board.h>
-#include <board_design_settings.h>
 #include <pcb_shape.h>
-
 #include <pcbplot.h>
 #include <wildcards_and_files_ext.h>
 #include <gbr_metadata.h>
@@ -115,7 +111,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
     // and component outline thickness (polyline)
     int flash_position_shape_diam = pcbIUScale.mmToIU( 0.3 ); // defined size for position shape (circle)
     int pad1_mark_size = pcbIUScale.mmToIU( 0.36 );           // defined size for pad 1 position (diamond)
-    int other_pads_mark_size = 0;                         // defined size for position shape (circle)
+    int other_pads_mark_size = 0;                             // defined size for position shape (circle)
     int line_thickness = pcbIUScale.mmToIU( 0.1 );            // defined size for component outlines
 
     brd_plotter.SetLayerSet( LSET( aLayer ) );
@@ -126,16 +122,16 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
     for( FOOTPRINT* footprint : fp_list )
     {
         // Manage the aperture attribute component position:
-        GBR_METADATA gbr_metadata;
-        gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_POSITION );
+        GBR_METADATA metadata;
+        metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_POSITION );
 
         // Add object attribute: component reference to flash (mainly useful for users)
         // using quoted UTF8 string
         wxString ref = ConvertNotAllowedCharsInGerber( footprint->Reference().GetShownText( false ),
                                                        allowUtf8, true );
 
-        gbr_metadata.SetCmpReference( ref );
-        gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
+        metadata.SetCmpReference( ref );
+        metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
 
         // Add P&P specific attributes
         GBR_CMP_PNP_METADATA pnpAttrib;
@@ -163,15 +159,15 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
         fp_info = FROM_UTF8( footprint->GetFPID().GetLibNickname().c_str() );
         pnpAttrib.m_LibraryName = ConvertNotAllowedCharsInGerber( fp_info, allowUtf8, true );
 
-        gbr_metadata.m_NetlistMetadata.SetExtraData( pnpAttrib.FormatCmpPnPMetadata() );
+        metadata.m_NetlistMetadata.SetExtraData( pnpAttrib.FormatCmpPnPMetadata() );
 
         VECTOR2I flash_pos = footprint->GetPosition();
 
-        plotter.FlashPadCircle( flash_pos, flash_position_shape_diam, FILLED, &gbr_metadata );
-        gbr_metadata.m_NetlistMetadata.ClearExtraData();
+        plotter.FlashPadCircle( flash_pos, flash_position_shape_diam, FILLED, &metadata );
+        metadata.m_NetlistMetadata.ClearExtraData();
 
         // Now some extra metadata is output, avoid blindly clearing the full metadata list
-        gbr_metadata.m_NetlistMetadata.m_TryKeepPreviousAttributes = true;
+        metadata.m_NetlistMetadata.m_TryKeepPreviousAttributes = true;
 
         // We plot the footprint courtyard when possible.
         // If not, the pads bounding box will be used.
@@ -184,8 +180,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
 
         if( ( footprint->GetFlags() & checkFlag ) == 0 )
         {
-            gbr_metadata.SetApertureAttrib(
-                    GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_COURTYARD );
+            metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_COURTYARD );
 
             const SHAPE_POLY_SET& courtyard = footprint->GetCourtyard( aLayer );
 
@@ -197,14 +192,13 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
                     continue;
 
                 useFpPadsBbox = false;
-                plotter.PLOTTER::PlotPoly( poly, FILL_T::NO_FILL, line_thickness, &gbr_metadata );
+                plotter.PLOTTER::PlotPoly( poly, FILL_T::NO_FILL, line_thickness, &metadata );
             }
         }
 
         if( useFpPadsBbox )
         {
-            gbr_metadata.SetApertureAttrib(
-                    GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_FOOTPRINT );
+            metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_FOOTPRINT );
 
             // bbox of fp pads, pos 0, rot 0, non flipped
             BOX2I bbox = footprint->GetFpPadsLocalBbox();
@@ -222,7 +216,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
 
             poly.Rotate( footprint->GetOrientation() );
             poly.Move( footprint->GetPosition() );
-            plotter.PLOTTER::PlotPoly( poly, FILL_T::NO_FILL, line_thickness, &gbr_metadata );
+            plotter.PLOTTER::PlotPoly( poly, FILL_T::NO_FILL, line_thickness, &metadata );
         }
 
         std::vector<PAD*>pad_key_list;
@@ -233,26 +227,21 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
 
             for( PAD* pad1 : pad_key_list )
             {
-                gbr_metadata.SetApertureAttrib(
-                        GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_PAD1_POSITION );
-
-                gbr_metadata.SetPadName( pad1->GetNumber(), allowUtf8, true );
-
-                gbr_metadata.SetPadPinFunction( pad1->GetPinFunction(), allowUtf8, true );
-
-                gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_PAD );
+                metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_PAD1_POS );
+                metadata.SetPadName( pad1->GetNumber(), allowUtf8, true );
+                metadata.SetPadPinFunction( pad1->GetPinFunction(), allowUtf8, true );
+                metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_PAD );
 
                 // Flashes a diamond at pad position:
                 plotter.FlashRegularPolygon( pad1->GetPosition(), pad1_mark_size, 4, ANGLE_0,
-                                             FILLED, &gbr_metadata );
+                                             FILLED, &metadata );
             }
         }
 
         if( m_plotOtherPadsMarker )
         {
-            gbr_metadata.SetApertureAttrib(
-                    GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_PADOTHER_POSITION );
-            gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_PAD );
+            metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_PADOTHER_POS );
+            metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_PAD );
 
             for( PAD* pad: footprint->Pads() )
             {
@@ -275,13 +264,11 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
                 if( !pad->IsOnLayer( aLayer ) )
                     continue;
 
-                gbr_metadata.SetPadName( pad->GetNumber(), allowUtf8, true );
-
-                gbr_metadata.SetPadPinFunction( pad->GetPinFunction(), allowUtf8, true );
+                metadata.SetPadName( pad->GetNumber(), allowUtf8, true );
+                metadata.SetPadPinFunction( pad->GetPinFunction(), allowUtf8, true );
 
                 // Flashes a round, 0 sized round shape at pad position
-                plotter.FlashPadCircle( pad->GetPosition(), other_pads_mark_size, FILLED,
-                                        &gbr_metadata );
+                plotter.FlashPadCircle( pad->GetPosition(), other_pads_mark_size, FILLED, &metadata );
             }
         }
 
@@ -296,7 +283,8 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
         brd_plotter.SetLayerSet( LSET( Edge_Cuts ) );
 
          // Plot edge layer and graphic items
-        brd_plotter.PlotBoardGraphicItems();
+        for( const BOARD_ITEM* item : m_pcb->Drawings() )
+            brd_plotter.PlotBoardGraphicItem( item );
 
         // Draw footprint other graphic items:
         for( FOOTPRINT* footprint : fp_list )
@@ -304,7 +292,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
             for( BOARD_ITEM* item : footprint->GraphicalItems() )
             {
                 if( item->Type() == PCB_SHAPE_T && item->GetLayer() == Edge_Cuts )
-                    brd_plotter.PlotPcbShape( static_cast<PCB_SHAPE*>( item ) );
+                    brd_plotter.PlotShape( static_cast<PCB_SHAPE*>( item ) );
             }
         }
     }
diff --git a/pcbnew/pcb_track.cpp b/pcbnew/pcb_track.cpp
index 4933efec62..6a9cbae3ef 100644
--- a/pcbnew/pcb_track.cpp
+++ b/pcbnew/pcb_track.cpp
@@ -32,12 +32,12 @@
 #include <convert_basic_shapes_to_polygon.h>
 #include <pcb_track.h>
 #include <base_units.h>
-#include <bitmaps.h>
+//#include <bitmaps.h>
 #include <string_utils.h>
 #include <view/view.h>
 #include <settings/color_settings.h>
 #include <settings/settings_manager.h>
-#include <i18n_utility.h>
+//#include <i18n_utility.h>
 #include <geometry/seg.h>
 #include <geometry/shape_segment.h>
 #include <geometry/shape_circle.h>
@@ -460,9 +460,7 @@ std::shared_ptr<SHAPE_SEGMENT> PCB_VIA::GetEffectiveHoleShape() const
 
 bool PCB_VIA::IsTented() const
 {
-    const BOARD* board = GetBoard();
-
-    if( board )
+    if( const BOARD* board = GetBoard() )
         return board->GetTentVias();
     else
         return true;
@@ -471,9 +469,7 @@ bool PCB_VIA::IsTented() const
 
 int PCB_VIA::GetSolderMaskExpansion() const
 {
-    const BOARD* board = GetBoard();
-
-    if( board )
+    if( const BOARD* board = GetBoard() )
         return board->GetDesignSettings().m_SolderMaskExpansion;
     else
         return 0;
@@ -615,7 +611,7 @@ void PCB_VIA::SanitizeLayers()
 
 bool PCB_VIA::FlashLayer( LSET aLayers ) const
 {
-    for( auto layer : aLayers.Seq() )
+    for( PCB_LAYER_ID layer : aLayers.Seq() )
     {
         if( FlashLayer( layer ) )
             return true;
@@ -737,10 +733,9 @@ double PCB_TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
 
 const BOX2I PCB_TRACK::ViewBBox() const
 {
-    BOX2I        bbox = GetBoundingBox();
-    const BOARD* board = GetBoard();
+    BOX2I bbox = GetBoundingBox();
 
-    if( board )
+    if( const BOARD* board = GetBoard() )
         bbox.Inflate( 2 * board->GetDesignSettings().GetBiggestClearanceValue() );
     else
         bbox.Inflate( GetWidth() );     // Add a bit extra for safety
@@ -777,7 +772,6 @@ double PCB_VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
 
     PCB_PAINTER*         painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
     PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
-    const BOARD*         board = GetBoard();
     LSET                 visible = LSET::AllLayersMask();
 
     // Meta control for hiding all vias
@@ -785,7 +779,7 @@ double PCB_VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
         return HIDE;
 
     // Handle board visibility
-    if( board )
+    if( const BOARD* board = GetBoard() )
         visible = board->GetVisibleLayers() & board->GetEnabledLayers();
 
     // In high contrast mode don't show vias that don't cross the high-contrast layer
@@ -1160,13 +1154,6 @@ EDA_ANGLE PCB_ARC::GetArcAngleStart() const
 }
 
 
-EDA_ANGLE PCB_ARC::GetArcAngleEnd() const
-{
-    EDA_ANGLE angleEnd( m_End - GetPosition() );
-    return angleEnd.Normalize();
-}
-
-
 bool PCB_TRACK::cmp_tracks::operator() ( const PCB_TRACK* a, const PCB_TRACK* b ) const
 {
     if( a->GetNetCode() != b->GetNetCode() )
diff --git a/pcbnew/pcb_track.h b/pcbnew/pcb_track.h
index 3d7f8ac2ec..c9969db7ca 100644
--- a/pcbnew/pcb_track.h
+++ b/pcbnew/pcb_track.h
@@ -27,9 +27,9 @@
  * for curved tracks (PCB_ARC) and vias (PCB_VIA).  All told there are three KICAD_Ts:
  * PCB_TRACK_T, PCB_ARC_T, and PCB_VIA_T.
  *
- * For vias there is a further VIATYPE which indicates THROUGH, BLIND_BURIED, or
- * MICROVIA, which are supported by the synthetic KICAD_Ts PCB_LOCATE_STDVIA_T,
- * PCB_LOCATE_BBVIA_T, and PCB_LOCATE_UVIA_T.
+ * For vias there is a further VIATYPE which indicates THROUGH, BLIND_BURIED, or MICROVIA,
+ * which are supported by the synthetic KICAD_Ts PCB_LOCATE_STDVIA_T, PCB_LOCATE_BBVIA_T, and
+ * PCB_LOCATE_UVIA_T.
  */
 
 #ifndef CLASS_TRACK_H
@@ -99,24 +99,24 @@ public:
 
     void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
 
-    void          SetPosition( const VECTOR2I& aPos ) override { m_Start = aPos; }
-    VECTOR2I      GetPosition() const override { return m_Start; }
-    const VECTOR2I GetFocusPosition() const override { return ( m_Start + m_End ) / 2; }
+    void SetPosition( const VECTOR2I& aPos ) override { m_Start = aPos; }
+    VECTOR2I GetPosition() const override             { return m_Start; }
+    const VECTOR2I GetFocusPosition() const override  { return ( m_Start + m_End ) / 2; }
 
-    void SetWidth( int aWidth )                 { m_Width = aWidth; }
-    int GetWidth() const                        { return m_Width; }
+    void SetWidth( int aWidth )             { m_Width = aWidth; }
+    int GetWidth() const                    { return m_Width; }
 
-    void            SetEnd( const VECTOR2I& aEnd ) { m_End = aEnd; }
-    const VECTOR2I& GetEnd() const { return m_End; }
+    void SetEnd( const VECTOR2I& aEnd )     { m_End = aEnd; }
+    const VECTOR2I& GetEnd() const          { return m_End; }
 
-    void            SetStart( const VECTOR2I& aStart ) { m_Start = aStart; }
-    const VECTOR2I& GetStart() const { return m_Start; }
+    void SetStart( const VECTOR2I& aStart ) { m_Start = aStart; }
+    const VECTOR2I& GetStart() const        { return m_Start; }
 
-    void SetEndX( int aX ) { m_End.x = aX; }
-    void SetEndY( int aY ) { m_End.y = aY; }
+    void SetEndX( int aX )                  { m_End.x = aX; }
+    void SetEndY( int aY )                  { m_End.y = aY; }
 
-    int GetEndX() const { return m_End.x; }
-    int GetEndY() const { return m_End.y; }
+    int GetEndX() const                     { return m_End.x; }
+    int GetEndY() const                     { return m_End.y; }
 
     /// Return the selected endpoint (start or end)
     const VECTOR2I& GetEndPoint( ENDPOINT_T aEndPoint ) const
@@ -275,12 +275,11 @@ protected:
                                      std::vector<MSG_PANEL_ITEM>& aList ) const;
 
 protected:
-    int      m_Width; ///< Thickness of track, or via diameter
-    VECTOR2I m_Start; ///< Line start point
-    VECTOR2I m_End;   ///< Line end point
-
-    double   m_CachedLOD; ///< Last LOD used to draw this track's net
+    int      m_Width;        ///< Thickness of track, or via diameter
+    VECTOR2I m_Start;        ///< Line start point
+    VECTOR2I m_End;          ///< Line end point
 
+    double   m_CachedLOD;    ///< Last LOD used to draw this track's net
     double   m_CachedScale;  ///< Last zoom scale used to draw this track's net.
 };
 
@@ -290,8 +289,7 @@ class PCB_ARC : public PCB_TRACK
 public:
     PCB_ARC( BOARD_ITEM* aParent ) :
         PCB_TRACK( aParent, PCB_ARC_T )
-    {
-    };
+    { }
 
     PCB_ARC( BOARD_ITEM* aParent, const SHAPE_ARC* aArc );
 
@@ -313,13 +311,10 @@ public:
 
     void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override;
 
-    void            SetMid( const VECTOR2I& aMid ) { m_Mid = aMid; }
-    const VECTOR2I& GetMid() const { return m_Mid; }
+    void SetMid( const VECTOR2I& aMid ) { m_Mid = aMid; }
+    const VECTOR2I& GetMid() const      { return m_Mid; }
 
-    void SetPosition( const VECTOR2I& aPos ) override
-    {
-        m_Start = aPos;
-    }
+    void SetPosition( const VECTOR2I& aPos ) override { m_Start = aPos; }
 
     virtual VECTOR2I GetPosition() const override;
 
@@ -328,7 +323,6 @@ public:
     double GetRadius() const;
     EDA_ANGLE GetAngle() const;
     EDA_ANGLE GetArcAngleStart() const;
-    EDA_ANGLE GetArcAngleEnd() const;
     virtual bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
 
     virtual bool HitTest( const BOX2I& aRect, bool aContained = true,
@@ -443,8 +437,8 @@ public:
      */
     void SanitizeLayers();
 
-    VECTOR2I GetPosition() const override { return m_Start; }
-    void     SetPosition( const VECTOR2I& aPoint ) override { m_Start = aPoint;  m_End = aPoint; }
+    VECTOR2I GetPosition() const override               { return m_Start; }
+    void SetPosition( const VECTOR2I& aPoint ) override { m_Start = aPoint;  m_End = aPoint; }
 
     void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
 
@@ -548,14 +542,9 @@ public:
      *
      * @return true if the via is a free via
      */
-    bool GetIsFree() const { return m_isFree; }
+    bool GetIsFree() const              { return m_isFree; }
     void SetIsFree( bool aFree = true ) { m_isFree = aFree; }
 
-    /**
-     * @return true if the drill value is default value (-1)
-     */
-    bool IsDrillDefault() const { return m_drill <= 0; }
-
     // @copydoc BOARD_ITEM::GetEffectiveShape
     std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
                                               FLASHING aFlash = FLASHING::DEFAULT ) const override;
diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h
index 89c4cd1e3c..a776edc1b0 100644
--- a/pcbnew/pcbplot.h
+++ b/pcbnew/pcbplot.h
@@ -55,13 +55,11 @@ class wxFileName;
 class BRDITEMS_PLOTTER : public PCB_PLOT_PARAMS
 {
 public:
-    BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts )
-            : PCB_PLOT_PARAMS( aPlotOpts )
-    {
-        m_plotter = aPlotter;
-        m_board = aBoard;
-        m_maxError = aBoard->GetDesignSettings().m_MaxError;
-    }
+    BRDITEMS_PLOTTER( PLOTTER* aPlotter, BOARD* aBoard, const PCB_PLOT_PARAMS& aPlotOpts ) :
+            PCB_PLOT_PARAMS( aPlotOpts ),
+            m_plotter( aPlotter ),
+            m_board( aBoard )
+    { }
 
     /**
      * @return a 'width adjustment' for the postscript engine
@@ -79,20 +77,13 @@ public:
     // Basic functions to plot a board item
     void SetLayerSet( LSET aLayerMask ) { m_layerMask = aLayerMask; }
     void PlotFootprintGraphicItems( const FOOTPRINT* aFootprint );
-    void PlotFootprintTextItem( const PCB_TEXT* aText, const COLOR4D& aColor );
-
-    /*
-     * Reference, Value, and other fields are plotted only if the corresponding option is enabled.
-     * Invisible text fields are plotted only if PlotInvisibleText option is set.
-     */
     void PlotFootprintTextItems( const FOOTPRINT* aFootprint );
 
     void PlotDimension( const PCB_DIMENSION_BASE* aDim );
     void PlotPcbTarget( const PCB_TARGET* aMire );
-    void PlotFilledAreas( const ZONE* aZone, PCB_LAYER_ID aLayer,
-                          const SHAPE_POLY_SET& aPolysList );
-    void PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout );
-    void PlotPcbShape( const PCB_SHAPE* aShape );
+    void PlotZones( const ZONE* aZone, PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPolysList );
+    void PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout );
+    void PlotShape( const PCB_SHAPE* aShape );
 
     /**
      * Plot a pad.
@@ -105,8 +96,7 @@ public:
     /**
      * Plot items like text and graphics but not tracks and footprints.
      */
-    void PlotBoardGraphicItems();
-    void PlotPcbGraphicItem( const BOARD_ITEM* item );
+    void PlotBoardGraphicItem( const BOARD_ITEM* item );
 
     /**
      * Draw a drill mark for pads and vias.
@@ -136,10 +126,9 @@ private:
                            const VECTOR2I& aDrillSize, const VECTOR2I& aPadSize,
                            const EDA_ANGLE& aOrientation, int aSmallDrill );
 
-    PLOTTER*    m_plotter;
-    BOARD*      m_board;
-    int         m_maxError;     // For use when approximating shapes as polygons
-    LSET        m_layerMask;
+    PLOTTER*  m_plotter;
+    BOARD*    m_board;
+    LSET      m_layerMask;
 };
 
 
diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp
index e81238cabf..9f8948776d 100644
--- a/pcbnew/plot_board_layers.cpp
+++ b/pcbnew/plot_board_layers.cpp
@@ -284,7 +284,8 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
     bool sketchPads = ( onFrontFab || onBackFab ) && aPlotOpt.GetSketchPadsOnFabLayers();
 
      // Plot edge layer and graphic items
-    itemplotter.PlotBoardGraphicItems();
+    for( const BOARD_ITEM* item : aBoard->Drawings() )
+        itemplotter.PlotBoardGraphicItem( item );
 
     // Draw footprint texts:
     for( const FOOTPRINT* footprint : aBoard->Footprints() )
@@ -376,7 +377,9 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
             // Note: a custom pad can have its pad anchor with size = 0
             if( pad->GetShape() != PAD_SHAPE::CUSTOM
                 && ( padPlotsSize.x <= 0 || padPlotsSize.y <= 0 ) )
+            {
                 continue;
+            }
 
             switch( pad->GetShape() )
             {
@@ -689,13 +692,13 @@ void PlotStandardLayer( BOARD* aBoard, PLOTTER* aPlotter, LSET aLayerMask,
                 }
             }
 
-            itemplotter.PlotFilledAreas( zone, layer, mainArea );
+            itemplotter.PlotZones( zone, layer, mainArea );
 
             if( !islands.IsEmpty() )
             {
                 ZONE dummy( *zone );
                 dummy.SetNet( &nonet );
-                itemplotter.PlotFilledAreas( &dummy, layer, islands );
+                itemplotter.PlotZones( &dummy, layer, islands );
             }
         }
     }
@@ -893,7 +896,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
                 else if( item->IsOnLayer( Edge_Cuts ) )
                 {
                     if( item->Type() == PCB_SHAPE_T )
-                        itemplotter.PlotPcbShape( static_cast<const PCB_SHAPE*>( item ) );
+                        itemplotter.PlotShape( static_cast<const PCB_SHAPE*>( item ) );
                 }
             }
         }
@@ -951,7 +954,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
             }
             else if( item->IsOnLayer( Edge_Cuts ) )
             {
-                itemplotter.PlotPcbGraphicItem( item );
+                itemplotter.PlotBoardGraphicItem( item );
             }
         }
 
@@ -989,7 +992,7 @@ void PlotSolderMaskLayer( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask,
     areas.BooleanAdd( initialPolys, SHAPE_POLY_SET::PM_FAST );
     areas.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
 
-    itemplotter.PlotFilledAreas( &zone, layer, areas );
+    itemplotter.PlotZones( &zone, layer, areas );
 }
 
 
diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp
index dfe2302c3a..19a4f481b4 100644
--- a/pcbnew/plot_brditems_plotter.cpp
+++ b/pcbnew/plot_brditems_plotter.cpp
@@ -24,7 +24,6 @@
 #include <algorithm>                          // for min
 #include <bitset>                             // for bitset, operator&, __bi...
 #include <math.h>                             // for abs
-#include <stddef.h>                           // for NULL, size_t
 
 #include <geometry/seg.h>                     // for SEG
 #include <geometry/shape_circle.h>
@@ -37,20 +36,15 @@
 #include <math/vector2d.h>                    // for VECTOR2I
 #include <plotters/plotter_gerber.h>
 #include <trigo.h>
-#include <callback_gal.h>
 
-#include <board_design_settings.h>            // for BOARD_DESIGN_SETTINGS
 #include <core/typeinfo.h>                    // for dyn_cast, PCB_DIMENSION_T
 #include <gbr_metadata.h>
 #include <gbr_netlist_metadata.h>             // for GBR_NETLIST_METADATA
 #include <layer_ids.h>                        // for LSET, IsCopperLayer
-#include <pad_shapes.h>                       // for PAD_ATTRIB::NPTH
 #include <pcbplot.h>
 #include <pcb_plot_params.h>                  // for PCB_PLOT_PARAMS, PCB_PL...
 #include <advanced_config.h>
 
-#include <board.h>
-#include <board_item.h>                       // for BOARD_ITEM, S_CIRCLE
 #include <pcb_dimension.h>
 #include <pcb_shape.h>
 #include <footprint.h>
@@ -68,8 +62,7 @@ COLOR4D BRDITEMS_PLOTTER::getColor( int aLayer ) const
 {
     COLOR4D color = ColorSettings()->GetColor( aLayer );
 
-    // A hack to avoid plotting a white item in white color, expecting the paper
-    // is also white: use a non white color:
+    // A hack to avoid plotting a white item in white color on white paper
     if( color == COLOR4D::WHITE )
         color = COLOR4D( LIGHTGRAY );
 
@@ -80,7 +73,7 @@ COLOR4D BRDITEMS_PLOTTER::getColor( int aLayer ) const
 void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_MODE aPlotMode )
 {
     VECTOR2I     shape_pos = aPad->ShapePos();
-    GBR_METADATA gbr_metadata;
+    GBR_METADATA metadata;
 
     bool plotOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
     bool plotOnExternalCopperLayer = ( m_layerMask & LSET::ExternalCuMask() ).any();
@@ -90,33 +83,33 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
     // Not yet in use.
     // bool isPadOnBoardTechLayers = ( aPad->GetLayerSet() & LSET::AllBoardTechMask() ).any();
 
-    gbr_metadata.SetCmpReference( aPad->GetParent()->GetReference() );
+    metadata.SetCmpReference( aPad->GetParent()->GetReference() );
 
     if( plotOnCopperLayer )
     {
-        gbr_metadata.SetNetAttribType( GBR_NETINFO_ALL );
-        gbr_metadata.SetCopper( true );
+        metadata.SetNetAttribType( GBR_NETINFO_ALL );
+        metadata.SetCopper( true );
 
         // Gives a default attribute, for instance for pads used as tracks in net ties:
         // Connector pads and SMD pads are on external layers
         // if on internal layers, they are certainly used as net tie
         // and are similar to tracks: just conductor items
-        gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
+        metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONDUCTOR );
 
         const bool useUTF8 = false;
         const bool useQuoting = false;
-        gbr_metadata.SetPadName( aPad->GetNumber(), useUTF8, useQuoting );
+        metadata.SetPadName( aPad->GetNumber(), useUTF8, useQuoting );
 
         if( !aPad->GetNumber().IsEmpty() )
-            gbr_metadata.SetPadPinFunction( aPad->GetPinFunction(), useUTF8, useQuoting );
+            metadata.SetPadPinFunction( aPad->GetPinFunction(), useUTF8, useQuoting );
 
-        gbr_metadata.SetNetName( aPad->GetNetname() );
+        metadata.SetNetName( aPad->GetNetname() );
 
         // Some pads are mechanical pads ( through hole or smd )
         // when this is the case, they have no pad name and/or are not plated.
         // In this case gerber files have slightly different attributes.
         if( aPad->GetAttribute() == PAD_ATTRIB::NPTH || aPad->GetNumber().IsEmpty() )
-            gbr_metadata.m_NetlistMetadata.m_NotInNet = true;
+            metadata.m_NetlistMetadata.m_NotInNet = true;
 
         if( !plotOnExternalCopperLayer )
         {
@@ -126,7 +119,7 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
             // Currently, Pcbnew does not handle embedded component, so we disable the .P
             // attribute on internal layers
             // Note the Gerber doc is not really clear about through holes pads about the .P
-            gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET |
+            metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_NET |
                                            GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
 
         }
@@ -139,25 +132,22 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
         switch( aPad->GetAttribute() )
         {
         case PAD_ATTRIB::NPTH:       // Mechanical pad through hole
-            gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD );
+            metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD );
             break;
 
         case PAD_ATTRIB::PTH :       // Pad through hole, a hole is also expected
-            gbr_metadata.SetApertureAttrib(
-                    GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_COMPONENTPAD );
+            metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_COMPONENTPAD );
             break;
 
         case PAD_ATTRIB::CONN:       // Connector pads, no solder paste but with solder mask.
             if( plotOnExternalCopperLayer )
-                gbr_metadata.SetApertureAttrib(
-                        GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONNECTORPAD );
+                metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CONNECTORPAD );
             break;
 
         case PAD_ATTRIB::SMD:        // SMD pads (on external copper layer only)
                                      // with solder paste and mask
             if( plotOnExternalCopperLayer )
-                gbr_metadata.SetApertureAttrib(
-                        GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_SMDPAD_CUDEF );
+                metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_SMDPAD_CUDEF );
             break;
         }
 
@@ -167,34 +157,28 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
         {
         case PAD_PROP::BGA:          // Only applicable to outer layers
             if( plotOnExternalCopperLayer )
-                gbr_metadata.SetApertureAttrib(
-                        GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_BGAPAD_CUDEF );
+                metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_BGAPAD_CUDEF );
             break;
 
         case PAD_PROP::FIDUCIAL_GLBL:
-            gbr_metadata.SetApertureAttrib(
-                    GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL );
+            metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_GLBL );
             break;
 
         case PAD_PROP::FIDUCIAL_LOCAL:
-            gbr_metadata.SetApertureAttrib(
-                    GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL );
+            metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_FIDUCIAL_LOCAL );
             break;
 
         case PAD_PROP::TESTPOINT:    // Only applicable to outer layers
             if( plotOnExternalCopperLayer )
-                gbr_metadata.SetApertureAttrib(
-                        GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_TESTPOINT );
+                metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_TESTPOINT );
             break;
 
         case PAD_PROP::HEATSINK:
-            gbr_metadata.SetApertureAttrib(
-                    GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_HEATSINKPAD );
+            metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_HEATSINKPAD );
             break;
 
         case PAD_PROP::CASTELLATED:
-            gbr_metadata.SetApertureAttrib(
-                    GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CASTELLATEDPAD );
+            metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CASTELLATEDPAD );
             break;
 
         case PAD_PROP::NONE:
@@ -203,11 +187,11 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
 
         // Ensure NPTH pads have *always* the GBR_APERTURE_ATTRIB_WASHERPAD attribute
         if( aPad->GetAttribute() == PAD_ATTRIB::NPTH )
-            gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD );
+            metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_WASHERPAD );
     }
     else
     {
-        gbr_metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
+        metadata.SetNetAttribType( GBR_NETLIST_METADATA::GBR_NETINFO_CMP );
     }
 
     // Set plot color (change WHITE to LIGHTGRAY because
@@ -215,27 +199,27 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
     m_plotter->SetColor( aColor != WHITE ? aColor : LIGHTGRAY);
 
     if( aPlotMode == SKETCH )
-        m_plotter->SetCurrentLineWidth( GetSketchPadLineWidth(), &gbr_metadata );
+        m_plotter->SetCurrentLineWidth( GetSketchPadLineWidth(), &metadata );
 
     switch( aPad->GetShape() )
     {
     case PAD_SHAPE::CIRCLE:
-        m_plotter->FlashPadCircle( shape_pos, aPad->GetSize().x, aPlotMode, &gbr_metadata );
+        m_plotter->FlashPadCircle( shape_pos, aPad->GetSize().x, aPlotMode, &metadata );
         break;
 
     case PAD_SHAPE::OVAL:
         m_plotter->FlashPadOval( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
-                                 &gbr_metadata );
+                                 &metadata );
         break;
 
     case PAD_SHAPE::RECTANGLE:
         m_plotter->FlashPadRect( shape_pos, aPad->GetSize(), aPad->GetOrientation(), aPlotMode,
-                                 &gbr_metadata );
+                                 &metadata );
         break;
 
     case PAD_SHAPE::ROUNDRECT:
         m_plotter->FlashPadRoundRect( shape_pos, aPad->GetSize(), aPad->GetRoundRectCornerRadius(),
-                                      aPad->GetOrientation(), aPlotMode, &gbr_metadata );
+                                      aPad->GetOrientation(), aPlotMode, &metadata );
         break;
 
     case PAD_SHAPE::TRAPEZOID:
@@ -254,8 +238,7 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
         coord[2] = VECTOR2I( half_size.x - trap_delta.y, -half_size.y + trap_delta.x );
         coord[3] = VECTOR2I( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
 
-        m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), aPlotMode,
-                                   &gbr_metadata );
+        m_plotter->FlashPadTrapez( shape_pos, coord, aPad->GetOrientation(), aPlotMode, &metadata );
     }
         break;
 
@@ -268,8 +251,7 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
                                                      aPad->GetRoundRectCornerRadius(),
                                                      aPad->GetChamferRectRatio(),
                                                      aPad->GetChamferPositions(),
-                                                     aPad->GetOrientation(), aPlotMode,
-                                                     &gbr_metadata );
+                                                     aPad->GetOrientation(), aPlotMode, &metadata );
             break;
         }
 
@@ -283,7 +265,7 @@ void BRDITEMS_PLOTTER::PlotPad( const PAD* aPad, const COLOR4D& aColor, OUTLINE_
         if( polygons->OutlineCount() )
         {
             m_plotter->FlashPadCustom( shape_pos, aPad->GetSize(), aPad->GetOrientation(),
-                                       polygons.get(), aPlotMode, &gbr_metadata );
+                                       polygons.get(), aPlotMode, &metadata );
         }
     }
         break;
@@ -300,7 +282,7 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItems( const FOOTPRINT* aFootprint )
     if( GetPlotReference() && m_layerMask[textLayer]
         && ( textItem->IsVisible() || GetPlotInvisibleText() ) )
     {
-        PlotPcbText( textItem, textLayer, textItem->IsKnockout() );
+        PlotText( textItem, textLayer, textItem->IsKnockout() );
     }
 
     textItem  = &aFootprint->Value();
@@ -309,7 +291,7 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItems( const FOOTPRINT* aFootprint )
     if( GetPlotValue() && m_layerMask[textLayer]
         && ( textItem->IsVisible() || GetPlotInvisibleText() ) )
     {
-        PlotPcbText( textItem, textLayer, textItem->IsKnockout() );
+        PlotText( textItem, textLayer, textItem->IsKnockout() );
     }
 
     for( const BOARD_ITEM* item : aFootprint->GraphicalItems() )
@@ -336,31 +318,31 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItems( const FOOTPRINT* aFootprint )
         if( textItem->GetText() == wxT( "${VALUE}" ) && !GetPlotValue() )
             continue;
 
-        PlotPcbText( textItem, textLayer, textItem->IsKnockout() );
+        PlotText( textItem, textLayer, textItem->IsKnockout() );
     }
 }
 
 
-void BRDITEMS_PLOTTER::PlotPcbGraphicItem( const BOARD_ITEM* item )
+void BRDITEMS_PLOTTER::PlotBoardGraphicItem( const BOARD_ITEM* item )
 {
     switch( item->Type() )
     {
     case PCB_SHAPE_T:
-        PlotPcbShape( static_cast<const PCB_SHAPE*>( item ) );
+        PlotShape( static_cast<const PCB_SHAPE*>( item ) );
         break;
 
     case PCB_TEXT_T:
     {
         const PCB_TEXT* text = static_cast<const PCB_TEXT*>( item );
-        PlotPcbText( text, text->GetLayer(), text->IsKnockout() );
+        PlotText( text, text->GetLayer(), text->IsKnockout() );
         break;
     }
 
     case PCB_TEXTBOX_T:
     {
         const PCB_TEXTBOX* textbox = static_cast<const PCB_TEXTBOX*>( item );
-        PlotPcbText( textbox, textbox->GetLayer(), textbox->IsKnockout() );
-        PlotPcbShape( textbox );
+        PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout() );
+        PlotShape( textbox );
         break;
     }
 
@@ -382,30 +364,23 @@ void BRDITEMS_PLOTTER::PlotPcbGraphicItem( const BOARD_ITEM* item )
 }
 
 
-void BRDITEMS_PLOTTER::PlotBoardGraphicItems()
-{
-    for( const BOARD_ITEM* item : m_board->Drawings() )
-        PlotPcbGraphicItem( item );
-}
-
-
 void BRDITEMS_PLOTTER::PlotDimension( const PCB_DIMENSION_BASE* aDim )
 {
     if( !m_layerMask[aDim->GetLayer()] )
         return;
 
-    PCB_SHAPE draw;
-
-    draw.SetStroke( STROKE_PARAMS( aDim->GetLineThickness(), PLOT_DASH_TYPE::SOLID ) );
-    draw.SetLayer( aDim->GetLayer() );
-
     COLOR4D color = ColorSettings()->GetColor( aDim->GetLayer() );
 
     // Set plot color (change WHITE to LIGHTGRAY because
     // the white items are not seen on a white paper or screen
     m_plotter->SetColor( color != WHITE ? color : LIGHTGRAY);
 
-    PlotPcbText( aDim, aDim->GetLayer(), false );
+    PlotText( aDim, aDim->GetLayer(), false );
+
+    PCB_SHAPE temp_item;
+
+    temp_item.SetStroke( STROKE_PARAMS( aDim->GetLineThickness(), PLOT_DASH_TYPE::SOLID ) );
+    temp_item.SetLayer( aDim->GetLayer() );
 
     for( const std::shared_ptr<SHAPE>& shape : aDim->GetShapes() )
     {
@@ -415,11 +390,11 @@ void BRDITEMS_PLOTTER::PlotDimension( const PCB_DIMENSION_BASE* aDim )
         {
             const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
 
-            draw.SetShape( SHAPE_T::SEGMENT );
-            draw.SetStart(  seg.A );
-            draw.SetEnd( seg.B );
+            temp_item.SetShape( SHAPE_T::SEGMENT );
+            temp_item.SetStart( seg.A );
+            temp_item.SetEnd( seg.B );
 
-            PlotPcbShape( &draw );
+            PlotShape( &temp_item );
             break;
         }
 
@@ -428,12 +403,12 @@ void BRDITEMS_PLOTTER::PlotDimension( const PCB_DIMENSION_BASE* aDim )
             VECTOR2I start( shape->Centre() );
             int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
 
-            draw.SetShape( SHAPE_T::CIRCLE );
-            draw.SetFilled( false );
-            draw.SetStart( start );
-            draw.SetEnd( VECTOR2I( start.x + radius, start.y ) );
+            temp_item.SetShape( SHAPE_T::CIRCLE );
+            temp_item.SetFilled( false );
+            temp_item.SetStart( start );
+            temp_item.SetEnd( VECTOR2I( start.x + radius, start.y ) );
 
-            PlotPcbShape( &draw );
+            PlotShape( &temp_item );
             break;
         }
 
@@ -453,24 +428,24 @@ void BRDITEMS_PLOTTER::PlotPcbTarget( const PCB_TARGET* aMire )
 
     m_plotter->SetColor( getColor( aMire->GetLayer() ) );
 
-    PCB_SHAPE draw;
+    PCB_SHAPE temp_item;
 
-    draw.SetShape( SHAPE_T::CIRCLE );
-    draw.SetFilled( false );
-    draw.SetStroke( STROKE_PARAMS( aMire->GetWidth(), PLOT_DASH_TYPE::SOLID ) );
-    draw.SetLayer( aMire->GetLayer() );
-    draw.SetStart( aMire->GetPosition() );
+    temp_item.SetShape( SHAPE_T::CIRCLE );
+    temp_item.SetFilled( false );
+    temp_item.SetStroke( STROKE_PARAMS( aMire->GetWidth(), PLOT_DASH_TYPE::SOLID ) );
+    temp_item.SetLayer( aMire->GetLayer() );
+    temp_item.SetStart( aMire->GetPosition() );
     radius = aMire->GetSize() / 3;
 
-    if( aMire->GetShape() )   // shape X
+    if( aMire->GetShape() )   // temp_item X
         radius = aMire->GetSize() / 2;
 
     // Draw the circle
-    draw.SetEnd( VECTOR2I( draw.GetStart().x + radius, draw.GetStart().y ) );
+    temp_item.SetEnd( VECTOR2I( temp_item.GetStart().x + radius, temp_item.GetStart().y ) );
 
-    PlotPcbShape( &draw );
+    PlotShape( &temp_item );
 
-    draw.SetShape( SHAPE_T::SEGMENT );
+    temp_item.SetShape( SHAPE_T::SEGMENT );
 
     radius = aMire->GetSize() / 2;
     dx1    = radius;
@@ -487,14 +462,14 @@ void BRDITEMS_PLOTTER::PlotPcbTarget( const PCB_TARGET* aMire )
 
     VECTOR2I mirePos( aMire->GetPosition() );
 
-    // Draw the X or + shape:
-    draw.SetStart( VECTOR2I( mirePos.x - dx1, mirePos.y - dy1 ) );
-    draw.SetEnd( VECTOR2I( mirePos.x + dx1, mirePos.y + dy1 ) );
-    PlotPcbShape( &draw );
+    // Draw the X or + temp_item:
+    temp_item.SetStart( VECTOR2I( mirePos.x - dx1, mirePos.y - dy1 ) );
+    temp_item.SetEnd( VECTOR2I( mirePos.x + dx1, mirePos.y + dy1 ) );
+    PlotShape( &temp_item );
 
-    draw.SetStart( VECTOR2I( mirePos.x - dx2, mirePos.y - dy2 ) );
-    draw.SetEnd( VECTOR2I( mirePos.x + dx2, mirePos.y + dy2 ) );
-    PlotPcbShape( &draw );
+    temp_item.SetStart( VECTOR2I( mirePos.x - dx2, mirePos.y - dy2 ) );
+    temp_item.SetEnd( VECTOR2I( mirePos.x + dx2, mirePos.y + dy2 ) );
+    PlotShape( &temp_item );
 }
 
 
@@ -512,7 +487,7 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
             const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( item );
 
             if( m_layerMask[ shape->GetLayer() ] )
-                PlotPcbShape( shape );
+                PlotShape( shape );
 
             break;
         }
@@ -523,8 +498,8 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
 
             if( m_layerMask[ textbox->GetLayer() ] )
             {
-                PlotPcbText( textbox, textbox->GetLayer(), textbox->IsKnockout() );
-                PlotPcbShape( textbox );
+                PlotText( textbox, textbox->GetLayer(), textbox->IsKnockout() );
+                PlotShape( textbox );
             }
 
             break;
@@ -556,16 +531,18 @@ void BRDITEMS_PLOTTER::PlotFootprintGraphicItems( const FOOTPRINT* aFootprint )
 
 
 #include <font/stroke_font.h>
-void BRDITEMS_PLOTTER::PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout )
+void BRDITEMS_PLOTTER::PlotText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, bool aIsKnockout )
 {
     KIFONT::FONT* font = aText->GetFont();
 
     if( !font )
     {
-        font = KIFONT::FONT::GetFont( m_plotter->RenderSettings()
-                                            ? m_plotter->RenderSettings()->GetDefaultFont()
-                                            : wxString( wxEmptyString ),
-                                      aText->IsBold(), aText->IsItalic() );
+        wxString defaultFontName;   // empty string is the KiCad stroke font
+
+        if( m_plotter->RenderSettings() )
+            defaultFontName = m_plotter->RenderSettings()->GetDefaultFont();
+
+        font = KIFONT::FONT::GetFont( defaultFontName, aText->IsBold(), aText->IsItalic() );
     }
 
     wxString shownText( aText->GetShownText( true ) );
@@ -596,9 +573,10 @@ void BRDITEMS_PLOTTER::PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer,
     if( aIsKnockout )
     {
         const PCB_TEXT* text = static_cast<const PCB_TEXT*>( aText );
-        SHAPE_POLY_SET finalPoly;
+        SHAPE_POLY_SET  finalPoly;
 
-        text->TransformTextToPolySet( finalPoly, 0, m_maxError, ERROR_INSIDE );
+        text->TransformTextToPolySet( finalPoly, 0, m_board->GetDesignSettings().m_MaxError,
+                                      ERROR_INSIDE );
         finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
 
         for( int ii = 0; ii < finalPoly.OutlineCount(); ++ii )
@@ -626,10 +604,10 @@ void BRDITEMS_PLOTTER::PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer,
 }
 
 
-void BRDITEMS_PLOTTER::PlotFilledAreas( const ZONE* aZone, PCB_LAYER_ID aLayer,
-                                        const SHAPE_POLY_SET& polysList )
+void BRDITEMS_PLOTTER::PlotZones( const ZONE* aZone, PCB_LAYER_ID aLayer,
+                                  const SHAPE_POLY_SET& aPolysList )
 {
-    if( polysList.IsEmpty() )
+    if( aPolysList.IsEmpty() )
         return;
 
     GBR_METADATA gbr_metadata;
@@ -644,8 +622,7 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( const ZONE* aZone, PCB_LAYER_ID aLayer,
         // be set as conductor
         if( aZone->GetNetname().IsEmpty() )
         {
-            gbr_metadata.SetApertureAttrib(
-                    GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
+            gbr_metadata.SetApertureAttrib( GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_NONCONDUCTOR );
         }
         else
         {
@@ -662,9 +639,9 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( const ZONE* aZone, PCB_LAYER_ID aLayer,
      * In non filled mode the outline is plotted, but not the filling items
      */
 
-    for( int idx = 0; idx < polysList.OutlineCount(); ++idx )
+    for( int idx = 0; idx < aPolysList.OutlineCount(); ++idx )
     {
-        const SHAPE_LINE_CHAIN& outline = polysList.Outline( idx );
+        const SHAPE_LINE_CHAIN& outline = aPolysList.Outline( idx );
 
         // Plot the current filled area (as region for Gerber plotter to manage attributes)
         if( GetPlotMode() == FILLED )
@@ -689,7 +666,7 @@ void BRDITEMS_PLOTTER::PlotFilledAreas( const ZONE* aZone, PCB_LAYER_ID aLayer,
 }
 
 
-void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape )
+void BRDITEMS_PLOTTER::PlotShape( const PCB_SHAPE* aShape )
 {
     if( !m_layerMask[aShape->GetLayer()] )
         return;
@@ -844,8 +821,7 @@ void BRDITEMS_PLOTTER::PlotPcbShape( const PCB_SHAPE* aShape )
 
                 poly.Append( pts[0] );  // Close polygon.
 
-                FILL_T fill_mode = aShape->IsFilled() ? FILL_T::FILLED_SHAPE
-                                                      : FILL_T::NO_FILL;
+                FILL_T fill_mode = aShape->IsFilled() ? FILL_T::FILLED_SHAPE : FILL_T::NO_FILL;
 
                 if( m_plotter->GetPlotterType() == PLOT_FORMAT::GERBER )
                 {