2022-12-11 13:57:21 -05:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
|
2023-12-19 14:29:17 -05:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2022-12-11 13:57:21 -05:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2023-08-19 11:46:18 -04:00
|
|
|
#include "command_pcb_export_gerbers.h"
|
2022-12-11 13:57:21 -05:00
|
|
|
#include <cli/exit_codes.h>
|
|
|
|
#include "jobs/job_export_pcb_gerbers.h"
|
|
|
|
#include <kiface_base.h>
|
|
|
|
#include <layer_ids.h>
|
2023-09-09 00:10:57 -04:00
|
|
|
#include <string_utils.h>
|
2022-12-11 13:57:21 -05:00
|
|
|
#include <wx/crt.h>
|
|
|
|
|
|
|
|
#include <macros.h>
|
|
|
|
#include <wx/tokenzr.h>
|
|
|
|
|
|
|
|
#include <locale_io.h>
|
|
|
|
|
|
|
|
#define ARG_USE_BOARD_PLOT_PARAMS "--board-plot-params"
|
|
|
|
|
2023-06-16 07:13:45 -04:00
|
|
|
|
2023-08-19 11:51:50 -04:00
|
|
|
CLI::PCB_EXPORT_GERBERS_COMMAND::PCB_EXPORT_GERBERS_COMMAND() :
|
|
|
|
PCB_EXPORT_GERBER_COMMAND( "gerbers" )
|
2022-12-11 13:57:21 -05:00
|
|
|
{
|
|
|
|
m_requireLayers = false;
|
|
|
|
|
2023-09-15 23:07:19 +00:00
|
|
|
m_argParser.add_description( UTF8STDSTR( _( "Plot multiple Gerbers for a PCB, including the "
|
2023-08-22 13:29:02 +00:00
|
|
|
"ability to use stored board plot settings" ) ) );
|
|
|
|
|
2023-02-08 13:55:20 +00:00
|
|
|
m_argParser.add_argument( "--cl", ARG_COMMON_LAYERS )
|
2022-12-11 13:57:21 -05:00
|
|
|
.default_value( std::string() )
|
|
|
|
.help( UTF8STDSTR(
|
2023-12-19 14:29:17 -05:00
|
|
|
_( "Layers to include on each plot, comma separated list of untranslated "
|
|
|
|
"layer names to include such as "
|
2023-08-31 22:01:07 -04:00
|
|
|
"F.Cu,B.Cu" ) ) )
|
|
|
|
.metavar( "COMMON_LAYER_LIST" );
|
2022-12-11 13:57:21 -05:00
|
|
|
|
|
|
|
m_argParser.add_argument( ARG_USE_BOARD_PLOT_PARAMS )
|
2023-12-19 14:29:17 -05:00
|
|
|
.help( UTF8STDSTR( _( "Use the Gerber plot settings already configured in the "
|
|
|
|
"board file" ) ) )
|
2024-01-03 21:39:54 -05:00
|
|
|
.flag();
|
2022-12-11 13:57:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-19 11:51:50 -04:00
|
|
|
int CLI::PCB_EXPORT_GERBERS_COMMAND::doPerform( KIWAY& aKiway )
|
2022-12-11 13:57:21 -05:00
|
|
|
{
|
2023-08-19 11:51:50 -04:00
|
|
|
int exitCode = PCB_EXPORT_BASE_COMMAND::doPerform( aKiway );
|
2023-06-16 07:13:45 -04:00
|
|
|
|
2022-12-11 13:57:21 -05:00
|
|
|
if( exitCode != EXIT_CODES::OK )
|
|
|
|
return exitCode;
|
|
|
|
|
2024-11-04 20:51:15 -05:00
|
|
|
std::unique_ptr<JOB_EXPORT_PCB_GERBERS> gerberJob( new JOB_EXPORT_PCB_GERBERS() );
|
2022-12-11 13:57:21 -05:00
|
|
|
|
|
|
|
exitCode = populateJob( gerberJob.get() );
|
2023-06-16 07:13:45 -04:00
|
|
|
|
2022-12-11 13:57:21 -05:00
|
|
|
if( exitCode != EXIT_CODES::OK )
|
|
|
|
return exitCode;
|
|
|
|
|
2023-09-09 00:10:57 -04:00
|
|
|
wxString layers = From_UTF8( m_argParser.get<std::string>( ARG_COMMON_LAYERS ).c_str() );
|
2022-12-11 13:57:21 -05:00
|
|
|
gerberJob->m_layersIncludeOnAll =
|
|
|
|
convertLayerStringList( layers, gerberJob->m_layersIncludeOnAllSet );
|
2023-06-16 07:13:45 -04:00
|
|
|
gerberJob->m_useBoardPlotParams = m_argParser.get<bool>( ARG_USE_BOARD_PLOT_PARAMS );
|
2022-12-11 13:57:21 -05:00
|
|
|
|
|
|
|
LOCALE_IO dummy;
|
|
|
|
exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, gerberJob.get() );
|
|
|
|
|
|
|
|
return exitCode;
|
2023-06-16 07:13:45 -04:00
|
|
|
}
|