Honour LAYER, SHEETNAME and SHEETPATH variable overrides on CLI.
Also allows the LAYER variable to work automatically if you're plotting/exporting a single layer. Fixes https://gitlab.com/kicad/code/kicad/-/issues/17680
This commit is contained in:
parent
c659b46d5e
commit
3e0c598500
|
@ -1204,6 +1204,11 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
PCB_LAYER_ID layer = *seq;
|
PCB_LAYER_ID layer = *seq;
|
||||||
|
wxString layerName = board->GetLayerName( layer );
|
||||||
|
//@todo allow controlling the sheet name and path that will be displayed in the title block
|
||||||
|
// Leave blank for now
|
||||||
|
wxString sheetName;
|
||||||
|
wxString sheetPath;
|
||||||
|
|
||||||
// All copper layers that are disabled are actually selected
|
// All copper layers that are disabled are actually selected
|
||||||
// This is due to wonkyness in automatically selecting copper layers
|
// This is due to wonkyness in automatically selecting copper layers
|
||||||
|
@ -1222,16 +1227,14 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event )
|
||||||
if( m_plotOpts.GetFormat() == PLOT_FORMAT::GERBER && m_useGerberExtensions->GetValue() )
|
if( m_plotOpts.GetFormat() == PLOT_FORMAT::GERBER && m_useGerberExtensions->GetValue() )
|
||||||
file_ext = GetGerberProtelExtension( layer );
|
file_ext = GetGerberProtelExtension( layer );
|
||||||
|
|
||||||
BuildPlotFileName( &fn, outputDir.GetPath(), board->GetLayerName( layer ), file_ext );
|
BuildPlotFileName( &fn, outputDir.GetPath(), layerName, file_ext );
|
||||||
wxString fullname = fn.GetFullName();
|
wxString fullname = fn.GetFullName();
|
||||||
jobfile_writer.AddGbrFile( layer, fullname );
|
jobfile_writer.AddGbrFile( layer, fullname );
|
||||||
|
|
||||||
LOCALE_IO toggle;
|
LOCALE_IO toggle;
|
||||||
|
|
||||||
//@todo allow controlling the sheet name and path that will be displayed in the title block
|
PLOTTER* plotter = StartPlotBoard( board, &m_plotOpts, layer, layerName, fn.GetFullPath(),
|
||||||
// Leave blank for now
|
sheetName, sheetPath );
|
||||||
PLOTTER* plotter = StartPlotBoard( board, &m_plotOpts, layer, fn.GetFullPath(),
|
|
||||||
wxEmptyString, wxEmptyString );
|
|
||||||
|
|
||||||
// Print diags in messages box:
|
// Print diags in messages box:
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
|
|
@ -87,12 +87,22 @@ bool EXPORT_SVG::Plot( BOARD* aBoard, const PCB_PLOT_SVG_OPTIONS& aSvgPlotOption
|
||||||
|
|
||||||
plot_opts.SetColorSettings( mgr.GetColorSettings( aSvgPlotOptions.m_colorTheme ) );
|
plot_opts.SetColorSettings( mgr.GetColorSettings( aSvgPlotOptions.m_colorTheme ) );
|
||||||
|
|
||||||
LOCALE_IO toggle;
|
LOCALE_IO toggle;
|
||||||
|
PCB_LAYER_ID layer = UNDEFINED_LAYER;
|
||||||
|
wxString layerName;
|
||||||
//@todo allow controlling the sheet name and path that will be displayed in the title block
|
//@todo allow controlling the sheet name and path that will be displayed in the title block
|
||||||
// Leave blank for now
|
// Leave blank for now
|
||||||
SVG_PLOTTER* plotter = (SVG_PLOTTER*) StartPlotBoard( aBoard, &plot_opts, UNDEFINED_LAYER, outputFile,
|
wxString sheetName;
|
||||||
wxEmptyString, wxEmptyString );
|
wxString sheetPath;
|
||||||
|
|
||||||
|
if( aSvgPlotOptions.m_printMaskLayer.size() == 1 )
|
||||||
|
{
|
||||||
|
layer = aSvgPlotOptions.m_printMaskLayer.front();
|
||||||
|
layerName = aBoard->GetLayerName( layer );
|
||||||
|
}
|
||||||
|
|
||||||
|
SVG_PLOTTER* plotter = (SVG_PLOTTER*) StartPlotBoard( aBoard, &plot_opts, layer, layerName,
|
||||||
|
outputFile, sheetName, sheetPath );
|
||||||
|
|
||||||
if( plotter )
|
if( plotter )
|
||||||
{
|
{
|
||||||
|
|
|
@ -494,8 +494,29 @@ int PCBNEW_JOBS_HANDLER::JobExportDxf( JOB* aJob )
|
||||||
plotOpts.SetPlotReference( aDxfJob->m_plotRefDes );
|
plotOpts.SetPlotReference( aDxfJob->m_plotRefDes );
|
||||||
plotOpts.SetLayerSelection( aDxfJob->m_printMaskLayer );
|
plotOpts.SetLayerSelection( aDxfJob->m_printMaskLayer );
|
||||||
|
|
||||||
DXF_PLOTTER* plotter = (DXF_PLOTTER*) StartPlotBoard(
|
PCB_LAYER_ID layer = UNDEFINED_LAYER;
|
||||||
brd, &plotOpts, UNDEFINED_LAYER, aDxfJob->m_outputFile, wxEmptyString, wxEmptyString );
|
wxString layerName;
|
||||||
|
wxString sheetName;
|
||||||
|
wxString sheetPath;
|
||||||
|
|
||||||
|
if( aDxfJob->m_printMaskLayer.size() == 1 )
|
||||||
|
{
|
||||||
|
layer = aDxfJob->m_printMaskLayer.front();
|
||||||
|
layerName = brd->GetLayerName( layer );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
|
||||||
|
layerName = aJob->GetVarOverrides().at( wxT( "LAYER" ) );
|
||||||
|
|
||||||
|
if( aJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
|
||||||
|
sheetName = aJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
|
||||||
|
|
||||||
|
if( aJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
|
||||||
|
sheetPath = aJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
|
||||||
|
|
||||||
|
DXF_PLOTTER* plotter = (DXF_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName,
|
||||||
|
aDxfJob->m_outputFile, sheetName,
|
||||||
|
sheetPath );
|
||||||
|
|
||||||
if( plotter )
|
if( plotter )
|
||||||
{
|
{
|
||||||
|
@ -555,8 +576,29 @@ int PCBNEW_JOBS_HANDLER::JobExportPdf( JOB* aJob )
|
||||||
case 2: plotOpts.SetDrillMarksType( DRILL_MARKS::FULL_DRILL_SHAPE ); break;
|
case 2: plotOpts.SetDrillMarksType( DRILL_MARKS::FULL_DRILL_SHAPE ); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PDF_PLOTTER* plotter = (PDF_PLOTTER*) StartPlotBoard(
|
PCB_LAYER_ID layer = UNDEFINED_LAYER;
|
||||||
brd, &plotOpts, UNDEFINED_LAYER, aPdfJob->m_outputFile, wxEmptyString, wxEmptyString );
|
wxString layerName;
|
||||||
|
wxString sheetName;
|
||||||
|
wxString sheetPath;
|
||||||
|
|
||||||
|
if( aPdfJob->m_printMaskLayer.size() == 1 )
|
||||||
|
{
|
||||||
|
layer = aPdfJob->m_printMaskLayer.front();
|
||||||
|
layerName = brd->GetLayerName( layer );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aPdfJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
|
||||||
|
layerName = aPdfJob->GetVarOverrides().at( wxT( "LAYER" ) );
|
||||||
|
|
||||||
|
if( aPdfJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
|
||||||
|
sheetName = aPdfJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
|
||||||
|
|
||||||
|
if( aPdfJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
|
||||||
|
sheetPath = aPdfJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
|
||||||
|
|
||||||
|
PDF_PLOTTER* plotter = (PDF_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName,
|
||||||
|
aPdfJob->m_outputFile, sheetName,
|
||||||
|
sheetPath );
|
||||||
|
|
||||||
if( plotter )
|
if( plotter )
|
||||||
{
|
{
|
||||||
|
@ -631,8 +673,11 @@ int PCBNEW_JOBS_HANDLER::JobExportGerbers( JOB* aJob )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick the basename from the board file
|
// Pick the basename from the board file
|
||||||
wxFileName fn( brd->GetFileName() );
|
wxFileName fn( brd->GetFileName() );
|
||||||
PCB_LAYER_ID layer = *seq;
|
PCB_LAYER_ID layer = *seq;
|
||||||
|
wxString layerName = brd->GetLayerName( layer );
|
||||||
|
wxString sheetName;
|
||||||
|
wxString sheetPath;
|
||||||
PCB_PLOT_PARAMS plotOpts;
|
PCB_PLOT_PARAMS plotOpts;
|
||||||
|
|
||||||
if( aGerberJob->m_useBoardPlotParams )
|
if( aGerberJob->m_useBoardPlotParams )
|
||||||
|
@ -645,14 +690,24 @@ int PCBNEW_JOBS_HANDLER::JobExportGerbers( JOB* aJob )
|
||||||
else
|
else
|
||||||
fileExt = FILEEXT::GerberFileExtension;
|
fileExt = FILEEXT::GerberFileExtension;
|
||||||
|
|
||||||
BuildPlotFileName( &fn, aGerberJob->m_outputFile, brd->GetLayerName( layer ), fileExt );
|
BuildPlotFileName( &fn, aGerberJob->m_outputFile, layerName, fileExt );
|
||||||
wxString fullname = fn.GetFullName();
|
wxString fullname = fn.GetFullName();
|
||||||
|
|
||||||
jobfile_writer.AddGbrFile( layer, fullname );
|
jobfile_writer.AddGbrFile( layer, fullname );
|
||||||
|
|
||||||
|
if( aJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
|
||||||
|
layerName = aJob->GetVarOverrides().at( wxT( "LAYER" ) );
|
||||||
|
|
||||||
|
if( aJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
|
||||||
|
sheetName = aJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
|
||||||
|
|
||||||
|
if( aJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
|
||||||
|
sheetPath = aJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
|
||||||
|
|
||||||
// We are feeding it one layer at the start here to silence a logic check
|
// We are feeding it one layer at the start here to silence a logic check
|
||||||
GERBER_PLOTTER* plotter = (GERBER_PLOTTER*) StartPlotBoard(
|
GERBER_PLOTTER* plotter = (GERBER_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer,
|
||||||
brd, &plotOpts, layer, fn.GetFullPath(), wxEmptyString, wxEmptyString );
|
layerName, fn.GetFullPath(),
|
||||||
|
sheetName, sheetPath );
|
||||||
|
|
||||||
if( plotter )
|
if( plotter )
|
||||||
{
|
{
|
||||||
|
@ -733,10 +788,30 @@ int PCBNEW_JOBS_HANDLER::JobExportGerber( JOB* aJob )
|
||||||
populateGerberPlotOptionsFromJob( plotOpts, aGerberJob );
|
populateGerberPlotOptionsFromJob( plotOpts, aGerberJob );
|
||||||
plotOpts.SetLayerSelection( aGerberJob->m_printMaskLayer );
|
plotOpts.SetLayerSelection( aGerberJob->m_printMaskLayer );
|
||||||
|
|
||||||
|
PCB_LAYER_ID layer = UNDEFINED_LAYER;
|
||||||
|
wxString layerName;
|
||||||
|
wxString sheetName;
|
||||||
|
wxString sheetPath;
|
||||||
|
|
||||||
|
if( aGerberJob->m_printMaskLayer.size() == 1 )
|
||||||
|
{
|
||||||
|
layer = aGerberJob->m_printMaskLayer.front();
|
||||||
|
layerName = brd->GetLayerName( layer );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
|
||||||
|
layerName = aJob->GetVarOverrides().at( wxT( "LAYER" ) );
|
||||||
|
|
||||||
|
if( aJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
|
||||||
|
sheetName = aJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
|
||||||
|
|
||||||
|
if( aJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
|
||||||
|
sheetPath = aJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
|
||||||
|
|
||||||
// We are feeding it one layer at the start here to silence a logic check
|
// We are feeding it one layer at the start here to silence a logic check
|
||||||
GERBER_PLOTTER* plotter = (GERBER_PLOTTER*) StartPlotBoard(
|
GERBER_PLOTTER* plotter = (GERBER_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName,
|
||||||
brd, &plotOpts, aGerberJob->m_printMaskLayer.front(), aGerberJob->m_outputFile,
|
aGerberJob->m_outputFile,
|
||||||
wxEmptyString, wxEmptyString );
|
sheetName, sheetPath );
|
||||||
|
|
||||||
if( plotter )
|
if( plotter )
|
||||||
{
|
{
|
||||||
|
|
|
@ -450,8 +450,10 @@ bool PLOT_CONTROLLER::OpenPlotfile( const wxString& aSuffix, PLOT_FORMAT aFormat
|
||||||
outputDirName = ExpandTextVars( outputDirName, &textResolver );
|
outputDirName = ExpandTextVars( outputDirName, &textResolver );
|
||||||
outputDirName = ExpandEnvVarSubstitutions( outputDirName, nullptr );
|
outputDirName = ExpandEnvVarSubstitutions( outputDirName, nullptr );
|
||||||
|
|
||||||
wxFileName outputDir = wxFileName::DirName( outputDirName );
|
wxFileName outputDir = wxFileName::DirName( outputDirName );
|
||||||
wxString boardFilename = m_board->GetFileName();
|
wxString boardFilename = m_board->GetFileName();
|
||||||
|
PCB_LAYER_ID layer = ToLAYER_ID( GetLayer() );
|
||||||
|
wxString layerName = m_board->GetLayerName( layer );
|
||||||
|
|
||||||
if( EnsureFileDirectoryExists( &outputDir, boardFilename ) )
|
if( EnsureFileDirectoryExists( &outputDir, boardFilename ) )
|
||||||
{
|
{
|
||||||
|
@ -471,7 +473,7 @@ bool PLOT_CONTROLLER::OpenPlotfile( const wxString& aSuffix, PLOT_FORMAT aFormat
|
||||||
// Build plot filenames from the board name and layer names:
|
// Build plot filenames from the board name and layer names:
|
||||||
BuildPlotFileName( &m_plotFile, outputDir.GetPath(), aSuffix, fileExt );
|
BuildPlotFileName( &m_plotFile, outputDir.GetPath(), aSuffix, fileExt );
|
||||||
|
|
||||||
m_plotter = StartPlotBoard( m_board, &GetPlotOptions(), ToLAYER_ID( GetLayer() ),
|
m_plotter = StartPlotBoard( m_board, &GetPlotOptions(), layer, layerName,
|
||||||
m_plotFile.GetFullPath(), aSheetName, aSheetPath );
|
m_plotFile.GetFullPath(), aSheetName, aSheetPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,8 +142,8 @@ private:
|
||||||
|
|
||||||
|
|
||||||
PLOTTER* StartPlotBoard( BOARD* aBoard, const PCB_PLOT_PARAMS* aPlotOpts, int aLayer,
|
PLOTTER* StartPlotBoard( BOARD* aBoard, const PCB_PLOT_PARAMS* aPlotOpts, int aLayer,
|
||||||
const wxString& aFullFileName, const wxString& aSheetName,
|
const wxString& aLayerName, const wxString& aFullFileName,
|
||||||
const wxString& aSheetPath );
|
const wxString& aSheetName, const wxString& aSheetPath );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot a sequence of board layer IDs.
|
* Plot a sequence of board layer IDs.
|
||||||
|
|
|
@ -1151,8 +1151,8 @@ static void ConfigureHPGLPenSizes( HPGL_PLOTTER *aPlotter, const PCB_PLOT_PARAMS
|
||||||
* @return the plotter object if OK, NULL if the file is not created (or has a problem).
|
* @return the plotter object if OK, NULL if the file is not created (or has a problem).
|
||||||
*/
|
*/
|
||||||
PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer,
|
PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer,
|
||||||
const wxString& aFullFileName, const wxString& aSheetName,
|
const wxString& aLayerName, const wxString& aFullFileName,
|
||||||
const wxString& aSheetPath )
|
const wxString& aSheetName, const wxString& aSheetPath )
|
||||||
{
|
{
|
||||||
// Create the plotter driver and set the few plotter specific options
|
// Create the plotter driver and set the few plotter specific options
|
||||||
PLOTTER* plotter = nullptr;
|
PLOTTER* plotter = nullptr;
|
||||||
|
@ -1213,9 +1213,7 @@ PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aL
|
||||||
KIGFX::PCB_RENDER_SETTINGS* renderSettings = new KIGFX::PCB_RENDER_SETTINGS();
|
KIGFX::PCB_RENDER_SETTINGS* renderSettings = new KIGFX::PCB_RENDER_SETTINGS();
|
||||||
renderSettings->LoadColors( aPlotOpts->ColorSettings() );
|
renderSettings->LoadColors( aPlotOpts->ColorSettings() );
|
||||||
renderSettings->SetDefaultPenWidth( pcbIUScale.mmToIU( 0.0212 ) ); // Hairline at 1200dpi
|
renderSettings->SetDefaultPenWidth( pcbIUScale.mmToIU( 0.0212 ) ); // Hairline at 1200dpi
|
||||||
|
renderSettings->SetLayerName( aLayerName );
|
||||||
if( aLayer >= 0 && aLayer < GAL_LAYER_ID_END )
|
|
||||||
renderSettings->SetLayerName( aBoard->GetLayerName( ToLAYER_ID( aLayer ) ) );
|
|
||||||
|
|
||||||
plotter->SetRenderSettings( renderSettings );
|
plotter->SetRenderSettings( renderSettings );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue