From d59053b7755f467e34224ce2d7b520281f7688e0 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Thu, 19 Nov 2020 20:07:08 -0500 Subject: [PATCH] Fix dxf import making all circles filled Filled objects in dxf is actually not handled at all, they are implemented as "hatched" objects --- pcbnew/import_gfx/dxf_import_plugin.cpp | 2 +- pcbnew/import_gfx/graphics_importer.h | 2 +- pcbnew/import_gfx/graphics_importer_buffer.cpp | 4 ++-- pcbnew/import_gfx/graphics_importer_buffer.h | 10 ++++++---- pcbnew/import_gfx/graphics_importer_pcbnew.cpp | 4 ++-- pcbnew/import_gfx/graphics_importer_pcbnew.h | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pcbnew/import_gfx/dxf_import_plugin.cpp b/pcbnew/import_gfx/dxf_import_plugin.cpp index a1371a525f..274cc87cda 100644 --- a/pcbnew/import_gfx/dxf_import_plugin.cpp +++ b/pcbnew/import_gfx/dxf_import_plugin.cpp @@ -347,7 +347,7 @@ void DXF_IMPORT_PLUGIN::addCircle( const DL_CircleData& aData ) VECTOR2D center( mapX( aData.cx ), mapY( aData.cy ) ); double lineWidth = mapWidth( attributes.getWidth() ); - m_internalImporter.AddCircle( center, mapDim( aData.radius ), lineWidth ); + m_internalImporter.AddCircle( center, mapDim( aData.radius ), lineWidth, false ); VECTOR2D radiusDelta( mapDim( aData.radius ), mapDim( aData.radius ) ); diff --git a/pcbnew/import_gfx/graphics_importer.h b/pcbnew/import_gfx/graphics_importer.h index 308a69b3ad..5fe53041c1 100644 --- a/pcbnew/import_gfx/graphics_importer.h +++ b/pcbnew/import_gfx/graphics_importer.h @@ -204,7 +204,7 @@ public: * @param aRadius is the circle radius expressed in mm. * @param aWidth is the segment thickness in mm. Use -1 for default line thickness */ - virtual void AddCircle( const VECTOR2D& aCenter, double aRadius, double aWidth ) = 0; + virtual void AddCircle( const VECTOR2D& aCenter, double aRadius, double aWidth, bool aFilled ) = 0; /** * Create an object representing an arc. diff --git a/pcbnew/import_gfx/graphics_importer_buffer.cpp b/pcbnew/import_gfx/graphics_importer_buffer.cpp index 45dc6839c6..503e7f6f76 100644 --- a/pcbnew/import_gfx/graphics_importer_buffer.cpp +++ b/pcbnew/import_gfx/graphics_importer_buffer.cpp @@ -39,9 +39,9 @@ void GRAPHICS_IMPORTER_BUFFER::AddLine( const VECTOR2D& aStart, const VECTOR2D& } -void GRAPHICS_IMPORTER_BUFFER::AddCircle( const VECTOR2D& aCenter, double aRadius, double aWidth ) +void GRAPHICS_IMPORTER_BUFFER::AddCircle( const VECTOR2D& aCenter, double aRadius, double aWidth, bool aFilled ) { - m_shapes.push_back( make_shape< IMPORTED_CIRCLE >( aCenter, aRadius, aWidth ) ); + m_shapes.push_back( make_shape( aCenter, aRadius, aWidth, aFilled ) ); } diff --git a/pcbnew/import_gfx/graphics_importer_buffer.h b/pcbnew/import_gfx/graphics_importer_buffer.h index cbe57688d1..13e353c3c5 100644 --- a/pcbnew/import_gfx/graphics_importer_buffer.h +++ b/pcbnew/import_gfx/graphics_importer_buffer.h @@ -63,22 +63,24 @@ private: class IMPORTED_CIRCLE : public IMPORTED_SHAPE { public: - IMPORTED_CIRCLE( const VECTOR2D& aCenter, double aRadius, double aWidth ) : + IMPORTED_CIRCLE( const VECTOR2D& aCenter, double aRadius, double aWidth, bool aFilled ) : m_center( aCenter ), m_radius( aRadius ), - m_width( aWidth ) + m_width( aWidth ), + m_filled( aFilled ) { } void ImportTo( GRAPHICS_IMPORTER& aImporter ) const override { - aImporter.AddCircle( m_center, m_radius, m_width ); + aImporter.AddCircle( m_center, m_radius, m_width, m_filled ); } private: const VECTOR2D m_center; double m_radius; double m_width; + bool m_filled; }; @@ -193,7 +195,7 @@ class GRAPHICS_IMPORTER_BUFFER : public GRAPHICS_IMPORTER public: void AddLine( const VECTOR2D& aStart, const VECTOR2D& aEnd, double aWidth ) override; - void AddCircle( const VECTOR2D& aCenter, double aRadius, double aWidth ) override; + void AddCircle( const VECTOR2D& aCenter, double aRadius, double aWidth, bool aFilled ) override; void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle, double aWidth ) override; diff --git a/pcbnew/import_gfx/graphics_importer_pcbnew.cpp b/pcbnew/import_gfx/graphics_importer_pcbnew.cpp index b9a10683c3..796e89bb07 100644 --- a/pcbnew/import_gfx/graphics_importer_pcbnew.cpp +++ b/pcbnew/import_gfx/graphics_importer_pcbnew.cpp @@ -75,11 +75,11 @@ void GRAPHICS_IMPORTER_PCBNEW::AddLine( const VECTOR2D& aOrigin, const VECTOR2D& } -void GRAPHICS_IMPORTER_PCBNEW::AddCircle( const VECTOR2D& aCenter, double aRadius, double aWidth ) +void GRAPHICS_IMPORTER_PCBNEW::AddCircle( const VECTOR2D& aCenter, double aRadius, double aWidth, bool aFilled ) { std::unique_ptr circle( createDrawing() ); circle->SetShape( S_CIRCLE ); - circle->SetFilled( GetLayer() != Edge_Cuts ); + circle->SetFilled( aFilled ); circle->SetLayer( GetLayer() ); circle->SetWidth( MapLineWidth( aWidth ) ); circle->SetCenter( MapCoordinate( aCenter ) ); diff --git a/pcbnew/import_gfx/graphics_importer_pcbnew.h b/pcbnew/import_gfx/graphics_importer_pcbnew.h index 08a47dd90d..d7cc20835a 100644 --- a/pcbnew/import_gfx/graphics_importer_pcbnew.h +++ b/pcbnew/import_gfx/graphics_importer_pcbnew.h @@ -60,7 +60,7 @@ public: void AddLine( const VECTOR2D& aOrigin, const VECTOR2D& aEnd, double aWidth ) override; - void AddCircle( const VECTOR2D& aOrigin, double aRadius, double aWidth ) override; + void AddCircle( const VECTOR2D& aOrigin, double aRadius, double aWidth, bool aFilled ) override; void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle, double aWidth ) override;