From a493a2c822b8b3d51f0ce86e13dcff5c238e42e2 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 7 Feb 2023 20:15:34 +0100 Subject: [PATCH] =?UTF-8?q?kicad-cli,=20pcbnew=20p=C3=A0lot:=20honor=20the?= =?UTF-8?q?=20color=20options=20when=20ploting=20pdf=20files=20--black-and?= =?UTF-8?q?-white=20and=20-t=20were=20shown=20in=20help,=20but=20not=20han?= =?UTF-8?q?dled=20Fixes=20#13805=20https://gitlab.com/kicad/code/kicad/iss?= =?UTF-8?q?ues/13805?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/jobs/job_export_pcb_pdf.h | 6 +++++- kicad/cli/command_export_pcb_pdf.cpp | 9 ++++++--- kicad/cli/command_export_sch_pdf.cpp | 2 +- pcbnew/pcbnew_jobs_handler.cpp | 7 +++++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/common/jobs/job_export_pcb_pdf.h b/common/jobs/job_export_pcb_pdf.h index 42e7742931..0706afcec2 100644 --- a/common/jobs/job_export_pcb_pdf.h +++ b/common/jobs/job_export_pcb_pdf.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2022 Mark Roszko - * 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 * under the terms of the GNU General Public License as published by the @@ -32,6 +32,8 @@ public: JOB( "pdf", aIsCli ), m_filename(), m_outputFile(), + m_colorTheme(), + m_blackAndWhite( false ), m_plotFootprintValues( true ), m_plotRefDes( true ), m_plotBorderTitleBlocks( false ), @@ -41,7 +43,9 @@ public: wxString m_filename; wxString m_outputFile; + wxString m_colorTheme; + bool m_blackAndWhite; bool m_plotFootprintValues; bool m_plotRefDes; bool m_plotBorderTitleBlocks; diff --git a/kicad/cli/command_export_pcb_pdf.cpp b/kicad/cli/command_export_pcb_pdf.cpp index 715e907b3b..001854c76d 100644 --- a/kicad/cli/command_export_pcb_pdf.cpp +++ b/kicad/cli/command_export_pcb_pdf.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2022 Mark Roszko - * 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 * 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 ) .default_value( std::string() ) - .help( std::string( - _( "Color theme to use (will default to pcbnew settings)" ).ToUTF8() ) ); + .help( UTF8STDSTR( _( "Color theme to use (will default to pcbnew settings)" ) ) ); } int CLI::EXPORT_PCB_PDF_COMMAND::doPerform( KIWAY& aKiway ) { int baseExit = EXPORT_PCB_BASE_COMMAND::doPerform( aKiway ); + if( baseExit != EXIT_CODES::OK ) return baseExit; @@ -84,6 +84,9 @@ int CLI::EXPORT_PCB_PDF_COMMAND::doPerform( KIWAY& aKiway ) pdfJob->m_plotBorderTitleBlocks = m_argParser.get( ARG_INCLUDE_BORDER_TITLE ); + pdfJob->m_blackAndWhite = m_argParser.get( ARG_BLACKANDWHITE ); + pdfJob->m_colorTheme = FROM_UTF8( m_argParser.get( ARG_THEME ).c_str() ); + pdfJob->m_printMaskLayer = m_selectedLayers; LOCALE_IO dummy; // Switch to "C" locale diff --git a/kicad/cli/command_export_sch_pdf.cpp b/kicad/cli/command_export_sch_pdf.cpp index dea9902cf5..925634f78b 100644 --- a/kicad/cli/command_export_sch_pdf.cpp +++ b/kicad/cli/command_export_sch_pdf.cpp @@ -35,7 +35,7 @@ CLI::EXPORT_SCH_PDF_COMMAND::EXPORT_SCH_PDF_COMMAND() : EXPORT_PCB_BASE_COMMAND( { m_argParser.add_argument( "-t", ARG_THEME ) .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 ) .help( UTF8STDSTR( _( ARG_BLACKANDWHITE_DESC ) ) ) diff --git a/pcbnew/pcbnew_jobs_handler.cpp b/pcbnew/pcbnew_jobs_handler.cpp index df1c0ef86a..00d80a1289 100644 --- a/pcbnew/pcbnew_jobs_handler.cpp +++ b/pcbnew/pcbnew_jobs_handler.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2022 Mark Roszko - * 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 * 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; plotOpts.SetFormat( PLOT_FORMAT::DXF ); - plotOpts.SetDXFPlotPolygonMode( aDxfJob->m_plotGraphicItemsUsingContours ); 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 ); + SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); + plotOpts.SetColorSettings( mgr.GetColorSettings( aPdfJob->m_colorTheme ) ); + plotOpts.SetBlackAndWhite( aPdfJob->m_blackAndWhite ); + PDF_PLOTTER* plotter = (PDF_PLOTTER*) StartPlotBoard( brd, &plotOpts, UNDEFINED_LAYER, aPdfJob->m_outputFile, wxEmptyString, wxEmptyString );