31#include <wx/tokenzr.h>
33#define ARG_EXCLUDE_DRAWING_SHEET "--exclude-drawing-sheet"
34#define ARG_NO_BACKGROUND_COLOR "--no-background-color"
35#define ARG_HPGL_PEN_SIZE "--pen-size"
36#define ARG_HPGL_ORIGIN "--origin"
37#define ARG_PAGES "--pages"
38#define ARG_EXCLUDE_PDF_PROPERTY_POPUPS "--exclude-pdf-property-popups"
39#define ARG_EXCLUDE_PDF_HIERARCHICAL_LINKS "--exclude-pdf-hierarchical-links"
40#define ARG_EXCLUDE_PDF_METADATA "--exclude-pdf-metadata"
50 const std::string& aDescription,
54 m_plotFormat( aPlotFormat )
62 if( aPlotFormat != SCH_PLOT_FORMAT::HPGL )
65 .default_value( std::string() )
66 .help(
UTF8STDSTR(
_(
"Color theme to use (will default to schematic "
68 .metavar(
"THEME_NAME" );
76 .implicit_value(
true )
77 .default_value(
false );
79 if( aPlotFormat == SCH_PLOT_FORMAT::PDF )
82 .help(
UTF8STDSTR(
_(
"Do not generate property popups in PDF" ) ) )
86 .help(
UTF8STDSTR(
_(
"Do not generate clickable links for hierarchical elements "
91 .help(
UTF8STDSTR(
_(
"Do not generate PDF metadata from AUTHOR and SUBJECT variables" ) ) )
95 if( aPlotFormat == SCH_PLOT_FORMAT::PDF
96 || aPlotFormat == SCH_PLOT_FORMAT::POST
97 || aPlotFormat == SCH_PLOT_FORMAT::SVG )
100 .help(
UTF8STDSTR(
_(
"Avoid setting a background color (regardless of theme)" ) ) )
105 .default_value( std::string() )
106 .help(
UTF8STDSTR(
_(
"List of page numbers separated by comma to print, blank or "
107 "unspecified is equivalent to all pages" ) ) )
108 .metavar(
"PAGE_LIST" );
110 if( aPlotFormat == SCH_PLOT_FORMAT::HPGL )
115 .default_value( 0.5 )
116 .metavar(
"PEN_SIZE" );
119 .help(
UTF8STDSTR(
_(
"Origin and scale: 0 bottom left, 1 centered, 2 page fit, 3 "
123 .metavar(
"ORIGIN" );
130 wxString filename = m_argInput;
131 if( !wxFile::Exists( filename ) )
133 wxFprintf( stderr,
_(
"Schematic file does not exist or is not accessible\n" ) );
137 std::vector<wxString> pages;
139 wxStringTokenizer tokenizer( pagesStr,
"," );
140 while( tokenizer.HasMoreTokens() )
142 pages.push_back( tokenizer.GetNextToken().Trim() );
145 std::unique_ptr<JOB_EXPORT_SCH_PLOT> plotJob =
146 std::make_unique<JOB_EXPORT_SCH_PLOT>();
147 plotJob->m_filename = filename;
148 plotJob->m_plotFormat = m_plotFormat;
149 plotJob->m_plotPages = pages;
151 plotJob->m_pageSizeSelect = JOB_PAGE_SIZE::PAGE_SIZE_AUTO;
153 if( m_plotFormat == SCH_PLOT_FORMAT::PDF
154 || m_plotFormat == SCH_PLOT_FORMAT::POST
155 || m_plotFormat == SCH_PLOT_FORMAT::SVG )
160 if ( m_plotFormat != SCH_PLOT_FORMAT::HPGL )
166 if( m_outputArgExpectsDir )
167 plotJob->m_outputDirectory = m_argOutput;
169 plotJob->m_outputFile = m_argOutput;
171 plotJob->m_plotAll = plotJob->m_plotPages.size() == 0;
173 plotJob->m_drawingSheet = m_argDrawingSheet;
174 plotJob->SetVarOverrides( m_argDefineVars );
177 if( m_plotFormat == SCH_PLOT_FORMAT::HPGL )
179 plotJob->m_HPGLPenSize =
182 if( origin < 0 || origin > 3 )
184 wxFprintf( stderr,
_(
"HPGL origin option must be 0, 1, 2 or 3\n" ) );
190 else if( m_plotFormat == SCH_PLOT_FORMAT::PDF )
193 plotJob->m_PDFHierarchicalLinks =
constexpr EDA_IU_SCALE schIUScale
argparse::ArgumentParser m_argParser
void addDefineArg()
Set up the drawing sheet arg used by many of the export commands.
void addCommonArgs(bool aInput, bool aOutput, bool aInputIsDir, bool aOutputIsDir)
Set up the most common of args used across cli.
void addDrawingSheetArg()
Set up the drawing sheet arg used by many of the export commands.
int doPerform(KIWAY &aKiway) override
The internal handler that should be overloaded to implement command specific processing and work.
SCH_EXPORT_PLOT_COMMAND(const std::string &aName, const std::string &aDescription, SCH_PLOT_FORMAT aPlotFormat, bool aOutputIsDir=true)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
int ProcessJob(KIWAY::FACE_T aFace, JOB *aJob)
#define ARG_BLACKANDWHITE_DESC
#define ARG_BLACKANDWHITE
#define ARG_EXCLUDE_DRAWING_SHEET
#define ARG_EXCLUDE_PDF_PROPERTY_POPUPS
#define ARG_NO_BACKGROUND_COLOR
#define ARG_EXCLUDE_PDF_HIERARCHICAL_LINKS
#define ARG_HPGL_PEN_SIZE
const JOB_HPGL_PLOT_ORIGIN_AND_UNITS hpgl_origin_ops[4]
#define ARG_EXCLUDE_PDF_METADATA
JOB_HPGL_PLOT_ORIGIN_AND_UNITS
This file contains miscellaneous commonly used macros and functions.
static const int ERR_ARGS
static const int ERR_INVALID_INPUT_FILE
wxString From_UTF8(const char *cstring)