32#include <wx/tokenzr.h>
34#define ARG_EXCLUDE_DRAWING_SHEET "--exclude-drawing-sheet"
35#define ARG_NO_BACKGROUND_COLOR "--no-background-color"
36#define ARG_HPGL_PEN_SIZE "--pen-size"
37#define ARG_HPGL_ORIGIN "--origin"
38#define ARG_PAGES "--pages"
39#define ARG_EXCLUDE_PDF_PROPERTY_POPUPS "--exclude-pdf-property-popups"
40#define ARG_EXCLUDE_PDF_HIERARCHICAL_LINKS "--exclude-pdf-hierarchical-links"
41#define ARG_EXCLUDE_PDF_METADATA "--exclude-pdf-metadata"
42#define ARG_FONT_NAME "--default-font"
52 const std::string& aDescription,
56 m_plotFormat( aPlotFormat )
64 if( aPlotFormat != SCH_PLOT_FORMAT::HPGL )
67 .default_value( std::string() )
68 .help(
UTF8STDSTR(
_(
"Color theme to use (will default to schematic "
70 .metavar(
"THEME_NAME" );
78 .implicit_value(
true )
79 .default_value(
false );
85 if( aPlotFormat == SCH_PLOT_FORMAT::PDF )
88 .help(
UTF8STDSTR(
_(
"Do not generate property popups in PDF" ) ) )
92 .help(
UTF8STDSTR(
_(
"Do not generate clickable links for hierarchical elements "
97 .help(
UTF8STDSTR(
_(
"Do not generate PDF metadata from AUTHOR and SUBJECT variables" ) ) )
101 if( aPlotFormat == SCH_PLOT_FORMAT::PDF
102 || aPlotFormat == SCH_PLOT_FORMAT::POST
103 || aPlotFormat == SCH_PLOT_FORMAT::SVG )
106 .help(
UTF8STDSTR(
_(
"Avoid setting a background color (regardless of theme)" ) ) )
111 .default_value( std::string() )
112 .help(
UTF8STDSTR(
_(
"List of page numbers separated by comma to print, blank or "
113 "unspecified is equivalent to all pages" ) ) )
114 .metavar(
"PAGE_LIST" );
116 if( aPlotFormat == SCH_PLOT_FORMAT::HPGL )
121 .default_value( 0.5 )
122 .metavar(
"PEN_SIZE" );
125 .help(
UTF8STDSTR(
_(
"Origin and scale: 0 bottom left, 1 centered, 2 page fit, 3 "
129 .metavar(
"ORIGIN" );
136 wxString filename = m_argInput;
138 if( !wxFile::Exists( filename ) )
140 wxFprintf( stderr,
_(
"Schematic file does not exist or is not accessible\n" ) );
144 std::vector<wxString> pages;
146 wxStringTokenizer tokenizer( pagesStr,
"," );
148 while( tokenizer.HasMoreTokens() )
149 pages.push_back( tokenizer.GetNextToken().Trim() );
151 std::unique_ptr<JOB_EXPORT_SCH_PLOT> plotJob;
153 switch( m_plotFormat )
155 case SCH_PLOT_FORMAT::PDF: plotJob = std::make_unique<JOB_EXPORT_SCH_PLOT_PDF>(
false );
break;
156 case SCH_PLOT_FORMAT::DXF: plotJob = std::make_unique<JOB_EXPORT_SCH_PLOT_DXF>();
break;
157 case SCH_PLOT_FORMAT::SVG: plotJob = std::make_unique<JOB_EXPORT_SCH_PLOT_SVG>();
break;
158 case SCH_PLOT_FORMAT::POST: plotJob = std::make_unique<JOB_EXPORT_SCH_PLOT_PS>();
break;
159 case SCH_PLOT_FORMAT::HPGL: plotJob = std::make_unique<JOB_EXPORT_SCH_PLOT_HPGL>();
break;
162 plotJob->m_filename = filename;
163 plotJob->m_plotFormat = m_plotFormat;
164 plotJob->m_plotPages = pages;
166 plotJob->m_pageSizeSelect = JOB_PAGE_SIZE::PAGE_SIZE_AUTO;
169 if( m_plotFormat == SCH_PLOT_FORMAT::PDF
170 || m_plotFormat == SCH_PLOT_FORMAT::POST
171 || m_plotFormat == SCH_PLOT_FORMAT::SVG )
176 if ( m_plotFormat != SCH_PLOT_FORMAT::HPGL )
182 plotJob->SetConfiguredOutputPath( m_argOutput );
184 plotJob->m_plotAll = plotJob->m_plotPages.size() == 0;
186 plotJob->m_drawingSheet = m_argDrawingSheet;
187 plotJob->SetVarOverrides( m_argDefineVars );
190 if( m_plotFormat == SCH_PLOT_FORMAT::HPGL )
192 plotJob->m_HPGLPenSize =
195 if( origin < 0 || origin > 3 )
197 wxFprintf( stderr,
_(
"HPGL origin option must be 0, 1, 2 or 3\n" ) );
203 else if( m_plotFormat == SCH_PLOT_FORMAT::PDF )
206 plotJob->m_PDFHierarchicalLinks =
constexpr EDA_IU_SCALE schIUScale
void addCommonArgs(bool aInput, bool aOutput, bool aInputCanBeDir, bool aOutputIsDir)
Set up the most common of args used across cli.
argparse::ArgumentParser m_argParser
void addDefineArg()
Set up the drawing sheet arg used by many of the export commands.
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, REPORTER *aReporter=nullptr)
#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)