30#include <wx/filename.h>
43 m_plotOpts( aParams ),
44 m_reporter( aReporter )
50 const LSEQ& aLayersToPlot,
51 const LSEQ& aCommonLayers,
52 bool aUseGerberFileExtensions,
53 bool aOutputPathIsSingle,
54 std::optional<wxString> aLayerName,
55 std::optional<wxString> aSheetName,
56 std::optional<wxString> aSheetPath )
58 std::function<bool( wxString* )> textResolver = [&]( wxString* token ) ->
bool
65 if( aLayersToPlot.size() < 1 )
93 if( aOutputPathIsSingle )
95 layersToPlot.push_back( aLayersToPlot[0] );
97 if( aLayersToPlot.size() > 1 )
99 commonLayers.insert( commonLayers.end(), aLayersToPlot.begin() + 1,
100 aLayersToPlot.end() );
105 layersToPlot = aLayersToPlot;
106 commonLayers = aCommonLayers;
109 size_t finalPageCount = 0;
119 std::unique_ptr<GERBER_JOBFILE_WRITER> jobfile_writer;
130 for(
size_t i = 0, pageNum = 1; i < layersToPlot.size(); i++ )
143 if( aOutputPathIsSingle )
145 fn = wxFileName( aOutputPath );
150 fn.Assign( aOutputPath, brdFn.GetName() );
169 wxString fullname = fn.GetFullName();
170 jobfile_writer->AddGbrFile( layer, fullname );
179 wxString pageNumber = wxString::Format(
"%zu", pageNum );
180 wxString pageName = layerName;
181 wxString sheetName = layerName;
183 if( aLayerName.has_value() )
185 layerName = aLayerName.value();
186 pageName = aLayerName.value();
189 if( aSheetName.has_value() )
190 sheetName = aSheetName.value();
192 if( aSheetPath.has_value() )
193 sheetPath = aSheetPath.value();
196 sheetName, sheetPath, pageName, pageNumber, finalPageCount );
205 msg = wxS(
"AUTHOR" );
210 msg = wxS(
"SUBJECT" );
228 && i != layersToPlot.size() - 1 )
230 wxString pageNumber = wxString::Format(
"%zu", pageNum + 1 );
237 nextLayer = layersToPlot[nextI];
239 && ( nextI < layersToPlot.size() - 1 ) );
242 wxString sheetName = layerName;
245 static_cast<PDF_PLOTTER*
>( plotter )->StartPage( pageNumber, pageName );
247 pageNumber, finalPageCount );
254 || i == aLayersToPlot.size() - 1
255 || pageNum == finalPageCount )
270 msg.Printf(
_(
"Plotted to '%s'." ), fn.GetFullPath() );
276 msg.Printf(
_(
"Failed to create file '%s'." ), fn.GetFullPath() );
294 jobfile_writer->CreateJobFile( fn.GetFullPath() );
317 const wxString& aSuffix,
const wxString& aExtension )
322 aFilename->SetPath( aOutputDir );
325 aFilename->SetExt( aExtension );
333 wxString suffix = aSuffix;
335 suffix.Trim(
false );
337 wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
338 badchars.Append(
"%." );
340 for(
unsigned ii = 0; ii < badchars.Len(); ii++ )
341 suffix.Replace( badchars[ii], wxT(
"_" ) );
343 if( !suffix.IsEmpty() )
344 aFilename->SetName( aFilename->GetName() + wxT(
"-" ) + suffix );
353 plotSequence.push_back( aLayerToPlot );
358 if(
find( plotSequence.begin(), plotSequence.end(), layer ) != plotSequence.end() )
361 plotSequence.push_back( layer );
397 : OUTLINE_MODE::FILLED );
458 if( theme.IsEmpty() )
468 aReporter.
Report( wxString::Format(
469 _(
"Color theme '%s' not found, will use theme from PCB Editor settings.\n" ),
constexpr EDA_IU_SCALE pcbIUScale
wxString m_ColorTheme
Active color theme name.
void SetAuxOrigin(const VECTOR2I &aOrigin)
const VECTOR2I & GetAuxOrigin() const
Information pertinent to a Pcbnew printed circuit board.
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
const PAGE_INFO & GetPageSettings() const
bool ResolveTextVar(wxString *token, int aDepth) const
TITLE_BLOCK & GetTitleBlock()
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
void SetPageSettings(const PAGE_INFO &aPageSettings)
const wxString & GetFileName() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
constexpr size_type GetWidth() const
constexpr size_type GetHeight() const
constexpr const Vec & GetOrigin() const
Color settings are a bit different than most of the settings objects in that there can be more than o...
bool m_plotGraphicItemsUsingContours
bool m_useProtelFileExtension
bool m_includeNetlistAttributes
bool m_disableApertureMacros
bool m_pdfFrontFPPropertyPopups
bool m_pdfSingle
This is a hack to deal with cli having the wrong behavior We will deprecate out the wrong behavior,...
bool m_pdfBackFPPropertyPopups
bool m_sketchDNPFPsOnFabLayers
bool m_plotFootprintValues
LSEQ m_plotOnAllLayersSequence
bool m_sketchPadsOnFabLayers
DRILL_MARKS m_drillShapeOption
Used by SVG/DXF/PDF/Gerbers.
bool m_crossoutDNPFPsOnFabLayers
bool m_hideDNPFPsOnFabLayers
bool m_mirror
Common Options.
bool m_subtractSolderMaskFromSilk
LSEQ m_plotLayerSequence
Layers to include on all individual layer prints.
wxString GetConfiguredOutputPath() const
Returns the configured output path for the job.
wxString GetFilename() const
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Describe the page size and margins of a paper page on which to eventually print or plot.
void SetHeightMils(double aHeightInMils)
void SetWidthMils(double aWidthInMils)
LSEQ getPlotSequence(PCB_LAYER_ID aLayerToPlot, LSEQ aPlotWithAllLayersSeq)
Generates a final LSEQ for plotting by removing duplicates.
bool Plot(const wxString &aOutputPath, const LSEQ &aLayersToPlot, const LSEQ &aCommonLayers, bool aUseGerberFileExtensions, bool aOutputPathIsSingle=false, std::optional< wxString > aLayerName=std::nullopt, std::optional< wxString > aSheetName=std::nullopt, std::optional< wxString > aSheetPath=std::nullopt)
static void PlotJobToPlotOpts(PCB_PLOT_PARAMS &aOpts, JOB_EXPORT_PCB_PLOT *aJob, REPORTER &aReporter)
Translate a JOB to PCB_PLOT_PARAMS.
PCB_PLOTTER(BOARD *aBoard, REPORTER *aReporter, PCB_PLOT_PARAMS &aParams)
PCB_PLOT_PARAMS m_plotOpts
bool copperLayerShouldBeSkipped(PCB_LAYER_ID aLayerToPlot)
All copper layers that are disabled are actually selected This is due to wonkyness in automatically s...
static void BuildPlotFileName(wxFileName *aFilename, const wxString &aOutputDir, const wxString &aSuffix, const wxString &aExtension)
Complete a plot filename.
Parameters and options when plotting/printing a board.
PLOT_FORMAT GetFormat() const
void SetDrillMarksType(DRILL_MARKS aVal)
void SetLayerSelection(LSET aSelection)
void SetOutputDirectory(const wxString &aDir)
void SetPlotReference(bool aFlag)
void SetSketchPadsOnFabLayers(bool aFlag)
void SetUseGerberX2format(bool aUse)
void SetPlotOnAllLayersSequence(LSEQ aSeq)
void SetDXFPlotPolygonMode(bool aFlag)
void SetPlotFrameRef(bool aFlag)
void SetSketchDNPFPsOnFabLayers(bool aFlag)
bool m_PDFMetadata
Generate PDF metadata for SUBJECT and AUTHOR.
bool GetCreateGerberJobFile() const
void SetPlotPadNumbers(bool aFlag)
bool GetSvgFitPagetoBoard() const
bool m_PDFFrontFPPropertyPopups
Generate PDF property popup menus for footprints.
void SetDisableGerberMacros(bool aDisable)
void SetMirror(bool aFlag)
void SetBlackAndWhite(bool blackAndWhite)
void SetGerberPrecision(int aPrecision)
void SetSubtractMaskFromSilk(bool aSubtract)
void SetHideDNPFPsOnFabLayers(bool aFlag)
void SetPlotValue(bool aFlag)
void SetUseGerberProtelExtensions(bool aUse)
void SetDXFPlotUnits(DXF_UNITS aUnit)
void SetColorSettings(COLOR_SETTINGS *aSettings)
void SetIncludeGerberNetlistInfo(bool aUse)
void SetCreateGerberJobFile(bool aCreate)
bool m_PDFSingle
Generate a single PDF file for all layers.
void SetNegative(bool aFlag)
void SetPlotMode(OUTLINE_MODE aPlotMode)
void SetUseAuxOrigin(bool aAux)
bool m_PDFBackFPPropertyPopups
on front and/or back of board
void SetSvgFitPageToBoard(int aSvgFitPageToBoard)
void SetSvgPrecision(unsigned aPrecision)
void SetCrossoutDNPFPsOnFabLayers(bool aFlag)
void SetFormat(PLOT_FORMAT aFormat)
virtual SETTINGS_MANAGER & GetSettingsManager() const
Base plotter engine class.
virtual void SetAuthor(const wxString &aAuthor)
virtual void SetTitle(const wxString &aTitle)
RENDER_SETTINGS * RenderSettings()
virtual void SetSubject(const wxString &aSubject)
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the end of the list, for objects that support report ordering.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieve a color settings object that applications can read colors from.
T * GetAppSettings(const wxString &aFilename)
Return a handle to the a given settings by type.
const wxString & GetTitle() const
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
wxString GetDefaultPlotExtension(PLOT_FORMAT aFormat)
Return the default plot extension for a format.
Classes used to generate a Gerber job file in JSON.
static const std::string GerberJobFileExtension
PCB_LAYER_ID
A quick note on layer IDs:
const wxString GetGerberProtelExtension(int aLayer)
PLOTTER * StartPlotBoard(BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aLayerName, const wxString &aFullFileName, const wxString &aSheetName, const wxString &aSheetPath, const wxString &aPageName=wxT("1"), const wxString &aPageNumber=wxEmptyString, const int aPageCount=1)
Open a new plotfile using the options (and especially the format) specified in the options and prepar...
void setupPlotterNewPDFPage(PLOTTER *aPlotter, BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, const wxString &aSheetName, const wxString &aSheetPath, const wxString &aPageNumber, int aPageCount)
void PlotBoardLayers(BOARD *aBoard, PLOTTER *aPlotter, const LSEQ &aLayerSequence, const PCB_PLOT_PARAMS &aPlotOptions)
Plot a sequence of board layer IDs.
void PlotInteractiveLayer(BOARD *aBoard, PLOTTER *aPlotter, const PCB_PLOT_PARAMS &aPlotOpt)
Plot interactive items (hypertext links, properties, etc.).
PGM_BASE & Pgm()
The global program "get" accessor.
Plotting engines similar to ps (PostScript, Gerber, svg)