KiCad PCB EDA Suite
Loading...
Searching...
No Matches
command_pcb_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) 2016 Cirilo Bernardo <[email protected]>
6 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
23#include <cli/exit_codes.h>
26#include <kiface_base.h>
27#include <layer_ids.h>
28#include <string_utils.h>
29#include <regex>
30#include <wx/crt.h>
31
32
33#define ARG_EXCLUDE_DRAWING_SHEET "--exclude-drawing-sheet"
34#define ARG_PAGE_SIZE "--page-size-mode"
35
36
38{
39 m_argParser.add_description( UTF8STDSTR( _( "Generate SVG outputs of a given layer list" ) ) );
40
41 addLayerArg( true );
44
45 m_argParser.add_argument( "-m", ARG_MIRROR )
46 .help( UTF8STDSTR( _( "Mirror the board (useful for trying to show bottom layers)" ) ) )
47 .flag();
48
49 m_argParser.add_argument( "-t", ARG_THEME )
50 .default_value( std::string() )
51 .help( UTF8STDSTR( _( "Color theme to use (will default to PCB editor settings)" ) ) )
52 .metavar( "THEME_NAME" );
53
55 .help( UTF8STDSTR( _( ARG_NEGATIVE_DESC ) ) )
56 .flag();
57
58 m_argParser.add_argument( ARG_BLACKANDWHITE )
60 .flag();
61
62 m_argParser.add_argument( "--sp", ARG_SKETCH_PADS_ON_FAB_LAYERS )
64 .flag();
65
66 m_argParser.add_argument( ARG_PAGE_SIZE )
67 .help( UTF8STDSTR( _( "Set page sizing mode (0 = page with frame and title block, 1 = "
68 "current page size, 2 = board area only)" ) ) )
69 .scan<'i', int>()
70 .default_value( 0 )
71 .metavar( "MODE" );
72
74 .help( UTF8STDSTR( _( "No drawing sheet" ) ) )
75 .flag();
76
79 .scan<'i', int>()
80 .default_value( 2 )
81 .metavar( "SHAPE_OPTION" );
82}
83
84
86{
87 int baseExit = PCB_EXPORT_BASE_COMMAND::doPerform( aKiway );
88 if( baseExit != EXIT_CODES::OK )
89 return baseExit;
90
91 std::unique_ptr<JOB_EXPORT_PCB_SVG> svgJob( new JOB_EXPORT_PCB_SVG( true ) );
92
93 svgJob->m_mirror = m_argParser.get<bool>( ARG_MIRROR );
94 svgJob->m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE );
95 svgJob->m_pageSizeMode = m_argParser.get<int>( ARG_PAGE_SIZE );
96 svgJob->m_negative = m_argParser.get<bool>( ARG_NEGATIVE );
97 svgJob->m_sketchPadsOnFabLayers = m_argParser.get<bool>( ARG_SKETCH_PADS_ON_FAB_LAYERS );
98 svgJob->m_drillShapeOption = m_argParser.get<int>( ARG_DRILL_SHAPE_OPTION );
99 svgJob->m_drawingSheet = m_argDrawingSheet;
100
101 svgJob->m_filename = m_argInput;
102 svgJob->m_outputFile = m_argOutput;
103 svgJob->m_colorTheme = From_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
104 svgJob->m_plotDrawingSheet = !m_argParser.get<bool>( ARG_EXCLUDE_DRAWING_SHEET );
105 svgJob->SetVarOverrides( m_argDefineVars );
106
107 if( !wxFile::Exists( svgJob->m_filename ) )
108 {
109 wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) );
111 }
112
113 svgJob->m_printMaskLayer = m_selectedLayers;
114
115 int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, svgJob.get() );
116
117 return exitCode;
118}
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
void addDrawingSheetArg()
Set up the drawing sheet arg used by many of the export commands.
Definition: command.cpp:157
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:709
@ FACE_PCB
pcbnew DSO
Definition: kiway.h:287
#define UTF8STDSTR(s)
Definition: command.h:27
#define ARG_SKETCH_PADS_ON_FAB_LAYERS_DESC
#define ARG_THEME
#define ARG_NEGATIVE
#define ARG_SKETCH_PADS_ON_FAB_LAYERS
#define ARG_BLACKANDWHITE_DESC
#define ARG_NEGATIVE_SHORT
#define ARG_BLACKANDWHITE
#define ARG_MIRROR
#define ARG_DRILL_SHAPE_OPTION_DESC
#define ARG_DRILL_SHAPE_OPTION
#define ARG_NEGATIVE_DESC
#define ARG_PAGE_SIZE
#define ARG_EXCLUDE_DRAWING_SHEET
#define _(s)
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.
int doPerform(KIWAY &aKiway) override
The internal handler that should be overloaded to implement command specific processing and work.