← Back to team overview

kicad-developers team mailing list archive

[Patch] Fix warnings in DXF plotting

 

After updating my compiler to Clang 8.0.0, it appears that some new
warnings are appearing. This patch cleans up the warnings in the DXF
plotter (they were related to the units enum and it overshadowing it some
common units). I left these separate since the DXF enum is tied to the
order in the plot window, so it can't use the main units enum.
From ba84280c1b0ac3d6c8e7f2b692897f28848b147b Mon Sep 17 00:00:00 2001
From: Ian McInerney <Ian.S.McInerney@xxxxxxxx>
Date: Sun, 30 Jun 2019 21:48:12 +0100
Subject: [PATCH] pcbnew: Clean up warnings with unit handling in the DXF
 export

---
 common/plotters/DXF_plotter.cpp |  6 +++---
 include/plotter.h               | 16 ++++++++--------
 pcbnew/dialogs/dialog_plot.cpp  |  2 +-
 pcbnew/pcb_plot_params.cpp      |  2 +-
 pcbnew/pcb_plot_params.h        | 13 +++----------
 pcbnew/plot_board_layers.cpp    |  3 ++-
 6 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/common/plotters/DXF_plotter.cpp b/common/plotters/DXF_plotter.cpp
index 9f721e661..1e8b15f95 100644
--- a/common/plotters/DXF_plotter.cpp
+++ b/common/plotters/DXF_plotter.cpp
@@ -122,18 +122,18 @@ static wxString getDXFColorName( COLOR4D aColor )
 }
 
 
-void DXF_PLOTTER::SetUnits( Units aUnit )
+void DXF_PLOTTER::SetUnits( DXF_Units aUnit )
 {
     m_plotUnits = aUnit;
 
     switch( aUnit )
     {
-    case MILIMETERS:
+    case DXF_UNIT_MILIMETERS:
         m_unitScalingFactor = 0.00254;
         m_measurementDirective = 1;
         break;
 
-    case INCHES:
+    case DXF_UNIT_INCHES:
     default:
         m_unitScalingFactor = 0.0001;
         m_measurementDirective = 0;
diff --git a/include/plotter.h b/include/plotter.h
index 7cdec2e1a..3a6f5bbf1 100644
--- a/include/plotter.h
+++ b/include/plotter.h
@@ -1259,7 +1259,7 @@ public:
         textAsLines = true;
         m_currentColor = COLOR4D::BLACK;
         m_currentLineType = 0;
-        SetUnits( DXF_PLOTTER::INCHES );
+        SetUnits( DXF_PLOTTER::DXF_UNIT_INCHES );
     }
 
     virtual PlotFormat GetPlotterType() const override
@@ -1343,11 +1343,11 @@ public:
                        void* aData = NULL ) override;
 
 
-    // Should be the same order as in the PCB_PLOT_PARAMS class
-    enum Units
+    // Must be in the same order as the drop-down list in the plot dialog inside pcbnew
+    enum DXF_Units
     {
-        INCHES = 0,
-        MILIMETERS = 1
+        DXF_UNIT_INCHES = 0,
+        DXF_UNIT_MILIMETERS = 1
     };
 
     /**
@@ -1355,14 +1355,14 @@ public:
      *
      * @param aUnit - The units to use
      */
-    void SetUnits( Units aUnit );
+    void SetUnits( DXF_Units aUnit );
 
     /**
      * The units currently enabled for plotting
      *
      * @return The currently configured units
      */
-    Units GetUnits() const
+    DXF_Units GetUnits() const
     {
         return m_plotUnits;
     }
@@ -1393,7 +1393,7 @@ protected:
     COLOR4D m_currentColor;
     int m_currentLineType;
 
-    Units        m_plotUnits;
+    DXF_Units    m_plotUnits;
     double       m_unitScalingFactor;
     unsigned int m_measurementDirective;
 };
diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp
index d4798681b..857819f09 100644
--- a/pcbnew/dialogs/dialog_plot.cpp
+++ b/pcbnew/dialogs/dialog_plot.cpp
@@ -574,7 +574,7 @@ void DIALOG_PLOT::applyPlotSettings()
     tempOptions.SetPlotMode( m_plotModeOpt->GetSelection() == 1 ? SKETCH : FILLED );
     tempOptions.SetDXFPlotPolygonMode( m_DXF_plotModeOpt->GetValue() );
     tempOptions.SetDXFPlotUnits(
-            static_cast<PCB_PLOT_PARAMS::Units>( m_DXF_plotUnits->GetSelection() ) );
+            static_cast<DXF_PLOTTER::DXF_Units>( m_DXF_plotUnits->GetSelection() ) );
     tempOptions.SetPlotViaOnMaskLayer( m_plotNoViaOnMaskOpt->GetValue() );
 
     if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() )     // Currently, only DXF supports this option
diff --git a/pcbnew/pcb_plot_params.cpp b/pcbnew/pcb_plot_params.cpp
index 077935259..9e03c76ba 100644
--- a/pcbnew/pcb_plot_params.cpp
+++ b/pcbnew/pcb_plot_params.cpp
@@ -103,7 +103,7 @@ PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
     m_plotViaOnMaskLayer         = false;
     m_plotMode                   = FILLED;
     m_DXFplotPolygonMode         = true;
-    m_DXFplotUnits               = INCHES;
+    m_DXFplotUnits               = DXF_PLOTTER::DXF_UNIT_INCHES;
     m_useAuxOrigin               = false;
     m_HPGLPenNum                 = 1;
     m_HPGLPenSpeed               = 20;        // this param is always in cm/s
diff --git a/pcbnew/pcb_plot_params.h b/pcbnew/pcb_plot_params.h
index cd92a8081..0ce529db0 100644
--- a/pcbnew/pcb_plot_params.h
+++ b/pcbnew/pcb_plot_params.h
@@ -44,13 +44,6 @@ public:
         FULL_DRILL_SHAPE  = 2
     };
 
-    // Must be in the same order as the drop-down list in the plot dialog
-    enum Units
-    {
-        INCHES = 0,
-        MILIMETERS = 1,
-    };
-
 private:
     // If true, do not plot NPTH pads
     // (mainly used to disable NPTH pads plotting on copper layers)
@@ -70,7 +63,7 @@ private:
     /**
      * DXF format: Units to use when plotting the DXF
      */
-    Units       m_DXFplotUnits;
+    DXF_PLOTTER::DXF_Units m_DXFplotUnits;
 
     /// Plot format type (chooses the driver to be used)
     PlotFormat  m_format;
@@ -208,12 +201,12 @@ public:
     void        SetDXFPlotPolygonMode( bool aFlag ) { m_DXFplotPolygonMode = aFlag; }
     bool        GetDXFPlotPolygonMode() const { return m_DXFplotPolygonMode; }
 
-    void SetDXFPlotUnits( Units aUnit )
+    void SetDXFPlotUnits( DXF_PLOTTER::DXF_Units aUnit )
     {
         m_DXFplotUnits = aUnit;
     }
 
-    Units GetDXFPlotUnits() const
+    DXF_PLOTTER::DXF_Units GetDXFPlotUnits() const
     {
         return m_DXFplotUnits;
     }
diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp
index 2dafbb520..2e7866066 100644
--- a/pcbnew/plot_board_layers.cpp
+++ b/pcbnew/plot_board_layers.cpp
@@ -1028,7 +1028,8 @@ PLOTTER* StartPlotBoard( BOARD *aBoard, PCB_PLOT_PARAMS *aPlotOpts,
     case PLOT_FORMAT_DXF:
         DXF_PLOTTER* DXF_plotter;
         DXF_plotter = new DXF_PLOTTER();
-        DXF_plotter->SetUnits( static_cast<DXF_PLOTTER::Units>( aPlotOpts->GetDXFPlotUnits() ) );
+        DXF_plotter->SetUnits(
+                static_cast<DXF_PLOTTER::DXF_Units>( aPlotOpts->GetDXFPlotUnits() ) );
 
         plotter = DXF_plotter;
         break;
-- 
2.21.0


Follow ups