KiCad PCB EDA Suite
command_export_pcb_gerbers.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-2022 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 <wx/crt.h>
27
28#include <macros.h>
29#include <wx/tokenzr.h>
30
31#include <locale_io.h>
32
33#define ARG_COMMON_LAYERS "--common-layers"
34#define ARG_USE_BOARD_PLOT_PARAMS "--board-plot-params"
35
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}
52
53
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}
argparse::ArgumentParser m_argParser
Definition: command.h:68
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:279
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
#define UTF8STDSTR(s)
Definition: command.h:27
#define ARG_COMMON_LAYERS
#define ARG_USE_BOARD_PLOT_PARAMS
#define _(s)
This file contains miscellaneous commonly used macros and functions.
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.