From 37df47a3e79262c2fe4cb3b86afefbfab1c23aee Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 4 Oct 2023 15:47:28 +0200 Subject: [PATCH] genDrillMapFile: reduce the pen width used to plot oval shapes (better look) --- common/plotters/PS_plotter.cpp | 2 +- pcbnew/exporters/gen_drill_report_files.cpp | 37 +++++++++++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/common/plotters/PS_plotter.cpp b/common/plotters/PS_plotter.cpp index d0ba6cf1f5..0b3e1d88a1 100644 --- a/common/plotters/PS_plotter.cpp +++ b/common/plotters/PS_plotter.cpp @@ -114,7 +114,7 @@ void PSLIKE_PLOTTER::FlashPadOval( const VECTOR2I& aPadPos, const VECTOR2I& aSiz if( aTraceMode == FILLED ) ThickSegment( a + aPadPos, b + aPadPos, size.x, aTraceMode, nullptr ); else - sketchOval( aPadPos, size, orient, -1 ); + sketchOval( aPadPos, size, orient, USE_DEFAULT_LINE_WIDTH ); } diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index ce907cd579..19e8481c1f 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -55,9 +55,31 @@ inline double diameter_in_mm( double ius ) // return a pen size to plot markers and having a readable shape -inline int getMarkerBestPenSize( int aMarkerDiameter ) +// clamped to be >= MIN_SIZE_MM to avoid too small line width +static int getMarkerBestPenSize( int aMarkerDiameter ) { - return aMarkerDiameter / 10; + int bestsize = aMarkerDiameter / 10; + + const double MIN_SIZE_MM = 0.1; + bestsize = std::max( bestsize, pcbIUScale.mmToIU( MIN_SIZE_MM ) ); + + return bestsize; +} + + +// return a pen size to plot outlines for oval holes +inline int getSketchOvalBestPenSize() +{ + const double SKETCH_LINE_WIDTH_MM = 0.1; + return pcbIUScale.mmToIU( SKETCH_LINE_WIDTH_MM ); +} + + +// return a default pen size to plot items with no specific line thickness +inline int getDefaultPenSize() +{ + const double DEFAULT_LINE_WIDTH_MM = 0.2; + return pcbIUScale.mmToIU( DEFAULT_LINE_WIDTH_MM ); } @@ -171,7 +193,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_ plotter->SetColorMode( false ); KIGFX::PCB_RENDER_SETTINGS renderSettings; - renderSettings.SetDefaultPenWidth( pcbIUScale.mmToIU( 0.2 ) ); + renderSettings.SetDefaultPenWidth( getDefaultPenSize() ); plotter->SetRenderSettings( &renderSettings ); @@ -476,7 +498,16 @@ bool GENDRILL_WRITER_BASE::plotDrillMarks( PLOTTER* aPlotter ) aPlotter->Marker( pos, hole.m_Hole_Diameter, hole.m_Tool_Reference - 1 ); if( hole.m_Hole_Shape != 0 ) + { + aPlotter->SetCurrentLineWidth( getSketchOvalBestPenSize() ); + // FlashPadOval uses also the render settings default pen size, so we need + // to initialize it: + KIGFX::RENDER_SETTINGS* renderSettings = aPlotter->RenderSettings(); + int curr_default_pensize = renderSettings->GetDefaultPenWidth(); + renderSettings->SetDefaultPenWidth( getSketchOvalBestPenSize() ); aPlotter->FlashPadOval( pos, hole.m_Hole_Size, hole.m_Hole_Orient, SKETCH, nullptr ); + renderSettings->SetDefaultPenWidth( curr_default_pensize ); + } } aPlotter->SetCurrentLineWidth( -1 );