diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index 63fbe8e4a5..9f278ae541 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -1204,6 +1204,11 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event ) } PCB_LAYER_ID layer = *seq; + wxString layerName = board->GetLayerName( layer ); + //@todo allow controlling the sheet name and path that will be displayed in the title block + // Leave blank for now + wxString sheetName; + wxString sheetPath; // All copper layers that are disabled are actually selected // This is due to wonkyness in automatically selecting copper layers @@ -1222,16 +1227,14 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event ) if( m_plotOpts.GetFormat() == PLOT_FORMAT::GERBER && m_useGerberExtensions->GetValue() ) file_ext = GetGerberProtelExtension( layer ); - BuildPlotFileName( &fn, outputDir.GetPath(), board->GetLayerName( layer ), file_ext ); + BuildPlotFileName( &fn, outputDir.GetPath(), layerName, file_ext ); wxString fullname = fn.GetFullName(); jobfile_writer.AddGbrFile( layer, fullname ); LOCALE_IO toggle; - //@todo allow controlling the sheet name and path that will be displayed in the title block - // Leave blank for now - PLOTTER* plotter = StartPlotBoard( board, &m_plotOpts, layer, fn.GetFullPath(), - wxEmptyString, wxEmptyString ); + PLOTTER* plotter = StartPlotBoard( board, &m_plotOpts, layer, layerName, fn.GetFullPath(), + sheetName, sheetPath ); // Print diags in messages box: wxString msg; diff --git a/pcbnew/exporters/export_svg.cpp b/pcbnew/exporters/export_svg.cpp index 5a4416a594..9a64b59791 100644 --- a/pcbnew/exporters/export_svg.cpp +++ b/pcbnew/exporters/export_svg.cpp @@ -87,12 +87,22 @@ bool EXPORT_SVG::Plot( BOARD* aBoard, const PCB_PLOT_SVG_OPTIONS& aSvgPlotOption plot_opts.SetColorSettings( mgr.GetColorSettings( aSvgPlotOptions.m_colorTheme ) ); - LOCALE_IO toggle; - + LOCALE_IO toggle; + PCB_LAYER_ID layer = UNDEFINED_LAYER; + wxString layerName; //@todo allow controlling the sheet name and path that will be displayed in the title block // Leave blank for now - SVG_PLOTTER* plotter = (SVG_PLOTTER*) StartPlotBoard( aBoard, &plot_opts, UNDEFINED_LAYER, outputFile, - wxEmptyString, wxEmptyString ); + wxString sheetName; + wxString sheetPath; + + if( aSvgPlotOptions.m_printMaskLayer.size() == 1 ) + { + layer = aSvgPlotOptions.m_printMaskLayer.front(); + layerName = aBoard->GetLayerName( layer ); + } + + SVG_PLOTTER* plotter = (SVG_PLOTTER*) StartPlotBoard( aBoard, &plot_opts, layer, layerName, + outputFile, sheetName, sheetPath ); if( plotter ) { diff --git a/pcbnew/pcbnew_jobs_handler.cpp b/pcbnew/pcbnew_jobs_handler.cpp index dedb50e337..9aa4493f34 100644 --- a/pcbnew/pcbnew_jobs_handler.cpp +++ b/pcbnew/pcbnew_jobs_handler.cpp @@ -494,8 +494,29 @@ int PCBNEW_JOBS_HANDLER::JobExportDxf( JOB* aJob ) plotOpts.SetPlotReference( aDxfJob->m_plotRefDes ); plotOpts.SetLayerSelection( aDxfJob->m_printMaskLayer ); - DXF_PLOTTER* plotter = (DXF_PLOTTER*) StartPlotBoard( - brd, &plotOpts, UNDEFINED_LAYER, aDxfJob->m_outputFile, wxEmptyString, wxEmptyString ); + 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->m_outputFile, sheetName, + sheetPath ); if( plotter ) { @@ -555,8 +576,29 @@ int PCBNEW_JOBS_HANDLER::JobExportPdf( JOB* aJob ) case 2: plotOpts.SetDrillMarksType( DRILL_MARKS::FULL_DRILL_SHAPE ); break; } - PDF_PLOTTER* plotter = (PDF_PLOTTER*) StartPlotBoard( - brd, &plotOpts, UNDEFINED_LAYER, aPdfJob->m_outputFile, wxEmptyString, wxEmptyString ); + PCB_LAYER_ID layer = UNDEFINED_LAYER; + wxString layerName; + wxString sheetName; + wxString sheetPath; + + if( aPdfJob->m_printMaskLayer.size() == 1 ) + { + layer = aPdfJob->m_printMaskLayer.front(); + layerName = brd->GetLayerName( layer ); + } + + if( aPdfJob->GetVarOverrides().contains( wxT( "LAYER" ) ) ) + layerName = aPdfJob->GetVarOverrides().at( wxT( "LAYER" ) ); + + if( aPdfJob->GetVarOverrides().contains( wxT( "SHEETNAME" ) ) ) + sheetName = aPdfJob->GetVarOverrides().at( wxT( "SHEETNAME" ) ); + + if( aPdfJob->GetVarOverrides().contains( wxT( "SHEETPATH" ) ) ) + sheetPath = aPdfJob->GetVarOverrides().at( wxT( "SHEETPATH" ) ); + + PDF_PLOTTER* plotter = (PDF_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName, + aPdfJob->m_outputFile, sheetName, + sheetPath ); if( plotter ) { @@ -631,8 +673,11 @@ int PCBNEW_JOBS_HANDLER::JobExportGerbers( JOB* aJob ) } // Pick the basename from the board file - wxFileName fn( brd->GetFileName() ); - PCB_LAYER_ID layer = *seq; + wxFileName fn( brd->GetFileName() ); + PCB_LAYER_ID layer = *seq; + wxString layerName = brd->GetLayerName( layer ); + wxString sheetName; + wxString sheetPath; PCB_PLOT_PARAMS plotOpts; if( aGerberJob->m_useBoardPlotParams ) @@ -645,14 +690,24 @@ int PCBNEW_JOBS_HANDLER::JobExportGerbers( JOB* aJob ) else fileExt = FILEEXT::GerberFileExtension; - BuildPlotFileName( &fn, aGerberJob->m_outputFile, brd->GetLayerName( layer ), fileExt ); + BuildPlotFileName( &fn, aGerberJob->m_outputFile, layerName, fileExt ); wxString fullname = fn.GetFullName(); jobfile_writer.AddGbrFile( layer, fullname ); + 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" ) ); + // We are feeding it one layer at the start here to silence a logic check - GERBER_PLOTTER* plotter = (GERBER_PLOTTER*) StartPlotBoard( - brd, &plotOpts, layer, fn.GetFullPath(), wxEmptyString, wxEmptyString ); + GERBER_PLOTTER* plotter = (GERBER_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, + layerName, fn.GetFullPath(), + sheetName, sheetPath ); if( plotter ) { @@ -733,10 +788,30 @@ int PCBNEW_JOBS_HANDLER::JobExportGerber( JOB* aJob ) populateGerberPlotOptionsFromJob( plotOpts, aGerberJob ); plotOpts.SetLayerSelection( aGerberJob->m_printMaskLayer ); + PCB_LAYER_ID layer = UNDEFINED_LAYER; + wxString layerName; + wxString sheetName; + wxString sheetPath; + + if( aGerberJob->m_printMaskLayer.size() == 1 ) + { + layer = aGerberJob->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" ) ); + // We are feeding it one layer at the start here to silence a logic check - GERBER_PLOTTER* plotter = (GERBER_PLOTTER*) StartPlotBoard( - brd, &plotOpts, aGerberJob->m_printMaskLayer.front(), aGerberJob->m_outputFile, - wxEmptyString, wxEmptyString ); + GERBER_PLOTTER* plotter = (GERBER_PLOTTER*) StartPlotBoard( brd, &plotOpts, layer, layerName, + aGerberJob->m_outputFile, + sheetName, sheetPath ); if( plotter ) { diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index 4bf4460ac7..c7a3487bf2 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -450,8 +450,10 @@ bool PLOT_CONTROLLER::OpenPlotfile( const wxString& aSuffix, PLOT_FORMAT aFormat outputDirName = ExpandTextVars( outputDirName, &textResolver ); outputDirName = ExpandEnvVarSubstitutions( outputDirName, nullptr ); - wxFileName outputDir = wxFileName::DirName( outputDirName ); - wxString boardFilename = m_board->GetFileName(); + wxFileName outputDir = wxFileName::DirName( outputDirName ); + wxString boardFilename = m_board->GetFileName(); + PCB_LAYER_ID layer = ToLAYER_ID( GetLayer() ); + wxString layerName = m_board->GetLayerName( layer ); if( EnsureFileDirectoryExists( &outputDir, boardFilename ) ) { @@ -471,7 +473,7 @@ bool PLOT_CONTROLLER::OpenPlotfile( const wxString& aSuffix, PLOT_FORMAT aFormat // Build plot filenames from the board name and layer names: BuildPlotFileName( &m_plotFile, outputDir.GetPath(), aSuffix, fileExt ); - m_plotter = StartPlotBoard( m_board, &GetPlotOptions(), ToLAYER_ID( GetLayer() ), + m_plotter = StartPlotBoard( m_board, &GetPlotOptions(), layer, layerName, m_plotFile.GetFullPath(), aSheetName, aSheetPath ); } diff --git a/pcbnew/pcbplot.h b/pcbnew/pcbplot.h index 8943c0cb2c..bd01b7fa5f 100644 --- a/pcbnew/pcbplot.h +++ b/pcbnew/pcbplot.h @@ -142,8 +142,8 @@ private: PLOTTER* StartPlotBoard( BOARD* aBoard, const PCB_PLOT_PARAMS* aPlotOpts, int aLayer, - const wxString& aFullFileName, const wxString& aSheetName, - const wxString& aSheetPath ); + const wxString& aLayerName, const wxString& aFullFileName, + const wxString& aSheetName, const wxString& aSheetPath ); /** * Plot a sequence of board layer IDs. diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index f8afe6cfbd..f521efa938 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -1151,8 +1151,8 @@ static void ConfigureHPGLPenSizes( HPGL_PLOTTER *aPlotter, const PCB_PLOT_PARAMS * @return the plotter object if OK, NULL if the file is not created (or has a problem). */ PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, - const wxString& aFullFileName, const wxString& aSheetName, - const wxString& aSheetPath ) + const wxString& aLayerName, const wxString& aFullFileName, + const wxString& aSheetName, const wxString& aSheetPath ) { // Create the plotter driver and set the few plotter specific options PLOTTER* plotter = nullptr; @@ -1213,9 +1213,7 @@ PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aL KIGFX::PCB_RENDER_SETTINGS* renderSettings = new KIGFX::PCB_RENDER_SETTINGS(); renderSettings->LoadColors( aPlotOpts->ColorSettings() ); renderSettings->SetDefaultPenWidth( pcbIUScale.mmToIU( 0.0212 ) ); // Hairline at 1200dpi - - if( aLayer >= 0 && aLayer < GAL_LAYER_ID_END ) - renderSettings->SetLayerName( aBoard->GetLayerName( ToLAYER_ID( aLayer ) ) ); + renderSettings->SetLayerName( aLayerName ); plotter->SetRenderSettings( renderSettings );