Add ability to set SVG plot units and precision

ADDED: Ability to set SVG to metric or imperial units
and made it possible to change the size of a step
This commit is contained in:
Johannes Pfister 2020-04-20 22:02:03 +00:00 committed by Ian McInerney
parent a23747c640
commit e5042a46ba
9 changed files with 469 additions and 30 deletions

View File

@ -105,7 +105,6 @@
#include <cstdint>
#include <wx/mstream.h>
/**
* Function XmlEsc
* translates '<' to "&lt;", '>' to "&gt;" and so on, according to the spec:
@ -171,6 +170,8 @@ SVG_PLOTTER::SVG_PLOTTER()
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 changable
}
@ -182,11 +183,28 @@ void SVG_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
plotOffset = aOffset;
plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = 1.0 / aIusPerDecimil;
/* Compute the paper size in IUs */
paperSize = pageInfo.GetSizeMils();
paperSize.x *= 10.0 * aIusPerDecimil;
paperSize.y *= 10.0 * aIusPerDecimil;
// set iuPerDeviceUnit, in 0.1mils ( 2.54um )
// this was used before the format was changable, so we set is as default
SetSvgCoordinatesFormat( 4, true );
}
void SVG_PLOTTER::SetSvgCoordinatesFormat( unsigned aResolution, bool aUseInches )
{
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;
iuPerDeviceUnit = pow( 10.0, m_precision ) / ( iusPerMM );
if( m_useInch )
iuPerDeviceUnit /= 25.4; // convert to inch
}
@ -702,13 +720,10 @@ bool SVG_PLOTTER::StartPlot()
// Write viewport pos and size
wxPoint origin; // TODO set to actual value
fprintf( outputFile,
" width=\"%gcm\" height=\"%gcm\" viewBox=\"%d %d %d %d\">\n",
fprintf( outputFile, " width=\"%gcm\" height=\"%gcm\" viewBox=\"%d %d %d %d\">\n",
(double) paperSize.x / m_IUsPerDecimil * 2.54 / 10000,
(double) paperSize.y / m_IUsPerDecimil * 2.54 / 10000,
origin.x, origin.y,
(int) ( paperSize.x / m_IUsPerDecimil ),
(int) ( paperSize.y / m_IUsPerDecimil) );
(double) paperSize.y / m_IUsPerDecimil * 2.54 / 10000, origin.x, origin.y,
(int) ( paperSize.x * iuPerDeviceUnit ), (int) ( paperSize.y * iuPerDeviceUnit) );
// Write title
char date_buf[250];

View File

@ -452,6 +452,11 @@ public:
// NOP for most plotters. Only for Gerber plotter
}
virtual void SetSvgCoordinatesFormat( unsigned aResolution, bool aUseInches = false )
{
// NOP for most plotters. Only for SVG plotter
}
/**
* calling this function allows one to define the beginning of a group
* of drawing items, for instance in SVG or Gerber format.
@ -962,6 +967,18 @@ public:
virtual void PenTo( const wxPoint& pos, char plume ) override;
/**
* Function SetSvgCoordinatesFormat
* selection of SVG step size (number of digits needed for 1 mm or 1 inch )
* @param aResolution = 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)
*
* Should be called only after SetViewport() is called
*/
virtual void SetSvgCoordinatesFormat( unsigned aResolution, bool aUseInches = false ) override;
/**
* calling this function allows one to define the beginning of a group
@ -991,18 +1008,25 @@ public:
void* aData = NULL ) override;
protected:
FILL_T m_fillMode; // true if the current contour
// rect, arc, circle, polygon must be filled
long m_pen_rgb_color; // current rgb color value: each color has
// a value 0 ... 255, and the 3 colors are
// grouped in a 3x8 bits value
// (written in hex to svg files)
long m_brush_rgb_color; // same as m_pen_rgb_color, used to fill
// some contours.
bool m_graphics_changed; // true if a pen/brush parameter is modified
// color, pen size, fil mode ...
// the new SVG stype must be output on file
PLOT_DASH_TYPE m_dashed; // plot line style
FILL_T m_fillMode; // true if the current contour
// rect, arc, circle, polygon must be filled
long m_pen_rgb_color; // current rgb color value: each color has
// a value 0 ... 255, and the 3 colors are
// grouped in a 3x8 bits value
// (written in hex to svg files)
long m_brush_rgb_color; // same as m_pen_rgb_color, used to fill
// some contours.
bool m_graphics_changed; // true if a pen/brush parameter is modified
// color, pen size, fil mode ...
// the new SVG stype must be output on file
PLOT_DASH_TYPE m_dashed; // plot line style
bool m_useInch; // is 0 if the step size is 10**-n*mm
// is 1 if the step size is 10**-n*inch
// Where n is given from m_precision
unsigned m_precision; // How fine the step size is
// Use 3-6 (3 means um precision, 6 nm precision) in pcbnew
// 3-4 in other moduls (avoid values >4 to avoid overflow)
// see also comment for m_useInch.
/**
* function emitSetRGBColor()

View File

@ -155,6 +155,10 @@ void DIALOG_PLOT::init_Dialog()
// Gerber precision for coordinates
m_coordFormatCtrl->SetSelection( m_plotOpts.GetGerberPrecision() == 5 ? 0 : 1 );
// 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_excludeEdgeLayerOpt->SetValue( m_plotOpts.GetExcludeEdgeLayer() );
@ -396,8 +400,9 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
switch( getPlotFormat() )
{
case PLOT_FORMAT::PDF:
case PLOT_FORMAT::SVG:
m_PlotOptionsSizer->Show( m_svgOptionsSizer );
case PLOT_FORMAT::PDF:
m_drillShapeOpt->Enable( true );
m_plotModeOpt->Enable( false );
setPlotModeChoiceSelection( FILLED );
@ -442,6 +447,7 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
m_PlotOptionsSizer->Show( m_PSOptionsSizer );
m_PlotOptionsSizer->Hide( m_SizerDXF_options );
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
break;
case PLOT_FORMAT::GERBER:
@ -469,6 +475,7 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
m_PlotOptionsSizer->Hide( m_SizerDXF_options );
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
break;
case PLOT_FORMAT::HPGL:
@ -492,6 +499,7 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
m_PlotOptionsSizer->Show( m_HPGLOptionsSizer );
m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
m_PlotOptionsSizer->Hide( m_SizerDXF_options );
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
break;
case PLOT_FORMAT::DXF:
@ -518,6 +526,7 @@ void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
m_PlotOptionsSizer->Show( m_SizerDXF_options );
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
OnChangeDXFPlotMode( event );
break;
@ -693,6 +702,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() );
LSET selectedLayers;
for( unsigned i = 0; i < m_layerList.size(); i++ )

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version Feb 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -336,8 +336,56 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr
m_PlotOptionsSizer->Add( m_SizerDXF_options, 0, wxEXPAND|wxALL, 5 );
m_svgOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("SVG Options") ), wxHORIZONTAL );
bmiddleSizer->Add( m_PlotOptionsSizer, 0, 0, 5 );
wxGridBagSizer* gbSizer21;
gbSizer21 = new wxGridBagSizer( 3, 0 );
gbSizer21->SetFlexibleDirection( wxHORIZONTAL );
gbSizer21->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
wxGridSizer* gSizer1;
gSizer1 = new wxGridSizer( 0, 2, 0, 0 );
gbSizer21->Add( gSizer1, wxGBPosition( 0, 3 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 );
gbSizer21->AddGrowableCol( 2 );
m_svgOptionsSizer->Add( gbSizer21, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxGridSizer* gSizer2;
gSizer2 = new wxGridSizer( 0, 4, 0, 0 );
svgUnitLabel = new wxStaticText( m_svgOptionsSizer->GetStaticBox(), wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, 0 );
svgUnitLabel->Wrap( -1 );
gSizer2->Add( svgUnitLabel, 0, wxALL, 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. Choose Millimeter when you are not sure.") );
gSizer2->Add( m_svgUnits, 0, wxALL, 5 );
svgPrecisionLabel = new wxStaticText( m_svgOptionsSizer->GetStaticBox(), wxID_ANY, _("Precision:"), wxDefaultPosition, wxDefaultSize, 0 );
svgPrecisionLabel->Wrap( -1 );
gSizer2->Add( svgPrecisionLabel, 0, wxALL, 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. 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.") );
gSizer2->Add( m_svgPrecsision, 0, wxALL, 5 );
m_svgOptionsSizer->Add( gSizer2, 1, wxEXPAND, 5 );
m_PlotOptionsSizer->Add( m_svgOptionsSizer, 1, wxEXPAND, 5 );
bmiddleSizer->Add( m_PlotOptionsSizer, 0, 0, 6 );
m_MainSizer->Add( bmiddleSizer, 0, wxEXPAND|wxALL, 5 );

View File

@ -493,7 +493,7 @@
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="border">6</property>
<property name="flag"></property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
@ -513,11 +513,11 @@
<property name="orient">wxVERTICAL</property>
<property name="parent">1</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxGridBagSizer" expanded="0">
<object class="wxGridBagSizer" expanded="1">
<property name="empty_cell_size"></property>
<property name="flexible_direction">wxHORIZONTAL</property>
<property name="growablecols">0,2</property>
@ -1870,11 +1870,11 @@
<property name="orient">wxHORIZONTAL</property>
<property name="parent">1</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxGridBagSizer" expanded="1">
<object class="wxGridBagSizer" expanded="0">
<property name="empty_cell_size"></property>
<property name="flexible_direction">wxHORIZONTAL</property>
<property name="growablecols">2</property>
@ -2360,7 +2360,7 @@
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxStaticBoxSizer" expanded="1">
<object class="wxStaticBoxSizer" expanded="0">
<property name="id">wxID_ANY</property>
<property name="label">HPGL Options</property>
<property name="minimum_size"></property>
@ -3397,6 +3397,316 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">SVG Options</property>
<property name="minimum_size"></property>
<property name="name">m_svgOptionsSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="parent">1</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxGridBagSizer" expanded="1">
<property name="empty_cell_size"></property>
<property name="flexible_direction">wxHORIZONTAL</property>
<property name="growablecols">2</property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">gbSizer21</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="vgap">3</property>
<object class="gbsizeritem" expanded="1">
<property name="border">5</property>
<property name="colspan">1</property>
<property name="column">3</property>
<property name="flag">wxEXPAND</property>
<property name="row">0</property>
<property name="rowspan">1</property>
<object class="wxGridSizer" expanded="1">
<property name="cols">2</property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">gSizer1</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">0</property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxGridSizer" expanded="1">
<property name="cols">4</property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">gSizer2</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Units:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">svgUnitLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Millimeter&quot; &quot;Inch&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_svgUnits</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">The units that are used for a SVG user units. Choose Millimeter when you are not sure.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Precision:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">svgPrecisionLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxSpinCtrl" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="initial">6</property>
<property name="max">6</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min">3</property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_svgPrecsision</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxSP_ARROW_KEYS</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">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^-&lt;N&gt; mm or 10^-&lt;N&gt; inch. Choose 6 if you are not sure.</property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version Feb 18 2020)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -31,6 +31,7 @@ class WX_HTML_REPORT_PANEL;
#include <wx/statbox.h>
#include <wx/checkbox.h>
#include <wx/gbsizer.h>
#include <wx/spinctrl.h>
#include <wx/panel.h>
#include <wx/menu.h>
#include <wx/dialog.h>
@ -112,6 +113,11 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM
wxCheckBox* m_DXF_plotTextStrokeFontOpt;
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;
wxBoxSizer* m_sizerButtons;
wxButton* m_buttonDRC;

View File

@ -101,6 +101,9 @@ PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
m_includeGerberNetlistInfo = true;
m_createGerberJobFile = true;
m_gerberPrecision = gbrDefaultPrecision;
// we used 0.1mils for SVG step before, but nm precision is more accurate, so we use nm
m_svgPrecision = 6;
m_svgUseInch = false;
m_excludeEdgeLayer = true;
m_lineWidth = g_DrawDefaultLineThickness;
m_plotFrameRef = false;
@ -161,6 +164,11 @@ void PCB_PLOT_PARAMS::SetGerberPrecision( int aPrecision )
gbrDefaultPrecision;
}
void PCB_PLOT_PARAMS::SetSvgPrecision( unsigned aPrecision, bool aUseInch )
{
m_svgUseInch = aUseInch;
m_svgPrecision = Clamp( 3U, aPrecision, 6U );
}
// PLEASE NOTE: only plot dialog options are processed
void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
@ -280,6 +288,10 @@ bool PCB_PLOT_PARAMS::IsSameAs( const PCB_PLOT_PARAMS &aPcbPlotParams, bool aCom
return false;
if( m_DXFplotUnits != aPcbPlotParams.m_DXFplotUnits )
return false;
if( m_svgPrecision != aPcbPlotParams.m_svgPrecision )
return false;
if( m_svgUseInch != aPcbPlotParams.m_svgUseInch )
return false;
}
if( m_useAuxOrigin != aPcbPlotParams.m_useAuxOrigin )
return false;

View File

@ -123,6 +123,14 @@ private:
/// 5 is the minimal value for professional boards.
int m_gerberPrecision;
/// precision of coordinates in SVG files: accepted 3 - 6
/// 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 absolue coordinates
bool m_useAuxOrigin;
@ -298,6 +306,10 @@ public:
void SetGerberPrecision( int aPrecision );
int GetGerberPrecision() const { return m_gerberPrecision; }
void SetSvgPrecision( unsigned aPrecision, bool aUseInch );
unsigned GetSvgPrecision() const { return m_svgPrecision; }
bool GetSvgUseInch() const { return m_svgUseInch; }
/** Default precision of coordinates in Gerber files.
* when units are in mm (7 in inches, but Pcbnew uses mm).
* 6 is the internal resolution of Pcbnew, so the default is 6

View File

@ -1113,6 +1113,8 @@ static void initializePlotter( PLOTTER *aPlotter, BOARD * aBoard,
aPlotter->SetViewport( offset, IU_PER_MILS/10, compound_scale, aPlotOpts->GetMirror() );
// Has meaning only for gerber plotter. Must be called only after SetViewport
aPlotter->SetGerberCoordinatesFormat( aPlotOpts->GetGerberPrecision() );
// Has meaning only for SVG plotter. Must be called only after SetViewport
aPlotter->SetSvgCoordinatesFormat( aPlotOpts->GetSvgPrecision(), aPlotOpts->GetSvgUseInch() );
aPlotter->SetCreator( wxT( "PCBNEW" ) );
aPlotter->SetColorMode( false ); // default is plot in Black and White.