kicad-cli, pcbnew pàlot: honor the color options when ploting pdf files

--black-and-white and -t were shown in help, but not handled
Fixes #13805
https://gitlab.com/kicad/code/kicad/issues/13805
This commit is contained in:
jean-pierre charras 2023-02-07 20:15:34 +01:00
parent d2ce3ce381
commit a493a2c822
4 changed files with 17 additions and 7 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> * Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -32,6 +32,8 @@ public:
JOB( "pdf", aIsCli ), JOB( "pdf", aIsCli ),
m_filename(), m_filename(),
m_outputFile(), m_outputFile(),
m_colorTheme(),
m_blackAndWhite( false ),
m_plotFootprintValues( true ), m_plotFootprintValues( true ),
m_plotRefDes( true ), m_plotRefDes( true ),
m_plotBorderTitleBlocks( false ), m_plotBorderTitleBlocks( false ),
@ -41,7 +43,9 @@ public:
wxString m_filename; wxString m_filename;
wxString m_outputFile; wxString m_outputFile;
wxString m_colorTheme;
bool m_blackAndWhite;
bool m_plotFootprintValues; bool m_plotFootprintValues;
bool m_plotRefDes; bool m_plotRefDes;
bool m_plotBorderTitleBlocks; bool m_plotBorderTitleBlocks;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> * Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -57,14 +57,14 @@ CLI::EXPORT_PCB_PDF_COMMAND::EXPORT_PCB_PDF_COMMAND() : EXPORT_PCB_BASE_COMMAND(
m_argParser.add_argument( "-t", ARG_THEME ) m_argParser.add_argument( "-t", ARG_THEME )
.default_value( std::string() ) .default_value( std::string() )
.help( std::string( .help( UTF8STDSTR( _( "Color theme to use (will default to pcbnew settings)" ) ) );
_( "Color theme to use (will default to pcbnew settings)" ).ToUTF8() ) );
} }
int CLI::EXPORT_PCB_PDF_COMMAND::doPerform( KIWAY& aKiway ) int CLI::EXPORT_PCB_PDF_COMMAND::doPerform( KIWAY& aKiway )
{ {
int baseExit = EXPORT_PCB_BASE_COMMAND::doPerform( aKiway ); int baseExit = EXPORT_PCB_BASE_COMMAND::doPerform( aKiway );
if( baseExit != EXIT_CODES::OK ) if( baseExit != EXIT_CODES::OK )
return baseExit; return baseExit;
@ -84,6 +84,9 @@ int CLI::EXPORT_PCB_PDF_COMMAND::doPerform( KIWAY& aKiway )
pdfJob->m_plotBorderTitleBlocks = m_argParser.get<bool>( ARG_INCLUDE_BORDER_TITLE ); pdfJob->m_plotBorderTitleBlocks = m_argParser.get<bool>( ARG_INCLUDE_BORDER_TITLE );
pdfJob->m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE );
pdfJob->m_colorTheme = FROM_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
pdfJob->m_printMaskLayer = m_selectedLayers; pdfJob->m_printMaskLayer = m_selectedLayers;
LOCALE_IO dummy; // Switch to "C" locale LOCALE_IO dummy; // Switch to "C" locale

View File

@ -35,7 +35,7 @@ CLI::EXPORT_SCH_PDF_COMMAND::EXPORT_SCH_PDF_COMMAND() : EXPORT_PCB_BASE_COMMAND(
{ {
m_argParser.add_argument( "-t", ARG_THEME ) m_argParser.add_argument( "-t", ARG_THEME )
.default_value( std::string() ) .default_value( std::string() )
.help( UTF8STDSTR( _( "Color theme to use (will default to pcbnew settings)" ) ) ); .help( UTF8STDSTR( _( "Color theme to use (will default to schematic settings)" ) ) );
m_argParser.add_argument( ARG_BLACKANDWHITE ) m_argParser.add_argument( ARG_BLACKANDWHITE )
.help( UTF8STDSTR( _( ARG_BLACKANDWHITE_DESC ) ) ) .help( UTF8STDSTR( _( ARG_BLACKANDWHITE_DESC ) ) )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> * Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -173,7 +173,6 @@ int PCBNEW_JOBS_HANDLER::JobExportDxf( JOB* aJob )
PCB_PLOT_PARAMS plotOpts; PCB_PLOT_PARAMS plotOpts;
plotOpts.SetFormat( PLOT_FORMAT::DXF ); plotOpts.SetFormat( PLOT_FORMAT::DXF );
plotOpts.SetDXFPlotPolygonMode( aDxfJob->m_plotGraphicItemsUsingContours ); plotOpts.SetDXFPlotPolygonMode( aDxfJob->m_plotGraphicItemsUsingContours );
if( aDxfJob->m_dxfUnits == JOB_EXPORT_PCB_DXF::DXF_UNITS::MILLIMETERS ) if( aDxfJob->m_dxfUnits == JOB_EXPORT_PCB_DXF::DXF_UNITS::MILLIMETERS )
@ -235,6 +234,10 @@ int PCBNEW_JOBS_HANDLER::JobExportPdf( JOB* aJob )
plotOpts.SetLayerSelection( aPdfJob->m_printMaskLayer ); plotOpts.SetLayerSelection( aPdfJob->m_printMaskLayer );
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
plotOpts.SetColorSettings( mgr.GetColorSettings( aPdfJob->m_colorTheme ) );
plotOpts.SetBlackAndWhite( aPdfJob->m_blackAndWhite );
PDF_PLOTTER* plotter = (PDF_PLOTTER*) StartPlotBoard( PDF_PLOTTER* plotter = (PDF_PLOTTER*) StartPlotBoard(
brd, &plotOpts, UNDEFINED_LAYER, aPdfJob->m_outputFile, wxEmptyString, wxEmptyString ); brd, &plotOpts, UNDEFINED_LAYER, aPdfJob->m_outputFile, wxEmptyString, wxEmptyString );