From 92f1ee556f0cffe4672257591fdf0239d55da8cc Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 17 Oct 2022 17:49:28 +0100 Subject: [PATCH] Don't fill drawing sheet rects with transparent fill. It might make sense to do that with board and/or schematic items for hit-testing or something, but it definitely doesn't make any sense for the drawing sheet border. Also, when reading in items with a transparent fill, treat them as unfilled (otherwise we get filled with layer colour in at least PCBNew). --- common/plotters/common_plot_functions.cpp | 8 ++++++-- pcbnew/import_gfx/svg_import_plugin.cpp | 12 ++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/common/plotters/common_plot_functions.cpp b/common/plotters/common_plot_functions.cpp index 7c76c80420..91cd056285 100644 --- a/common/plotters/common_plot_functions.cpp +++ b/common/plotters/common_plot_functions.cpp @@ -112,8 +112,12 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL case WSG_RECT_T: { DS_DRAW_ITEM_RECT* rect = (DS_DRAW_ITEM_RECT*) item; - int penWidth = std::max( rect->GetPenWidth(), defaultPenWidth ); - plotter->Rect( rect->GetStart(), rect->GetEnd(), FILL_T::NO_FILL, penWidth ); + plotter->SetCurrentLineWidth( std::max( rect->GetPenWidth(), defaultPenWidth ) ); + plotter->MoveTo( rect->GetStart() ); + plotter->LineTo( VECTOR2I( rect->GetEnd().x, rect->GetStart().y ) ); + plotter->LineTo( VECTOR2I( rect->GetEnd().x, rect->GetEnd().y ) ); + plotter->LineTo( VECTOR2I( rect->GetStart().x, rect->GetEnd().y ) ); + plotter->FinishTo( rect->GetStart() ); } break; diff --git a/pcbnew/import_gfx/svg_import_plugin.cpp b/pcbnew/import_gfx/svg_import_plugin.cpp index 65b175234d..903aaea5d0 100644 --- a/pcbnew/import_gfx/svg_import_plugin.cpp +++ b/pcbnew/import_gfx/svg_import_plugin.cpp @@ -70,9 +70,16 @@ bool SVG_IMPORT_PLUGIN::Load( const wxString& aFileName ) bool SVG_IMPORT_PLUGIN::Import() { + auto alpha = + []( int color ) + { + return color >> 24; + }; + for( NSVGshape* shape = m_parsedImage->shapes; shape != nullptr; shape = shape->next ) { double lineWidth = shape->strokeWidth; + bool filled = shape->fill.type == NSVG_PAINT_COLOR && alpha( shape->fill.color ) > 0; GRAPHICS_IMPORTER::POLY_FILL_RULE rule = GRAPHICS_IMPORTER::PF_NONZERO; @@ -87,8 +94,9 @@ bool SVG_IMPORT_PLUGIN::Import() for( NSVGpath* path = shape->paths; path != nullptr; path = path->next ) { - DrawPath( path->pts, path->npts, path->closed || rule == GRAPHICS_IMPORTER::PF_EVEN_ODD, - shape->fill.type == NSVG_PAINT_COLOR, lineWidth ); + bool closed = path->closed || rule == GRAPHICS_IMPORTER::PF_EVEN_ODD; + + DrawPath( path->pts, path->npts, closed, filled, lineWidth ); } }