mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Cleanup.
This commit is contained in:
parent
413d6747c5
commit
dd921354fc
@ -106,7 +106,7 @@ bool PCB_PLOTTER::Plot( const wxString& aOutputPath,
|
||||
commonLayers = aCommonLayers;
|
||||
}
|
||||
|
||||
size_t finalPageCount = 0;
|
||||
int finalPageCount = 0;
|
||||
|
||||
for( PCB_LAYER_ID layer : layersToPlot )
|
||||
{
|
||||
@ -126,18 +126,17 @@ bool PCB_PLOTTER::Plot( const wxString& aOutputPath,
|
||||
wxString msg;
|
||||
bool success = true;
|
||||
PLOTTER* plotter = nullptr;
|
||||
int pageNum = 1;
|
||||
|
||||
for( size_t i = 0, pageNum = 1; i < layersToPlot.size(); i++ )
|
||||
for( size_t i = 0; i < layersToPlot.size(); i++ )
|
||||
{
|
||||
PCB_LAYER_ID layer = layersToPlot[i];
|
||||
|
||||
if( copperLayerShouldBeSkipped( layer ) )
|
||||
continue;
|
||||
|
||||
LSEQ plotSequence = getPlotSequence( layer, commonLayers );
|
||||
|
||||
wxString layerName = m_board->GetLayerName( layer );
|
||||
|
||||
LSEQ plotSequence = getPlotSequence( layer, commonLayers );
|
||||
wxString layerName = m_board->GetLayerName( layer );
|
||||
wxFileName fn;
|
||||
|
||||
if( aOutputPathIsSingle )
|
||||
@ -155,13 +154,9 @@ bool PCB_PLOTTER::Plot( const wxString& aOutputPath,
|
||||
fileExt = GetGerberProtelExtension( layer );
|
||||
|
||||
if( m_plotOpts.GetFormat() == PLOT_FORMAT::PDF && m_plotOpts.m_PDFSingle )
|
||||
{
|
||||
fn.SetExt( GetDefaultPlotExtension( PLOT_FORMAT::PDF ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildPlotFileName( &fn, aOutputPath, layerName, fileExt );
|
||||
}
|
||||
}
|
||||
|
||||
if( jobfile_writer )
|
||||
@ -228,15 +223,14 @@ bool PCB_PLOTTER::Plot( const wxString& aOutputPath,
|
||||
&& i != layersToPlot.size() - 1 )
|
||||
{
|
||||
wxString pageNumber = wxString::Format( "%zu", pageNum + 1 );
|
||||
size_t nextI = i;
|
||||
PCB_LAYER_ID nextLayer;
|
||||
size_t nextI = i + 1;
|
||||
PCB_LAYER_ID nextLayer = layersToPlot[nextI];
|
||||
|
||||
do
|
||||
while( copperLayerShouldBeSkipped( nextLayer ) && nextI < layersToPlot.size() - 1 )
|
||||
{
|
||||
++nextI;
|
||||
nextLayer = layersToPlot[nextI];
|
||||
} while( copperLayerShouldBeSkipped( nextLayer )
|
||||
&& ( nextI < layersToPlot.size() - 1 ) );
|
||||
}
|
||||
|
||||
wxString pageName = m_board->GetLayerName( nextLayer );
|
||||
wxString sheetName = layerName;
|
||||
@ -247,12 +241,11 @@ bool PCB_PLOTTER::Plot( const wxString& aOutputPath,
|
||||
pageNumber, finalPageCount );
|
||||
}
|
||||
|
||||
|
||||
// last page
|
||||
if( m_plotOpts.GetFormat() != PLOT_FORMAT::PDF
|
||||
|| !m_plotOpts.m_PDFSingle
|
||||
|| i == aLayersToPlot.size() - 1
|
||||
|| pageNum == finalPageCount )
|
||||
|| !m_plotOpts.m_PDFSingle
|
||||
|| i == aLayersToPlot.size() - 1
|
||||
|| pageNum == finalPageCount )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -942,55 +942,54 @@ int PCBNEW_JOBS_HANDLER::JobExportDxf( JOB* aJob )
|
||||
|
||||
int PCBNEW_JOBS_HANDLER::JobExportPdf( JOB* aJob )
|
||||
{
|
||||
JOB_EXPORT_PCB_PDF* aPdfJob = dynamic_cast<JOB_EXPORT_PCB_PDF*>( aJob );
|
||||
bool plotAllLayersOneFile = false;
|
||||
JOB_EXPORT_PCB_PDF* pdfJob = dynamic_cast<JOB_EXPORT_PCB_PDF*>( aJob );
|
||||
|
||||
if( aPdfJob == nullptr )
|
||||
if( pdfJob == nullptr )
|
||||
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
|
||||
BOARD* brd = getBoard( aPdfJob->m_filename );
|
||||
BOARD* brd = getBoard( pdfJob->m_filename );
|
||||
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
aJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
loadOverrideDrawingSheet( brd, aPdfJob->m_drawingSheet );
|
||||
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
|
||||
pdfJob->SetTitleBlock( brd->GetTitleBlock() );
|
||||
loadOverrideDrawingSheet( brd, pdfJob->m_drawingSheet );
|
||||
brd->GetProject()->ApplyTextVars( pdfJob->GetVarOverrides() );
|
||||
brd->SynchronizeProperties();
|
||||
aPdfJob->m_plotLayerSequence = convertLayerArg( aPdfJob->m_argLayers, brd );
|
||||
aPdfJob->m_plotOnAllLayersSequence = convertLayerArg( aPdfJob->m_argCommonLayers, brd );
|
||||
pdfJob->m_plotLayerSequence = convertLayerArg( pdfJob->m_argLayers, brd );
|
||||
pdfJob->m_plotOnAllLayersSequence = convertLayerArg( pdfJob->m_argCommonLayers, brd );
|
||||
|
||||
if( aPdfJob->m_plotLayerSequence.size() < 1 )
|
||||
if( pdfJob->m_pdfGenMode == JOB_EXPORT_PCB_PDF::GEN_MODE::ALL_LAYERS_ONE_FILE )
|
||||
plotAllLayersOneFile = true;
|
||||
|
||||
if( pdfJob->m_plotLayerSequence.size() < 1 )
|
||||
{
|
||||
m_reporter->Report( _( "At least one layer must be specified\n" ), RPT_SEVERITY_ERROR );
|
||||
return CLI::EXIT_CODES::ERR_ARGS;
|
||||
}
|
||||
|
||||
if( aPdfJob->m_pdfGenMode == JOB_EXPORT_PCB_PDF::GEN_MODE::ALL_LAYERS_ONE_FILE
|
||||
&& aPdfJob->GetConfiguredOutputPath().IsEmpty() )
|
||||
if( plotAllLayersOneFile && pdfJob->GetConfiguredOutputPath().IsEmpty() )
|
||||
{
|
||||
wxFileName fn = brd->GetFileName();
|
||||
fn.SetName( fn.GetName() );
|
||||
fn.SetExt( GetDefaultPlotExtension( PLOT_FORMAT::PDF ) );
|
||||
|
||||
aPdfJob->SetWorkingOutputPath( fn.GetFullName() );
|
||||
pdfJob->SetWorkingOutputPath( fn.GetFullName() );
|
||||
}
|
||||
|
||||
PCB_PLOT_PARAMS plotOpts;
|
||||
PCB_PLOTTER::PlotJobToPlotOpts( plotOpts, aPdfJob, *m_reporter );
|
||||
|
||||
int returnCode = CLI::EXIT_CODES::OK;
|
||||
PCB_PLOTTER::PlotJobToPlotOpts( plotOpts, pdfJob, *m_reporter );
|
||||
|
||||
// ensure this is set for this one gen mode
|
||||
if( aPdfJob->m_pdfGenMode == JOB_EXPORT_PCB_PDF::GEN_MODE::ONE_PAGE_PER_LAYER_ONE_FILE )
|
||||
{
|
||||
if( plotAllLayersOneFile )
|
||||
plotOpts.m_PDFSingle = true;
|
||||
}
|
||||
|
||||
PCB_PLOTTER pcbPlotter( brd, m_reporter, plotOpts );
|
||||
|
||||
wxString outPath = aPdfJob->GetFullOutputPath( brd->GetProject() );
|
||||
wxString outPath = pdfJob->GetFullOutputPath( brd->GetProject() );
|
||||
|
||||
if( !PATHS::EnsurePathExists( outPath, aPdfJob->m_pdfGenMode == JOB_EXPORT_PCB_PDF::GEN_MODE::ALL_LAYERS_ONE_FILE ) )
|
||||
if( !PATHS::EnsurePathExists( outPath, plotAllLayersOneFile ) )
|
||||
{
|
||||
m_reporter->Report( _( "Failed to create output directory\n" ), RPT_SEVERITY_ERROR );
|
||||
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
@ -999,30 +998,30 @@ int PCBNEW_JOBS_HANDLER::JobExportPdf( JOB* aJob )
|
||||
std::optional<wxString> layerName;
|
||||
std::optional<wxString> sheetName;
|
||||
std::optional<wxString> sheetPath;
|
||||
if( aPdfJob->m_pdfGenMode == JOB_EXPORT_PCB_PDF::GEN_MODE::ALL_LAYERS_ONE_FILE )
|
||||
|
||||
if( plotAllLayersOneFile )
|
||||
{
|
||||
if( aPdfJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
|
||||
layerName = aPdfJob->GetVarOverrides().at( wxT( "LAYER" ) );
|
||||
if( pdfJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
|
||||
layerName = pdfJob->GetVarOverrides().at( wxT( "LAYER" ) );
|
||||
|
||||
if( aPdfJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
|
||||
sheetName = aPdfJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
|
||||
if( pdfJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
|
||||
sheetName = pdfJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
|
||||
|
||||
if( aPdfJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
|
||||
sheetPath = aPdfJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
|
||||
if( pdfJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
|
||||
sheetPath = pdfJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
|
||||
}
|
||||
|
||||
|
||||
LOCALE_IO dummy;
|
||||
|
||||
if( !pcbPlotter.Plot( outPath, aPdfJob->m_plotLayerSequence,
|
||||
aPdfJob->m_plotOnAllLayersSequence, false,
|
||||
aPdfJob->m_pdfGenMode == JOB_EXPORT_PCB_PDF::GEN_MODE::ALL_LAYERS_ONE_FILE,
|
||||
if( !pcbPlotter.Plot( outPath, pdfJob->m_plotLayerSequence,
|
||||
pdfJob->m_plotOnAllLayersSequence, false, plotAllLayersOneFile,
|
||||
layerName, sheetName, sheetPath ) )
|
||||
{
|
||||
returnCode = CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
return returnCode;
|
||||
return CLI::EXIT_CODES::OK;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user