31#include <wx/filename.h>
49 if(
scale == 0.0 ) selection = 0;
50 else if(
scale == 1.5 ) selection = 2;
51 else if(
scale == 2.0 ) selection = 3;
52 else if(
scale == 3.0 ) selection = 4;
67 const LSEQ& aCommonLayers,
bool aUseGerberFileExtensions,
68 bool aOutputPathIsSingle, std::optional<wxString> aLayerName,
69 std::optional<wxString> aSheetName, std::optional<wxString> aSheetPath,
70 std::vector<wxString>* aOutputFiles )
72 std::function<bool( wxString* )> textResolver = [&]( wxString* token ) ->
bool
75 return m_board->ResolveTextVar( token, 0 );
79 if( aLayersToPlot.size() < 1 )
86 VECTOR2I existingAuxOrigin =
m_board->GetDesignSettings().GetAuxOrigin();
90 BOX2I bbox =
m_board->ComputeBoundingBox(
false,
false );
94 if(
m_board->GetBoardPolygonOutlines( boardOutlines,
false ) && boardOutlines.
OutlineCount() > 0 )
95 bbox = boardOutlines.
BBox();
102 m_board->SetPageSettings( currPageInfo );
106 m_board->GetDesignSettings().SetAuxOrigin( origin );
113 const bool isPdfMultiPage =
116 if( aOutputPathIsSingle && !
m_plotOpts.GetDXFMultiLayeredExportOption() && !isPdfMultiPage )
118 layersToPlot.push_back( aLayersToPlot[0] );
120 if( aLayersToPlot.size() > 1 )
121 commonLayers.insert( commonLayers.end(), aLayersToPlot.begin() + 1, aLayersToPlot.end() );
125 layersToPlot = aLayersToPlot;
126 commonLayers = aCommonLayers;
129 int finalPageCount = 0;
130 std::vector<std::pair<PCB_LAYER_ID, wxString>> layersToExport;
140 layersToExport.emplace_back( layer,
m_board->GetLayerName( layer ) );
143 std::unique_ptr<GERBER_JOBFILE_WRITER> jobfile_writer;
156 for(
size_t i = 0; i < layersToPlot.size(); i++ )
164 wxString layerName =
m_board->GetLayerName( layer );
167 if( aOutputPathIsSingle )
169 fn = wxFileName( aOutputPath );
173 wxFileName brdFn =
m_board->GetFileName();
174 fn.Assign( aOutputPath, brdFn.GetName(), fileExt );
191 wxString fullname = fn.GetFullName();
192 jobfile_writer->AddGbrFile( layer, fullname );
202 wxString pageNumber = wxString::Format(
"%d", pageNum );
203 wxString pageName = layerName;
204 wxString sheetName = layerName;
206 if( aLayerName.has_value() )
208 layerName = aLayerName.value();
209 pageName = aLayerName.value();
212 if( aSheetName.has_value() )
213 sheetName = aSheetName.value();
215 if( aSheetPath.has_value() )
216 sheetPath = aSheetPath.value();
218 m_plotOpts.SetLayersToExport( layersToExport );
220 sheetName, sheetPath, pageName, pageNumber, finalPageCount );
230 msg = wxS(
"AUTHOR" );
232 if(
m_board->ResolveTextVar( &msg, 0 ) )
235 msg = wxS(
"SUBJECT" );
237 if(
m_board->ResolveTextVar( &msg, 0 ) )
254 && i != layersToPlot.size() - 1 )
256 wxString pageNumber = wxString::Format(
"%d", pageNum + 1 );
257 size_t nextI = i + 1;
263 nextLayer = layersToPlot[nextI];
266 layerName =
m_board->GetLayerName( nextLayer );
268 wxString pageName = layerName;
269 wxString sheetName = layerName;
272 static_cast<PDF_PLOTTER*
>( plotter )->StartPage( pageNumber, pageName );
274 sheetPath, pageNumber, finalPageCount );
280 || i == aLayersToPlot.size() - 1
281 || pageNum == finalPageCount )
296 msg.Printf(
_(
"Plotted to '%s'." ), fn.GetFullPath() );
300 aOutputFiles->push_back( fn.GetFullPath() );
305 msg.Printf(
_(
"Failed to create file '%s'." ), fn.GetFullPath() );
316 if( jobfile_writer &&
m_plotOpts.GetCreateGerberJobFile() )
319 wxFileName fn(
m_board->GetFileName() );
323 jobfile_writer->CreateJobFile( fn.GetFullPath() );
326 aOutputFiles->push_back( fn.GetFullPath() );
334 m_board->SetPageSettings( existingPageInfo );
335 m_board->GetDesignSettings().SetAuxOrigin( existingAuxOrigin );
349 const wxString& aSuffix,
const wxString& aExtension )
354 aFilename->SetPath( aOutputDir );
357 aFilename->SetExt( aExtension );
365 wxString suffix = aSuffix;
367 suffix.Trim(
false );
369 wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
370 badchars.Append(
"%." );
372 for(
unsigned ii = 0; ii < badchars.Len(); ii++ )
373 suffix.Replace( badchars[ii], wxT(
"_" ) );
375 if( !suffix.IsEmpty() )
376 aFilename->SetName( aFilename->GetName() + wxT(
"-" ) + suffix );
385 plotSequence.push_back( aLayerToPlot );
390 if(
find( plotSequence.begin(), plotSequence.end(), layer ) != plotSequence.end() )
393 plotSequence.push_back( layer );
500 if( theme.IsEmpty() )
503 theme = pcbSettings->m_ColorTheme;
510 aReporter.
Report( wxString::Format(
_(
"Color theme '%s' not found, will use theme from PCB Editor.\n" ),
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Information pertinent to a Pcbnew printed circuit board.
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
wxString m_pdfBackgroundColor
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
Used by SVG & PDF.
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.
double m_trackWidthCorrection
wxString GetConfiguredOutputPath() const
Returns the configured output path for the job.
wxString GetFilename() const
A color representation with 4 components: red, green, blue, alpha.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
static LSET AllCuMask(int aCuLayerCount)
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.
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 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, std::vector< wxString > *aOutputFiles=nullptr)
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.
void SetDrillMarksType(DRILL_MARKS aVal)
void SetLayerSelection(const LSET &aSelection)
void SetOutputDirectory(const wxString &aDir)
void SetPlotReference(bool aFlag)
void SetSketchPadsOnFabLayers(bool aFlag)
void SetUseGerberX2format(bool aUse)
void SetA4Output(int aForce)
void SetPlotOnAllLayersSequence(LSEQ aSeq)
void SetDXFPlotPolygonMode(bool aFlag)
void SetAutoScale(bool aFlag)
void SetPlotFrameRef(bool aFlag)
void SetSketchDNPFPsOnFabLayers(bool aFlag)
bool m_PDFMetadata
Generate PDF metadata for SUBJECT and AUTHOR.
void SetPlotPadNumbers(bool aFlag)
bool m_PDFFrontFPPropertyPopups
Generate PDF property popup menus for footprints.
void SetScale(double aVal)
void SetDisableGerberMacros(bool aDisable)
void SetDXFMultiLayeredExportOption(bool aFlag)
void SetScaleSelection(int aSelection)
void SetFineScaleAdjustX(double aVal)
void SetMirror(bool aFlag)
void SetBlackAndWhite(bool blackAndWhite)
void SetGerberPrecision(int aPrecision)
void SetSubtractMaskFromSilk(bool aSubtract)
void SetHideDNPFPsOnFabLayers(bool aFlag)
void SetPlotValue(bool aFlag)
COLOR4D m_PDFBackgroundColor
Background color to use if m_PDFUseBackgroundColor is true.
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)
bool GetBlackAndWhite() const
void SetUseAuxOrigin(bool aAux)
bool m_PDFBackFPPropertyPopups
on front and/or back of board
void SetDXFPlotMode(DXF_OUTLINE_MODE aPlotMode)
void SetSvgFitPageToBoard(int aSvgFitPageToBoard)
void SetSvgPrecision(unsigned aPrecision)
void SetCrossoutDNPFPsOnFabLayers(bool aFlag)
void SetFormat(PLOT_FORMAT aFormat)
void SetFineScaleAdjustY(double aVal)
void SetWidthAdjust(int aVal)
Base plotter engine class.
virtual void SetAuthor(const wxString &aAuthor)
void SetLayer(PCB_LAYER_ID aLayer)
Sets the ID of the current layer.
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 & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Represent a set of closed polygons.
int OutlineCount() const
Return the number of outlines in the set.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
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:
static int scaleToSelection(double scale)
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, PCB_PLOT_PARAMS *aPlotOpts, const wxString &aLayerName, 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.).
PLOT_FORMAT
The set of supported output plot formats.
Plotting engines similar to ps (PostScript, Gerber, svg)
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetAppSettings(const char *aFilename)
VECTOR2< int32_t > VECTOR2I