From bcea2019d4eecf1fd5158d7558a165a1283a99cb Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 13 May 2020 17:44:21 +0100 Subject: [PATCH] Unify support for line width magic cookies. They were added for the Gerber plotter but once there there's the expectation by others that they'll work. --- common/gr_text.cpp | 1 + common/plotters/GERBER_plotter.cpp | 4 ++++ common/plotters/PDF_plotter.cpp | 8 +++++++- common/plotters/PS_plotter.cpp | 9 +++++++++ common/plotters/SVG_plotter.cpp | 9 +++++++++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/common/gr_text.cpp b/common/gr_text.cpp index 440f87328c..843caebd80 100644 --- a/common/gr_text.cpp +++ b/common/gr_text.cpp @@ -233,6 +233,7 @@ void PLOTTER::Text( const wxPoint& aPos, void* aData ) { SetColor( aColor ); + SetCurrentLineWidth( aPenWidth ); GRText( NULL, aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aPenWidth, aItalic, aBold, nullptr, nullptr, this ); diff --git a/common/plotters/GERBER_plotter.cpp b/common/plotters/GERBER_plotter.cpp index e7f9bc3c31..43b309b84a 100644 --- a/common/plotters/GERBER_plotter.cpp +++ b/common/plotters/GERBER_plotter.cpp @@ -286,6 +286,10 @@ void GERBER_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData ) { if( aWidth == DO_NOT_SET_LINE_WIDTH ) return; + else if( aWidth == USE_DEFAULT_LINE_WIDTH ) + aWidth = m_renderSettings->GetDefaultPenWidth(); + + wxASSERT_MSG( aWidth >= 0, "Plotter called to set negative pen width" ); GBR_METADATA* gbr_metadata = static_cast( aData ); int aperture_attribute = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0; diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index 955b38d18b..e91e724bb7 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -91,9 +91,15 @@ void PDF_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData ) { wxASSERT( workFile ); - if( aWidth == 0 ) + if( aWidth == DO_NOT_SET_LINE_WIDTH ) + return; + else if( aWidth == USE_DEFAULT_LINE_WIDTH ) + aWidth = m_renderSettings->GetDefaultPenWidth(); + else if( aWidth == 0 ) aWidth = 1; + wxASSERT_MSG( aWidth > 0, "Plotter called to set negative pen width" ); + if( aWidth != currentPenWidth ) fprintf( workFile, "%g w\n", userToDeviceSize( aWidth ) ); diff --git a/common/plotters/PS_plotter.cpp b/common/plotters/PS_plotter.cpp index 6187d32c40..963631306d 100644 --- a/common/plotters/PS_plotter.cpp +++ b/common/plotters/PS_plotter.cpp @@ -521,6 +521,15 @@ void PS_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData ) { wxASSERT( outputFile ); + if( aWidth == DO_NOT_SET_LINE_WIDTH ) + return; + else if( aWidth == USE_DEFAULT_LINE_WIDTH ) + aWidth = m_renderSettings->GetDefaultPenWidth(); + else if( aWidth == 0 ) + aWidth = 1; + + wxASSERT_MSG( aWidth > 0, "Plotter called to set negative pen width" ); + if( aWidth != GetCurrentLineWidth() ) fprintf( outputFile, "%g setlinewidth\n", userToDeviceSize( aWidth ) ); diff --git a/common/plotters/SVG_plotter.cpp b/common/plotters/SVG_plotter.cpp index 83f8e1850d..cbde35a4c2 100644 --- a/common/plotters/SVG_plotter.cpp +++ b/common/plotters/SVG_plotter.cpp @@ -303,6 +303,15 @@ void SVG_PLOTTER::setSVGPlotStyle( bool aIsGroup, const std::string& aExtraStyle */ void SVG_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData ) { + if( aWidth == DO_NOT_SET_LINE_WIDTH ) + return; + else if( aWidth == USE_DEFAULT_LINE_WIDTH ) + aWidth = m_renderSettings->GetDefaultPenWidth(); + else if( aWidth == 0 ) + aWidth = 1; + + wxASSERT_MSG( aWidth > 0, "Plotter called to set negative pen width" ); + if( aWidth != currentPenWidth ) { m_graphics_changed = true;