From f347118ce3dc02048169d5c4bf6c71569e5d5092 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 8 Sep 2020 20:18:50 +0100 Subject: [PATCH] Add a min pin width advanced config for plotting. Fixes https://gitlab.com/kicad/code/kicad/issues/5546 --- common/advanced_config.cpp | 24 ++++++++++++++++++------ common/render_settings.cpp | 1 + eeschema/lib_arc.cpp | 2 +- eeschema/lib_bezier.cpp | 2 +- eeschema/lib_circle.cpp | 2 +- eeschema/lib_field.cpp | 2 +- eeschema/lib_rectangle.cpp | 2 +- eeschema/lib_text.cpp | 5 +++-- eeschema/sch_bus_entry.cpp | 2 ++ eeschema/sch_field.cpp | 8 +++++--- eeschema/sch_line.cpp | 4 ++-- eeschema/sch_no_connect.cpp | 2 +- eeschema/sch_painter.cpp | 3 +++ eeschema/sch_sheet.cpp | 2 +- eeschema/sch_text.cpp | 1 + include/advanced_config.h | 15 +++++++++++---- include/render_settings.h | 5 +++++ pcbnew/board_design_settings.cpp | 2 +- pcbnew/zone_filler.cpp | 2 +- 19 files changed, 60 insertions(+), 26 deletions(-) diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index 119a7f6718..53c5b110fb 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -76,8 +76,8 @@ static const wxChar DRCEpsilon[] = wxT( "DRCEpsilon" ); /** * Used to calculate the actual hole size from the finish hole size. - * IPC-6012 says 15-18um; Cadence says at least 0.020 for a Class 2 board and at least 0.025 - * for Class 3. + * IPC-6012 says 0.015-0.018mm; Cadence says at least 0.020mm for a Class 2 board and at least + * 0.025mm for Class 3. */ static const wxChar HoleWallThickness[] = wxT( "HoleWallPlatingThickness" ); @@ -132,6 +132,12 @@ static const wxChar StrokeTriangulation[] = wxT( "StrokeTriangulation" ); */ static const wxChar PluginAltiumSch[] = wxT( "PluginAltiumSch" ); +/** + * Absolute minimum pen width to send to the plotter. PDF seems happy enough with 0.0212mm + * (which equates to 1px @ 1200dpi). + */ +static const wxChar MinPlotPenWidth[] = wxT( "MinPlotPenWidth" ); + } // namespace KEYS @@ -217,13 +223,16 @@ ADVANCED_CFG::ADVANCED_CFG() m_DrawTriangulationOutlines = false; m_PluginAltiumSch = false; - m_extraClearance = 0.0005; + m_ExtraClearance = 0.0005; m_DRCEpsilon = 0.0005; // 500nm is small enough not to materially violate // any constraints. - m_holeWallThickness = 0.020; // IPC-6012 says 15-18um; Cadence says at least + m_HoleWallThickness = 0.020; // IPC-6012 says 15-18um; Cadence says at least // 0.020 for a Class 2 board and at least 0.025 // for Class 3. + + m_MinPlotPenWidth = 0.0212; // 1 pixel at 1200dpi. + loadFromConfigFile(); } @@ -265,13 +274,13 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) &m_realTimeConnectivity, true ) ); configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::ExtraFillMargin, - &m_extraClearance, 0.0005, 0.0, 1.0 ) ); + &m_ExtraClearance, 0.0005, 0.0, 1.0 ) ); configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::DRCEpsilon, &m_DRCEpsilon, 0.0005, 0.0, 1.0 ) ); configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::HoleWallThickness, - &m_holeWallThickness, 0.020, 0.0, 1.0 ) ); + &m_HoleWallThickness, 0.020, 0.0, 1.0 ) ); configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::CoroutineStackSize, &m_coroutineStackSize, AC_STACK::default_stack, @@ -295,6 +304,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::PluginAltiumSch, &m_PluginAltiumSch, false ) ); + configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::MinPlotPenWidth, + &m_MinPlotPenWidth, 0.0212, 0.0, 1.0 ) ); + wxConfigLoadSetups( &aCfg, configParams ); for( PARAM_CFG* param : configParams ) diff --git a/common/render_settings.cpp b/common/render_settings.cpp index 23b01a01b7..838c2674f1 100644 --- a/common/render_settings.cpp +++ b/common/render_settings.cpp @@ -39,6 +39,7 @@ RENDER_SETTINGS::RENDER_SETTINGS() : m_outlineWidth = 1; m_worksheetLineWidth = 100000; m_defaultPenWidth = 0; + m_minPenWidth = 0; m_showPageLimits = false; } diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 4b0707a141..057c7dc735 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -275,7 +275,7 @@ void LIB_ARC::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, if( !already_filled || pen_size > 0 ) { - pen_size = std::max( pen_size, aPlotter->RenderSettings()->GetDefaultPenWidth() ); + pen_size = std::max( pen_size, aPlotter->RenderSettings()->GetMinPenWidth() ); aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE ) ); aPlotter->Arc( pos, -t2, -t1, m_Radius, already_filled ? NO_FILL : m_Fill, pen_size ); diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 3f8b1a8658..3095b8326b 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -187,7 +187,7 @@ void LIB_BEZIER::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, if( !already_filled || pen_size > 0 ) { - pen_size = std::max( pen_size, aPlotter->RenderSettings()->GetDefaultPenWidth() ); + pen_size = std::max( pen_size, aPlotter->RenderSettings()->GetMinPenWidth() ); aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE ) ); aPlotter->PlotPoly( cornerList, already_filled ? NO_FILL : m_Fill, pen_size ); diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index 3b780b826d..8bf2d3cb96 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -178,7 +178,7 @@ void LIB_CIRCLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, if( !already_filled || pen_size > 0 ) { - pen_size = std::max( pen_size, aPlotter->RenderSettings()->GetDefaultPenWidth() ); + pen_size = std::max( pen_size, aPlotter->RenderSettings()->GetMinPenWidth() ); aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE ) ); aPlotter->Circle( pos, GetRadius() * 2, already_filled ? NO_FILL : m_Fill, pen_size ); diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 61d02dc785..0164f04dc7 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -288,7 +288,7 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, else color = COLOR4D::BLACK; - int penWidth = std::max( GetPenWidth(),aPlotter->RenderSettings()->GetDefaultPenWidth() ); + int penWidth = std::max( GetPenWidth(),aPlotter->RenderSettings()->GetMinPenWidth() ); aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify, penWidth, IsItalic(), IsBold() ); diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 9861a16825..f63f675543 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -144,7 +144,7 @@ void LIB_RECTANGLE::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, if( !already_filled || pen_size > 0 ) { - pen_size = std::max( pen_size, aPlotter->RenderSettings()->GetDefaultPenWidth() ); + pen_size = std::max( pen_size, aPlotter->RenderSettings()->GetMinPenWidth() ); aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE ) ); aPlotter->Rect( pos, end, already_filled ? NO_FILL : m_Fill, pen_size ); diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index e20260055e..11be053365 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -287,8 +287,9 @@ void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, else color = COLOR4D::BLACK; - int penWidth = std::max( GetEffectiveTextPenWidth(), - plotter->RenderSettings()->GetDefaultPenWidth() ); + RENDER_SETTINGS* settings = plotter->RenderSettings(); + + int penWidth = std::max( GetEffectiveTextPenWidth(), settings->GetMinPenWidth() ); plotter->Text( pos, color, GetText(), t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, penWidth, IsItalic(), diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 5cc748e5be..3965a501e3 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -395,6 +395,8 @@ void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter ) settings->GetLayerColor( m_Layer ) : GetStrokeColor(); int penWidth = ( GetPenWidth() == 0 ) ? settings->GetDefaultPenWidth() : GetPenWidth(); + penWidth = std::max( penWidth, settings->GetMinPenWidth() ); + aPlotter->SetCurrentLineWidth( penWidth ); aPlotter->SetColor( color ); aPlotter->SetDash( GetStrokeStyle() ); diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 68b332b5f0..1ef9c18817 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -526,9 +526,11 @@ bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) void SCH_FIELD::Plot( PLOTTER* aPlotter ) { - COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( GetLayer() ); - int penWidth = GetEffectiveTextPenWidth( - aPlotter->RenderSettings()->GetDefaultPenWidth() ); + RENDER_SETTINGS* settings = aPlotter->RenderSettings(); + COLOR4D color = settings->GetLayerColor( GetLayer() ); + int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() ); + + penWidth = std::max( penWidth, settings->GetMinPenWidth() ); if( !IsVisible() ) return; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 1f501316bb..770a479d28 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -749,11 +749,11 @@ void SCH_LINE::Plot( PLOTTER* aPlotter ) default: penWidth = GetPenWidth(); break; } - penWidth = std::max( penWidth, aPlotter->RenderSettings()->GetDefaultPenWidth() ); - if( m_stroke.GetWidth() != 0 ) penWidth = m_stroke.GetWidth(); + penWidth = std::max( penWidth, settings->GetMinPenWidth() ); + aPlotter->SetCurrentLineWidth( penWidth ); aPlotter->SetDash( GetEffectiveLineStyle() ); diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index b0839f4b68..48cfdd59ec 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -177,7 +177,7 @@ void SCH_NO_CONNECT::Plot( PLOTTER* aPlotter ) int delta = GetSize() / 2; int pX = m_pos.x; int pY = m_pos.y; - int penWidth = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetDefaultPenWidth() ); + int penWidth = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() ); aPlotter->SetCurrentLineWidth( penWidth ); aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_NOCONNECT ) ); diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index b3ab06d41c..cc8b9abae7 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include "sch_painter.h" namespace KIGFX @@ -83,6 +84,8 @@ SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() : m_JunctionSize( DEFAULT_JUNCTION_DIAM * IU_PER_MILS ) { SetDefaultPenWidth( DEFAULT_LINE_THICKNESS * IU_PER_MILS ); + + m_minPenWidth = ADVANCED_CFG::GetCfg().m_MinPlotPenWidth * IU_PER_MM; } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index b11716862d..8e43b7723f 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -966,7 +966,7 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter ) aPlotter->SetColor( borderColor ); - int penWidth = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetDefaultPenWidth() ); + int penWidth = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() ); aPlotter->SetCurrentLineWidth( penWidth ); aPlotter->MoveTo( m_pos ); diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 6f6d084734..491f7ccdf0 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -581,6 +581,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter ) COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( GetLayer() ); int penWidth = GetEffectiveTextPenWidth( aPlotter->RenderSettings()->GetDefaultPenWidth() ); + penWidth = std::max( penWidth, aPlotter->RenderSettings()->GetMinPenWidth() ); aPlotter->SetCurrentLineWidth( penWidth ); if( IsMultilineAllowed() ) diff --git a/include/advanced_config.h b/include/advanced_config.h index 2525bea812..7e03308d78 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -84,20 +84,21 @@ public: /** * Extra fill clearance for zone fills. Note that for zone tests this is essentially - * additive with m_DRCEpsilon. + * additive with m_DRCEpsilon. Units are mm. */ - double m_extraClearance; + double m_ExtraClearance; /** * Epsilon for DRC tests. Note that for zone tests this is essentially additive with - * m_extraClearance. + * m_extraClearance. Units are mm. */ double m_DRCEpsilon; /** * Hole wall plating thickness. Used to determine actual hole size from finish hole size. + * Units are mm. */ - double m_holeWallThickness; + double m_HoleWallThickness; /** * Do real-time connectivity @@ -131,6 +132,12 @@ public: */ bool m_PluginAltiumSch; + /** + * Sets an absolute minimum pen width for plotting. Some formats (PDF, for example) don't + * like ultra-thin lines. Units are mm. + */ + double m_MinPlotPenWidth; + private: ADVANCED_CFG(); diff --git a/include/render_settings.h b/include/render_settings.h index 3ed3ac553c..7007c7dfdd 100644 --- a/include/render_settings.h +++ b/include/render_settings.h @@ -164,6 +164,9 @@ public: int GetDefaultPenWidth() const { return m_defaultPenWidth; } void SetDefaultPenWidth( int aWidth ) { m_defaultPenWidth = aWidth; } + int GetMinPenWidth() const { return m_minPenWidth; } + void SetMinPenWidth( int aWidth ) { m_minPenWidth = aWidth; } + bool GetShowPageLimits() const { return m_showPageLimits; } void SetShowPageLimits( bool aDraw ) { m_showPageLimits = aDraw; } @@ -268,6 +271,8 @@ protected: float m_worksheetLineWidth; // Line width used when drawing worksheet int m_defaultPenWidth; + int m_minPenWidth; // Some clients (such as PDF) don't like ultra-thin + // lines. This sets an absolute minimum. bool m_showPageLimits; wxDC* m_printDC; // This can go away once we have Cairo-based printing. diff --git a/pcbnew/board_design_settings.cpp b/pcbnew/board_design_settings.cpp index 334a6851f5..fd6bded85a 100644 --- a/pcbnew/board_design_settings.cpp +++ b/pcbnew/board_design_settings.cpp @@ -969,7 +969,7 @@ int BOARD_DESIGN_SETTINGS::GetDRCEpsilon() const int BOARD_DESIGN_SETTINGS::GetHolePlatingThickness() const { - return Millimeter2iu( ADVANCED_CFG::GetCfg().m_holeWallThickness ); + return Millimeter2iu( ADVANCED_CFG::GetCfg().m_HoleWallThickness ); } diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index 944f0ab602..82eaee28bb 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -601,7 +601,7 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA // requested clearance due to many approximations in calculations, like arc to segment // approx, rounding issues, etc. // 1 micron is a good value - int extra_margin = Millimeter2iu( ADVANCED_CFG::GetCfg().m_extraClearance ); + int extra_margin = Millimeter2iu( ADVANCED_CFG::GetCfg().m_ExtraClearance ); BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings(); int zone_clearance = aZone->GetLocalClearance();