Browse Source

Use std::optional to better flag presence of arguments.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20460

(cherry picked from commit 8076bfa3c7)
9.0
Jeff Young 7 months ago
parent
commit
0e8afc8243
  1. 4
      common/jobs/job_export_pcb_plot.h
  2. 4
      common/jobs/job_fp_export_svg.h
  3. 57
      pcbnew/pcbnew_jobs_handler.cpp

4
common/jobs/job_export_pcb_plot.h

@ -43,8 +43,8 @@ public:
JOB_EXPORT_PCB_PLOT( PLOT_FORMAT aFormat, const std::string& aType, bool aOutputIsDirectory );
public:
wxString m_argLayers;
wxString m_argCommonLayers;
std::optional<wxString> m_argLayers;
std::optional<wxString> m_argCommonLayers;
PLOT_FORMAT m_plotFormat;

4
common/jobs/job_fp_export_svg.h

@ -46,8 +46,8 @@ public:
bool m_sketchDNPFPsOnFabLayers;
bool m_crossoutDNPFPsOnFabLayers;
wxString m_argLayers;
LSEQ m_plotLayerSequence;
std::optional<wxString> m_argLayers;
LSEQ m_plotLayerSequence;
};
#endif

57
pcbnew/pcbnew_jobs_handler.cpp

@ -815,11 +815,11 @@ int PCBNEW_JOBS_HANDLER::JobExportSvg( JOB* aJob )
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
brd->SynchronizeProperties();
if( aSvgJob->m_plotLayerSequence.empty() )
{
aSvgJob->m_plotLayerSequence = convertLayerArg( aSvgJob->m_argLayers, brd );
aSvgJob->m_plotOnAllLayersSequence = convertLayerArg( aSvgJob->m_argCommonLayers, brd );
}
if( aSvgJob->m_argLayers )
aSvgJob->m_plotLayerSequence = convertLayerArg( aSvgJob->m_argLayers.value(), brd );
if( aSvgJob->m_argCommonLayers )
aSvgJob->m_plotOnAllLayersSequence = convertLayerArg( aSvgJob->m_argCommonLayers.value(), brd );
if( aSvgJob->m_plotLayerSequence.size() < 1 )
{
@ -878,11 +878,11 @@ int PCBNEW_JOBS_HANDLER::JobExportDxf( JOB* aJob )
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
brd->SynchronizeProperties();
if( aDxfJob->m_plotLayerSequence.empty() )
{
aDxfJob->m_plotLayerSequence = convertLayerArg( aDxfJob->m_argLayers, brd );
aDxfJob->m_plotOnAllLayersSequence = convertLayerArg( aDxfJob->m_argCommonLayers, brd );
}
if( aDxfJob->m_argLayers )
aDxfJob->m_plotLayerSequence = convertLayerArg( aDxfJob->m_argLayers.value(), brd );
if( aDxfJob->m_argCommonLayers )
aDxfJob->m_plotOnAllLayersSequence = convertLayerArg( aDxfJob->m_argCommonLayers.value(), brd );
if( aDxfJob->m_plotLayerSequence.size() < 1 )
{
@ -960,11 +960,11 @@ int PCBNEW_JOBS_HANDLER::JobExportPdf( JOB* aJob )
brd->GetProject()->ApplyTextVars( pdfJob->GetVarOverrides() );
brd->SynchronizeProperties();
if( pdfJob->m_plotLayerSequence.empty() )
{
pdfJob->m_plotLayerSequence = convertLayerArg( pdfJob->m_argLayers, brd );
pdfJob->m_plotOnAllLayersSequence = convertLayerArg( pdfJob->m_argCommonLayers, brd );
}
if( pdfJob->m_argLayers )
pdfJob->m_plotLayerSequence = convertLayerArg( pdfJob->m_argLayers.value(), brd );
if( pdfJob->m_argCommonLayers )
pdfJob->m_plotOnAllLayersSequence = convertLayerArg( pdfJob->m_argCommonLayers.value(), brd );
if( pdfJob->m_pdfGenMode == JOB_EXPORT_PCB_PDF::GEN_MODE::ALL_LAYERS_ONE_FILE )
plotAllLayersOneFile = true;
@ -1057,16 +1057,17 @@ int PCBNEW_JOBS_HANDLER::JobExportGerbers( JOB* aJob )
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
brd->SynchronizeProperties();
if( aGerberJob->m_plotLayerSequence.empty() )
if( aGerberJob->m_argLayers )
{
if( !aGerberJob->m_argLayers.empty() )
aGerberJob->m_plotLayerSequence = convertLayerArg( aGerberJob->m_argLayers, nullptr );
if( !aGerberJob->m_argLayers.value().empty() )
aGerberJob->m_plotLayerSequence = convertLayerArg( aGerberJob->m_argLayers.value(), nullptr );
else
aGerberJob->m_plotLayerSequence = LSET::AllLayersMask().SeqStackupForPlotting();
aGerberJob->m_plotOnAllLayersSequence = convertLayerArg( aGerberJob->m_argCommonLayers, brd );
}
if( aGerberJob->m_argCommonLayers )
aGerberJob->m_plotOnAllLayersSequence = convertLayerArg( aGerberJob->m_argCommonLayers.value(), brd );
PCB_PLOT_PARAMS boardPlotOptions = brd->GetPlotOptions();
GERBER_JOBFILE_WRITER jobfile_writer( brd );
@ -1285,11 +1286,11 @@ int PCBNEW_JOBS_HANDLER::JobExportGerber( JOB* aJob )
brd->GetProject()->ApplyTextVars( aJob->GetVarOverrides() );
brd->SynchronizeProperties();
if( aGerberJob->m_plotLayerSequence.empty() )
{
aGerberJob->m_plotLayerSequence = convertLayerArg( aGerberJob->m_argLayers, brd );
aGerberJob->m_plotOnAllLayersSequence = convertLayerArg( aGerberJob->m_argCommonLayers, brd );
}
if( aGerberJob->m_argLayers )
aGerberJob->m_plotLayerSequence = convertLayerArg( aGerberJob->m_argLayers.value(), brd );
if( aGerberJob->m_argCommonLayers )
aGerberJob->m_plotOnAllLayersSequence = convertLayerArg( aGerberJob->m_argCommonLayers.value(), brd );
if( aGerberJob->m_plotLayerSequence.size() < 1 )
{
@ -1773,10 +1774,10 @@ int PCBNEW_JOBS_HANDLER::JobExportFpSvg( JOB* aJob )
PCB_IO_KICAD_SEXPR pcb_io( CTL_FOR_LIBRARY );
FP_CACHE fpLib( &pcb_io, svgJob->m_libraryPath );
if( svgJob->m_plotLayerSequence.empty() )
if( svgJob->m_argLayers )
{
if( !svgJob->m_argLayers.empty() )
svgJob->m_plotLayerSequence = convertLayerArg( svgJob->m_argLayers, nullptr );
if( !svgJob->m_argLayers.value().empty() )
svgJob->m_plotLayerSequence = convertLayerArg( svgJob->m_argLayers.value(), nullptr );
else
svgJob->m_plotLayerSequence = LSET::AllLayersMask().SeqStackupForPlotting();
}

Loading…
Cancel
Save