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_PAGES "--pages"
37#define ARG_EXCLUDE_PDF_PROPERTY_POPUPS "--exclude-pdf-property-popups"
38#define ARG_EXCLUDE_PDF_HIERARCHICAL_LINKS "--exclude-pdf-hierarchical-links"
39#define ARG_EXCLUDE_PDF_METADATA "--exclude-pdf-metadata"
40#define ARG_FONT_NAME "--default-font"
41#define ARG_DRAW_HOP_OVER "--draw-hop-over"
43#define DEPRECATED_ARG_HPGL_PEN_SIZE "--pen-size"
44#define DEPRECATED_ARG_HPGL_ORIGIN "--origin"
47 const std::string& aDescription,
51 m_plotFormat( aPlotFormat )
60 .default_value( std::string() )
61 .help(
UTF8STDSTR(
_(
"Color theme to use (will default to schematic settings)" ) ) )
62 .metavar(
"THEME_NAME" );
69 .implicit_value(
true )
70 .default_value(
false );
74 .default_value( wxString(
"" ).ToStdString() );
77 .help(
UTF8STDSTR(
_(
"Draw hop over at wire crossings" ) ) )
78 .implicit_value(
true )
79 .default_value(
false );
81 if( aPlotFormat == SCH_PLOT_FORMAT::PDF )
84 .help(
UTF8STDSTR(
_(
"Do not generate property popups in PDF" ) ) )
88 .help(
UTF8STDSTR(
_(
"Do not generate clickable links for hierarchical elements in PDF" ) ) )
92 .help(
UTF8STDSTR(
_(
"Do not generate PDF metadata from AUTHOR and SUBJECT variables" ) ) )
96 if( aPlotFormat == SCH_PLOT_FORMAT::PDF
97 || aPlotFormat == SCH_PLOT_FORMAT::POST
98 || aPlotFormat == SCH_PLOT_FORMAT::SVG )
101 .help(
UTF8STDSTR(
_(
"Avoid setting a background color (regardless of theme)" ) ) )
106 .default_value( std::string() )
107 .help(
UTF8STDSTR(
_(
"List of page numbers separated by comma to print, blank or "
108 "unspecified is equivalent to all pages" ) ) )
109 .metavar(
"PAGE_LIST" );
111 if( aPlotFormat == SCH_PLOT_FORMAT::HPGL )
114 .help(
UTF8STDSTR(
_(
"Deprecated. Has no effect." ) ) )
116 .default_value( 0.5 )
117 .metavar(
"PEN_SIZE" );
120 .help(
UTF8STDSTR(
_(
"Deprecated. Has no effect." ) ) )
123 .metavar(
"ORIGIN" );
130 if( m_plotFormat == SCH_PLOT_FORMAT::HPGL )
132 wxFprintf( stderr,
_(
"Plotting to HPGL is no longer supported as of KiCad 10.0.\n" ) );
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:
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;
170 if( m_plotFormat == SCH_PLOT_FORMAT::PDF
171 || m_plotFormat == SCH_PLOT_FORMAT::POST
172 || m_plotFormat == SCH_PLOT_FORMAT::SVG )
180 plotJob->SetConfiguredOutputPath( m_argOutput );
182 plotJob->m_plotAll = plotJob->m_plotPages.size() == 0;
184 plotJob->m_drawingSheet = m_argDrawingSheet;
185 plotJob->SetVarOverrides( m_argDefineVars );
188 if( m_plotFormat == SCH_PLOT_FORMAT::PDF )
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 DEPRECATED_ARG_HPGL_ORIGIN
#define ARG_EXCLUDE_PDF_HIERARCHICAL_LINKS
#define ARG_DRAW_HOP_OVER
#define DEPRECATED_ARG_HPGL_PEN_SIZE
#define ARG_EXCLUDE_PDF_METADATA
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)