KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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 <string_utils.h>
27#include <wx/crt.h>
28#include <wx/dir.h>
29
30#include <macros.h>
31#include <wx/tokenzr.h>
32
33#define ARG_FOOTPRINT "--footprint"
34
36{
37 m_argParser.add_description( UTF8STDSTR( _( "Exports the footprint or entire footprint "
38 "library to SVG" ) ) );
39
40 addLayerArg( false );
42
43 m_argParser.add_argument( "-t", ARG_THEME )
44 .default_value( std::string() )
45 .help( UTF8STDSTR( _( "Color theme to use (will default to footprint editor "
46 "settings)" ) ) );
47
48 m_argParser.add_argument( "--fp", ARG_FOOTPRINT )
49 .default_value( std::string() )
50 .help( UTF8STDSTR( _( "Specific footprint to export within the library" ) ) )
51 .metavar( "FOOTPRINT_NAME" );
52
53 m_argParser.add_argument( "--sp", ARG_SKETCH_PADS_ON_FAB_LAYERS )
55 .flag();
56
57 m_argParser.add_argument( "--hdnp", ARG_HIDE_DNP_FPS_ON_FAB_LAYERS )
59 .flag();
60
61 m_argParser.add_argument( "--sdnp", ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS )
63 .flag();
64
65 m_argParser.add_argument( "--cdnp", ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS )
67 .flag();
68
69 m_argParser.add_argument( ARG_BLACKANDWHITE )
71 .flag();
72}
73
74
76{
77 int baseExit = PCB_EXPORT_BASE_COMMAND::doPerform( aKiway );
78 if( baseExit != EXIT_CODES::OK )
79 return baseExit;
80
81 std::unique_ptr<JOB_FP_EXPORT_SVG> svgJob = std::make_unique<JOB_FP_EXPORT_SVG>();
82
83 svgJob->m_libraryPath = m_argInput;
84 svgJob->m_outputDirectory = m_argOutput;
85 svgJob->m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE );
86 svgJob->m_sketchPadsOnFabLayers = m_argParser.get<bool>( ARG_SKETCH_PADS_ON_FAB_LAYERS );
87 svgJob->m_hideDNPFPsOnFabLayers = m_argParser.get<bool>( ARG_HIDE_DNP_FPS_ON_FAB_LAYERS );
88 svgJob->m_sketchDNPFPsOnFabLayers = m_argParser.get<bool>( ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS );
89 svgJob->m_crossoutDNPFPsOnFabLayers = m_argParser.get<bool>( ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS );
90 svgJob->m_footprint = From_UTF8( m_argParser.get<std::string>( ARG_FOOTPRINT ).c_str() );
91 svgJob->SetVarOverrides( m_argDefineVars );
92
93 if( !wxDir::Exists( svgJob->m_libraryPath ) )
94 {
95 wxFprintf( stderr, _( "Footprint library does not exist or is not accessible\n" ) );
97 }
98
99 svgJob->m_colorTheme = From_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
100
101 if( !m_selectedLayers.empty() )
102 svgJob->m_printMaskLayer = m_selectedLayers;
103 else
104 svgJob->m_printMaskLayer = LSET::AllLayersMask().SeqStackupForPlotting();
105
106 int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, svgJob.get() );
107
108 return exitCode;
109}
argparse::ArgumentParser m_argParser
Definition: command.h:100
void addDefineArg()
Set up the drawing sheet arg used by many of the export commands.
Definition: command.cpp:169
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:284
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob)
Definition: kiway.cpp:709
@ FACE_PCB
pcbnew DSO
Definition: kiway.h:292
static LSET AllLayersMask()
Definition: lset.cpp:711
LSEQ SeqStackupForPlotting() const
Return the sequence that is typical for a bottom-to-top stack-up.
Definition: lset.cpp:510
#define UTF8STDSTR(s)
Definition: command.h:27
#define ARG_FOOTPRINT
#define ARG_SKETCH_PADS_ON_FAB_LAYERS_DESC
#define ARG_THEME
#define ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS_DESC
#define ARG_SKETCH_PADS_ON_FAB_LAYERS
#define ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS_DESC
#define ARG_BLACKANDWHITE_DESC
#define ARG_BLACKANDWHITE
#define ARG_CROSSOUT_DNP_FPS_ON_FAB_LAYERS
#define ARG_HIDE_DNP_FPS_ON_FAB_LAYERS
#define ARG_HIDE_DNP_FPS_ON_FAB_LAYERS_DESC
#define ARG_SKETCH_DNP_FPS_ON_FAB_LAYERS
#define _(s)
This file contains miscellaneous commonly used macros and functions.
static const int OK
Definition: exit_codes.h:30
static const int ERR_INVALID_INPUT_FILE
Definition: exit_codes.h:33
wxString From_UTF8(const char *cstring)
int doPerform(KIWAY &aKiway) override
The internal handler that should be overloaded to implement command specific processing and work.