KiCad PCB EDA Suite
Loading...
Searching...
No Matches
command_pcb_export_ps.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 The 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
21#include <base_units.h>
23#include <cli/exit_codes.h>
25#include <kiface_base.h>
26#include <string_utils.h>
27#include <wx/crt.h>
28
29#define ARG_MODE_SINGLE "--mode-single"
30#define ARG_MODE_MULTI "--mode-multi"
31#define ARG_TRACK_WIDTH_CORRECTION "--track-width-correction"
32#define ARG_X_SCALE_FACTOR "--x-scale-factor"
33#define ARG_Y_SCALE_FACTOR "--y-scale-factor"
34#define ARG_FORCE_A4 "--force-a4"
35
38{
39 m_argParser.add_description( UTF8STDSTR( _( "Generate Postscript from a list of layers" ) ) );
40
45
46 m_argParser.add_argument( "-m", ARG_MIRROR )
47 .help( UTF8STDSTR( _( "Mirror the board (useful for trying to show bottom layers)" ) ) )
48 .flag();
49
50 m_argParser.add_argument( "--erd", ARG_EXCLUDE_REFDES )
51 .help( UTF8STDSTR( _( "Exclude the reference designator text" ) ) )
52 .flag();
53
54 m_argParser.add_argument( "--ev", ARG_EXCLUDE_VALUE )
55 .help( UTF8STDSTR( _( "Exclude the value text" ) ) )
56 .flag();
57
58 m_argParser.add_argument( "--ibt", ARG_INCLUDE_BORDER_TITLE )
59 .help( UTF8STDSTR( _( "Include the border and title block" ) ) )
60 .flag();
61
63 .help( UTF8STDSTR( _( "Subtract soldermask from silkscreen" ) ) )
64 .flag();
65
66 m_argParser.add_argument( "--sp", ARG_SKETCH_PADS_ON_FAB_LAYERS )
68 .flag();
69
70 m_argParser.add_argument( "--spn", ARG_SKETCH_PAD_NUMBERS )
72 .flag();
73
74 m_argParser.add_argument( "--hdnp", ARG_HIDE_DNP_FPS_ON_FAB_LAYERS )
76 .flag();
77
78 m_argParser.add_argument( "--sdnp", ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS )
80 .flag();
81
82 m_argParser.add_argument( "--cdnp", ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS )
84 .flag();
85
87 .help( UTF8STDSTR( _( ARG_NEGATIVE_DESC ) ) )
88 .flag();
89
90 m_argParser.add_argument( ARG_BLACKANDWHITE )
92 .flag();
93
94 m_argParser.add_argument( "-t", ARG_THEME )
95 .default_value( std::string() )
96 .help( UTF8STDSTR( _( "Color theme to use (will default to PCB Editor settings)" ) ) )
97 .metavar( "THEME_NAME" );
98
101 .scan<'i', int>()
102 .default_value( 2 );
103
104 m_argParser.add_argument( ARG_MODE_SINGLE )
105 .help( UTF8STDSTR(
106 _( "Generates a single file with the output arg path acting as the complete "
107 "directory and filename path. COMMON_LAYER_LIST does not function in this "
108 "mode. Instead LAYER_LIST controls all layers plotted." ) ) )
109 .flag();
110
111 m_argParser.add_argument( ARG_MODE_MULTI )
112 .help( UTF8STDSTR( _( "Generates one or more files with behavior similar to the KiCad "
113 "GUI plotting. The given output path specifies a directory in "
114 "which files may be output." ) ) )
115 .flag();
116
117 m_argParser.add_argument( "-C", ARG_TRACK_WIDTH_CORRECTION )
118 .help( UTF8STDSTR( _( "Track width correction [mm]. Used to compensate errors in "
119 "track widths, pad and via sizes." ) ) )
120 .scan<'g', double>()
121 .default_value( 0.0 )
122 .metavar( "TRACK_COR" );
123
124 m_argParser.add_argument( "-X", ARG_X_SCALE_FACTOR )
125 .help( UTF8STDSTR( _( "X scale adjust for exact scale." ) ) )
126 .scan<'g', double>()
127 .default_value( 1.0 )
128 .metavar( "X_SCALE" );
129
130 m_argParser.add_argument( "-Y", ARG_Y_SCALE_FACTOR )
131 .help( UTF8STDSTR( _( "Y scale adjust for exact scale." ) ) )
132 .scan<'g', double>()
133 .default_value( 1.0 )
134 .metavar( "Y_SCALE" );
135
136 m_argParser.add_argument( "-A", ARG_FORCE_A4 )
137 .help( UTF8STDSTR( _( "Force A4 paper size." ) ) )
138 .flag();
139
140 m_argParser.add_argument( ARG_SCALE )
141 .help( UTF8STDSTR( _( ARG_SCALE_DESC ) ) )
142 .scan<'g', double>()
143 .default_value( 1.0 )
144 .metavar( "SCALE" );
145
146 m_argParser.add_argument( ARG_CHECK_ZONES )
147 .help( UTF8STDSTR( _( ARG_CHECK_ZONES_DESC ) ) )
148 .flag();
149
151}
152
153
155{
156 std::unique_ptr<JOB_EXPORT_PCB_PS> psJob( new JOB_EXPORT_PCB_PS() );
157
158 psJob->m_filename = m_argInput;
159 psJob->SetConfiguredOutputPath( m_argOutput );
160 psJob->m_drawingSheet = m_argDrawingSheet;
161 psJob->SetVarOverrides( m_argDefineVars );
162
163 if( !m_argVariantNames.empty() )
164 psJob->m_variant = m_argVariantNames.front();
165
166 if( !wxFile::Exists( psJob->m_filename ) )
167 {
168 wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) );
170 }
171
172 psJob->m_plotFootprintValues = !m_argParser.get<bool>( ARG_EXCLUDE_VALUE );
173 psJob->m_plotRefDes = !m_argParser.get<bool>( ARG_EXCLUDE_REFDES );
174
175 psJob->m_plotDrawingSheet = m_argParser.get<bool>( ARG_INCLUDE_BORDER_TITLE );
176 psJob->m_subtractSolderMaskFromSilk = m_argParser.get<bool>( ARG_SUBTRACT_SOLDERMASK );
177 psJob->m_mirror = m_argParser.get<bool>( ARG_MIRROR );
178 psJob->m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE );
179 psJob->m_colorTheme = From_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
180 psJob->m_negative = m_argParser.get<bool>( ARG_NEGATIVE );
181 psJob->m_scale = m_argParser.get<double>( ARG_SCALE );
182 psJob->m_checkZonesBeforePlot = m_argParser.get<bool>( ARG_CHECK_ZONES );
183
184 psJob->m_sketchPadsOnFabLayers = m_argParser.get<bool>( ARG_SKETCH_PADS_ON_FAB_LAYERS );
185 psJob->m_plotPadNumbers = psJob->m_sketchPadsOnFabLayers && m_argParser.get<bool>( ARG_SKETCH_PAD_NUMBERS );
186 psJob->m_hideDNPFPsOnFabLayers = m_argParser.get<bool>( ARG_HIDE_DNP_FPS_ON_FAB_LAYERS );
187 psJob->m_sketchDNPFPsOnFabLayers = m_argParser.get<bool>( ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS );
188 psJob->m_crossoutDNPFPsOnFabLayers = m_argParser.get<bool>( ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS );
189
190 int drillShape = m_argParser.get<int>( ARG_DRILL_SHAPE_OPTION );
191 psJob->m_drillShapeOption = static_cast<DRILL_MARKS>( drillShape );
192
193 psJob->m_argLayers = From_UTF8( m_argParser.get<std::string>( ARG_LAYERS ).c_str() );
194 psJob->m_argCommonLayers = From_UTF8( m_argParser.get<std::string>( ARG_COMMON_LAYERS ).c_str() );
195
196 if( m_argParser.get<bool>( ARG_MODE_MULTI ) )
197 psJob->m_genMode = JOB_EXPORT_PCB_PS::GEN_MODE::MULTI;
198 else if( m_argParser.get<bool>( ARG_MODE_SINGLE ) )
199 psJob->m_genMode = JOB_EXPORT_PCB_PS::GEN_MODE::SINGLE;
200
201 psJob->m_trackWidthCorrection = m_argParser.get<double>( ARG_TRACK_WIDTH_CORRECTION );
202 psJob->m_XScaleAdjust = m_argParser.get<double>( ARG_X_SCALE_FACTOR );
203 psJob->m_YScaleAdjust = m_argParser.get<double>( ARG_Y_SCALE_FACTOR );
204 psJob->m_forceA4 = m_argParser.get<bool>( ARG_FORCE_A4 );
205
206 return aKiway.ProcessJob( KIWAY::FACE_PCB, psJob.get() );
207}
std::map< wxString, wxString > m_argDefineVars
Value of the drawing sheet arg if configured.
Definition command.h:158
void addVariantsArg()
Set up the list of variants to output arguement.
Definition command.cpp:227
argparse::ArgumentParser m_argParser
Definition command.h:113
void addDefineArg()
Set up the drawing sheet arg used by many of the export commands.
Definition command.cpp:212
wxString m_argDrawingSheet
Value of the drawing sheet arg if configured.
Definition command.h:153
wxString m_argOutput
Value of the output arg if configured.
Definition command.h:148
wxString m_argInput
Value of the common input arg if configured.
Definition command.h:143
std::vector< wxString > m_argVariantNames
The list of variant names to output.
Definition command.h:170
void addDrawingSheetArg()
Set up the drawing sheet arg used by many of the export commands.
Definition command.cpp:200
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:315
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob, REPORTER *aReporter=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Definition kiway.cpp:750
@ FACE_PCB
pcbnew DSO
Definition kiway.h:323
#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_CHECK_ZONES_DESC
#define ARG_SKETCH_PADS_ON_FAB_LAYERS
#define ARG_COMMON_LAYERS
#define ARG_SCALE_DESC
#define ARG_SCALE
#define ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS_DESC
#define ARG_EXCLUDE_REFDES
#define ARG_BLACKANDWHITE_DESC
#define ARG_CHECK_ZONES
#define ARG_NEGATIVE_SHORT
#define ARG_SKETCH_PAD_NUMBERS
#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_SUBTRACT_SOLDERMASK
#define ARG_DRILL_SHAPE_OPTION_DESC
#define ARG_LAYERS
#define ARG_SKETCH_PAD_NUMBERS_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 ARG_MODE_MULTI
#define ARG_MODE_SINGLE
#define ARG_FORCE_A4
#define ARG_Y_SCALE_FACTOR
#define ARG_X_SCALE_FACTOR
#define ARG_TRACK_WIDTH_CORRECTION
#define _(s)
static const int ERR_INVALID_INPUT_FILE
Definition exit_codes.h:33
DRILL_MARKS
Plots and prints can show holes in pads and vias 3 options are available:
wxString From_UTF8(const char *cstring)
PCB_EXPORT_BASE_COMMAND(const std::string &aName, IO_TYPE aInputType=IO_TYPE::FILE, IO_TYPE aOutputType=IO_TYPE::FILE)