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
37 PCB_EXPORT_BASE_COMMAND( "ps", false, true )
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( "--hdnp", ARG_HIDE_DNP_FPS_ON_FAB_LAYERS )
72 .flag();
73
74 m_argParser.add_argument( "--sdnp", ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS )
76 .flag();
77
78 m_argParser.add_argument( "--cdnp", ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS )
80 .flag();
81
83 .help( UTF8STDSTR( _( ARG_NEGATIVE_DESC ) ) )
84 .flag();
85
86 m_argParser.add_argument( ARG_BLACKANDWHITE )
88 .flag();
89
90 m_argParser.add_argument( "-t", ARG_THEME )
91 .default_value( std::string() )
92 .help( UTF8STDSTR( _( "Color theme to use (will default to PCB Editor settings)" ) ) )
93 .metavar( "THEME_NAME" );
94
97 .scan<'i', int>()
98 .default_value( 2 );
99
100 m_argParser.add_argument( ARG_MODE_SINGLE )
101 .help( UTF8STDSTR(
102 _( "Generates a single file with the output arg path acting as the complete "
103 "directory and filename path. COMMON_LAYER_LIST does not function in this "
104 "mode. Instead LAYER_LIST controls all layers plotted." ) ) )
105 .flag();
106
107 m_argParser.add_argument( ARG_MODE_MULTI )
108 .help( UTF8STDSTR( _( "Generates one or more files with behavior similar to the KiCad "
109 "GUI plotting. The given output path specifies a directory in "
110 "which files may be output." ) ) )
111 .flag();
112
113 m_argParser.add_argument( "-C", ARG_TRACK_WIDTH_CORRECTION )
114 .help( UTF8STDSTR( _( "Track width correction [mm]. Used to compensate errors in "
115 "track widths, pad and via sizes." ) ) )
116 .scan<'g', double>()
117 .default_value( 0.0 )
118 .metavar( "TRACK_COR" );
119
120 m_argParser.add_argument( "-X", ARG_X_SCALE_FACTOR )
121 .help( UTF8STDSTR( _( "X scale adjust for exact scale." ) ) )
122 .scan<'g', double>()
123 .default_value( 1.0 )
124 .metavar( "X_SCALE" );
125
126 m_argParser.add_argument( "-Y", ARG_Y_SCALE_FACTOR )
127 .help( UTF8STDSTR( _( "Y scale adjust for exact scale." ) ) )
128 .scan<'g', double>()
129 .default_value( 1.0 )
130 .metavar( "Y_SCALE" );
131
132 m_argParser.add_argument( "-A", ARG_FORCE_A4 )
133 .help( UTF8STDSTR( _( "Force A4 paper size." ) ) )
134 .flag();
135
136 m_argParser.add_argument( ARG_SCALE )
137 .help( UTF8STDSTR( _( ARG_SCALE_DESC ) ) )
138 .scan<'g', double>()
139 .default_value( 1.0 )
140 .metavar( "SCALE" );
141
142 m_argParser.add_argument( ARG_CHECK_ZONES )
143 .help( UTF8STDSTR( _( ARG_CHECK_ZONES_DESC ) ) )
144 .flag();
145}
146
147
149{
150 std::unique_ptr<JOB_EXPORT_PCB_PS> psJob( new JOB_EXPORT_PCB_PS() );
151
152 psJob->m_filename = m_argInput;
153 psJob->SetConfiguredOutputPath( m_argOutput );
154 psJob->m_drawingSheet = m_argDrawingSheet;
155 psJob->SetVarOverrides( m_argDefineVars );
156
157 if( !wxFile::Exists( psJob->m_filename ) )
158 {
159 wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) );
161 }
162
163 psJob->m_plotFootprintValues = !m_argParser.get<bool>( ARG_EXCLUDE_VALUE );
164 psJob->m_plotRefDes = !m_argParser.get<bool>( ARG_EXCLUDE_REFDES );
165
166 psJob->m_plotDrawingSheet = m_argParser.get<bool>( ARG_INCLUDE_BORDER_TITLE );
167 psJob->m_subtractSolderMaskFromSilk = m_argParser.get<bool>( ARG_SUBTRACT_SOLDERMASK );
168 psJob->m_mirror = m_argParser.get<bool>( ARG_MIRROR );
169 psJob->m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE );
170 psJob->m_colorTheme = From_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
171 psJob->m_negative = m_argParser.get<bool>( ARG_NEGATIVE );
172 psJob->m_scale = m_argParser.get<double>( ARG_SCALE );
173 psJob->m_checkZonesBeforePlot = m_argParser.get<bool>( ARG_CHECK_ZONES );
174
175 psJob->m_sketchPadsOnFabLayers = m_argParser.get<bool>( ARG_SKETCH_PADS_ON_FAB_LAYERS );
176 psJob->m_hideDNPFPsOnFabLayers = m_argParser.get<bool>( ARG_HIDE_DNP_FPS_ON_FAB_LAYERS );
177 psJob->m_sketchDNPFPsOnFabLayers = m_argParser.get<bool>( ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS );
178 psJob->m_crossoutDNPFPsOnFabLayers = m_argParser.get<bool>( ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS );
179
180 int drillShape = m_argParser.get<int>( ARG_DRILL_SHAPE_OPTION );
181 psJob->m_drillShapeOption = static_cast<DRILL_MARKS>( drillShape );
182
183 psJob->m_argLayers = From_UTF8( m_argParser.get<std::string>( ARG_LAYERS ).c_str() );
184 psJob->m_argCommonLayers = From_UTF8( m_argParser.get<std::string>( ARG_COMMON_LAYERS ).c_str() );
185
186 if( m_argParser.get<bool>( ARG_MODE_MULTI ) )
187 psJob->m_genMode = JOB_EXPORT_PCB_PS::GEN_MODE::MULTI;
188 else if( m_argParser.get<bool>( ARG_MODE_SINGLE ) )
189 psJob->m_genMode = JOB_EXPORT_PCB_PS::GEN_MODE::SINGLE;
190
191 psJob->m_trackWidthCorrection = m_argParser.get<double>( ARG_TRACK_WIDTH_CORRECTION );
192 psJob->m_XScaleAdjust = m_argParser.get<double>( ARG_X_SCALE_FACTOR );
193 psJob->m_YScaleAdjust = m_argParser.get<double>( ARG_Y_SCALE_FACTOR );
194 psJob->m_forceA4 = m_argParser.get<bool>( ARG_FORCE_A4 );
195
196 return aKiway.ProcessJob( KIWAY::FACE_PCB, psJob.get() );
197}
std::map< wxString, wxString > m_argDefineVars
Value of the drawing sheet arg if configured.
Definition command.h:145
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:168
wxString m_argDrawingSheet
Value of the drawing sheet arg if configured.
Definition command.h:140
wxString m_argOutput
Value of the output arg if configured.
Definition command.h:135
wxString m_argInput
Value of the common input arg if configured.
Definition command.h:130
void addDrawingSheetArg()
Set up the drawing sheet arg used by many of the export commands.
Definition command.cpp:156
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:286
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob, REPORTER *aReporter=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Definition kiway.cpp:701
@ FACE_PCB
pcbnew DSO
Definition kiway.h:294
#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_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_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, bool aInputCanBeDir=false, bool aOutputIsDir=false)