KiCad PCB EDA Suite
CLI::EXPORT_PCB_GERBERS_COMMAND Class Reference

#include <command_export_pcb_gerbers.h>

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

Public Member Functions

 EXPORT_PCB_GERBERS_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 28 of file command_export_pcb_gerbers.h.

Constructor & Destructor Documentation

◆ EXPORT_PCB_GERBERS_COMMAND()

CLI::EXPORT_PCB_GERBERS_COMMAND::EXPORT_PCB_GERBERS_COMMAND ( )

Definition at line 36 of file command_export_pcb_gerbers.cpp.

36 :
37 EXPORT_PCB_GERBER_COMMAND( "gerbers" )
38{
39 m_requireLayers = false;
40
41 m_argParser.add_argument( "--cl", ARG_COMMON_LAYERS )
42 .default_value( std::string() )
43 .help( UTF8STDSTR(
44 _( "Layers to include on each plot, comma separated list of untranslated layer names to include such as "
45 "F.Cu,B.Cu" ) ) );
46
48 .help( UTF8STDSTR( _( "Use the gerber plot settings already configured in the board file" ) ) )
49 .implicit_value( true )
50 .default_value( false );
51}
argparse::ArgumentParser m_argParser
Definition: command.h:68
#define UTF8STDSTR(s)
Definition: command.h:27
#define ARG_COMMON_LAYERS
#define ARG_USE_BOARD_PLOT_PARAMS
#define _(s)

References _, ARG_COMMON_LAYERS, ARG_USE_BOARD_PLOT_PARAMS, CLI::COMMAND::m_argParser, CLI::EXPORT_PCB_BASE_COMMAND::m_requireLayers, and UTF8STDSTR.

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(), CLI::EXPORT_PCB_GERBER_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_GERBERS_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_GERBER_COMMAND.

Definition at line 54 of file command_export_pcb_gerbers.cpp.

55{
56 int exitCode = EXPORT_PCB_BASE_COMMAND::doPerform( aKiway );
57 if( exitCode != EXIT_CODES::OK )
58 return exitCode;
59
60 std::unique_ptr<JOB_EXPORT_PCB_GERBERS> gerberJob( new JOB_EXPORT_PCB_GERBERS( true ) );
61
62 exitCode = populateJob( gerberJob.get() );
63 if( exitCode != EXIT_CODES::OK )
64 return exitCode;
65
66 wxString layers = FROM_UTF8( m_argParser.get<std::string>( ARG_COMMON_LAYERS ).c_str() );
67 gerberJob->m_layersIncludeOnAll =
68 convertLayerStringList( layers, gerberJob->m_layersIncludeOnAllSet );
69
71 exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, gerberJob.get() );
72
73 return exitCode;
74}
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 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 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.
LSET convertLayerStringList(wxString &aLayerString, bool &aLayerArgSet) const

References ARG_COMMON_LAYERS, CLI::EXPORT_PCB_BASE_COMMAND::doPerform(), dummy, KIWAY::FACE_PCB, FROM_UTF8(), 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)
protectedinherited

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
#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
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: