KiCad PCB EDA Suite
CLI::EXPORT_PCB_GERBER_COMMAND Class Reference

#include <command_export_pcb_gerber.h>

Inheritance diagram for CLI::EXPORT_PCB_GERBER_COMMAND:
CLI::EXPORT_PCB_BASE_COMMAND CLI::COMMAND CLI::EXPORT_PCB_GERBERS_COMMAND

Public Member Functions

 EXPORT_PCB_GERBER_COMMAND (const std::string &aName)
 
 EXPORT_PCB_GERBER_COMMAND ()
 
int Perform (KIWAY &aKiway)
 Entry point to processing commands from args and doing work. More...
 
argparse::ArgumentParser & GetArgParser ()
 
const std::string & GetName () const
 
void PrintHelp ()
 

Protected Member Functions

int doPerform (KIWAY &aKiway) override
 The internal handler that should be overloaded to implement command specific processing and work. More...
 
int populateJob (JOB_EXPORT_PCB_GERBER *aJob)
 
LSET convertLayerStringList (wxString &aLayerString, bool &aLayerArgSet) const
 
void addLayerArg (bool aRequire)
 

Protected Attributes

std::map< std::string, LSETm_layerMasks
 
LSET m_selectedLayers
 
bool m_selectedLayersSet
 
bool m_hasLayerArg
 
bool m_requireLayers
 
std::string m_name
 
argparse::ArgumentParser m_argParser
 

Detailed Description

Definition at line 36 of file command_export_pcb_gerber.h.

Constructor & Destructor Documentation

◆ EXPORT_PCB_GERBER_COMMAND() [1/2]

CLI::EXPORT_PCB_GERBER_COMMAND::EXPORT_PCB_GERBER_COMMAND ( const std::string &  aName)

Definition at line 34 of file command_export_pcb_gerber.cpp.

34 :
36{
37 addLayerArg( true );
38
39 m_argParser.add_argument( "--erd", ARG_EXCLUDE_REFDES )
40 .help( UTF8STDSTR( _( "Exclude the reference designator text" ) ) )
41 .implicit_value( true )
42 .default_value( false );
43
44 m_argParser.add_argument( "--ev", ARG_EXCLUDE_VALUE )
45 .help( UTF8STDSTR( _( "Exclude the value text" ) ) )
46 .implicit_value( true )
47 .default_value( false );
48
49 m_argParser.add_argument( "--ibt", ARG_INCLUDE_BORDER_TITLE )
50 .help( UTF8STDSTR( _( "Include the border and title block" ) ) )
51 .implicit_value( true )
52 .default_value( false );
53
54 m_argParser.add_argument( ARG_NO_X2 )
55 .help( UTF8STDSTR( _( "Do not use the extended X2 format" ) ) )
56 .implicit_value( true )
57 .default_value( false );
58
59 m_argParser.add_argument( ARG_NO_NETLIST )
60 .help( UTF8STDSTR( _( "Do not generate netlist attributes" ) ) )
61 .implicit_value( true )
62 .default_value( false );
63
65 .help( UTF8STDSTR( _( "Subtract soldermask from silkscreen" ) ) )
66 .implicit_value( true )
67 .default_value( false );
68
70 .help( UTF8STDSTR( _( "Disable aperture macros" ) ) )
71 .implicit_value( true )
72 .default_value( false );
73
74 m_argParser.add_argument( ARG_PRECISION )
75 .help( UTF8STDSTR( _( "Precision of gerber coordinates, valid options: 5 or 6" ) ) )
76 .scan<'i', int>()
77 .default_value( 6 );
78}
argparse::ArgumentParser m_argParser
Definition: command.h:68
#define UTF8STDSTR(s)
Definition: command.h:27
#define ARG_INCLUDE_BORDER_TITLE
#define ARG_EXCLUDE_REFDES
#define ARG_EXCLUDE_VALUE
#define ARG_PRECISION
#define ARG_NO_X2
#define ARG_NO_NETLIST
#define ARG_DISABLE_APERTURE_MACROS
#define ARG_SUBTRACT_SOLDERMASK
#define _(s)
EXPORT_PCB_BASE_COMMAND(const std::string &aName, bool aOutputIsDir=false)

References _, CLI::EXPORT_PCB_BASE_COMMAND::addLayerArg(), ARG_DISABLE_APERTURE_MACROS, ARG_EXCLUDE_REFDES, ARG_EXCLUDE_VALUE, ARG_INCLUDE_BORDER_TITLE, ARG_NO_NETLIST, ARG_NO_X2, ARG_PRECISION, ARG_SUBTRACT_SOLDERMASK, CLI::COMMAND::m_argParser, and UTF8STDSTR.

◆ EXPORT_PCB_GERBER_COMMAND() [2/2]

CLI::EXPORT_PCB_GERBER_COMMAND::EXPORT_PCB_GERBER_COMMAND ( )

Definition at line 81 of file command_export_pcb_gerber.cpp.

Member Function Documentation

◆ addLayerArg()

void CLI::EXPORT_PCB_BASE_COMMAND::addLayerArg ( bool  aRequire)
protectedinherited

Definition at line 102 of file command_export_pcb_base.cpp.

103{
104 m_argParser.add_argument( "-l", ARG_LAYERS )
105 .default_value( std::string() )
106 .help( UTF8STDSTR(
107 _( "Comma separated list of untranslated layer names to include such as "
108 "F.Cu,B.Cu" ) ) );
109
110 m_hasLayerArg = true;
111 m_requireLayers = aRequire;
112}
#define ARG_LAYERS

References _, ARG_LAYERS, and UTF8STDSTR.

Referenced by CLI::EXPORT_PCB_DXF_COMMAND::EXPORT_PCB_DXF_COMMAND(), EXPORT_PCB_GERBER_COMMAND(), CLI::EXPORT_PCB_PDF_COMMAND::EXPORT_PCB_PDF_COMMAND(), CLI::EXPORT_PCB_SVG_COMMAND::EXPORT_PCB_SVG_COMMAND(), and CLI::FP_EXPORT_SVG_COMMAND::FP_EXPORT_SVG_COMMAND().

◆ convertLayerStringList()

LSET CLI::EXPORT_PCB_BASE_COMMAND::convertLayerStringList ( wxString &  aLayerString,
bool &  aLayerArgSet 
) const
protectedinherited

Definition at line 75 of file command_export_pcb_base.cpp.

76{
77 LSET layerMask;
78
79 if( !aLayerString.IsEmpty() )
80 {
81 layerMask.reset();
82 wxStringTokenizer layerTokens( aLayerString, "," );
83 while( layerTokens.HasMoreTokens() )
84 {
85 std::string token = TO_UTF8( layerTokens.GetNextToken() );
86 if( m_layerMasks.count( token ) )
87 {
88 layerMask |= m_layerMasks.at(token);
89 aLayerArgSet = true;
90 }
91 else
92 {
93 wxFprintf( stderr, _( "Invalid layer name \"%s\"\n" ), token );
94 }
95 }
96 }
97
98 return layerMask;
99}
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:532
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
std::map< std::string, LSET > m_layerMasks

References _, and TO_UTF8.

◆ doPerform()

int CLI::EXPORT_PCB_GERBER_COMMAND::doPerform ( KIWAY aKiway)
overrideprotectedvirtual

The internal handler that should be overloaded to implement command specific processing and work.

If not overloaded, the command will simply emit the help options by default

Reimplemented from CLI::EXPORT_PCB_BASE_COMMAND.

Reimplemented in CLI::EXPORT_PCB_GERBERS_COMMAND.

Definition at line 117 of file command_export_pcb_gerber.cpp.

118{
119 int exitCode = EXPORT_PCB_BASE_COMMAND::doPerform( aKiway );
120 if( exitCode != EXIT_CODES::OK )
121 return exitCode;
122
123 std::unique_ptr<JOB_EXPORT_PCB_GERBER> gerberJob( new JOB_EXPORT_PCB_GERBER( true ) );
124
125 exitCode = populateJob( gerberJob.get() );
126 if( exitCode != EXIT_CODES::OK )
127 return exitCode;
128
130 exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, gerberJob.get() );
131
132 return exitCode;
133}
int populateJob(JOB_EXPORT_PCB_GERBER *aJob)
int ProcessJob(KIWAY::FACE_T aFace, JOB *job)
Definition: kiway.cpp:660
@ FACE_PCB
pcbnew DSO
Definition: kiway.h:287
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
static const int OK
Definition: exit_codes.h:30
std::vector< FAB_LAYER_COLOR > dummy
int doPerform(KIWAY &aKiway) override
The internal handler that should be overloaded to implement command specific processing and work.

References CLI::EXPORT_PCB_BASE_COMMAND::doPerform(), dummy, KIWAY::FACE_PCB, CLI::EXIT_CODES::OK, and KIWAY::ProcessJob().

◆ GetArgParser()

argparse::ArgumentParser & CLI::COMMAND::GetArgParser ( )
inlineinherited

Definition at line 54 of file command.h.

54{ return m_argParser; }

References CLI::COMMAND::m_argParser.

Referenced by recurseArgParserBuild(), and recurseArgParserSubCommandUsed().

◆ GetName()

const std::string & CLI::COMMAND::GetName ( void  ) const
inlineinherited

Definition at line 55 of file command.h.

55{ return m_name; }
std::string m_name
Definition: command.h:67

References CLI::COMMAND::m_name.

Referenced by recurseArgParserSubCommandUsed().

◆ Perform()

int CLI::COMMAND::Perform ( KIWAY aKiway)
inherited

Entry point to processing commands from args and doing work.

Definition at line 49 of file command.cpp.

50{
51 if( m_argParser[ARG_HELP] == true )
52 {
53 PrintHelp();
54
55 return 0;
56 }
57
58 return doPerform( aKiway );
59}
virtual int doPerform(KIWAY &aKiway)
The internal handler that should be overloaded to implement command specific processing and work.
Definition: command.cpp:62
void PrintHelp()
Definition: command.cpp:41
#define ARG_HELP
Definition: command.h:30

References ARG_HELP.

◆ populateJob()

int CLI::EXPORT_PCB_GERBER_COMMAND::populateJob ( JOB_EXPORT_PCB_GERBER aJob)
protected

Definition at line 86 of file command_export_pcb_gerber.cpp.

87{
88 aJob->m_filename = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() );
89 aJob->m_outputFile = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
90
92 aJob->m_plotRefDes = !m_argParser.get<bool>( ARG_EXCLUDE_REFDES );
97 aJob->m_useX2Format = !m_argParser.get<bool>( ARG_NO_X2 );
98 aJob->m_precision = m_argParser.get<int>( ARG_PRECISION );
100
101 if( !wxFile::Exists( aJob->m_filename ) )
102 {
103 wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) );
105 }
106
107 if( aJob->m_precision != 5 && aJob->m_precision != 6 )
108 {
109 wxFprintf( stderr, _( "Gerber coordinate precision should be either 5 or 6\n" ) );
111 }
112
113 return EXIT_CODES::OK;
114}
#define ARG_OUTPUT
#define ARG_INPUT
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
static const int ERR_ARGS
Definition: exit_codes.h:31
static const int ERR_INVALID_INPUT_FILE
Definition: exit_codes.h:33

References _, ARG_DISABLE_APERTURE_MACROS, ARG_EXCLUDE_REFDES, ARG_EXCLUDE_VALUE, ARG_INCLUDE_BORDER_TITLE, ARG_INPUT, ARG_NO_NETLIST, ARG_NO_X2, ARG_OUTPUT, ARG_PRECISION, ARG_SUBTRACT_SOLDERMASK, CLI::EXIT_CODES::ERR_ARGS, CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE, FROM_UTF8(), JOB_EXPORT_PCB_GERBER::m_disableApertureMacros, JOB_EXPORT_PCB_GERBER::m_filename, JOB_EXPORT_PCB_GERBER::m_includeNetlistAttributes, JOB_EXPORT_PCB_GERBER::m_outputFile, JOB_EXPORT_PCB_GERBER::m_plotBorderTitleBlocks, JOB_EXPORT_PCB_GERBER::m_plotFootprintValues, JOB_EXPORT_PCB_GERBER::m_plotRefDes, JOB_EXPORT_PCB_GERBER::m_precision, JOB_EXPORT_PCB_GERBER::m_printMaskLayer, JOB_EXPORT_PCB_GERBER::m_subtractSolderMaskFromSilk, JOB_EXPORT_PCB_GERBER::m_useX2Format, and CLI::EXIT_CODES::OK.

◆ PrintHelp()

void CLI::COMMAND::PrintHelp ( )
inherited

Definition at line 41 of file command.cpp.

42{
43 std::stringstream ss;
44 ss << m_argParser;
45 wxPrintf( FROM_UTF8( ss.str().c_str() ) );
46}

References FROM_UTF8().

Member Data Documentation

◆ m_argParser

◆ m_hasLayerArg

bool CLI::EXPORT_PCB_BASE_COMMAND::m_hasLayerArg
protectedinherited

◆ m_layerMasks

std::map<std::string, LSET> CLI::EXPORT_PCB_BASE_COMMAND::m_layerMasks
protectedinherited

◆ m_name

std::string CLI::COMMAND::m_name
protectedinherited

Definition at line 67 of file command.h.

Referenced by CLI::COMMAND::GetName().

◆ m_requireLayers

bool CLI::EXPORT_PCB_BASE_COMMAND::m_requireLayers
protectedinherited

◆ m_selectedLayers

LSET CLI::EXPORT_PCB_BASE_COMMAND::m_selectedLayers
protectedinherited

Definition at line 51 of file command_export_pcb_base.h.

◆ m_selectedLayersSet

bool CLI::EXPORT_PCB_BASE_COMMAND::m_selectedLayersSet
protectedinherited

The documentation for this class was generated from the following files: