mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-02 00:26:45 +00:00
Restore the page size mode behavior
Fixes https://gitlab.com/kicad/code/kicad/-/issues/20014
This commit is contained in:
parent
28ce3c2e7d
commit
b6743653f3
@ -30,14 +30,15 @@ NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_SVG::GEN_MODE,
|
||||
|
||||
JOB_EXPORT_PCB_SVG::JOB_EXPORT_PCB_SVG() :
|
||||
JOB_EXPORT_PCB_PLOT( JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::SVG, "svg", false ),
|
||||
m_pageSizeMode( 0 ),
|
||||
m_fitPageToBoard( false ),
|
||||
m_precision( 4 ),
|
||||
m_genMode( GEN_MODE::SINGLE ) // TODO change to MULTI for V10
|
||||
{
|
||||
m_plotDrawingSheet = true;
|
||||
|
||||
m_params.emplace_back( new JOB_PARAM<wxString>( "color_theme", &m_colorTheme, m_colorTheme ) );
|
||||
m_params.emplace_back( new JOB_PARAM<int>( "page_size_mode", &m_pageSizeMode, m_pageSizeMode ) );
|
||||
m_params.emplace_back(
|
||||
new JOB_PARAM<bool>( "fit_page_to_board", &m_fitPageToBoard, m_fitPageToBoard ) );
|
||||
m_params.emplace_back( new JOB_PARAM<unsigned int>( "precision", &m_precision, m_precision ) );
|
||||
m_params.emplace_back( new JOB_PARAM<GEN_MODE>( "gen_mode", &m_genMode, m_genMode ) );
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
wxString GetDefaultDescription() const override;
|
||||
wxString GetSettingsDialogTitle() const override;
|
||||
|
||||
int m_pageSizeMode;
|
||||
bool m_fitPageToBoard;
|
||||
unsigned int m_precision;
|
||||
|
||||
enum class GEN_MODE
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#define ARG_EXCLUDE_DRAWING_SHEET "--exclude-drawing-sheet"
|
||||
#define ARG_PAGE_SIZE "--page-size-mode"
|
||||
#define ARG_FIT_PAGE_TO_BOARD "--fit-page-to-board"
|
||||
#define ARG_MODE_SINGLE "--mode-single"
|
||||
#define ARG_MODE_MULTI "--mode-multi"
|
||||
|
||||
@ -87,6 +88,10 @@ CLI::PCB_EXPORT_SVG_COMMAND::PCB_EXPORT_SVG_COMMAND() : PCB_EXPORT_BASE_COMMAND(
|
||||
.default_value( 0 )
|
||||
.metavar( "MODE" );
|
||||
|
||||
m_argParser.add_argument( ARG_FIT_PAGE_TO_BOARD )
|
||||
.help( UTF8STDSTR( _( "Fit the page to the board" ) ) )
|
||||
.flag();
|
||||
|
||||
m_argParser.add_argument( ARG_EXCLUDE_DRAWING_SHEET )
|
||||
.help( UTF8STDSTR( _( "No drawing sheet" ) ) )
|
||||
.flag();
|
||||
@ -135,7 +140,6 @@ int CLI::PCB_EXPORT_SVG_COMMAND::doPerform( KIWAY& aKiway )
|
||||
|
||||
svgJob->m_mirror = m_argParser.get<bool>( ARG_MIRROR );
|
||||
svgJob->m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE );
|
||||
svgJob->m_pageSizeMode = m_argParser.get<int>( ARG_PAGE_SIZE );
|
||||
svgJob->m_negative = m_argParser.get<bool>( ARG_NEGATIVE );
|
||||
svgJob->m_sketchPadsOnFabLayers = m_argParser.get<bool>( ARG_SKETCH_PADS_ON_FAB_LAYERS );
|
||||
svgJob->m_hideDNPFPsOnFabLayers = m_argParser.get<bool>( ARG_HIDE_DNP_FPS_ON_FAB_LAYERS );
|
||||
@ -149,6 +153,25 @@ int CLI::PCB_EXPORT_SVG_COMMAND::doPerform( KIWAY& aKiway )
|
||||
if( m_argParser.get<bool>( DEPRECATED_ARG_PLOT_INVISIBLE_TEXT ) )
|
||||
wxFprintf( stdout, DEPRECATED_ARD_PLOT_INVISIBLE_TEXT_WARNING );
|
||||
|
||||
svgJob->m_fitPageToBoard = m_argParser.get<bool>( ARG_FIT_PAGE_TO_BOARD );
|
||||
|
||||
// legacy compat, should eliminate this arg eventually
|
||||
int legacyPageSizeMode = m_argParser.get<int>( ARG_PAGE_SIZE );
|
||||
|
||||
if( legacyPageSizeMode == 0 )
|
||||
{
|
||||
svgJob->m_plotDrawingSheet = true;
|
||||
}
|
||||
else if( legacyPageSizeMode == 1 )
|
||||
{
|
||||
svgJob->m_plotDrawingSheet = false;
|
||||
}
|
||||
else if( legacyPageSizeMode == 2 )
|
||||
{
|
||||
svgJob->m_fitPageToBoard = true;
|
||||
svgJob->m_plotDrawingSheet = false;
|
||||
}
|
||||
|
||||
svgJob->m_filename = m_argInput;
|
||||
svgJob->SetConfiguredOutputPath( m_argOutput );
|
||||
svgJob->m_colorTheme = From_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
|
||||
|
@ -360,6 +360,7 @@ void DIALOG_PLOT::init_Dialog()
|
||||
|
||||
// SVG precision and units for coordinates
|
||||
m_svgPrecsision->SetValue( m_plotOpts.GetSvgPrecision() );
|
||||
m_SVG_fitPageToBoard->SetValue( m_plotOpts.GetSvgFitPagetoBoard() );
|
||||
|
||||
m_sketchPadsOnFabLayers->SetValue( m_plotOpts.GetSketchPadsOnFabLayers() );
|
||||
m_plotPadNumbers->SetValue( m_plotOpts.GetPlotPadNumbers() );
|
||||
@ -446,6 +447,7 @@ void DIALOG_PLOT::transferPlotParamsToJob()
|
||||
JOB_EXPORT_PCB_SVG* svgJob = static_cast<JOB_EXPORT_PCB_SVG*>( m_job );
|
||||
svgJob->m_precision = m_plotOpts.GetSvgPrecision();
|
||||
svgJob->m_genMode = JOB_EXPORT_PCB_SVG::GEN_MODE::MULTI;
|
||||
svgJob->m_fitPageToBoard = m_plotOpts.GetSvgFitPagetoBoard();
|
||||
}
|
||||
|
||||
if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::DXF )
|
||||
@ -1157,6 +1159,7 @@ void DIALOG_PLOT::applyPlotSettings()
|
||||
|
||||
tempOptions.SetGerberPrecision( m_coordFormatCtrl->GetSelection() == 0 ? 5 : 6 );
|
||||
tempOptions.SetSvgPrecision( m_svgPrecsision->GetValue() );
|
||||
tempOptions.SetSvgFitPageToBoard( m_SVG_fitPageToBoard->GetValue() );
|
||||
|
||||
LSET selectedLayers;
|
||||
|
||||
|
@ -383,6 +383,9 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr
|
||||
m_SVGColorChoice->SetSelection( 0 );
|
||||
gbSizer3->Add( m_SVGColorChoice, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_SVG_fitPageToBoard = new wxCheckBox( m_svgOptionsSizer->GetStaticBox(), wxID_ANY, _("Fit page to board"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
gbSizer3->Add( m_SVG_fitPageToBoard, wxGBPosition( 2, 0 ), wxGBSpan( 2, 1 ), wxALL, 5 );
|
||||
|
||||
|
||||
m_svgOptionsSizer->Add( gbSizer3, 1, wxEXPAND|wxBOTTOM, 5 );
|
||||
|
||||
|
@ -3929,6 +3929,74 @@
|
||||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="gbsizeritem" expanded="true">
|
||||
<property name="border">5</property>
|
||||
<property name="colspan">1</property>
|
||||
<property name="column">0</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="row">2</property>
|
||||
<property name="rowspan">2</property>
|
||||
<object class="wxCheckBox" expanded="true">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer">0</property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position">0</property>
|
||||
<property name="aui_row">0</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="checked">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="drag_accept_files">0</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">Fit page to board</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_SVG_fitPageToBoard</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="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>
|
||||
</object>
|
||||
</object>
|
||||
|
@ -116,6 +116,7 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM
|
||||
wxSpinCtrl* m_svgPrecsision;
|
||||
wxStaticText* m_staticText18;
|
||||
wxChoice* m_SVGColorChoice;
|
||||
wxCheckBox* m_SVG_fitPageToBoard;
|
||||
wxStaticBoxSizer* m_PDFOptionsSizer;
|
||||
wxStaticText* m_staticText19;
|
||||
wxChoice* m_PDFColorChoice;
|
||||
|
@ -102,6 +102,7 @@ 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_svgFitPageToBoard = false;
|
||||
m_plotDrawingSheet = false;
|
||||
m_plotMode = FILLED;
|
||||
m_DXFPolygonMode = true;
|
||||
|
@ -153,6 +153,9 @@ public:
|
||||
void SetSvgPrecision( unsigned aPrecision );
|
||||
unsigned GetSvgPrecision() const { return m_svgPrecision; }
|
||||
|
||||
void SetSvgFitPageToBoard( int aSvgFitPageToBoard ) { m_svgFitPageToBoard = aSvgFitPageToBoard; }
|
||||
bool GetSvgFitPagetoBoard() const { return m_svgFitPageToBoard; }
|
||||
|
||||
void SetBlackAndWhite( bool blackAndWhite ) { m_blackAndWhite = blackAndWhite; }
|
||||
unsigned GetBlackAndWhite() const { return m_blackAndWhite; }
|
||||
|
||||
@ -260,6 +263,7 @@ private:
|
||||
|
||||
/// Precision of coordinates in SVG: accepted 3 - 6; 6 is the internal resolution of Pcbnew
|
||||
unsigned m_svgPrecision;
|
||||
bool m_svgFitPageToBoard;
|
||||
|
||||
bool m_useAuxOrigin; ///< Plot gerbers using auxiliary (drill) origin instead
|
||||
///< of absolute coordinates
|
||||
|
@ -68,6 +68,24 @@ bool PCB_PLOTTER::Plot( const wxString& aOutputPath,
|
||||
return false;
|
||||
}
|
||||
|
||||
PAGE_INFO existingPageInfo = m_board->GetPageSettings();
|
||||
VECTOR2I existingAuxOrigin = m_board->GetDesignSettings().GetAuxOrigin();
|
||||
|
||||
if( m_plotOpts.GetFormat() == PLOT_FORMAT::SVG && m_plotOpts.GetSvgFitPagetoBoard() ) // Page is board boundary size
|
||||
{
|
||||
BOX2I bbox = m_board->ComputeBoundingBox( false );
|
||||
PAGE_INFO currPageInfo = m_board->GetPageSettings();
|
||||
|
||||
currPageInfo.SetWidthMils( bbox.GetWidth() / pcbIUScale.IU_PER_MILS );
|
||||
currPageInfo.SetHeightMils( bbox.GetHeight() / pcbIUScale.IU_PER_MILS );
|
||||
|
||||
m_board->SetPageSettings( currPageInfo );
|
||||
m_plotOpts.SetUseAuxOrigin( true );
|
||||
|
||||
VECTOR2I origin = bbox.GetOrigin();
|
||||
m_board->GetDesignSettings().SetAuxOrigin( origin );
|
||||
}
|
||||
|
||||
// To reuse logic, in single plot mode, we want to kick any extra layers from the main list to commonLayers
|
||||
LSEQ layersToPlot;
|
||||
LSEQ commonLayers;
|
||||
@ -263,6 +281,13 @@ bool PCB_PLOTTER::Plot( const wxString& aOutputPath,
|
||||
|
||||
m_reporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
|
||||
|
||||
if( m_plotOpts.GetFormat() == PLOT_FORMAT::SVG && m_plotOpts.GetSvgFitPagetoBoard() )
|
||||
{
|
||||
// restore the original page and aux origin
|
||||
m_board->SetPageSettings( existingPageInfo );
|
||||
m_board->GetDesignSettings().SetAuxOrigin( existingAuxOrigin );
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@ -343,6 +368,7 @@ void PCB_PLOTTER::PlotJobToPlotOpts( PCB_PLOT_PARAMS& aOpts, JOB_EXPORT_PCB_PLOT
|
||||
{
|
||||
JOB_EXPORT_PCB_SVG* svgJob = static_cast<JOB_EXPORT_PCB_SVG*>( aJob );
|
||||
aOpts.SetSvgPrecision( svgJob->m_precision );
|
||||
aOpts.SetSvgFitPageToBoard( svgJob->m_fitPageToBoard );
|
||||
}
|
||||
|
||||
if( aJob->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::DXF )
|
||||
|
Loading…
Reference in New Issue
Block a user