Adds the missing plot formats to `kicad-cli sch export`

This commit is contained in:
Salvador E. Tropea 2023-03-22 02:14:50 +00:00 committed by Marek Roszko
parent fe5c7a60ab
commit 561441b48a
11 changed files with 175 additions and 337 deletions

View File

@ -1,49 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef JOB_EXPORT_SCH_PDF_H
#define JOB_EXPORT_SCH_PDF_H
#include <wx/string.h>
#include "job.h"
class JOB_EXPORT_SCH_PDF : public JOB
{
public:
JOB_EXPORT_SCH_PDF( bool aIsCli ) :
JOB( "pdf", aIsCli ),
m_filename(),
m_outputFile(),
m_blackAndWhite( false ),
m_useBackgroundColor( false ),
m_plotDrawingSheet( false )
{
}
wxString m_filename;
wxString m_outputFile;
wxString m_colorTheme;
bool m_blackAndWhite;
bool m_useBackgroundColor;
bool m_plotDrawingSheet;
};
#endif

View File

@ -18,21 +18,24 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COMMAND_EXPORT_SCH_PDF_H
#define COMMAND_EXPORT_SCH_PDF_H
#ifndef JOB_EXPORT_SCH_PLOT_H
#define JOB_EXPORT_SCH_PLOT_H
#include "command_export_pcb_base.h"
#include <wx/string.h>
#include <plotters/plotter.h>
#include "job.h"
namespace CLI
{
class EXPORT_SCH_PDF_COMMAND : public EXPORT_PCB_BASE_COMMAND
class JOB_EXPORT_SCH_PLOT : public JOB
{
public:
EXPORT_SCH_PDF_COMMAND();
JOB_EXPORT_SCH_PLOT( bool aIsCli, PLOT_FORMAT aPlotFormat, wxString aFilename ) :
JOB( "plot", aIsCli ), m_plotFormat( aPlotFormat ), m_filename( aFilename )
{
}
protected:
int doPerform( KIWAY& aKiway ) override;
PLOT_FORMAT m_plotFormat;
wxString m_filename;
SCH_PLOT_SETTINGS settings;
};
} // namespace CLI
#endif

View File

@ -1,49 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef JOB_EXPORT_SCH_SVG_H
#define JOB_EXPORT_SCH_SVG_H
#include <wx/string.h>
#include "job.h"
class JOB_EXPORT_SCH_SVG : public JOB
{
public:
JOB_EXPORT_SCH_SVG( bool aIsCli ) :
JOB( "svg", aIsCli ),
m_filename(),
m_outputDirectory(),
m_blackAndWhite( false ),
m_useBackgroundColor( false ),
m_plotDrawingSheet( false )
{
}
wxString m_filename;
wxString m_outputDirectory;
wxString m_colorTheme;
bool m_blackAndWhite;
bool m_useBackgroundColor;
bool m_plotDrawingSheet;
};
#endif

View File

@ -19,15 +19,14 @@
*/
#include "eeschema_jobs_handler.h"
#include <pgm_base.h>
#include <cli/exit_codes.h>
#include <sch_plotter.h>
#include <jobs/job_export_sch_pythonbom.h>
#include <jobs/job_export_sch_netlist.h>
#include <jobs/job_export_sch_pdf.h>
#include <jobs/job_export_sch_svg.h>
#include <jobs/job_export_sch_plot.h>
#include <jobs/job_sym_export_svg.h>
#include <jobs/job_sym_upgrade.h>
#include <pgm_base.h>
#include <sch_plotter.h>
#include <schematic.h>
#include <wx/crt.h>
#include <wx/dir.h>
@ -63,10 +62,8 @@ EESCHEMA_JOBS_HANDLER::EESCHEMA_JOBS_HANDLER()
std::bind( &EESCHEMA_JOBS_HANDLER::JobExportPythonBom, this, std::placeholders::_1 ) );
Register( "netlist",
std::bind( &EESCHEMA_JOBS_HANDLER::JobExportNetlist, this, std::placeholders::_1 ) );
Register( "pdf",
std::bind( &EESCHEMA_JOBS_HANDLER::JobExportPdf, this, std::placeholders::_1 ) );
Register( "svg",
std::bind( &EESCHEMA_JOBS_HANDLER::JobExportSvg, this, std::placeholders::_1 ) );
Register( "plot",
std::bind( &EESCHEMA_JOBS_HANDLER::JobExportPlot, this, std::placeholders::_1 ) );
Register( "symupgrade",
std::bind( &EESCHEMA_JOBS_HANDLER::JobSymUpgrade, this, std::placeholders::_1 ) );
Register( "symsvg",
@ -109,14 +106,14 @@ REPORTER& EESCHEMA_JOBS_HANDLER::Report( const wxString& aText, SEVERITY aSeveri
}
int EESCHEMA_JOBS_HANDLER::JobExportPdf( JOB* aJob )
int EESCHEMA_JOBS_HANDLER::JobExportPlot( JOB* aJob )
{
JOB_EXPORT_SCH_PDF* aPdfJob = dynamic_cast<JOB_EXPORT_SCH_PDF*>( aJob );
JOB_EXPORT_SCH_PLOT* aPlotJob = dynamic_cast<JOB_EXPORT_SCH_PLOT*>( aJob );
if( !aPdfJob )
if( !aPlotJob )
return CLI::EXIT_CODES::ERR_UNKNOWN;
SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aPdfJob->m_filename, SCH_IO_MGR::SCH_KICAD );
SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aPlotJob->m_filename, SCH_IO_MGR::SCH_KICAD );
if( sch == nullptr )
{
@ -126,56 +123,10 @@ int EESCHEMA_JOBS_HANDLER::JobExportPdf( JOB* aJob )
std::unique_ptr<KIGFX::SCH_RENDER_SETTINGS> renderSettings =
std::make_unique<KIGFX::SCH_RENDER_SETTINGS>();
InitRenderSettings( renderSettings.get(), aPdfJob->m_colorTheme, sch );
InitRenderSettings( renderSettings.get(), aPlotJob->settings.m_theme, sch );
std::unique_ptr<SCH_PLOTTER> schPlotter = std::make_unique<SCH_PLOTTER>( sch );
SCH_PLOT_SETTINGS settings;
settings.m_plotAll = true;
settings.m_plotDrawingSheet = aPdfJob->m_plotDrawingSheet;
settings.m_blackAndWhite = aPdfJob->m_blackAndWhite;
settings.m_theme = aPdfJob->m_colorTheme;
settings.m_useBackgroundColor = aPdfJob->m_useBackgroundColor;
settings.m_pageSizeSelect = PAGE_SIZE_AUTO;
settings.m_outputFile = aPdfJob->m_outputFile;
schPlotter->Plot( PLOT_FORMAT::PDF, settings, renderSettings.get(), this );
return CLI::EXIT_CODES::OK;
}
int EESCHEMA_JOBS_HANDLER::JobExportSvg( JOB* aJob )
{
JOB_EXPORT_SCH_SVG* aSvgJob = dynamic_cast<JOB_EXPORT_SCH_SVG*>( aJob );
if( !aSvgJob )
return CLI::EXIT_CODES::ERR_UNKNOWN;
SCHEMATIC* sch = EESCHEMA_HELPERS::LoadSchematic( aSvgJob->m_filename, SCH_IO_MGR::SCH_KICAD );
if( sch == nullptr )
{
wxFprintf( stderr, _( "Failed to load schematic file\n" ) );
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
}
std::unique_ptr<KIGFX::SCH_RENDER_SETTINGS> renderSettings =
std::make_unique<KIGFX::SCH_RENDER_SETTINGS>();
InitRenderSettings( renderSettings.get(), aSvgJob->m_colorTheme, sch );
std::unique_ptr<SCH_PLOTTER> schPlotter = std::make_unique<SCH_PLOTTER>( sch );
SCH_PLOT_SETTINGS settings;
settings.m_plotAll = true;
settings.m_plotDrawingSheet = aSvgJob->m_plotDrawingSheet;
settings.m_blackAndWhite = aSvgJob->m_blackAndWhite;
settings.m_theme = aSvgJob->m_colorTheme;
settings.m_pageSizeSelect = PAGE_SIZE_AUTO;
settings.m_outputDirectory = aSvgJob->m_outputDirectory;
settings.m_useBackgroundColor = aSvgJob->m_useBackgroundColor;
schPlotter->Plot( PLOT_FORMAT::SVG, settings, renderSettings.get(), this );
schPlotter->Plot( aPlotJob->m_plotFormat, aPlotJob->settings, renderSettings.get(), this );
return CLI::EXIT_CODES::OK;
}

View File

@ -43,8 +43,7 @@ public:
EESCHEMA_JOBS_HANDLER();
int JobExportPythonBom( JOB* aJob );
int JobExportNetlist( JOB* aJob );
int JobExportPdf( JOB* aJob );
int JobExportSvg( JOB* aJob );
int JobExportPlot( JOB* aJob );
int JobSymUpgrade( JOB* aJob );
int JobSymExportSvg( JOB* aJob );

View File

@ -48,8 +48,7 @@ set( KICAD_CLI_SRCS
cli/command_fp_upgrade.cpp
cli/command_export_sch_pythonbom.cpp
cli/command_export_sch_netlist.cpp
cli/command_export_sch_pdf.cpp
cli/command_export_sch_svg.cpp
cli/command_export_sch_plot.cpp
cli/command_sym_export_svg.cpp
cli/command_sym_upgrade.cpp
cli/command_version.cpp

View File

@ -1,78 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "command_export_sch_pdf.h"
#include <cli/exit_codes.h>
#include "jobs/job_export_sch_pdf.h"
#include <kiface_base.h>
#include <layer_ids.h>
#include <wx/crt.h>
#include <macros.h>
#include <wx/tokenzr.h>
#define ARG_EXCLUDE_DRAWING_SHEET "--exclude-drawing-sheet"
#define ARG_NO_BACKGROUND_COLOR "--no-background-color"
CLI::EXPORT_SCH_PDF_COMMAND::EXPORT_SCH_PDF_COMMAND() : EXPORT_PCB_BASE_COMMAND( "pdf" )
{
m_argParser.add_argument( "-t", ARG_THEME )
.default_value( std::string() )
.help( UTF8STDSTR( _( "Color theme to use (will default to schematic settings)" ) ) );
m_argParser.add_argument( ARG_BLACKANDWHITE )
.help( UTF8STDSTR( _( ARG_BLACKANDWHITE_DESC ) ) )
.implicit_value( true )
.default_value( false );
m_argParser.add_argument( ARG_EXCLUDE_DRAWING_SHEET )
.help( UTF8STDSTR( _( "No drawing sheet" ) ) )
.implicit_value( true )
.default_value( false );
m_argParser.add_argument( ARG_NO_BACKGROUND_COLOR )
.help( UTF8STDSTR( _( "Avoid setting a background color (regardless of theme)" ) ) )
.implicit_value( true )
.default_value( false );
}
int CLI::EXPORT_SCH_PDF_COMMAND::doPerform( KIWAY& aKiway )
{
std::unique_ptr<JOB_EXPORT_SCH_PDF> pdfJob = std::make_unique<JOB_EXPORT_SCH_PDF>( true );
pdfJob->m_filename = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() );
pdfJob->m_outputFile = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
pdfJob->m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE );
pdfJob->m_plotDrawingSheet = !m_argParser.get<bool>( ARG_EXCLUDE_DRAWING_SHEET );
pdfJob->m_useBackgroundColor = !m_argParser.get<bool>( ARG_NO_BACKGROUND_COLOR );
if( !wxFile::Exists( pdfJob->m_filename ) )
{
wxFprintf( stderr, _( "Schematic file does not exist or is not accessible\n" ) );
return EXIT_CODES::ERR_INVALID_INPUT_FILE;
}
pdfJob->m_colorTheme = FROM_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, pdfJob.get() );
return exitCode;
}

View File

@ -0,0 +1,125 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <kiface_base.h>
#include <sch_plotter.h>
#include "command_export_sch_plot.h"
#include <cli/exit_codes.h>
#include "jobs/job_export_sch_plot.h"
#include <layer_ids.h>
#include <wx/crt.h>
#include <macros.h>
#include <wx/tokenzr.h>
#define ARG_EXCLUDE_DRAWING_SHEET "--exclude-drawing-sheet"
#define ARG_NO_BACKGROUND_COLOR "--no-background-color"
#define ARG_PLOT_ONE "--plot-one"
#define ARG_HPGL_PEN_SIZE "--pen-size"
#define ARG_HPGL_ORIGIN "--origin"
const HPGL_PLOT_ORIGIN_AND_UNITS hpgl_origin_ops[4] = {
HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT, HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER,
HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE, HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT
};
CLI::EXPORT_SCH_PLOT_COMMAND::EXPORT_SCH_PLOT_COMMAND( const std::string& aName,
PLOT_FORMAT aPlotFormat,
bool aOutputIsDir ) :
EXPORT_PCB_BASE_COMMAND( aName, aOutputIsDir ),
m_plotFormat( aPlotFormat ), m_useDir( aOutputIsDir )
{
m_argParser.add_argument( "-t", ARG_THEME )
.default_value( std::string() )
.help( UTF8STDSTR( _( "Color theme to use (will default to schematic settings)" ) ) );
m_argParser.add_argument( "-b", ARG_BLACKANDWHITE )
.help( UTF8STDSTR( _( ARG_BLACKANDWHITE_DESC ) ) )
.implicit_value( true )
.default_value( false );
m_argParser.add_argument( "-e", ARG_EXCLUDE_DRAWING_SHEET )
.help( UTF8STDSTR( _( "No drawing sheet" ) ) )
.implicit_value( true )
.default_value( false );
m_argParser.add_argument( "-n", ARG_NO_BACKGROUND_COLOR )
.help( UTF8STDSTR( _( "Avoid setting a background color (regardless of theme)" ) ) )
.implicit_value( true )
.default_value( false );
m_argParser.add_argument( "-O", ARG_PLOT_ONE )
.implicit_value( true )
.default_value( false );
if( aPlotFormat == PLOT_FORMAT::HPGL )
{
m_argParser.add_argument( "-p", ARG_HPGL_PEN_SIZE )
.scan<'g', double>()
.default_value( 0.5 );
m_argParser.add_argument( "-r", ARG_HPGL_ORIGIN )
.scan<'d', int>()
.default_value( 1 );
}
}
int CLI::EXPORT_SCH_PLOT_COMMAND::doPerform( KIWAY& aKiway )
{
wxString filename = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() );
if( !wxFile::Exists( filename ) )
{
wxFprintf( stderr, _( "Schematic file does not exist or is not accessible\n" ) );
return EXIT_CODES::ERR_INVALID_INPUT_FILE;
}
std::unique_ptr<JOB_EXPORT_SCH_PLOT> plotJob =
std::make_unique<JOB_EXPORT_SCH_PLOT>( true, m_plotFormat, filename );
SCH_PLOT_SETTINGS& settings = plotJob->settings;
settings.m_plotAll = !m_argParser.get<bool>( ARG_PLOT_ONE );
settings.m_plotDrawingSheet = !m_argParser.get<bool>( ARG_EXCLUDE_DRAWING_SHEET );
settings.m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE );
settings.m_pageSizeSelect = PAGE_SIZE_AUTO;
settings.m_useBackgroundColor = !m_argParser.get<bool>( ARG_NO_BACKGROUND_COLOR );
settings.m_theme = FROM_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
if( m_useDir )
settings.m_outputDirectory =
FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
else
settings.m_outputFile = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
// HPGL local options
if( m_plotFormat == PLOT_FORMAT::HPGL )
{
settings.m_HPGLPenSize =
m_argParser.get<double>( ARG_HPGL_PEN_SIZE ) * schIUScale.IU_PER_MM;
int origin = m_argParser.get<int>( ARG_HPGL_ORIGIN );
if( origin < 0 || origin > 3 )
{
return EXIT_CODES::ERR_ARGS;
}
settings.m_HPGLPlotOrigin = hpgl_origin_ops[origin];
}
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, plotJob.get() );
return exitCode;
}

View File

@ -18,17 +18,22 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COMMAND_EXPORT_SCH_SVG_H
#define COMMAND_EXPORT_SCH_SVG_H
#ifndef COMMAND_EXPORT_SCH_PLOT_H
#define COMMAND_EXPORT_SCH_PLOT_H
#include "command_export_pcb_base.h"
#include <plotters/plotter.h>
namespace CLI
{
class EXPORT_SCH_SVG_COMMAND : public EXPORT_PCB_BASE_COMMAND
class EXPORT_SCH_PLOT_COMMAND : public EXPORT_PCB_BASE_COMMAND
{
public:
EXPORT_SCH_SVG_COMMAND();
EXPORT_SCH_PLOT_COMMAND( const std::string& aName, PLOT_FORMAT aPlotFormat,
bool aOutputIsDir = true );
PLOT_FORMAT m_plotFormat;
bool m_useDir;
protected:
int doPerform( KIWAY& aKiway ) override;

View File

@ -1,78 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "command_export_sch_svg.h"
#include <cli/exit_codes.h>
#include "jobs/job_export_sch_svg.h"
#include <kiface_base.h>
#include <layer_ids.h>
#include <wx/crt.h>
#include <macros.h>
#include <wx/tokenzr.h>
#define ARG_EXCLUDE_DRAWING_SHEET "--exclude-drawing-sheet"
#define ARG_NO_BACKGROUND_COLOR "--no-background-color"
CLI::EXPORT_SCH_SVG_COMMAND::EXPORT_SCH_SVG_COMMAND() : EXPORT_PCB_BASE_COMMAND( "svg", true )
{
m_argParser.add_argument( "-t", ARG_THEME )
.default_value( std::string() )
.help( UTF8STDSTR( _( "Color theme to use (will default to pcbnew settings)" ) ) );
m_argParser.add_argument( ARG_BLACKANDWHITE )
.help( UTF8STDSTR( _( ARG_BLACKANDWHITE_DESC ) ) )
.implicit_value( true )
.default_value( false );
m_argParser.add_argument( ARG_EXCLUDE_DRAWING_SHEET )
.help( UTF8STDSTR( _( "No drawing sheet" ) ) )
.implicit_value( true )
.default_value( false );
m_argParser.add_argument( ARG_NO_BACKGROUND_COLOR )
.help( UTF8STDSTR( _( "Avoid setting a background color (regardless of theme)" ) ) )
.implicit_value( true )
.default_value( false );
}
int CLI::EXPORT_SCH_SVG_COMMAND::doPerform( KIWAY& aKiway )
{
std::unique_ptr<JOB_EXPORT_SCH_SVG> svgJob = std::make_unique<JOB_EXPORT_SCH_SVG>( true );
svgJob->m_filename = FROM_UTF8( m_argParser.get<std::string>( ARG_INPUT ).c_str() );
svgJob->m_outputDirectory = FROM_UTF8( m_argParser.get<std::string>( ARG_OUTPUT ).c_str() );
svgJob->m_blackAndWhite = m_argParser.get<bool>( ARG_BLACKANDWHITE );
svgJob->m_plotDrawingSheet = !m_argParser.get<bool>( ARG_EXCLUDE_DRAWING_SHEET );
svgJob->m_useBackgroundColor = !m_argParser.get<bool>( ARG_NO_BACKGROUND_COLOR );
if( !wxFile::Exists( svgJob->m_filename ) )
{
wxFprintf( stderr, _( "Schematic file does not exist or is not accessible\n" ) );
return EXIT_CODES::ERR_INVALID_INPUT_FILE;
}
svgJob->m_colorTheme = FROM_UTF8( m_argParser.get<std::string>( ARG_THEME ).c_str() );
int exitCode = aKiway.ProcessJob( KIWAY::FACE_SCH, svgJob.get() );
return exitCode;
}

View File

@ -46,6 +46,7 @@
#include <build_version.h>
#include <kiplatform/app.h>
#include <kiplatform/environment.h>
#include <locale_io.h>
#include "cli/command_pcb.h"
#include "cli/command_pcb_export.h"
@ -59,8 +60,7 @@
#include "cli/command_export_pcb_step.h"
#include "cli/command_export_sch_pythonbom.h"
#include "cli/command_export_sch_netlist.h"
#include "cli/command_export_sch_pdf.h"
#include "cli/command_export_sch_svg.h"
#include "cli/command_export_sch_plot.h"
#include "cli/command_fp.h"
#include "cli/command_fp_export.h"
#include "cli/command_fp_export_svg.h"
@ -136,8 +136,11 @@ static CLI::EXPORT_SCH_COMMAND exportSchCmd{};
static CLI::SCH_COMMAND schCmd{};
static CLI::EXPORT_SCH_PYTHONBOM_COMMAND exportSchPythonBomCmd{};
static CLI::EXPORT_SCH_NETLIST_COMMAND exportSchNetlistCmd{};
static CLI::EXPORT_SCH_PDF_COMMAND exportSchPdfCmd{};
static CLI::EXPORT_SCH_SVG_COMMAND exportSchSvgCmd{};
static CLI::EXPORT_SCH_PLOT_COMMAND exportSchDxfCmd{ "dxf", PLOT_FORMAT::DXF };
static CLI::EXPORT_SCH_PLOT_COMMAND exportSchHpglCmd{ "hpgl", PLOT_FORMAT::HPGL };
static CLI::EXPORT_SCH_PLOT_COMMAND exportSchPdfCmd{ "pdf", PLOT_FORMAT::PDF, false };
static CLI::EXPORT_SCH_PLOT_COMMAND exportSchPostscriptCmd{ "ps", PLOT_FORMAT::POST };
static CLI::EXPORT_SCH_PLOT_COMMAND exportSchSvgCmd{ "svg", PLOT_FORMAT::SVG };
static CLI::FP_COMMAND fpCmd{};
static CLI::FP_EXPORT_COMMAND fpExportCmd{};
static CLI::FP_EXPORT_SVG_COMMAND fpExportSvgCmd{};
@ -188,8 +191,11 @@ static std::vector<COMMAND_ENTRY> commandStack = {
{
&exportSchCmd,
{
&exportSchDxfCmd,
&exportSchHpglCmd,
&exportSchNetlistCmd,
&exportSchPdfCmd,
&exportSchPostscriptCmd,
&exportSchPythonBomCmd,
&exportSchSvgCmd
}
@ -311,9 +317,13 @@ int PGM_KICAD::OnPgmRun()
try
{
// Use the C locale to parse arguments
// Otherwise the decimal separator for the locale will be applied
LOCALE_IO dummy;
argParser.parse_args( m_argcUtf8, m_argvUtf8 );
}
catch( const std::runtime_error& err )
// std::runtime_error doesn't seem to be enough for the scan<>()
catch( const std::exception& err )
{
wxPrintf( "%s\n", err.what() );