mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 00:21:25 +00:00
Squash the pdf handling for the old path into the new like dxf/svg
This commit is contained in:
parent
afe7c893d5
commit
16d10dc76e
@ -30,6 +30,7 @@
|
||||
|
||||
#define ARG_MODE_SEPARATE "--mode-separate"
|
||||
#define ARG_MODE_MULTIPAGE "--mode-multipage"
|
||||
#define ARG_MODE_SINGLE "--mode-single"
|
||||
|
||||
CLI::PCB_EXPORT_PDF_COMMAND::PCB_EXPORT_PDF_COMMAND() : PCB_EXPORT_BASE_COMMAND( "pdf" )
|
||||
{
|
||||
@ -39,14 +40,6 @@ CLI::PCB_EXPORT_PDF_COMMAND::PCB_EXPORT_PDF_COMMAND() : PCB_EXPORT_BASE_COMMAND(
|
||||
addDrawingSheetArg();
|
||||
addDefineArg();
|
||||
|
||||
m_argParser.add_argument( ARG_MODE_SEPARATE )
|
||||
.help( UTF8STDSTR( _( "Plot the layers to individual PDF files" ) ) )
|
||||
.flag();
|
||||
|
||||
m_argParser.add_argument( ARG_MODE_MULTIPAGE )
|
||||
.help( UTF8STDSTR( _( "Plot the layers to a single PDF file with multiple pages" ) ) )
|
||||
.flag();
|
||||
|
||||
m_argParser.add_argument( "-m", ARG_MIRROR )
|
||||
.help( UTF8STDSTR( _( "Mirror the board (useful for trying to show bottom layers)" ) ) )
|
||||
.flag();
|
||||
@ -108,6 +101,21 @@ CLI::PCB_EXPORT_PDF_COMMAND::PCB_EXPORT_PDF_COMMAND() : PCB_EXPORT_BASE_COMMAND(
|
||||
m_argParser.add_argument( ARG_PLOT_INVISIBLE_TEXT )
|
||||
.help( UTF8STDSTR( _( ARG_PLOT_INVISIBLE_TEXT_DESC ) ) )
|
||||
.flag();
|
||||
|
||||
m_argParser.add_argument( ARG_MODE_SINGLE )
|
||||
.help( UTF8STDSTR(
|
||||
_( "Generates a single file with the output arg path acting as the complete "
|
||||
"directory and filename path. COMMON_LAYER_LIST does not function in this "
|
||||
"mode. Instead LAYER_LIST controls all layers plotted." ) ) )
|
||||
.flag();
|
||||
|
||||
m_argParser.add_argument( ARG_MODE_SEPARATE )
|
||||
.help( UTF8STDSTR( _( "Plot the layers to individual PDF files" ) ) )
|
||||
.flag();
|
||||
|
||||
m_argParser.add_argument( ARG_MODE_MULTIPAGE )
|
||||
.help( UTF8STDSTR( _( "Plot the layers to a single PDF file with multiple pages" ) ) )
|
||||
.flag();
|
||||
}
|
||||
|
||||
|
||||
@ -154,6 +162,7 @@ int CLI::PCB_EXPORT_PDF_COMMAND::doPerform( KIWAY& aKiway )
|
||||
|
||||
bool argModeMulti = m_argParser.get<bool>( ARG_MODE_MULTIPAGE );
|
||||
bool argModeSeparate = m_argParser.get<bool>( ARG_MODE_SEPARATE );
|
||||
bool argModeSingle = m_argParser.get<bool>( ARG_MODE_SINGLE );
|
||||
|
||||
if( argModeMulti && argModeSeparate )
|
||||
{
|
||||
@ -166,26 +175,11 @@ int CLI::PCB_EXPORT_PDF_COMMAND::doPerform( KIWAY& aKiway )
|
||||
pdfJob->m_printMaskLayersToIncludeOnAllLayers = convertLayerStringList( layers, blah );
|
||||
|
||||
if( argModeMulti )
|
||||
{
|
||||
pdfJob->m_pdfGenMode = JOB_EXPORT_PCB_PDF::GEN_MODE::ONE_PAGE_PER_LAYER_ONE_FILE;
|
||||
}
|
||||
else if( argModeSeparate )
|
||||
{
|
||||
pdfJob->m_pdfGenMode = JOB_EXPORT_PCB_PDF::GEN_MODE::ALL_LAYERS_SEPARATE_FILE;
|
||||
}
|
||||
|
||||
if( pdfJob->m_pdfGenMode == JOB_EXPORT_PCB_PDF::GEN_MODE::ALL_LAYERS_ONE_FILE )
|
||||
{
|
||||
wxFprintf( stdout,
|
||||
wxT( "\033[33;1m%s\033[0m\n" ),
|
||||
_( "This command has deprecated behavior as of KiCad 9.0, the default behavior of this command will change in a future release." ) );
|
||||
|
||||
wxFprintf( stdout, wxT( "\033[33;1m%s\033[0m\n" ),
|
||||
_( "The new behavior will match --mode-separate" ) );
|
||||
|
||||
wxFprintf( stdout, wxT( "\033[33;1m%s\033[0m\n" ),
|
||||
_( "The behavior with neither --mode flags will no longer exist" ) );
|
||||
}
|
||||
else if( argModeSingle )
|
||||
pdfJob->m_pdfGenMode = JOB_EXPORT_PCB_PDF::GEN_MODE::ALL_LAYERS_ONE_FILE;
|
||||
|
||||
LOCALE_IO dummy; // Switch to "C" locale
|
||||
int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, pdfJob.get() );
|
||||
|
@ -87,6 +87,7 @@
|
||||
#include <dialogs/dialog_plot.h>
|
||||
#include <dialogs/dialog_drc_job_config.h>
|
||||
#include <dialogs/dialog_render_job.h>
|
||||
#include <paths.h>
|
||||
|
||||
#include "pcbnew_scripting_helpers.h"
|
||||
#include <locale_io.h>
|
||||
@ -842,20 +843,25 @@ int PCBNEW_JOBS_HANDLER::JobExportPdf( JOB* aJob )
|
||||
|
||||
int returnCode = CLI::EXIT_CODES::OK;
|
||||
|
||||
// DEPRECATED CLI BEHAVIOR AS OF KICAD 9.0, TO BE REMOVED
|
||||
// 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 )
|
||||
{
|
||||
plotOpts.m_PDFSingle = true;
|
||||
}
|
||||
|
||||
PCB_PLOTTER pcbPlotter( brd, m_reporter, plotOpts );
|
||||
|
||||
if( !PATHS::EnsurePathExists( aPdfJob->GetFullOutputPath() ) )
|
||||
{
|
||||
m_reporter->Report( _( "Failed to create output directory\n" ), RPT_SEVERITY_ERROR );
|
||||
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
PCB_LAYER_ID layer = UNDEFINED_LAYER;
|
||||
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" ) );
|
||||
|
||||
@ -864,53 +870,19 @@ int PCBNEW_JOBS_HANDLER::JobExportPdf( JOB* aJob )
|
||||
|
||||
if( aPdfJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
|
||||
sheetPath = aPdfJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
|
||||
|
||||
LOCALE_IO dummy;
|
||||
PDF_PLOTTER* plotter = (PDF_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName,
|
||||
aPdfJob->GetFullOutputPath(),
|
||||
sheetName, sheetPath );
|
||||
|
||||
if( plotter )
|
||||
{
|
||||
PlotBoardLayers( brd, plotter, aPdfJob->m_printMaskLayer, plotOpts );
|
||||
PlotInteractiveLayer( brd, plotter, plotOpts );
|
||||
plotter->EndPlot();
|
||||
}
|
||||
else
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "Failed to create file '%s'." ), aPdfJob->GetFullOutputPath() );
|
||||
m_reporter->Report( msg, RPT_SEVERITY_ERROR );
|
||||
|
||||
returnCode = CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
delete plotter;
|
||||
}
|
||||
else
|
||||
|
||||
|
||||
LOCALE_IO dummy;
|
||||
if( !pcbPlotter.Plot( aPdfJob->GetFullOutputPath(), aPdfJob->m_printMaskLayer,
|
||||
aPdfJob->m_printMaskLayersToIncludeOnAllLayers,
|
||||
false,
|
||||
aPdfJob->m_pdfGenMode == JOB_EXPORT_PCB_PDF::GEN_MODE::ALL_LAYERS_ONE_FILE,
|
||||
layerName,
|
||||
sheetName,
|
||||
sheetPath ) )
|
||||
{
|
||||
// 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 )
|
||||
{
|
||||
plotOpts.m_PDFSingle = true;
|
||||
}
|
||||
|
||||
PCB_PLOTTER pcbPlotter( brd, m_reporter, plotOpts );
|
||||
// ensure output dir exists
|
||||
wxFileName fnOut( aPdfJob->GetFullOutputPath() + wxT( "/" ) );
|
||||
|
||||
if( !fnOut.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ) )
|
||||
{
|
||||
m_reporter->Report( _( "Failed to create output directory\n" ), RPT_SEVERITY_ERROR );
|
||||
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
|
||||
}
|
||||
|
||||
LOCALE_IO dummy;
|
||||
if( !pcbPlotter.Plot( aPdfJob->GetFullOutputPath(), aPdfJob->m_printMaskLayer,
|
||||
aPdfJob->m_printMaskLayersToIncludeOnAllLayers, false ) )
|
||||
{
|
||||
returnCode = CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
}
|
||||
returnCode = CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
return returnCode;
|
||||
|
Loading…
Reference in New Issue
Block a user