7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 14:31:42 +00:00

Deprecate and support using the more normal "plot" logic for dxf and svg.

This commit is contained in:
Marek Roszko 2024-12-31 23:07:50 -05:00
parent cad0e3fc27
commit 8f750baa79
11 changed files with 329 additions and 213 deletions

View File

@ -22,6 +22,12 @@
#include <jobs/job_registry.h>
#include <i18n_utility.h>
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_DXF::GEN_MODE,
{
{ JOB_EXPORT_PCB_DXF::GEN_MODE::DEPRECATED, "deprecated" },
{ JOB_EXPORT_PCB_DXF::GEN_MODE::NEW, "new" },
} )
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_DXF::DXF_UNITS,
{
{ JOB_EXPORT_PCB_DXF::DXF_UNITS::INCHES, "in" },
@ -31,13 +37,19 @@ NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_DXF::DXF_UNITS,
JOB_EXPORT_PCB_DXF::JOB_EXPORT_PCB_DXF() :
JOB_EXPORT_PCB_PLOT( JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::DXF, "dxf", false ),
m_plotGraphicItemsUsingContours( true ),
m_dxfUnits( DXF_UNITS::INCHES )
m_polygonMode( true ),
m_dxfUnits( DXF_UNITS::INCHES ),
m_genMode( GEN_MODE::NEW )
{
m_plotDrawingSheet = false;
m_params.emplace_back(
new JOB_PARAM<bool>( "plot_footprint_values", &m_plotFootprintValues, m_plotFootprintValues ) );
m_params.emplace_back( new JOB_PARAM<bool>( "plot_graphic_items_using_contours", &m_plotGraphicItemsUsingContours,
m_plotGraphicItemsUsingContours ) );
m_params.emplace_back( new JOB_PARAM<DXF_UNITS>( "units", &m_dxfUnits, m_dxfUnits ) );
m_params.emplace_back( new JOB_PARAM<bool>( "polygon_mode", &m_polygonMode, m_polygonMode ) );
m_params.emplace_back( new JOB_PARAM<GEN_MODE>( "gen_mode", &m_genMode, m_genMode ) );
}

View File

@ -40,8 +40,17 @@ public:
MILLIMETERS
};
bool m_plotGraphicItemsUsingContours;
enum class GEN_MODE
{
DEPRECATED,
NEW
};
bool m_plotGraphicItemsUsingContours;
bool m_polygonMode;
DXF_UNITS m_dxfUnits;
GEN_MODE m_genMode;
};
#endif

View File

@ -42,6 +42,8 @@ JOB_EXPORT_PCB_PDF::JOB_EXPORT_PCB_PDF() :
m_pdfBackFPPropertyPopups( true ),
m_pdfMetadata( true ), m_pdfSingle( false ), m_pdfGenMode( GEN_MODE::ALL_LAYERS_ONE_FILE )
{
m_plotDrawingSheet = false;
m_params.emplace_back( new JOB_PARAM<wxString>( "color_theme", &m_colorTheme, m_colorTheme ) );
m_params.emplace_back( new JOB_PARAM<bool>( "mirror", &m_mirror, m_mirror ) );
m_params.emplace_back(

View File

@ -22,11 +22,17 @@
#include <jobs/job_registry.h>
#include <i18n_utility.h>
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_SVG::GEN_MODE,
{
{ JOB_EXPORT_PCB_SVG::GEN_MODE::DEPRECATED, "deprecated" },
{ JOB_EXPORT_PCB_SVG::GEN_MODE::NEW, "new" },
} )
JOB_EXPORT_PCB_SVG::JOB_EXPORT_PCB_SVG() :
JOB_EXPORT_PCB_PLOT( JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::SVG, "svg", false ),
m_pageSizeMode( 0 ),
m_precision( 4 )
m_precision( 4 ),
m_genMode( GEN_MODE::NEW )
{
m_plotDrawingSheet = true;
@ -42,6 +48,8 @@ JOB_EXPORT_PCB_SVG::JOB_EXPORT_PCB_SVG() :
m_params.emplace_back(
new JOB_PARAM<DRILL_MARKS>( "drill_shape", &m_drillShapeOption, m_drillShapeOption ) );
m_params.emplace_back( new JOB_PARAM<unsigned int>( "precision", &m_precision, m_precision ) );
m_params.emplace_back( new JOB_PARAM<GEN_MODE>( "gen_mode", &m_genMode, m_genMode ) );
}

View File

@ -36,6 +36,14 @@ public:
int m_pageSizeMode;
unsigned int m_precision;
enum class GEN_MODE
{
DEPRECATED,
NEW
};
GEN_MODE m_genMode;
};
#endif

View File

@ -34,6 +34,7 @@
#define ARG_USE_CONTOURS "--use-contours"
#define ARG_OUTPUT_UNITS "--output-units"
#define ARG_USE_DRILL_ORIGIN "--use-drill-origin"
#define ARG_MODE_NEW "--mode-new"
CLI::PCB_EXPORT_DXF_COMMAND::PCB_EXPORT_DXF_COMMAND() : PCB_EXPORT_BASE_COMMAND( "dxf" )
{
@ -67,6 +68,20 @@ CLI::PCB_EXPORT_DXF_COMMAND::PCB_EXPORT_DXF_COMMAND() : PCB_EXPORT_BASE_COMMAND(
.default_value( std::string( "in" ) )
.help( UTF8STDSTR( _( "Output units, valid options: mm, in" ) ) )
.metavar( "UNITS" );
m_argParser.add_argument( "--cl", ARG_COMMON_LAYERS )
.default_value( std::string() )
.help( UTF8STDSTR(
_( "Layers to include on each plot, comma separated list of untranslated "
"layer names to include such as "
"F.Cu,B.Cu" ) ) )
.metavar( "COMMON_LAYER_LIST" );
m_argParser.add_argument( ARG_MODE_NEW )
.help( UTF8STDSTR(
_( "Opt into the new behavior which means output path is a directory, a file "
"per layer is generated and the common layers arg becomes available. " ) ) )
.flag();
}
@ -113,6 +128,26 @@ int CLI::PCB_EXPORT_DXF_COMMAND::doPerform( KIWAY& aKiway )
dxfJob->m_printMaskLayer = m_selectedLayers;
wxString layers = From_UTF8( m_argParser.get<std::string>( ARG_COMMON_LAYERS ).c_str() );
bool blah = false;
dxfJob->m_printMaskLayersToIncludeOnAllLayers = convertLayerStringList( layers, blah );
if( m_argParser.get<bool>( ARG_MODE_NEW ) )
dxfJob->m_genMode = JOB_EXPORT_PCB_DXF::GEN_MODE::NEW;
else
dxfJob->m_genMode = JOB_EXPORT_PCB_DXF::GEN_MODE::DEPRECATED;
if( dxfJob->m_genMode == JOB_EXPORT_PCB_DXF::GEN_MODE::DEPRECATED )
{
wxFprintf( stdout, wxT( "\033[33;1m%s\033[0m\n" ),
_( "This command has deprecated behavior as of KiCad 9.0, the default behavior "
"of this command will change in a future release." ) );
wxFprintf( stdout, wxT( "\033[33;1m%s\033[0m\n" ),
_( "The new behavior will match --mode-new" ) );
}
LOCALE_IO dummy; // Switch to "C" locale
int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, dxfJob.get() );

View File

@ -32,7 +32,7 @@
#define ARG_EXCLUDE_DRAWING_SHEET "--exclude-drawing-sheet"
#define ARG_PAGE_SIZE "--page-size-mode"
#define ARG_MODE_NEW "--mode-new"
CLI::PCB_EXPORT_SVG_COMMAND::PCB_EXPORT_SVG_COMMAND() : PCB_EXPORT_BASE_COMMAND( "svg" )
{
@ -91,6 +91,20 @@ CLI::PCB_EXPORT_SVG_COMMAND::PCB_EXPORT_SVG_COMMAND() : PCB_EXPORT_BASE_COMMAND(
.scan<'i', int>()
.default_value( 2 )
.metavar( "SHAPE_OPTION" );
m_argParser.add_argument( "--cl", ARG_COMMON_LAYERS )
.default_value( std::string() )
.help( UTF8STDSTR(
_( "Layers to include on each plot, comma separated list of untranslated "
"layer names to include such as "
"F.Cu,B.Cu" ) ) )
.metavar( "COMMON_LAYER_LIST" );
m_argParser.add_argument( ARG_MODE_NEW )
.help( UTF8STDSTR(
_( "Opt into the new behavior which means output path is a directory, a file "
"per layer is generated and the common layers arg becomes available. " ) ) )
.flag();
}
@ -120,6 +134,10 @@ int CLI::PCB_EXPORT_SVG_COMMAND::doPerform( KIWAY& aKiway )
svgJob->m_plotDrawingSheet = !m_argParser.get<bool>( ARG_EXCLUDE_DRAWING_SHEET );
svgJob->SetVarOverrides( m_argDefineVars );
wxString layers = From_UTF8( m_argParser.get<std::string>( ARG_COMMON_LAYERS ).c_str() );
bool blah = false;
svgJob->m_printMaskLayersToIncludeOnAllLayers = convertLayerStringList( layers, blah );
if( !wxFile::Exists( svgJob->m_filename ) )
{
wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) );
@ -128,6 +146,21 @@ int CLI::PCB_EXPORT_SVG_COMMAND::doPerform( KIWAY& aKiway )
svgJob->m_printMaskLayer = m_selectedLayers;
if( m_argParser.get<bool>( ARG_MODE_NEW ) )
svgJob->m_genMode = JOB_EXPORT_PCB_SVG::GEN_MODE::NEW;
else
svgJob->m_genMode = JOB_EXPORT_PCB_SVG::GEN_MODE::DEPRECATED;
if( svgJob->m_genMode == JOB_EXPORT_PCB_SVG::GEN_MODE::DEPRECATED )
{
wxFprintf( stdout, wxT( "\033[33;1m%s\033[0m\n" ),
_( "This command has deprecated behavior as of KiCad 9.0, the default behavior "
"of this command will change in a future release." ) );
wxFprintf( stdout, wxT( "\033[33;1m%s\033[0m\n" ),
_( "The new behavior will match --mode-new" ) );
}
int exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, svgJob.get() );
return exitCode;

View File

@ -111,7 +111,7 @@ DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aEditFrame, wxWindow* aParent,
if( m_job )
{
loadPlotParamsFromJob();
PCB_PLOTTER::PlotJobToPlotOpts( m_plotOpts, m_job );
m_messagesPanel->Hide();
m_browseButton->Hide();
@ -426,87 +426,6 @@ void DIALOG_PLOT::init_Dialog()
}
void DIALOG_PLOT::loadPlotParamsFromJob()
{
if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::GERBER )
{
JOB_EXPORT_PCB_GERBERS* gJob = static_cast<JOB_EXPORT_PCB_GERBERS*>( m_job );
m_plotOpts.SetDisableGerberMacros( gJob->m_disableApertureMacros );
m_plotOpts.SetUseGerberProtelExtensions( gJob->m_useProtelFileExtension );
m_plotOpts.SetUseGerberX2format( gJob->m_useX2Format );
m_plotOpts.SetIncludeGerberNetlistInfo( gJob->m_includeNetlistAttributes );
m_plotOpts.SetCreateGerberJobFile( gJob->m_createJobsFile );
m_plotOpts.SetGerberPrecision( gJob->m_precision );
m_plotOpts.SetSubtractMaskFromSilk( gJob->m_subtractSolderMaskFromSilk );
}
if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::SVG )
{
JOB_EXPORT_PCB_SVG* svgJob = static_cast<JOB_EXPORT_PCB_SVG*>( m_job );
m_plotOpts.SetSvgPrecision( svgJob->m_precision );
}
if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::DXF )
{
JOB_EXPORT_PCB_DXF* dxfJob = static_cast<JOB_EXPORT_PCB_DXF*>( m_job );
m_plotOpts.SetDXFPlotUnits( dxfJob->m_dxfUnits == JOB_EXPORT_PCB_DXF::DXF_UNITS::INCHES
? DXF_UNITS::INCHES : DXF_UNITS::MILLIMETERS );
m_plotOpts.SetPlotMode( dxfJob->m_plotGraphicItemsUsingContours ? OUTLINE_MODE::SKETCH
: OUTLINE_MODE::FILLED );
}
if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::PDF )
{
JOB_EXPORT_PCB_PDF* pdfJob = static_cast<JOB_EXPORT_PCB_PDF*>( m_job );
m_plotOpts.m_PDFFrontFPPropertyPopups = pdfJob->m_pdfFrontFPPropertyPopups;
m_plotOpts.m_PDFBackFPPropertyPopups = pdfJob->m_pdfBackFPPropertyPopups;
m_plotOpts.m_PDFMetadata = pdfJob->m_pdfMetadata;
m_plotOpts.m_PDFSingle = pdfJob->m_pdfSingle;
}
m_plotOpts.SetUseAuxOrigin( m_job->m_useDrillOrigin );
m_plotOpts.SetPlotFrameRef( m_job->m_plotDrawingSheet );
m_plotOpts.SetPlotInvisibleText( m_job->m_plotInvisibleText );
m_plotOpts.SetSketchPadsOnFabLayers( m_job->m_sketchPadsOnFabLayers );
m_plotOpts.SetHideDNPFPsOnFabLayers( m_job->m_hideDNPFPsOnFabLayers );
m_plotOpts.SetSketchDNPFPsOnFabLayers( m_job->m_sketchDNPFPsOnFabLayers );
m_plotOpts.SetCrossoutDNPFPsOnFabLayers( m_job->m_crossoutDNPFPsOnFabLayers );
m_plotOpts.SetPlotPadNumbers( m_job->m_plotPadNumbers );
m_plotOpts.SetBlackAndWhite( m_job->m_blackAndWhite );
m_plotOpts.SetMirror( m_job->m_mirror );
m_plotOpts.SetNegative( m_job->m_negative );
m_plotOpts.SetLayerSelection( m_job->m_printMaskLayer );
m_plotOpts.SetPlotOnAllLayersSelection( m_job->m_printMaskLayersToIncludeOnAllLayers );
switch( m_job->m_plotFormat )
{
default:
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::GERBER: m_plotOpts.SetFormat( PLOT_FORMAT::GERBER ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::POST: m_plotOpts.SetFormat( PLOT_FORMAT::POST ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::SVG: m_plotOpts.SetFormat( PLOT_FORMAT::SVG ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::DXF: m_plotOpts.SetFormat( PLOT_FORMAT::DXF ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::HPGL: m_plotOpts.SetFormat( PLOT_FORMAT::HPGL ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::PDF: m_plotOpts.SetFormat( PLOT_FORMAT::PDF ); break;
}
switch (m_job->m_drillShapeOption)
{
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::NO_DRILL_SHAPE:
m_plotOpts.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE );
break;
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::SMALL_DRILL_SHAPE:
m_plotOpts.SetDrillMarksType( DRILL_MARKS::SMALL_DRILL_SHAPE );
break;
default:
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::FULL_DRILL_SHAPE:
m_plotOpts.SetDrillMarksType( DRILL_MARKS::FULL_DRILL_SHAPE );
break;
}
}
void DIALOG_PLOT::transferPlotParamsToJob()
{
if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::GERBER )
@ -535,6 +454,7 @@ void DIALOG_PLOT::transferPlotParamsToJob()
? JOB_EXPORT_PCB_DXF::DXF_UNITS::INCHES
: JOB_EXPORT_PCB_DXF::DXF_UNITS::MILLIMETERS;
dxfJob->m_plotGraphicItemsUsingContours = m_plotOpts.GetPlotMode() == OUTLINE_MODE::SKETCH;
dxfJob->m_polygonMode = m_plotOpts.GetDXFPlotPolygonMode();
}
if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::PDF )

View File

@ -29,6 +29,11 @@
#include <pcbplot.h>
#include <wx/filename.h>
#include <gerber_jobfile_writer.h>
#include <jobs/job_export_pcb_gerbers.h>
#include <jobs/job_export_pcb_dxf.h>
#include <jobs/job_export_pcb_pdf.h>
#include <jobs/job_export_pcb_plot.h>
#include <jobs/job_export_pcb_svg.h>
PCB_PLOTTER::PCB_PLOTTER( BOARD* aBoard, REPORTER* aReporter, PCB_PLOT_PARAMS& aParams ) :
@ -256,4 +261,91 @@ LSEQ PCB_PLOTTER::getPlotSequence( PCB_LAYER_ID aLayerToPlot, LSEQ aPlotWithAllL
}
return plotSequence;
}
void PCB_PLOTTER::PlotJobToPlotOpts( PCB_PLOT_PARAMS& aPlotOpts, JOB_EXPORT_PCB_PLOT* aJob )
{
if( aJob->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::GERBER )
{
JOB_EXPORT_PCB_GERBERS* gJob = static_cast<JOB_EXPORT_PCB_GERBERS*>( aJob );
aPlotOpts.SetDisableGerberMacros( gJob->m_disableApertureMacros );
aPlotOpts.SetUseGerberProtelExtensions( gJob->m_useProtelFileExtension );
aPlotOpts.SetUseGerberX2format( gJob->m_useX2Format );
aPlotOpts.SetIncludeGerberNetlistInfo( gJob->m_includeNetlistAttributes );
aPlotOpts.SetCreateGerberJobFile( gJob->m_createJobsFile );
aPlotOpts.SetGerberPrecision( gJob->m_precision );
aPlotOpts.SetSubtractMaskFromSilk( gJob->m_subtractSolderMaskFromSilk );
}
if( aJob->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::SVG )
{
JOB_EXPORT_PCB_SVG* svgJob = static_cast<JOB_EXPORT_PCB_SVG*>( aJob );
aPlotOpts.SetSvgPrecision( svgJob->m_precision );
}
if( aJob->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::DXF )
{
JOB_EXPORT_PCB_DXF* dxfJob = static_cast<JOB_EXPORT_PCB_DXF*>( aJob );
aPlotOpts.SetDXFPlotUnits( dxfJob->m_dxfUnits == JOB_EXPORT_PCB_DXF::DXF_UNITS::INCHES
? DXF_UNITS::INCHES
: DXF_UNITS::MILLIMETERS );
aPlotOpts.SetPlotMode( dxfJob->m_plotGraphicItemsUsingContours ? OUTLINE_MODE::SKETCH
: OUTLINE_MODE::FILLED );
aPlotOpts.SetDXFPlotPolygonMode( dxfJob->m_polygonMode );
}
if( aJob->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::PDF )
{
JOB_EXPORT_PCB_PDF* pdfJob = static_cast<JOB_EXPORT_PCB_PDF*>( aJob );
aPlotOpts.m_PDFFrontFPPropertyPopups = pdfJob->m_pdfFrontFPPropertyPopups;
aPlotOpts.m_PDFBackFPPropertyPopups = pdfJob->m_pdfBackFPPropertyPopups;
aPlotOpts.m_PDFMetadata = pdfJob->m_pdfMetadata;
aPlotOpts.m_PDFSingle = pdfJob->m_pdfSingle;
}
aPlotOpts.SetUseAuxOrigin( aJob->m_useDrillOrigin );
aPlotOpts.SetPlotFrameRef( aJob->m_plotDrawingSheet );
aPlotOpts.SetPlotInvisibleText( aJob->m_plotInvisibleText );
aPlotOpts.SetSketchPadsOnFabLayers( aJob->m_sketchPadsOnFabLayers );
aPlotOpts.SetHideDNPFPsOnFabLayers( aJob->m_hideDNPFPsOnFabLayers );
aPlotOpts.SetSketchDNPFPsOnFabLayers( aJob->m_sketchDNPFPsOnFabLayers );
aPlotOpts.SetCrossoutDNPFPsOnFabLayers( aJob->m_crossoutDNPFPsOnFabLayers );
aPlotOpts.SetPlotPadNumbers( aJob->m_plotPadNumbers );
aPlotOpts.SetBlackAndWhite( aJob->m_blackAndWhite );
aPlotOpts.SetMirror( aJob->m_mirror );
aPlotOpts.SetNegative( aJob->m_negative );
aPlotOpts.SetLayerSelection( aJob->m_printMaskLayer );
aPlotOpts.SetPlotOnAllLayersSelection( aJob->m_printMaskLayersToIncludeOnAllLayers );
switch( aJob->m_plotFormat )
{
default:
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::GERBER:
aPlotOpts.SetFormat( PLOT_FORMAT::GERBER );
break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::POST: aPlotOpts.SetFormat( PLOT_FORMAT::POST ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::SVG: aPlotOpts.SetFormat( PLOT_FORMAT::SVG ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::DXF: aPlotOpts.SetFormat( PLOT_FORMAT::DXF ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::HPGL: aPlotOpts.SetFormat( PLOT_FORMAT::HPGL ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::PDF: aPlotOpts.SetFormat( PLOT_FORMAT::PDF ); break;
}
switch( aJob->m_drillShapeOption )
{
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::NO_DRILL_SHAPE:
aPlotOpts.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE );
break;
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::SMALL_DRILL_SHAPE:
aPlotOpts.SetDrillMarksType( DRILL_MARKS::SMALL_DRILL_SHAPE );
break;
default:
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::FULL_DRILL_SHAPE:
aPlotOpts.SetDrillMarksType( DRILL_MARKS::FULL_DRILL_SHAPE );
break;
}
}

View File

@ -28,6 +28,7 @@
class BOARD;
class REPORTER;
class wxFileName;
class JOB_EXPORT_PCB_PLOT;
class PCB_PLOTTER
{
@ -62,6 +63,11 @@ public:
static void BuildPlotFileName( wxFileName* aFilename, const wxString& aOutputDir, const wxString& aSuffix,
const wxString& aExtension );
/**
* Translate a JOB to PCB_PLOT_PARAMS
*/
static void PlotJobToPlotOpts( PCB_PLOT_PARAMS& aPlotOpts, JOB_EXPORT_PCB_PLOT* aJob );
protected:
BOARD* m_board;
PCB_PLOT_PARAMS m_plotOpts;

View File

@ -632,35 +632,6 @@ int PCBNEW_JOBS_HANDLER::JobExportSvg( JOB* aJob )
if( aSvgJob == nullptr )
return CLI::EXIT_CODES::ERR_UNKNOWN;
PCB_PLOT_SVG_OPTIONS svgPlotOptions;
svgPlotOptions.m_blackAndWhite = aSvgJob->m_blackAndWhite;
svgPlotOptions.m_colorTheme = aSvgJob->m_colorTheme;
svgPlotOptions.m_outputFile = aSvgJob->GetFullOutputPath();
svgPlotOptions.m_mirror = aSvgJob->m_mirror;
svgPlotOptions.m_negative = aSvgJob->m_negative;
svgPlotOptions.m_pageSizeMode = aSvgJob->m_pageSizeMode;
svgPlotOptions.m_printMaskLayer = aSvgJob->m_printMaskLayer;
svgPlotOptions.m_plotFrame = aSvgJob->m_plotDrawingSheet;
svgPlotOptions.m_sketchPadsOnFabLayers = aSvgJob->m_sketchPadsOnFabLayers;
svgPlotOptions.m_hideDNPFPsOnFabLayers = aSvgJob->m_hideDNPFPsOnFabLayers;
svgPlotOptions.m_sketchDNPFPsOnFabLayers = aSvgJob->m_sketchDNPFPsOnFabLayers;
svgPlotOptions.m_crossoutDNPFPsOnFabLayers = aSvgJob->m_crossoutDNPFPsOnFabLayers;
svgPlotOptions.m_precision = aSvgJob->m_precision;
switch( aSvgJob->m_drillShapeOption )
{
default:
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::NO_DRILL_SHAPE:
svgPlotOptions.m_drillShapeOption = static_cast<int>( DRILL_MARKS::NO_DRILL_SHAPE );
break;
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::SMALL_DRILL_SHAPE:
svgPlotOptions.m_drillShapeOption = static_cast<int>( DRILL_MARKS::SMALL_DRILL_SHAPE );
break;
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::FULL_DRILL_SHAPE:
svgPlotOptions.m_drillShapeOption = static_cast<int>( DRILL_MARKS::FULL_DRILL_SHAPE );
break;
}
BOARD* brd = getBoard( aSvgJob->m_filename );
if( !brd )
@ -670,16 +641,63 @@ int PCBNEW_JOBS_HANDLER::JobExportSvg( JOB* aJob )
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
brd->SynchronizeProperties();
if( EXPORT_SVG::Plot( brd, svgPlotOptions ) )
if( aSvgJob->m_genMode == JOB_EXPORT_PCB_SVG::GEN_MODE::DEPRECATED )
{
m_reporter->Report( _( "Successfully created svg file" ) + wxS( "\n" ), RPT_SEVERITY_INFO );
return CLI::EXIT_CODES::OK;
PCB_PLOT_SVG_OPTIONS svgPlotOptions;
svgPlotOptions.m_blackAndWhite = aSvgJob->m_blackAndWhite;
svgPlotOptions.m_colorTheme = aSvgJob->m_colorTheme;
svgPlotOptions.m_outputFile = aSvgJob->GetFullOutputPath();
svgPlotOptions.m_mirror = aSvgJob->m_mirror;
svgPlotOptions.m_negative = aSvgJob->m_negative;
svgPlotOptions.m_pageSizeMode = aSvgJob->m_pageSizeMode;
svgPlotOptions.m_printMaskLayer = aSvgJob->m_printMaskLayer;
svgPlotOptions.m_plotFrame = aSvgJob->m_plotDrawingSheet;
svgPlotOptions.m_sketchPadsOnFabLayers = aSvgJob->m_sketchPadsOnFabLayers;
svgPlotOptions.m_hideDNPFPsOnFabLayers = aSvgJob->m_hideDNPFPsOnFabLayers;
svgPlotOptions.m_sketchDNPFPsOnFabLayers = aSvgJob->m_sketchDNPFPsOnFabLayers;
svgPlotOptions.m_crossoutDNPFPsOnFabLayers = aSvgJob->m_crossoutDNPFPsOnFabLayers;
svgPlotOptions.m_precision = aSvgJob->m_precision;
switch( aSvgJob->m_drillShapeOption )
{
default:
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::NO_DRILL_SHAPE:
svgPlotOptions.m_drillShapeOption = static_cast<int>( DRILL_MARKS::NO_DRILL_SHAPE );
break;
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::SMALL_DRILL_SHAPE:
svgPlotOptions.m_drillShapeOption = static_cast<int>( DRILL_MARKS::SMALL_DRILL_SHAPE );
break;
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::FULL_DRILL_SHAPE:
svgPlotOptions.m_drillShapeOption = static_cast<int>( DRILL_MARKS::FULL_DRILL_SHAPE );
break;
}
if( EXPORT_SVG::Plot( brd, svgPlotOptions ) )
{
m_reporter->Report( _( "Successfully created svg file" ) + wxS( "\n" ),
RPT_SEVERITY_INFO );
return CLI::EXIT_CODES::OK;
}
else
{
m_reporter->Report( _( "Error creating svg file" ) + wxS( "\n" ), RPT_SEVERITY_ERROR );
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
}
}
else
{
m_reporter->Report( _( "Error creating svg file" ) + wxS( "\n" ), RPT_SEVERITY_ERROR );
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
PCB_PLOT_PARAMS plotOpts;
PCB_PLOTTER::PlotJobToPlotOpts( plotOpts, aSvgJob );
PCB_PLOTTER plotter( brd, m_reporter, plotOpts );
if( plotter.Plot( aSvgJob->GetFullOutputPath(), aSvgJob->m_printMaskLayer,
aSvgJob->m_printMaskLayersToIncludeOnAllLayers, false ) )
{
return CLI::EXIT_CODES::ERR_UNKNOWN;
}
}
return CLI::EXIT_CODES::OK;
}
@ -699,63 +717,78 @@ int PCBNEW_JOBS_HANDLER::JobExportDxf( JOB* aJob )
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
brd->SynchronizeProperties();
if( aDxfJob->GetOutputPath().IsEmpty() )
if( aDxfJob->m_genMode == JOB_EXPORT_PCB_DXF::GEN_MODE::DEPRECATED )
{
wxFileName fn = brd->GetFileName();
fn.SetName( fn.GetName() );
fn.SetExt( GetDefaultPlotExtension( PLOT_FORMAT::DXF ) );
if( aDxfJob->GetOutputPath().IsEmpty() )
{
wxFileName fn = brd->GetFileName();
fn.SetName( fn.GetName() );
fn.SetExt( GetDefaultPlotExtension( PLOT_FORMAT::DXF ) );
aDxfJob->SetOutputPath( fn.GetFullName() );
aDxfJob->SetOutputPath( fn.GetFullName() );
}
PCB_PLOT_PARAMS plotOpts;
plotOpts.SetFormat( PLOT_FORMAT::DXF );
plotOpts.SetDXFPlotPolygonMode( aDxfJob->m_polygonMode );
plotOpts.SetUseAuxOrigin( aDxfJob->m_useDrillOrigin );
if( aDxfJob->m_dxfUnits == JOB_EXPORT_PCB_DXF::DXF_UNITS::MILLIMETERS )
plotOpts.SetDXFPlotUnits( DXF_UNITS::MILLIMETERS );
else
plotOpts.SetDXFPlotUnits( DXF_UNITS::INCHES );
plotOpts.SetPlotFrameRef( aDxfJob->m_plotDrawingSheet );
plotOpts.SetPlotValue( aDxfJob->m_plotFootprintValues );
plotOpts.SetPlotReference( aDxfJob->m_plotRefDes );
plotOpts.SetLayerSelection( aDxfJob->m_printMaskLayer );
plotOpts.SetPlotOnAllLayersSelection( aDxfJob->m_printMaskLayersToIncludeOnAllLayers );
PCB_LAYER_ID layer = UNDEFINED_LAYER;
wxString layerName;
wxString sheetName;
wxString sheetPath;
if( aDxfJob->m_printMaskLayer.size() == 1 )
{
layer = aDxfJob->m_printMaskLayer.front();
layerName = brd->GetLayerName( layer );
}
if( aJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
layerName = aJob->GetVarOverrides().at( wxT( "LAYER" ) );
if( aJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
sheetName = aJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
if( aJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
sheetPath = aJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
DXF_PLOTTER* plotter = (DXF_PLOTTER*) StartPlotBoard(
brd, &plotOpts, layer, layerName, aDxfJob->GetFullOutputPath(), sheetName, sheetPath );
if( plotter )
{
PlotBoardLayers( brd, plotter, aDxfJob->m_printMaskLayer, plotOpts );
plotter->EndPlot();
}
delete plotter;
}
PCB_PLOT_PARAMS plotOpts;
plotOpts.SetFormat( PLOT_FORMAT::DXF );
plotOpts.SetDXFPlotPolygonMode( aDxfJob->m_plotGraphicItemsUsingContours );
plotOpts.SetUseAuxOrigin( aDxfJob->m_useDrillOrigin );
if( aDxfJob->m_dxfUnits == JOB_EXPORT_PCB_DXF::DXF_UNITS::MILLIMETERS )
plotOpts.SetDXFPlotUnits( DXF_UNITS::MILLIMETERS );
else
plotOpts.SetDXFPlotUnits( DXF_UNITS::INCHES );
plotOpts.SetPlotFrameRef( aDxfJob->m_plotDrawingSheet );
plotOpts.SetPlotValue( aDxfJob->m_plotFootprintValues );
plotOpts.SetPlotReference( aDxfJob->m_plotRefDes );
plotOpts.SetLayerSelection( aDxfJob->m_printMaskLayer );
plotOpts.SetPlotOnAllLayersSelection( aDxfJob->m_printMaskLayersToIncludeOnAllLayers );
PCB_LAYER_ID layer = UNDEFINED_LAYER;
wxString layerName;
wxString sheetName;
wxString sheetPath;
if( aDxfJob->m_printMaskLayer.size() == 1 )
{
layer = aDxfJob->m_printMaskLayer.front();
layerName = brd->GetLayerName( layer );
PCB_PLOT_PARAMS plotOpts;
PCB_PLOTTER::PlotJobToPlotOpts( plotOpts, aDxfJob );
PCB_PLOTTER plotter( brd, m_reporter, plotOpts );
if( plotter.Plot( aDxfJob->GetFullOutputPath(), aDxfJob->m_printMaskLayer,
aDxfJob->m_printMaskLayersToIncludeOnAllLayers, false ) )
{
return CLI::EXIT_CODES::ERR_UNKNOWN;
}
}
if( aJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
layerName = aJob->GetVarOverrides().at( wxT( "LAYER" ) );
if( aJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
sheetName = aJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
if( aJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) )
sheetPath = aJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
DXF_PLOTTER* plotter = (DXF_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName, aDxfJob->GetFullOutputPath(), sheetName,
sheetPath );
if( plotter )
{
PlotBoardLayers( brd, plotter, aDxfJob->m_printMaskLayer, plotOpts );
plotter->EndPlot();
}
delete plotter;
return CLI::EXIT_CODES::OK;
}
@ -787,49 +820,7 @@ int PCBNEW_JOBS_HANDLER::JobExportPdf( JOB* aJob )
}
PCB_PLOT_PARAMS plotOpts;
plotOpts.SetFormat( PLOT_FORMAT::PDF );
plotOpts.SetPlotFrameRef( aPdfJob->m_plotDrawingSheet );
plotOpts.SetPlotValue( aPdfJob->m_plotFootprintValues );
plotOpts.SetPlotReference( aPdfJob->m_plotRefDes );
plotOpts.SetPlotInvisibleText( aPdfJob->m_plotInvisibleText );
plotOpts.SetLayerSelection( aPdfJob->m_printMaskLayer );
plotOpts.SetPlotOnAllLayersSelection( aPdfJob->m_printMaskLayersToIncludeOnAllLayers );
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
plotOpts.SetColorSettings( mgr.GetColorSettings( aPdfJob->m_colorTheme ) );
plotOpts.SetMirror( aPdfJob->m_mirror );
plotOpts.SetBlackAndWhite( aPdfJob->m_blackAndWhite );
plotOpts.SetNegative( aPdfJob->m_negative );
if( aPdfJob->m_sketchPadsOnFabLayers )
{
plotOpts.SetSketchPadsOnFabLayers( true );
plotOpts.SetPlotPadNumbers( true );
}
plotOpts.SetUseAuxOrigin( aPdfJob->m_useDrillOrigin );
plotOpts.SetHideDNPFPsOnFabLayers( aPdfJob->m_hideDNPFPsOnFabLayers );
plotOpts.SetSketchDNPFPsOnFabLayers( aPdfJob->m_sketchDNPFPsOnFabLayers );
plotOpts.SetCrossoutDNPFPsOnFabLayers( aPdfJob->m_crossoutDNPFPsOnFabLayers );
plotOpts.m_PDFBackFPPropertyPopups = aPdfJob->m_pdfBackFPPropertyPopups;
plotOpts.m_PDFFrontFPPropertyPopups = aPdfJob->m_pdfFrontFPPropertyPopups;
plotOpts.m_PDFMetadata = aPdfJob->m_pdfMetadata;
plotOpts.m_PDFSingle = aPdfJob->m_pdfSingle;
switch( aPdfJob->m_drillShapeOption )
{
default:
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::NO_DRILL_SHAPE:
plotOpts.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE ); break;
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::SMALL_DRILL_SHAPE:
plotOpts.SetDrillMarksType( DRILL_MARKS::SMALL_DRILL_SHAPE ); break;
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::FULL_DRILL_SHAPE:
plotOpts.SetDrillMarksType( DRILL_MARKS::FULL_DRILL_SHAPE ); break;
}
PCB_PLOTTER::PlotJobToPlotOpts( plotOpts, aPdfJob );
int returnCode = CLI::EXIT_CODES::OK;