KiCad PCB EDA Suite
command_fp_export_svg.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#include <wx/dir.h>
28
29#include <macros.h>
30#include <wx/tokenzr.h>
31
32#define ARG_FOOTPRINT "--footprint"
33
35{
36 addLayerArg( false );
37
38 m_argParser.add_argument( "-t", ARG_THEME )
39 .default_value( std::string() )
40 .help( UTF8STDSTR( _( "Color theme to use (will default to pcbnew settings)" ) ) );
41
42 m_argParser.add_argument( "--fp", ARG_FOOTPRINT )
43 .default_value( std::string() )
44 .help( UTF8STDSTR( _( "Specific symbol to export within the library" ) ) );
45
46 m_argParser.add_argument( ARG_BLACKANDWHITE )
48 .implicit_value( true )
49 .default_value( false );
50}
51
52
54{
55 int baseExit = EXPORT_PCB_BASE_COMMAND::doPerform( aKiway );
56 if( baseExit != EXIT_CODES::OK )
57 return baseExit;
58
59 std::unique_ptr<JOB_FP_EXPORT_SVG> svgJob = std::make_unique<JOB_FP_EXPORT_SVG>( true );
60
61 svgJob->m_libraryPath = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() );
62 svgJob->m_outputDirectory = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
63 svgJob->m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE );
64 svgJob->m_footprint = FROM_UTF8( m_argParser.get<std::string>( ARG_FOOTPRINT ).c_str() );
65
66 if( !wxDir::Exists( svgJob->m_libraryPath ) )
67 {
68 wxFprintf( stderr, _( "Footprint library does not exist or is not accessible\n" ) );
70 }
71
72 svgJob->m_colorTheme = FROM_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
73
74 if( m_selectedLayers.count() > 0 )
75 svgJob->m_printMaskLayer = m_selectedLayers;
76 else
77 svgJob->m_printMaskLayer = LSET::AllLayersMask();
78
79 int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, svgJob.get() );
80
81 return exitCode;
82}
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
static LSET AllLayersMask()
Definition: lset.cpp:808
#define UTF8STDSTR(s)
Definition: command.h:27
#define ARG_OUTPUT
#define ARG_INPUT
#define ARG_THEME
#define ARG_BLACKANDWHITE_DESC
#define ARG_BLACKANDWHITE
#define ARG_FOOTPRINT
#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
static const int ERR_INVALID_INPUT_FILE
Definition: exit_codes.h:33
int doPerform(KIWAY &aKiway) override
The internal handler that should be overloaded to implement command specific processing and work.