KiCad PCB EDA Suite
Loading...
Searching...
No Matches
command_pcb_export_pdf.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2022 Mark Roszko <[email protected]>
5 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
22#include <cli/exit_codes.h>
24#include <kiface_base.h>
25#include <layer_ids.h>
26#include <string_utils.h>
27#include <wx/crt.h>
28
29#include <locale_io.h>
30
31
33{
34 m_argParser.add_description( UTF8STDSTR( _( "Generate PDF from a list of layers" ) ) );
35
36 addLayerArg( true );
39
40 m_argParser.add_argument( "-m", ARG_MIRROR )
41 .help( UTF8STDSTR( _( "Mirror the board (useful for trying to show bottom layers)" ) ) )
42 .flag();
43
44 m_argParser.add_argument( "--erd", ARG_EXCLUDE_REFDES )
45 .help( UTF8STDSTR( _( "Exclude the reference designator text" ) ) )
46 .flag();
47
48 m_argParser.add_argument( "--ev", ARG_EXCLUDE_VALUE )
49 .help( UTF8STDSTR( _( "Exclude the value text" ) ) )
50 .flag();
51
52 m_argParser.add_argument( "--ibt", ARG_INCLUDE_BORDER_TITLE )
53 .help( UTF8STDSTR( _( "Include the border and title block" ) ) )
54 .flag();
55
56 m_argParser.add_argument( "--sp", ARG_SKETCH_PADS_ON_FAB_LAYERS )
58 .flag();
59
60 m_argParser.add_argument( "--hdnp", ARG_HIDE_DNP_FPS_ON_FAB_LAYERS )
62 .flag();
63
64 m_argParser.add_argument( "--sdnp", ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS )
66 .flag();
67
68 m_argParser.add_argument( "--cdnp", ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS )
70 .flag();
71
73 .help( UTF8STDSTR( _( ARG_NEGATIVE_DESC ) ) )
74 .flag();
75
76 m_argParser.add_argument( ARG_BLACKANDWHITE )
78 .flag();
79
80 m_argParser.add_argument( "-t", ARG_THEME )
81 .default_value( std::string() )
82 .help( UTF8STDSTR( _( "Color theme to use (will default to PCB Editor settings)" ) ) )
83 .metavar( "THEME_NAME" );
84
87 .scan<'i', int>()
88 .default_value( 2 );
89}
90
91
93{
94 int baseExit = PCB_EXPORT_BASE_COMMAND::doPerform( aKiway );
95
96 if( baseExit != EXIT_CODES::OK )
97 return baseExit;
98
99 std::unique_ptr<JOB_EXPORT_PCB_PDF> pdfJob( new JOB_EXPORT_PCB_PDF() );
100
101 pdfJob->m_filename = m_argInput;
102 pdfJob->SetOutputPath( m_argOutput );
103 pdfJob->m_drawingSheet = m_argDrawingSheet;
104 pdfJob->SetVarOverrides( m_argDefineVars );
105
106 if( !wxFile::Exists( pdfJob->m_filename ) )
107 {
108 wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) );
110 }
111
112 pdfJob->m_plotFootprintValues = !m_argParser.get<bool>( ARG_EXCLUDE_VALUE );
113 pdfJob->m_plotRefDes = !m_argParser.get<bool>( ARG_EXCLUDE_REFDES );
114
115 pdfJob->m_plotDrawingSheet = m_argParser.get<bool>( ARG_INCLUDE_BORDER_TITLE );
116
117 pdfJob->m_mirror = m_argParser.get<bool>( ARG_MIRROR );
118 pdfJob->m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE );
119 pdfJob->m_colorTheme = From_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
120 pdfJob->m_negative = m_argParser.get<bool>( ARG_NEGATIVE );
121
122 pdfJob->m_sketchPadsOnFabLayers = m_argParser.get<bool>( ARG_SKETCH_PADS_ON_FAB_LAYERS );
123 pdfJob->m_hideDNPFPsOnFabLayers = m_argParser.get<bool>( ARG_HIDE_DNP_FPS_ON_FAB_LAYERS );
124 pdfJob->m_sketchDNPFPsOnFabLayers = m_argParser.get<bool>( ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS );
125 pdfJob->m_crossoutDNPFPsOnFabLayers = m_argParser.get<bool>( ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS );
126 pdfJob->m_drillShapeOption = m_argParser.get<int>( ARG_DRILL_SHAPE_OPTION );
127
128 pdfJob->m_printMaskLayer = m_selectedLayers;
129
130 LOCALE_IO dummy; // Switch to "C" locale
131 int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, pdfJob.get() );
132
133 return exitCode;
134}
argparse::ArgumentParser m_argParser
Definition: command.h:100
void addDefineArg()
Set up the drawing sheet arg used by many of the export commands.
Definition: command.cpp:169
void addDrawingSheetArg()
Set up the drawing sheet arg used by many of the export commands.
Definition: command.cpp:157
int doPerform(KIWAY &aKiway) override
The internal handler that should be overloaded to implement command specific processing and work.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:284
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob)
Definition: kiway.cpp:709
@ FACE_PCB
pcbnew DSO
Definition: kiway.h:292
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
#define UTF8STDSTR(s)
Definition: command.h:27
#define ARG_SKETCH_PADS_ON_FAB_LAYERS_DESC
#define ARG_THEME
#define ARG_NEGATIVE
#define ARG_INCLUDE_BORDER_TITLE
#define ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS_DESC
#define ARG_SKETCH_PADS_ON_FAB_LAYERS
#define ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS_DESC
#define ARG_EXCLUDE_REFDES
#define ARG_BLACKANDWHITE_DESC
#define ARG_NEGATIVE_SHORT
#define ARG_EXCLUDE_VALUE
#define ARG_BLACKANDWHITE
#define ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS
#define ARG_MIRROR
#define ARG_HIDE_DNP_FPS_ON_FAB_LAYERS
#define ARG_DRILL_SHAPE_OPTION_DESC
#define ARG_HIDE_DNP_FPS_ON_FAB_LAYERS_DESC
#define ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS
#define ARG_DRILL_SHAPE_OPTION
#define ARG_NEGATIVE_DESC
#define _(s)
static const int OK
Definition: exit_codes.h:30
static const int ERR_INVALID_INPUT_FILE
Definition: exit_codes.h:33
std::vector< FAB_LAYER_COLOR > dummy
wxString From_UTF8(const char *cstring)
int doPerform(KIWAY &aKiway) override
The internal handler that should be overloaded to implement command specific processing and work.