mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-19 23:21:41 +00:00
Squash dxf job path for single/multi like svg
This commit is contained in:
parent
0ba869465c
commit
afe7c893d5
common/jobs
kicad/cli
pcbnew
@ -24,8 +24,8 @@
|
||||
|
||||
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" },
|
||||
{ JOB_EXPORT_PCB_DXF::GEN_MODE::MULTI, "multi" },
|
||||
{ JOB_EXPORT_PCB_DXF::GEN_MODE::SINGLE, "single" },
|
||||
} )
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM( JOB_EXPORT_PCB_DXF::DXF_UNITS,
|
||||
@ -39,7 +39,7 @@ JOB_EXPORT_PCB_DXF::JOB_EXPORT_PCB_DXF() :
|
||||
m_plotGraphicItemsUsingContours( true ),
|
||||
m_polygonMode( true ),
|
||||
m_dxfUnits( DXF_UNITS::INCHES ),
|
||||
m_genMode( GEN_MODE::NEW )
|
||||
m_genMode( GEN_MODE::MULTI )
|
||||
{
|
||||
m_plotDrawingSheet = false;
|
||||
|
||||
|
@ -43,8 +43,8 @@ public:
|
||||
|
||||
enum class GEN_MODE
|
||||
{
|
||||
DEPRECATED,
|
||||
NEW
|
||||
SINGLE,
|
||||
MULTI
|
||||
};
|
||||
|
||||
bool m_plotGraphicItemsUsingContours;
|
||||
|
@ -34,7 +34,8 @@
|
||||
#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"
|
||||
#define ARG_MODE_SINGLE "--mode-single"
|
||||
#define ARG_MODE_MULTI "--mode-multi"
|
||||
|
||||
CLI::PCB_EXPORT_DXF_COMMAND::PCB_EXPORT_DXF_COMMAND() : PCB_EXPORT_BASE_COMMAND( "dxf" )
|
||||
{
|
||||
@ -82,10 +83,17 @@ CLI::PCB_EXPORT_DXF_COMMAND::PCB_EXPORT_DXF_COMMAND() : PCB_EXPORT_BASE_COMMAND(
|
||||
"F.Cu,B.Cu" ) ) )
|
||||
.metavar( "COMMON_LAYER_LIST" );
|
||||
|
||||
m_argParser.add_argument( ARG_MODE_NEW )
|
||||
m_argParser.add_argument( ARG_MODE_SINGLE )
|
||||
.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. " ) ) )
|
||||
_( "Generates a single file with the output arg path acting as the complete "
|
||||
"directory and filename path. COMMON_LAYER_LIST does not function in this "
|
||||
"mode. Instead LAYER_LIST controls all layers plotted." ) ) )
|
||||
.flag();
|
||||
|
||||
m_argParser.add_argument( ARG_MODE_MULTI )
|
||||
.help( UTF8STDSTR( _( "Generates one or more files with behavior similar to the KiCad "
|
||||
"GUI plotting. The given output path specifies a directory in "
|
||||
"which files may be output." ) ) )
|
||||
.flag();
|
||||
|
||||
m_argParser.add_argument( ARG_PLOT_INVISIBLE_TEXT )
|
||||
@ -145,19 +153,18 @@ int CLI::PCB_EXPORT_DXF_COMMAND::doPerform( KIWAY& aKiway )
|
||||
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;
|
||||
if( m_argParser.get<bool>( ARG_MODE_MULTI ) )
|
||||
dxfJob->m_genMode = JOB_EXPORT_PCB_DXF::GEN_MODE::MULTI;
|
||||
else if( m_argParser.get<bool>( ARG_MODE_SINGLE ) )
|
||||
dxfJob->m_genMode = JOB_EXPORT_PCB_DXF::GEN_MODE::SINGLE;
|
||||
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" ) );
|
||||
_( "The new behavior will match --mode-multi" ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -464,7 +464,7 @@ void DIALOG_PLOT::transferPlotParamsToJob()
|
||||
: JOB_EXPORT_PCB_DXF::DXF_UNITS::MILLIMETERS;
|
||||
dxfJob->m_plotGraphicItemsUsingContours = m_plotOpts.GetPlotMode() == OUTLINE_MODE::SKETCH;
|
||||
dxfJob->m_polygonMode = m_plotOpts.GetDXFPlotPolygonMode();
|
||||
dxfJob->m_genMode = JOB_EXPORT_PCB_DXF::GEN_MODE::NEW;
|
||||
dxfJob->m_genMode = JOB_EXPORT_PCB_DXF::GEN_MODE::MULTI;
|
||||
}
|
||||
|
||||
if( m_job->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::PDF )
|
||||
|
@ -698,6 +698,18 @@ int PCBNEW_JOBS_HANDLER::JobExportSvg( JOB* aJob )
|
||||
if( !brd )
|
||||
return CLI::EXIT_CODES::ERR_INVALID_INPUT_FILE;
|
||||
|
||||
if( aSvgJob->m_genMode == JOB_EXPORT_PCB_SVG::GEN_MODE::SINGLE )
|
||||
{
|
||||
if( aSvgJob->GetOutputPath().IsEmpty() )
|
||||
{
|
||||
wxFileName fn = brd->GetFileName();
|
||||
fn.SetName( fn.GetName() );
|
||||
fn.SetExt( GetDefaultPlotExtension( PLOT_FORMAT::SVG ) );
|
||||
|
||||
aSvgJob->SetOutputPath( fn.GetFullName() );
|
||||
}
|
||||
}
|
||||
|
||||
loadOverrideDrawingSheet( brd, aSvgJob->m_drawingSheet );
|
||||
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
|
||||
brd->SynchronizeProperties();
|
||||
@ -753,7 +765,8 @@ int PCBNEW_JOBS_HANDLER::JobExportDxf( JOB* aJob )
|
||||
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
|
||||
brd->SynchronizeProperties();
|
||||
|
||||
if( aDxfJob->m_genMode == JOB_EXPORT_PCB_DXF::GEN_MODE::DEPRECATED )
|
||||
|
||||
if( aDxfJob->m_genMode == JOB_EXPORT_PCB_DXF::GEN_MODE::SINGLE )
|
||||
{
|
||||
if( aDxfJob->GetOutputPath().IsEmpty() )
|
||||
{
|
||||
@ -763,66 +776,35 @@ int PCBNEW_JOBS_HANDLER::JobExportDxf( JOB* aJob )
|
||||
|
||||
aDxfJob->SetOutputPath( fn.GetFullName() );
|
||||
}
|
||||
}
|
||||
|
||||
PCB_PLOT_PARAMS plotOpts;
|
||||
plotOpts.SetFormat( PLOT_FORMAT::DXF );
|
||||
PCB_PLOT_PARAMS plotOpts;
|
||||
PCB_PLOTTER::PlotJobToPlotOpts( plotOpts, aDxfJob );
|
||||
|
||||
plotOpts.SetDXFPlotPolygonMode( aDxfJob->m_polygonMode );
|
||||
plotOpts.SetUseAuxOrigin( aDxfJob->m_useDrillOrigin );
|
||||
PCB_PLOTTER plotter( brd, m_reporter, plotOpts );
|
||||
|
||||
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 );
|
||||
}
|
||||
std::optional<wxString> layerName;
|
||||
std::optional<wxString> sheetName;
|
||||
std::optional<wxString> sheetPath;
|
||||
|
||||
if( aDxfJob->m_genMode == JOB_EXPORT_PCB_DXF::GEN_MODE::SINGLE )
|
||||
{
|
||||
if( aJob->GetVarOverrides().contains( wxT( "LAYER" ) ) )
|
||||
layerName = aJob->GetVarOverrides().at( wxT( "LAYER" ) );
|
||||
layerName = aDxfJob->GetVarOverrides().at( wxT( "LAYER" ) );
|
||||
|
||||
if( aJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) )
|
||||
sheetName = aJob->GetVarOverrides().at( wxT( "SHEETNAME" ) );
|
||||
sheetName = aDxfJob->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;
|
||||
sheetPath = aDxfJob->GetVarOverrides().at( wxT( "SHEETPATH" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
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( !plotter.Plot( aDxfJob->GetFullOutputPath(), aDxfJob->m_printMaskLayer,
|
||||
aDxfJob->m_printMaskLayersToIncludeOnAllLayers, false,
|
||||
aDxfJob->m_genMode == JOB_EXPORT_PCB_DXF::GEN_MODE::SINGLE, layerName,
|
||||
sheetName, sheetPath ) )
|
||||
{
|
||||
return CLI::EXIT_CODES::ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
return CLI::EXIT_CODES::OK;
|
||||
|
Loading…
Reference in New Issue
Block a user