diff --git a/common/plotters/SVG_plotter.cpp b/common/plotters/SVG_plotter.cpp index 2f58d9a04a..791ba98447 100644 --- a/common/plotters/SVG_plotter.cpp +++ b/common/plotters/SVG_plotter.cpp @@ -99,6 +99,11 @@ #include +// Note: +// During tests, we (JPC) found issues when the coordinates used 6 digits in mantissa +// especially for stroke-width using very small (but not null) values < 0.00001 mm +// So to avoid this king of issue, we are using 4 digits in mantissa +// The resolution (m_precision ) is 0.1 micron, that looks enougt for a SVG file /** * Translates '<' to "<", '>' to ">" and so on, according to the spec: @@ -161,11 +166,11 @@ SVG_PLOTTER::SVG_PLOTTER() m_graphics_changed = true; SetTextMode( PLOT_TEXT_MODE::STROKE ); m_fillMode = FILL_T::NO_FILL; // or FILLED_SHAPE or FILLED_WITH_BG_BODYCOLOR - m_pen_rgb_color = 0; // current color value (black) - m_brush_rgb_color = 0; // current color value (black) + m_pen_rgb_color = 0; // current color value (black) + m_brush_rgb_color = 0; // current color value (black) m_dashed = PLOT_DASH_TYPE::SOLID; - m_useInch = true; // decimils is the default - m_precision = 4; // because there where used before it was changeable + m_useInch = false; // millimeters are always the svg unit + m_precision = 4; // default: 4 digits in mantissa. } @@ -178,28 +183,24 @@ void SVG_PLOTTER::SetViewport( const VECTOR2I& aOffset, double aIusPerDecimil, m_plotScale = aScale; m_IUsPerDecimil = aIusPerDecimil; - /* Compute the paper size in IUs */ + // Compute the paper size in IUs. for historical reasons the page size is in mils m_paperSize = m_pageInfo.GetSizeMils(); m_paperSize.x *= 10.0 * aIusPerDecimil; m_paperSize.y *= 10.0 * aIusPerDecimil; - // set iuPerDeviceUnit, in 0.1mils ( 2.54um ) - // this was used before the format was changeable, so we set is as default - SetSvgCoordinatesFormat( 4, true ); + // gives now a default value to iuPerDeviceUnit (because the units of the caller is now known) + double iusPerMM = m_IUsPerDecimil / 2.54 * 1000; + m_iuPerDeviceUnit = 1 / iusPerMM; + + SetSvgCoordinatesFormat( 4 ); } -void SVG_PLOTTER::SetSvgCoordinatesFormat( unsigned aResolution, bool aUseInches ) +void SVG_PLOTTER::SetSvgCoordinatesFormat( unsigned aPrecision ) { - m_useInch = aUseInches; - m_precision = aResolution; - - // gives now a default value to iuPerDeviceUnit (because the units of the caller is now known) - double iusPerMM = m_IUsPerDecimil / 2.54 * 1000; - m_iuPerDeviceUnit = pow( 10.0, m_precision ) / ( iusPerMM ); - - if( m_useInch ) - m_iuPerDeviceUnit /= 25.4; // convert to inch + // Only number of digits in mantissa are adjustable. + // SVG units are always mm + m_precision = aPrecision; } @@ -243,16 +244,21 @@ void SVG_PLOTTER::setSVGPlotStyle( bool aIsGroup, const std::string& aExtraStyle if( pen_w < 0.0 ) // Ensure pen width validity pen_w = 0.0; - fprintf( m_outputFile, "\nstroke:#%6.6lX; stroke-width:%f; stroke-opacity:1; \n", - m_pen_rgb_color, pen_w ); + // Fix a strange issue found in Inkscape: aWidth < 100 nm create issues on degrouping objects + // So we use only 4 digits in mantissa for stroke-width. + // TODO: perhaps used only 3 or 4 digits in mantissa for all values in mm, because some + // issues were previouly reported reported when using nm as integer units + + fprintf( m_outputFile, "\nstroke:#%6.6lX; stroke-width:%.*f; stroke-opacity:1; \n", + m_pen_rgb_color, m_precision, pen_w ); fputs( "stroke-linecap:round; stroke-linejoin:round;", m_outputFile ); //set any extra attributes for non-solid lines switch( m_dashed ) { case PLOT_DASH_TYPE::DASH: - fprintf( m_outputFile, "stroke-dasharray:%f,%f;", - GetDashMarkLenIU(), GetDashGapLenIU() ); + fprintf( m_outputFile, "stroke-dasharray:%.*f,%.*f;", + m_precision, GetDashMarkLenIU(), m_precision, GetDashGapLenIU() ); break; case PLOT_DASH_TYPE::DOT: fprintf( m_outputFile, "stroke-dasharray:%f,%f;", @@ -299,15 +305,15 @@ void SVG_PLOTTER::SetCurrentLineWidth( int aWidth, void* aData ) 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" ); + // Note: aWidth == 0 is fine: used for filled shapes with no outline thickness + + wxASSERT_MSG( aWidth >= 0, "Plotter called to set negative pen width" ); if( aWidth != m_currentPenWidth ) { m_graphics_changed = true; - m_currentPenWidth = aWidth; + m_currentPenWidth = aWidth; } if( m_graphics_changed ) @@ -371,9 +377,9 @@ void SVG_PLOTTER::Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T fill, int { EDA_RECT rect( p1, VECTOR2I( p2.x - p1.x, p2.y - p1.y ) ); rect.Normalize(); - VECTOR2D org_dev = userToDeviceCoordinates( rect.GetOrigin() ); - VECTOR2D end_dev = userToDeviceCoordinates( rect.GetEnd() ); - VECTOR2D size_dev = end_dev - org_dev; + VECTOR2D org_dev = userToDeviceCoordinates( rect.GetOrigin() ); + VECTOR2D end_dev = userToDeviceCoordinates( rect.GetEnd() ); + VECTOR2D size_dev = end_dev - org_dev; // Ensure size of rect in device coordinates is > 0 // I don't know if this is a SVG issue or a Inkscape issue, but @@ -389,9 +395,9 @@ void SVG_PLOTTER::Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T fill, int if( rect_dev.GetSize().x == 0.0 || rect_dev.GetSize().y == 0.0 ) // Draw a line { fprintf( m_outputFile, - "\n", - rect_dev.GetPosition().x, rect_dev.GetPosition().y, - rect_dev.GetEnd().x, rect_dev.GetEnd().y ); + "\n", + m_precision, rect_dev.GetPosition().x, m_precision, rect_dev.GetPosition().y, + m_precision, rect_dev.GetEnd().x, m_precision, rect_dev.GetEnd().y ); } else { @@ -406,8 +412,8 @@ void SVG_PLOTTER::Rect( const VECTOR2I& p1, const VECTOR2I& p2, FILL_T fill, int void SVG_PLOTTER::Circle( const VECTOR2I& pos, int diametre, FILL_T fill, int width ) { - VECTOR2D pos_dev = userToDeviceCoordinates( pos ); - double radius = userToDeviceSize( diametre / 2.0 ); + VECTOR2D pos_dev = userToDeviceCoordinates( pos ); + double radius = userToDeviceSize( diametre / 2.0 ); setFillMode( fill ); SetCurrentLineWidth( width ); @@ -422,8 +428,8 @@ void SVG_PLOTTER::Circle( const VECTOR2I& pos, int diametre, FILL_T fill, int wi } fprintf( m_outputFile, - " \n", - pos_dev.x, pos_dev.y, radius ); + " \n", + m_precision, pos_dev.x, m_precision, pos_dev.y, m_precision, radius ); } @@ -450,8 +456,8 @@ void SVG_PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle, std::swap( startAngle, endAngle ); // Calculate start point. - VECTOR2D centre_device = userToDeviceCoordinates( aCenter ); - double radius_device = userToDeviceSize( aRadius ); + VECTOR2D centre_device = userToDeviceCoordinates( aCenter ); + double radius_device = userToDeviceSize( aRadius ); if( !m_yaxisReversed ) // Should be never the case { @@ -516,18 +522,21 @@ void SVG_PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle, setFillMode( aFill ); SetCurrentLineWidth( 0 ); - fprintf( m_outputFile, "\n", - start.x, start.y, radius_device, radius_device, + fprintf( m_outputFile, "\n", + m_precision, start.x, m_precision, start.y, + m_precision, radius_device, m_precision, radius_device, flg_arc, flg_sweep, - end.x, end.y, centre_device.x, centre_device.y ); + m_precision, end.x, m_precision, end.y, + m_precision, centre_device.x, m_precision, centre_device.y ); } setFillMode( FILL_T::NO_FILL ); SetCurrentLineWidth( aWidth ); - fprintf( m_outputFile, "\n", - start.x, start.y, radius_device, radius_device, + fprintf( m_outputFile, "\n", + m_precision, start.x, m_precision, start.y, + m_precision, radius_device, m_precision, radius_device, flg_arc, flg_sweep, - end.x, end.y ); + m_precision, end.x, m_precision, end.y ); } @@ -539,15 +548,17 @@ void SVG_PLOTTER::BezierCurve( const VECTOR2I& aStart, const VECTOR2I& aControl1 setFillMode( FILL_T::NO_FILL ); SetCurrentLineWidth( aLineThickness ); - VECTOR2D start = userToDeviceCoordinates( aStart ); - VECTOR2D ctrl1 = userToDeviceCoordinates( aControl1 ); - VECTOR2D ctrl2 = userToDeviceCoordinates( aControl2 ); - VECTOR2D end = userToDeviceCoordinates( aEnd ); + VECTOR2D start = userToDeviceCoordinates( aStart ); + VECTOR2D ctrl1 = userToDeviceCoordinates( aControl1 ); + VECTOR2D ctrl2 = userToDeviceCoordinates( aControl2 ); + VECTOR2D end = userToDeviceCoordinates( aEnd ); // Generate a cubic curve: start point and 3 other control points. - fprintf( m_outputFile, "\n", - start.x, start.y, ctrl1.x, ctrl1.y, - ctrl2.x, ctrl2.y, end.x, end.y ); + fprintf( m_outputFile, "\n", + m_precision, start.x, m_precision, start.y, + m_precision, ctrl1.x, m_precision, ctrl1.y, + m_precision, ctrl2.x, m_precision, ctrl2.y, + m_precision, end.x, m_precision, end.y ); #else PLOTTER::BezierCurve( aStart, aControl1, aControl2, aEnd, aTolerance, aLineThickness ); #endif @@ -578,12 +589,12 @@ void SVG_PLOTTER::PlotPoly( const std::vector& aCornerList, FILL_T aFi } VECTOR2D pos = userToDeviceCoordinates( aCornerList[0] ); - fprintf( m_outputFile, "d=\"M %f,%f\n", pos.x, pos.y ); + fprintf( m_outputFile, "d=\"M %.*f,%.*f\n", m_precision, pos.x, m_precision, pos.y ); for( unsigned ii = 1; ii < aCornerList.size() - 1; ii++ ) { pos = userToDeviceCoordinates( aCornerList[ii] ); - fprintf( m_outputFile, "%f,%f\n", pos.x, pos.y ); + fprintf( m_outputFile, "%.*f,%.*f\n", m_precision, pos.x, m_precision, pos.y ); } // If the corner list ends where it begins, then close the poly @@ -594,7 +605,7 @@ void SVG_PLOTTER::PlotPoly( const std::vector& aCornerList, FILL_T aFi else { pos = userToDeviceCoordinates( aCornerList.back() ); - fprintf( m_outputFile, "%f,%f\n\" /> \n", pos.x, pos.y ); + fprintf( m_outputFile, "%.*f,%.*f\n\" /> \n", m_precision, pos.x, m_precision, pos.y ); } } @@ -639,8 +650,8 @@ void SVG_PLOTTER::PlotImage( const wxImage& aImage, const VECTOR2I& aPos, double fprintf( m_outputFile, "\n" ); } - fprintf( m_outputFile, "\"\npreserveAspectRatio=\"none\" width=\"%f\" height=\"%f\" />", - userToDeviceSize( drawsize.x ), userToDeviceSize( drawsize.y ) ); + fprintf( m_outputFile, "\"\npreserveAspectRatio=\"none\" width=\"%.*f\" height=\"%.*f\" />", + m_precision, userToDeviceSize( drawsize.x ), m_precision, userToDeviceSize( drawsize.y ) ); } } @@ -672,12 +683,12 @@ void SVG_PLOTTER::PenTo( const VECTOR2I& pos, char plume ) setSVGPlotStyle(); } - fprintf( m_outputFile, "\n", - (double) m_paperSize.x / m_IUsPerDecimil * 2.54 / 10000, - (double) m_paperSize.y / m_IUsPerDecimil * 2.54 / 10000, origin.x, origin.y, - (int) ( m_paperSize.x * m_iuPerDeviceUnit ), - (int) ( m_paperSize.y * m_iuPerDeviceUnit) ); + VECTOR2D origin; // TODO set to actual value + fprintf( m_outputFile, " width=\"%.*fmm\" height=\"%.*fmm\" viewBox=\"%.*f %.*f %.*f %.*f\">\n", + m_precision, (double) m_paperSize.x / m_IUsPerDecimil * 2.54 / 1000, + m_precision, (double) m_paperSize.y / m_IUsPerDecimil * 2.54 / 1000, + m_precision, origin.x, m_precision, origin.y, + m_precision, m_paperSize.x * m_iuPerDeviceUnit, + m_precision, m_paperSize.y * m_iuPerDeviceUnit); // Write title char date_buf[250]; @@ -733,8 +745,8 @@ bool SVG_PLOTTER::StartPlot() // output the pen and brush color (RVB values in hex) and opacity double opacity = 1.0; // 0.0 (transparent to 1.0 (solid) fprintf( m_outputFile, - "\n", - - aOrient.AsDegrees(), anchor_pos_dev.x, anchor_pos_dev.y ); + "\n", + - aOrient.AsDegrees(), m_precision, anchor_pos_dev.x, m_precision, anchor_pos_dev.y ); } - fprintf( m_outputFile, "\n", - sz_dev.x, sz_dev.y, hjust, TO_UTF8( XmlEsc( aText ) ) ); + m_precision, sz_dev.x, m_precision, sz_dev.y, hjust, TO_UTF8( XmlEsc( aText ) ) ); if( !aOrient.IsZero() ) fputs( "\n", m_outputFile ); diff --git a/include/plotters/plotter.h b/include/plotters/plotter.h index af19bc1edd..03a4d43d11 100644 --- a/include/plotters/plotter.h +++ b/include/plotters/plotter.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -461,7 +461,8 @@ public: // NOP for most plotters. Only for Gerber plotter } - virtual void SetSvgCoordinatesFormat( unsigned aResolution, bool aUseInches = false ) + /// Set the number of digits for mantissa in coordinates in mm for SVG plotter + virtual void SetSvgCoordinatesFormat( unsigned aPrecision ) { // NOP for most plotters. Only for SVG plotter } diff --git a/include/plotters/plotters_pslike.h b/include/plotters/plotters_pslike.h index aaeaa7433d..ee4682914e 100644 --- a/include/plotters/plotters_pslike.h +++ b/include/plotters/plotters_pslike.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -475,17 +475,16 @@ public: virtual void PenTo( const VECTOR2I& pos, char plume ) override; /** - * Select SVG step size (number of digits needed for 1 mm or 1 inch ) - * + * Select SVG coordinate precision (number of digits needed for 1 mm ) + * (SVG plotter uses always metric unit) * Should be called only after SetViewport() is called * - * @param aResolution = number of digits in mantissa of coordinate + * @param aPrecision = number of digits in mantissa of coordinate * use a value from 3-6 * do not use value > 6 to avoid overflow in PCBNEW * do not use value > 4 to avoid overflow for other parts - * @param aUseInches = true to use inches, false to use mm (default) */ - virtual void SetSvgCoordinatesFormat( unsigned aResolution, bool aUseInches = false ) override; + virtual void SetSvgCoordinatesFormat( unsigned aPrecision ) override; /** * Calling this function allows one to define the beginning of a group diff --git a/pcbnew/dialogs/dialog_export_svg.cpp b/pcbnew/dialogs/dialog_export_svg.cpp index b14d6ca499..49e6eb2f1b 100644 --- a/pcbnew/dialogs/dialog_export_svg.cpp +++ b/pcbnew/dialogs/dialog_export_svg.cpp @@ -328,6 +328,8 @@ bool DIALOG_EXPORT_SVG::CreateSVGFile( const wxString& aFullFileName ) plot_opts.SetMirror( m_printMirror ); plot_opts.SetFormat( PLOT_FORMAT::SVG ); + // coord format: 4 digits in mantissa (units always in mm). This is a good choice. + plot_opts.SetSvgPrecision( 4 ); PAGE_INFO savedPageInfo = m_board->GetPageSettings(); VECTOR2I savedAuxOrigin = m_board->GetDesignSettings().GetAuxOrigin(); diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index d9ce106471..d5c9d417ce 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -163,7 +163,6 @@ void DIALOG_PLOT::init_Dialog() // SVG precision and units for coordinates m_svgPrecsision->SetValue( m_plotOpts.GetSvgPrecision() ); - m_svgUnits->SetSelection( m_plotOpts.GetSvgUseInch() ); // Option for excluding contents of "Edges Pcb" layer m_includeEdgeLayerOpt->SetValue( !m_plotOpts.GetExcludeEdgeLayer() ); @@ -734,7 +733,7 @@ void DIALOG_PLOT::applyPlotSettings() tempOptions.SetCreateGerberJobFile( m_generateGerberJobFile->GetValue() ); tempOptions.SetGerberPrecision( m_coordFormatCtrl->GetSelection() == 0 ? 5 : 6 ); - tempOptions.SetSvgPrecision( m_svgPrecsision->GetValue(), m_svgUnits->GetSelection() ); + tempOptions.SetSvgPrecision( m_svgPrecsision->GetValue() ); LSET selectedLayers; diff --git a/pcbnew/dialogs/dialog_plot_base.cpp b/pcbnew/dialogs/dialog_plot_base.cpp index 823fa9db45..c75fbc0603 100644 --- a/pcbnew/dialogs/dialog_plot_base.cpp +++ b/pcbnew/dialogs/dialog_plot_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) +// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -371,27 +371,12 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr m_svgOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("SVG Options") ), wxHORIZONTAL ); - svgUnitLabel = new wxStaticText( m_svgOptionsSizer->GetStaticBox(), wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, 0 ); - svgUnitLabel->Wrap( -1 ); - m_svgOptionsSizer->Add( svgUnitLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - wxString m_svgUnitsChoices[] = { _("Millimeter"), _("Inch") }; - int m_svgUnitsNChoices = sizeof( m_svgUnitsChoices ) / sizeof( wxString ); - m_svgUnits = new wxChoice( m_svgOptionsSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_svgUnitsNChoices, m_svgUnitsChoices, 0 ); - m_svgUnits->SetSelection( 0 ); - m_svgUnits->SetToolTip( _("The units that are used for a SVG user units.\nChoose Millimeter when you are not sure.") ); - - m_svgOptionsSizer->Add( m_svgUnits, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - - m_svgOptionsSizer->Add( 30, 0, 0, 0, 5 ); - svgPrecisionLabel = new wxStaticText( m_svgOptionsSizer->GetStaticBox(), wxID_ANY, _("Precision:"), wxDefaultPosition, wxDefaultSize, 0 ); svgPrecisionLabel->Wrap( -1 ); m_svgOptionsSizer->Add( svgPrecisionLabel, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_svgPrecsision = new wxSpinCtrl( m_svgOptionsSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 3, 6, 6 ); - m_svgPrecsision->SetToolTip( _("How big a SVG user unit is.\nThe number defines how many digits are exported that are below 1 mm or 1 inch.\nUser unit is 10^- mm or 10^- inch.\nChoose 6 if you are not sure.") ); + m_svgPrecsision = new wxSpinCtrl( m_svgOptionsSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 3, 6, 4 ); + m_svgPrecsision->SetToolTip( _("This number defines how many digits are exported that are below 1 mm.\nUser unit is 10^- mm\nChoose 4 if you are not sure.") ); m_svgOptionsSizer->Add( m_svgPrecsision, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); diff --git a/pcbnew/dialogs/dialog_plot_base.fbp b/pcbnew/dialogs/dialog_plot_base.fbp index 4408bb7231..556dd285cf 100644 --- a/pcbnew/dialogs/dialog_plot_base.fbp +++ b/pcbnew/dialogs/dialog_plot_base.fbp @@ -3593,141 +3593,6 @@ wxHORIZONTAL 1 protected - - 5 - wxALL|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Units: - 0 - - 0 - - - 0 - - 1 - svgUnitLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - 5 - wxALL|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Millimeter" "Inch" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_svgUnits - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - ; ; forward_declare - 0 - The units that are used for a SVG user units. Choose Millimeter when you are not sure. - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 5 - - 0 - - 0 - protected - 30 - - 5 wxALL|wxALIGN_CENTER_VERTICAL @@ -3821,7 +3686,7 @@ 0 0 wxID_ANY - 6 + 4 6 0 @@ -3844,7 +3709,7 @@ wxSP_ARROW_KEYS ; ; forward_declare 0 - How big a SVG user unit is. The number defines how many digits are exported that are below 1 mm or 1 inch. User unit is 10^-<N> mm or 10^-<N> inch. Choose 6 if you are not sure. + This number defines how many digits are exported that are below 1 mm. User unit is 10^-<N> mm Choose 4 if you are not sure. diff --git a/pcbnew/dialogs/dialog_plot_base.h b/pcbnew/dialogs/dialog_plot_base.h index 17f76d4e52..1b68ea2399 100644 --- a/pcbnew/dialogs/dialog_plot_base.h +++ b/pcbnew/dialogs/dialog_plot_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) +// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -15,6 +15,7 @@ class WX_HTML_REPORT_PANEL; #include "dialog_shim.h" #include #include +#include #include #include #include @@ -118,8 +119,6 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM wxStaticText* DXF_exportUnitsLabel; wxChoice* m_DXF_plotUnits; wxStaticBoxSizer* m_svgOptionsSizer; - wxStaticText* svgUnitLabel; - wxChoice* m_svgUnits; wxStaticText* svgPrecisionLabel; wxSpinCtrl* m_svgPrecsision; WX_HTML_REPORT_PANEL* m_messagesPanel; diff --git a/pcbnew/pcb_plot_params.cpp b/pcbnew/pcb_plot_params.cpp index 618e46eed2..9d63959000 100644 --- a/pcbnew/pcb_plot_params.cpp +++ b/pcbnew/pcb_plot_params.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -43,7 +43,7 @@ #define SVG_PRECISION_MIN 3U #define SVG_PRECISION_MAX 6U -#define SVG_PRECISION_DEFAULT 6 +#define SVG_PRECISION_DEFAULT 4 // default trailing digits in Gerber coordinates, when units are mm @@ -101,7 +101,6 @@ PCB_PLOT_PARAMS::PCB_PLOT_PARAMS() // we used 0.1mils for SVG step before, but nm precision is more accurate, so we use nm m_svgPrecision = SVG_PRECISION_DEFAULT; - m_svgUseInch = false; m_excludeEdgeLayer = true; m_plotFrameRef = false; m_plotViaOnMaskLayer = false; @@ -158,9 +157,8 @@ void PCB_PLOT_PARAMS::SetGerberPrecision( int aPrecision ) } -void PCB_PLOT_PARAMS::SetSvgPrecision( unsigned aPrecision, bool aUseInch ) +void PCB_PLOT_PARAMS::SetSvgPrecision( unsigned aPrecision ) { - m_svgUseInch = aUseInch; m_svgPrecision = Clamp( SVG_PRECISION_MIN, aPrecision, SVG_PRECISION_MAX ); } @@ -179,7 +177,7 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter, aFormatter->Print( aNestLevel+1, "(layerselection 0x%s)\n", m_layerSelection.FmtHex().c_str() ); - aFormatter->Print( aNestLevel+1, "(disableapertmacros %s)\n", + aFormatter->Print( aNestLevel+1, "(disableapertmacros %s)\n", printBool( m_gerberDisableApertMacros ) ); aFormatter->Print( aNestLevel+1, "(usegerberextensions %s)\n", @@ -203,7 +201,6 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter, aFormatter->Print( aNestLevel+1, "(dashed_line_gap_ratio %f)\n", GetDashedLineGapRatio() ); // SVG options - aFormatter->Print( aNestLevel+1, "(svguseinch %s)\n", printBool( m_svgUseInch ) ); aFormatter->Print( aNestLevel+1, "(svgprecision %d)\n", m_svgPrecision ); aFormatter->Print( aNestLevel+1, "(excludeedgelayer %s)\n", printBool( m_excludeEdgeLayer ) ); @@ -240,7 +237,7 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter, aFormatter->Print( aNestLevel+1, "(mirror %s)\n", printBool( m_mirror ) ); aFormatter->Print( aNestLevel+1, "(drillshape %d)\n", m_drillMarks ); aFormatter->Print( aNestLevel+1, "(scaleselection %d)\n", m_scaleSelection ); - aFormatter->Print( aNestLevel+1, "(outputdirectory \"%s\")", + aFormatter->Print( aNestLevel+1, "(outputdirectory \"%s\")", (const char*) m_outputDirectory.utf8_str() ); aFormatter->Print( 0, "\n" ); aFormatter->Print( aNestLevel, ")\n" ); @@ -303,9 +300,6 @@ bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams ) const if( m_svgPrecision != aPcbPlotParams.m_svgPrecision ) return false; - if( m_svgUseInch != aPcbPlotParams.m_svgUseInch ) - return false; - if( m_useAuxOrigin != aPcbPlotParams.m_useAuxOrigin ) return false; @@ -484,7 +478,7 @@ void PCB_PLOT_PARAMS_PARSER::Parse( PCB_PLOT_PARAMS* aPcbPlotParams ) break; case T_svguseinch: - aPcbPlotParams->m_svgUseInch = parseBool(); + parseBool(); // Unused. For compatibility break; case T_psa4output: diff --git a/pcbnew/pcb_plot_params.h b/pcbnew/pcb_plot_params.h index 345b083e1c..b4572e55ea 100644 --- a/pcbnew/pcb_plot_params.h +++ b/pcbnew/pcb_plot_params.h @@ -3,7 +3,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -149,9 +149,8 @@ public: void SetGerberPrecision( int aPrecision ); int GetGerberPrecision() const { return m_gerberPrecision; } - void SetSvgPrecision( unsigned aPrecision, bool aUseInch ); + void SetSvgPrecision( unsigned aPrecision ); unsigned GetSvgPrecision() const { return m_svgPrecision; } - bool GetSvgUseInch() const { return m_svgUseInch; } /** * Default precision of coordinates in Gerber files. @@ -282,10 +281,6 @@ private: /// 6 is the internal resolution of Pcbnew unsigned m_svgPrecision; - /// units for SVG plot - /// false for metric, true for inch/mils - bool m_svgUseInch; - /// Plot gerbers using auxiliary (drill) origin instead of absolute coordinates bool m_useAuxOrigin; diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 22c71aa235..8a0d2fdc42 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -1080,7 +1080,7 @@ static void initializePlotter( PLOTTER* aPlotter, const BOARD* aBoard, aPlotter->SetGerberCoordinatesFormat( aPlotOpts->GetGerberPrecision() ); // Has meaning only for SVG plotter. Must be called only after SetViewport - aPlotter->SetSvgCoordinatesFormat( aPlotOpts->GetSvgPrecision(), aPlotOpts->GetSvgUseInch() ); + aPlotter->SetSvgCoordinatesFormat( aPlotOpts->GetSvgPrecision() ); aPlotter->SetCreator( wxT( "PCBNEW" ) ); aPlotter->SetColorMode( false ); // default is plot in Black and White.