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_METADATA "--exclude-pdf-metadata"
49 const std::string& aDescription,
53 m_plotFormat( aPlotFormat )
61 if( aPlotFormat != SCH_PLOT_FORMAT::HPGL )
64 .default_value( std::string() )
65 .help(
UTF8STDSTR(
_(
"Color theme to use (will default to schematic "
67 .metavar(
"THEME_NAME" );
75 .implicit_value(
true )
76 .default_value(
false );
78 if( aPlotFormat == SCH_PLOT_FORMAT::PDF )
81 .help(
UTF8STDSTR(
_(
"Do not generate property popups in PDF" ) ) )
85 .help(
UTF8STDSTR(
_(
"Do not generate PDF metadata from AUTHOR and SUBJECT variables" ) ) )
89 if( aPlotFormat == SCH_PLOT_FORMAT::PDF
90 || aPlotFormat == SCH_PLOT_FORMAT::POST
91 || aPlotFormat == SCH_PLOT_FORMAT::SVG )
94 .help(
UTF8STDSTR(
_(
"Avoid setting a background color (regardless of theme)" ) ) )
99 .default_value( std::string() )
100 .help(
UTF8STDSTR(
_(
"List of page numbers separated by comma to print, blank or "
101 "unspecified is equivalent to all pages" ) ) )
102 .metavar(
"PAGE_LIST" );
104 if( aPlotFormat == SCH_PLOT_FORMAT::HPGL )
109 .default_value( 0.5 )
110 .metavar(
"PEN_SIZE" );
113 .help(
UTF8STDSTR(
_(
"Origin and scale: 0 bottom left, 1 centered, 2 page fit, 3 "
117 .metavar(
"ORIGIN" );
124 wxString filename = m_argInput;
125 if( !wxFile::Exists( filename ) )
127 wxFprintf( stderr,
_(
"Schematic file does not exist or is not accessible\n" ) );
131 std::vector<wxString> pages;
133 wxStringTokenizer tokenizer( pagesStr,
"," );
134 while( tokenizer.HasMoreTokens() )
136 pages.push_back( tokenizer.GetNextToken().Trim() );
139 std::unique_ptr<JOB_EXPORT_SCH_PLOT> plotJob =
140 std::make_unique<JOB_EXPORT_SCH_PLOT>(
true, m_plotFormat, filename );
142 plotJob->m_plotPages = pages;
144 plotJob->m_pageSizeSelect = JOB_PAGE_SIZE::PAGE_SIZE_AUTO;
146 if( m_plotFormat == SCH_PLOT_FORMAT::PDF
147 || m_plotFormat == SCH_PLOT_FORMAT::POST
148 || m_plotFormat == SCH_PLOT_FORMAT::SVG )
153 if ( m_plotFormat != SCH_PLOT_FORMAT::HPGL )
159 if( m_outputArgExpectsDir )
160 plotJob->m_outputDirectory = m_argOutput;
162 plotJob->m_outputFile = m_argOutput;
164 plotJob->m_plotAll = plotJob->m_plotPages.size() == 0;
166 plotJob->m_drawingSheet = m_argDrawingSheet;
167 plotJob->SetVarOverrides( m_argDefineVars );
170 if( m_plotFormat == SCH_PLOT_FORMAT::HPGL )
172 plotJob->m_HPGLPenSize =
175 if( origin < 0 || origin > 3 )
177 wxFprintf( stderr,
_(
"HPGL origin option must be 0, 1, 2 or 3\n" ) );
183 else if( m_plotFormat == SCH_PLOT_FORMAT::PDF )
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 *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]
#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)