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"
48 const std::string& aDescription,
52 m_plotFormat( aPlotFormat )
60 if( aPlotFormat != SCH_PLOT_FORMAT::HPGL )
63 .default_value( std::string() )
64 .help(
UTF8STDSTR(
_(
"Color theme to use (will default to schematic settings)" ) ) )
65 .metavar(
"THEME_NAME" );
68 .implicit_value(
true )
69 .default_value(
false );
74 .implicit_value(
true )
75 .default_value(
false );
77 if( aPlotFormat == SCH_PLOT_FORMAT::PDF )
80 .help(
UTF8STDSTR(
_(
"Do not generate property popups in PDF" ) ) )
81 .implicit_value(
true )
82 .default_value(
false );
85 if( aPlotFormat == SCH_PLOT_FORMAT::PDF
86 || aPlotFormat == SCH_PLOT_FORMAT::POST
87 || aPlotFormat == SCH_PLOT_FORMAT::SVG )
90 .help(
UTF8STDSTR(
_(
"Avoid setting a background color (regardless of theme)" ) ) )
91 .implicit_value(
true )
92 .default_value(
false );
96 .default_value( std::string() )
97 .help(
UTF8STDSTR(
_(
"List of page numbers separated by comma to print, blank or unspecified is equivalent to all pages" ) ) )
98 .metavar(
"PAGE_LIST" );
100 if( aPlotFormat == SCH_PLOT_FORMAT::HPGL )
105 .default_value( 0.5 )
106 .metavar(
"PEN_SIZE" );
109 .help(
UTF8STDSTR(
_(
"Origin and scale: 0 bottom left, 1 centered, 2 page fit, 3 "
113 .metavar(
"ORIGIN" );
120 wxString filename = m_argInput;
121 if( !wxFile::Exists( filename ) )
123 wxFprintf( stderr,
_(
"Schematic file does not exist or is not accessible\n" ) );
127 std::vector<wxString> pages;
129 wxStringTokenizer tokenizer( pagesStr,
"," );
130 while( tokenizer.HasMoreTokens() )
132 pages.push_back( tokenizer.GetNextToken().Trim() );
135 std::unique_ptr<JOB_EXPORT_SCH_PLOT> plotJob =
136 std::make_unique<JOB_EXPORT_SCH_PLOT>(
true, m_plotFormat, filename );
138 plotJob->m_plotPages = pages;
140 plotJob->m_pageSizeSelect = JOB_PAGE_SIZE::PAGE_SIZE_AUTO;
142 if( m_plotFormat == SCH_PLOT_FORMAT::PDF
143 || m_plotFormat == SCH_PLOT_FORMAT::POST
144 || m_plotFormat == SCH_PLOT_FORMAT::SVG )
149 if ( m_plotFormat != SCH_PLOT_FORMAT::HPGL )
155 if( m_outputArgExpectsDir )
156 plotJob->m_outputDirectory = m_argOutput;
158 plotJob->m_outputFile = m_argOutput;
160 plotJob->m_plotAll = plotJob->m_plotPages.size() == 0;
162 plotJob->m_drawingSheet = m_argDrawingSheet;
163 plotJob->SetVarOverrides( m_argDefineVars );
166 if( m_plotFormat == SCH_PLOT_FORMAT::HPGL )
168 plotJob->m_HPGLPenSize =
171 if( origin < 0 || origin > 3 )
173 wxFprintf( stderr,
_(
"HPGL origin option must be 0, 1, 2 or 3\n" ) );
179 else if( m_plotFormat == SCH_PLOT_FORMAT::PDF )
constexpr EDA_IU_SCALE schIUScale
argparse::ArgumentParser m_argParser
void addDefineArg()
Sets up the drawing sheet arg used by many of the export commands.
void addCommonArgs(bool aInput, bool aOutput, bool aInputIsDir, bool aOutputIsDir)
Sets up the most common of args used across cli.
void addDrawingSheetArg()
Sets 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 *job)
#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_HPGL_PEN_SIZE
const JOB_HPGL_PLOT_ORIGIN_AND_UNITS hpgl_origin_ops[4]
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)