KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_plotter.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <pcb_plotter.h>
21#include <common.h>
22#include <plotters/plotter.h>
24#include <board.h>
25#include <board_loader.h>
26#include <footprint.h>
27#include <pad.h>
28#include <project.h>
30#include <pcb_drill_chart.h>
31#include <reporter.h>
32#include <pcbplot.h>
33#include <wx/filename.h>
42#include <pgm_base.h>
43#include <pcbnew_settings.h>
45#include <math/util.h> // for KiROUND
46
47
48static int scaleToSelection( double scale )
49{
50 int selection = 1;
51
52 if( scale == 0.0 ) selection = 0;
53 else if( scale == 1.5 ) selection = 2;
54 else if( scale == 2.0 ) selection = 3;
55 else if( scale == 3.0 ) selection = 4;
56
57 return selection;
58}
59
60
61PCB_PLOTTER::PCB_PLOTTER( BOARD* aBoard, REPORTER* aReporter, PCB_PLOT_PARAMS& aParams ) :
62 m_board( aBoard ),
63 m_plotOpts( aParams ),
64 m_reporter( aReporter )
65{
66}
67
68
69bool PCB_PLOTTER::Plot( const wxString& aOutputPath, const LSEQ& aLayersToPlot,
70 const LSEQ& aCommonLayers, bool aUseGerberFileExtensions,
71 bool aOutputPathIsSingle, std::optional<wxString> aLayerName,
72 std::optional<wxString> aSheetName, std::optional<wxString> aSheetPath,
73 std::vector<wxString>* aOutputFiles )
74{
75 std::function<bool( wxString* )> textResolver =
76 [&]( wxString* token ) -> bool
77 {
78 // Handles board->GetTitleBlock() *and* board->GetProject()
79 return m_board->ResolveTextVar( token, 0 );
80 };
81
82 // sanity, ensure one layer to print
83 if( aLayersToPlot.size() < 1 )
84 {
85 if( m_reporter )
86 m_reporter->Report( _( "No layers selected for plotting." ), RPT_SEVERITY_ERROR );
87
88 return false;
89 }
90
91 // The one path GUI plotting, PNG, PS and every CLI plot job share. Common layers are
92 // included or a chart plotted as one slips past the policy
93 LSET plotted( { aLayersToPlot } );
94 plotted |= LSET( { aCommonLayers } );
95
97
98 PAGE_INFO existingPageInfo = m_board->GetPageSettings();
99 VECTOR2I existingAuxOrigin = m_board->GetDesignSettings().GetAuxOrigin();
100
101 if( m_plotOpts.GetFormat() == PLOT_FORMAT::SVG && m_plotOpts.GetSvgFitPagetoBoard() ) // Page is board boundary size
102 {
103 BOX2I bbox = m_board->ComputeBoundingBox( false, false );
104 SHAPE_POLY_SET boardOutlines;
105
106 // Board outline geometry is better if it exists so that origin is not influenced by Edge.Cuts line width
107 if( m_board->GetBoardPolygonOutlines( boardOutlines, false ) && boardOutlines.OutlineCount() > 0 )
108 bbox = boardOutlines.BBox();
109
110 PAGE_INFO currPageInfo = m_board->GetPageSettings();
111
112 currPageInfo.SetWidthMils( bbox.GetWidth() / pcbIUScale.IU_PER_MILS );
113 currPageInfo.SetHeightMils( bbox.GetHeight() / pcbIUScale.IU_PER_MILS );
114
115 m_board->SetPageSettings( currPageInfo );
116 m_plotOpts.SetUseAuxOrigin( true );
117
118 // Keep the origin at the board origin so it lands on the SVG origin. The SVG
119 // plotter was given the bounding box to build its viewBox from elsewhere.
120 m_board->GetDesignSettings().SetAuxOrigin( VECTOR2I( 0, 0 ) );
121 }
122
123 // To reuse logic, in single plot mode, we want to kick any extra layers from the main list to commonLayers
124 LSEQ layersToPlot;
125 LSEQ commonLayers;
126
127 const bool isPdfMultiPage = ( m_plotOpts.GetFormat() == PLOT_FORMAT::PDF && m_plotOpts.m_PDFSingle );
128
129 if( aOutputPathIsSingle && !m_plotOpts.GetDXFMultiLayeredExportOption() && !isPdfMultiPage )
130 {
131 layersToPlot.push_back( aLayersToPlot[0] );
132
133 if( aLayersToPlot.size() > 1 )
134 commonLayers.insert( commonLayers.end(), aLayersToPlot.begin() + 1, aLayersToPlot.end() );
135 }
136 else
137 {
138 layersToPlot = aLayersToPlot;
139 commonLayers = aCommonLayers;
140 }
141
142 int finalPageCount = 0;
143 std::vector<std::pair<PCB_LAYER_ID, wxString>> layersToExport;
144
145 // Skip the disabled copper layers and build the layer ID -> layer name mapping for plotter
146 // DXF plotter will use this information to name its layers
147 for( PCB_LAYER_ID layer : layersToPlot )
148 {
149 if( copperLayerShouldBeSkipped( layer ) )
150 continue;
151
152 finalPageCount++;
153 layersToExport.emplace_back( layer, m_board->GetLayerName( layer ) );
154 }
155
156 std::unique_ptr<GERBER_JOBFILE_WRITER> jobfile_writer;
157
158 if( m_plotOpts.GetFormat() == PLOT_FORMAT::GERBER && !aOutputPathIsSingle )
159 jobfile_writer = std::make_unique<GERBER_JOBFILE_WRITER>( m_board, m_reporter );
160
161 PLOT_FORMAT plot_format = m_plotOpts.GetFormat();
162 wxString fileExt( GetDefaultPlotExtension( m_plotOpts.GetFormat() ) );
163 wxString sheetPath;
164 wxString msg;
165 bool success = true;
166 PLOTTER* plotter = nullptr;
167 int pageNum = 1;
168
169 for( size_t i = 0; i < layersToPlot.size(); i++ )
170 {
171 PCB_LAYER_ID layer = layersToPlot[i];
172
173 if( copperLayerShouldBeSkipped( layer ) )
174 continue;
175
176 LSEQ plotSequence = getPlotSequence( layer, commonLayers );
177 wxString layerName = m_board->GetLayerName( layer );
178 wxFileName fn;
179
180 if( aOutputPathIsSingle )
181 {
182 fn = wxFileName( aOutputPath );
183 }
184 else
185 {
186 wxFileName brdFn = m_board->GetFileName();
187 fn.Assign( aOutputPath, brdFn.GetName(), fileExt );
188
189 // Use Gerber Extensions based on layer number
190 // (See http://en.wikipedia.org/wiki/Gerber_File)
191 if( m_plotOpts.GetFormat() == PLOT_FORMAT::GERBER && aUseGerberFileExtensions )
192 fileExt = GetGerberProtelExtension( layer );
193
194 if( plot_format == PLOT_FORMAT::PDF && m_plotOpts.m_PDFSingle )
196 else if ( plot_format == PLOT_FORMAT::DXF && m_plotOpts.GetDXFMultiLayeredExportOption() )
198 else
199 BuildPlotFileName( &fn, aOutputPath, layerName, fileExt );
200 }
201
202 if( jobfile_writer )
203 {
204 wxString fullname = fn.GetFullName();
205 jobfile_writer->AddGbrFile( layer, fullname );
206 }
207
208 if( ( plot_format != PLOT_FORMAT::PDF && plot_format != PLOT_FORMAT::DXF )
209 || ( !m_plotOpts.m_PDFSingle && !m_plotOpts.GetDXFMultiLayeredExportOption() )
210 || ( pageNum == 1
211 && ( ( plot_format == PLOT_FORMAT::PDF && m_plotOpts.m_PDFSingle )
212 || ( plot_format == PLOT_FORMAT::DXF && m_plotOpts.GetDXFMultiLayeredExportOption() ) ) ) )
213 {
214 // this will only be used by pdf
215 wxString pageNumber = wxString::Format( "%d", pageNum );
216 wxString pageName = layerName;
217 wxString sheetName = layerName;
218
219 if( aLayerName.has_value() )
220 {
221 layerName = aLayerName.value();
222 pageName = aLayerName.value();
223 }
224
225 if( aSheetName.has_value() )
226 sheetName = aSheetName.value();
227
228 if( aSheetPath.has_value() )
229 sheetPath = aSheetPath.value();
230
231 m_plotOpts.SetLayersToExport( layersToExport );
232 plotter = StartPlotBoard( m_board, &m_plotOpts, layer, layerName, fn.GetFullPath(),
233 sheetName, sheetPath, pageName, pageNumber, finalPageCount );
234 }
235
236 if( plotter )
237 {
238 plotter->SetLayer( layer );
239 plotter->SetTitle( ExpandTextVars( m_board->GetTitleBlock().GetTitle(), &textResolver, FOR_GUI ) );
240
241 if( m_plotOpts.m_PDFMetadata )
242 {
243 msg = wxS( "AUTHOR" );
244
245 if( m_board->ResolveTextVar( &msg, 0 ) )
246 plotter->SetAuthor( msg );
247
248 msg = wxS( "SUBJECT" );
249
250 if( m_board->ResolveTextVar( &msg, 0 ) )
251 plotter->SetSubject( msg );
252 }
253
254 try
255 {
256 PlotBoardLayers( m_board, plotter, plotSequence, m_plotOpts );
258 }
259 catch( ... )
260 {
261 success = false;
262 delete plotter->RenderSettings();
263 delete plotter;
264 plotter = nullptr;
265 break;
266 }
267
268 if( m_plotOpts.GetFormat() == PLOT_FORMAT::PDF && m_plotOpts.m_PDFSingle && pageNum != finalPageCount )
269 {
270 wxString pageNumber = wxString::Format( "%d", pageNum + 1 );
271 size_t nextI = i + 1;
272 PCB_LAYER_ID nextLayer = layersToPlot[nextI];
273
274 while( copperLayerShouldBeSkipped( nextLayer ) && nextI < layersToPlot.size() - 1 )
275 {
276 ++nextI;
277 nextLayer = layersToPlot[nextI];
278 }
279
280 layerName = m_board->GetLayerName( nextLayer );
281
282 wxString pageName = layerName;
283 wxString sheetName = layerName;
284
285 static_cast<PDF_PLOTTER*>( plotter )->ClosePage();
286 static_cast<PDF_PLOTTER*>( plotter )->StartPage( pageNumber, pageName );
287 setupPlotterNewPDFPage( plotter, m_board, &m_plotOpts, layerName, sheetName,
288 sheetPath, pageNumber, finalPageCount );
289 }
290
291 // last page
292 if( ( plot_format != PLOT_FORMAT::PDF && plot_format != PLOT_FORMAT::DXF )
293 || ( !m_plotOpts.m_PDFSingle && !m_plotOpts.GetDXFMultiLayeredExportOption() )
294 || i == aLayersToPlot.size() - 1
295 || pageNum == finalPageCount )
296 {
297 try
298 {
299 success &= plotter->EndPlot();
300 }
301 catch( ... )
302 {
303 success = false;
304 }
305
306 delete plotter->RenderSettings();
307 delete plotter;
308 plotter = nullptr;
309
310 if( m_reporter )
311 {
312 m_reporter->Report( wxString::Format( _( "Plotted to '%s'." ), fn.GetFullPath() ),
314 }
315
316 if( aOutputFiles )
317 aOutputFiles->push_back( fn.GetFullPath() );
318 }
319 }
320 else
321 {
322 if( m_reporter )
323 {
324 m_reporter->Report( wxString::Format( _( "Failed to create file '%s'." ), fn.GetFullPath() ),
326 }
327
328 success = false;
329 }
330
331 pageNum++;
332
333 wxSafeYield(); // displays report message.
334 }
335
336 if( jobfile_writer && m_plotOpts.GetCreateGerberJobFile() )
337 {
338 // Pick the basename from the board file
339 wxFileName fn( m_board->GetFileName() );
340
341 // Build gerber job file from basename
342 BuildPlotFileName( &fn, aOutputPath, wxT( "job" ), FILEEXT::GerberJobFileExtension );
343 jobfile_writer->CreateJobFile( fn.GetFullPath() );
344
345 if( aOutputFiles )
346 aOutputFiles->push_back( fn.GetFullPath() );
347 }
348
349 if( m_reporter )
350 m_reporter->ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
351
352 if( m_plotOpts.GetFormat() == PLOT_FORMAT::SVG && m_plotOpts.GetSvgFitPagetoBoard() )
353 {
354 // restore the original page and aux origin
355 m_board->SetPageSettings( existingPageInfo );
356 m_board->GetDesignSettings().SetAuxOrigin( existingAuxOrigin );
357 }
358
359 return success;
360}
361
362
364{
365 return ( LSET::AllCuMask() & ~m_board->GetEnabledLayers() )[aLayerToPlot];
366}
367
368
369void PCB_PLOTTER::BuildPlotFileName( wxFileName* aFilename, const wxString& aOutputDir,
370 const wxString& aSuffix, const wxString& aExtension )
371{
372 // aFilename contains the base filename only (without path and extension)
373 // when calling this function.
374 // It is expected to be a valid filename (this is usually the board filename)
375 aFilename->SetPath( aOutputDir );
376
377 // Set the file extension
378 aFilename->SetExt( aExtension );
379
380 // remove leading and trailing spaces if any from the suffix, if
381 // something survives add it to the name;
382 // also the suffix can contain some not allowed chars in filename (/ \ . : and some others),
383 // so change them to underscore
384 // Remember it can be called from a python script, so the illegal chars
385 // have to be filtered here.
386 wxString suffix = aSuffix;
387 suffix.Trim( true );
388 suffix.Trim( false );
389
390 wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
391 badchars.Append( "%." );
392
393 for( unsigned ii = 0; ii < badchars.Len(); ii++ )
394 suffix.Replace( badchars[ii], wxT( "_" ) );
395
396 if( !suffix.IsEmpty() )
397 aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix );
398}
399
400
401LSEQ PCB_PLOTTER::getPlotSequence( PCB_LAYER_ID aLayerToPlot, LSEQ aPlotWithAllLayersSeq )
402{
403 LSEQ plotSequence;
404
405 // Base layer always gets plotted first.
406 plotSequence.push_back( aLayerToPlot );
407
408 for( PCB_LAYER_ID layer : aPlotWithAllLayersSeq )
409 {
410 // Don't plot the same layer more than once;
411 if( find( plotSequence.begin(), plotSequence.end(), layer ) != plotSequence.end() )
412 continue;
413
414 plotSequence.push_back( layer );
415 }
416
417 return plotSequence;
418}
419
420
422 REPORTER& aReporter )
423{
425 {
426 JOB_EXPORT_PCB_GERBERS* gJob = static_cast<JOB_EXPORT_PCB_GERBERS*>( aJob );
429 aOpts.SetUseGerberX2format( gJob->m_useX2Format );
432 aOpts.SetGerberPrecision( gJob->m_precision );
433 // Always disable plot pad holes
435 }
436 else
437 {
438 // Scale, doesn't apply to GERBER
439 aOpts.SetScale( aJob->m_scale );
440 aOpts.SetAutoScale( !aJob->m_scale );
442 // Drill marks doesn't apply to GERBER
443 switch( aJob->m_drillShapeOption )
444 {
447 default:
449 }
450 }
451
453 {
454 JOB_EXPORT_PCB_SVG* svgJob = static_cast<JOB_EXPORT_PCB_SVG*>( aJob );
455 aOpts.SetSvgPrecision( svgJob->m_precision );
456 aOpts.SetSvgFitPageToBoard( svgJob->m_fitPageToBoard );
457 }
458
460 {
461 JOB_EXPORT_PCB_DXF* dxfJob = static_cast<JOB_EXPORT_PCB_DXF*>( aJob );
463 : DXF_UNITS::MM );
466 aOpts.SetDXFPlotPolygonMode( dxfJob->m_polygonMode );
469 }
470
472 {
473 JOB_EXPORT_PCB_PDF* pdfJob = static_cast<JOB_EXPORT_PCB_PDF*>( aJob );
476 aOpts.m_PDFMetadata = pdfJob->m_pdfMetadata;
477 aOpts.m_PDFSingle = pdfJob->m_pdfSingle;
479 }
480
482 {
483 JOB_EXPORT_PCB_PS* psJob = static_cast<JOB_EXPORT_PCB_PS*>( aJob );
484 aOpts.SetWidthAdjust( KiROUND( psJob->m_trackWidthCorrection * pcbIUScale.IU_PER_MM ) );
485 aOpts.SetFineScaleAdjustX( psJob->m_XScaleAdjust );
486 aOpts.SetFineScaleAdjustY( psJob->m_YScaleAdjust );
487 aOpts.SetA4Output( psJob->m_forceA4 );
488 }
489
490 wxString theme = aJob->m_colorTheme;
491
492 // Theme may be empty when running from a job in GUI context, so use the GUI settings.
493 if( theme.IsEmpty() )
494 {
495 if( PCBNEW_SETTINGS* pcbSettings = GetAppSettings<PCBNEW_SETTINGS>( "pcbnew" ) )
496 theme = pcbSettings->m_ColorTheme;
497 }
498
499 COLOR_SETTINGS* colors = ::GetColorSettings( theme );
500
501 if( colors->GetFilename() != theme && !aOpts.GetBlackAndWhite() )
502 {
503 aReporter.Report( wxString::Format( _( "Color theme '%s' not found, will use theme from PCB Editor.\n" ),
504 theme ),
506 }
507
509 {
510 JOB_EXPORT_PCB_PNG* pngJob = static_cast<JOB_EXPORT_PCB_PNG*>( aJob );
511 aOpts.SetPngDPI( pngJob->m_dpi );
512 aOpts.SetPngAntialias( pngJob->m_antialias );
513
514 if( pngJob->m_useBackgroundColor )
516 }
517
518 aOpts.SetUseAuxOrigin( aJob->m_useDrillOrigin );
519 aOpts.SetPlotFrameRef( aJob->m_plotDrawingSheet );
521 aOpts.SetPlotReference( aJob->m_plotRefDes );
522 aOpts.SetPlotValue( aJob->m_plotFootprintValues );
527 aOpts.SetPlotPadNumbers( aJob->m_plotPadNumbers );
528
529 aOpts.SetBlackAndWhite( aJob->m_blackAndWhite );
530 aOpts.SetMirror( aJob->m_mirror );
531 aOpts.SetNegative( aJob->m_negative );
532
535
536 switch( aJob->m_plotFormat )
537 {
538 default:
543 case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::HPGL: /* no longer supported */ break;
546 }
547
548 aOpts.SetColorSettings( colors );
550}
551
552
553bool PlotFootprintToSVG( const FOOTPRINT& aFootprint, PROJECT& aProject,
554 const std::map<wxString, wxString>* aVarOverrides, PCB_PLOT_PARAMS& aPlotOpts,
555 const LSEQ& aLayersToPlot, const LSEQ& aLayersOnAll, const wxString& aFileName,
556 REPORTER* aReporter )
557{
558 // Plot the footprint by placing it at the origin of a temporary board; the SVG
559 // fit-to-board options make the footprint origin land on the SVG origin and size the
560 // page/viewBox to the footprint's bounding box.
561
562 // The hack for now is we create fake boards containing the footprint and plot the board
563 // until we refactor better plot api later
564 std::unique_ptr<BOARD> brd = BOARD_LOADER::CreateEmptyBoard( &aProject );
565
566 if( aVarOverrides )
567 brd->GetProject()->ApplyTextVars( *aVarOverrides );
568
569 brd->SynchronizeProperties();
570
571 FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( aFootprint.Clone() );
572
573 if( fp == nullptr )
574 return false;
575
576 fp->SetLink( niluuid );
577 fp->SetFlags( IS_NEW );
578 fp->SetParent( brd.get() );
579
580 for( PAD* pad : fp->Pads() )
581 {
582 pad->SetLocalRatsnestVisible( false );
583 pad->SetNetCode( 0 );
584 }
585
586 fp->SetOrientation( ANGLE_0 );
587 fp->SetPosition( VECTOR2I( 0, 0 ) );
588
589 brd->Add( fp, ADD_MODE::INSERT, true );
590
591 aPlotOpts.SetFormat( PLOT_FORMAT::SVG );
592 aPlotOpts.SetPlotFrameRef( false );
593 aPlotOpts.SetSvgFitPageToBoard( true );
594 aPlotOpts.SetMirror( false );
595 aPlotOpts.SetSkipPlotNPTH_Pads( false );
596
597 PCB_PLOTTER plotter( brd.get(), aReporter, aPlotOpts );
598
599 return plotter.Plot( aFileName, aLayersToPlot, aLayersOnAll, false, true, wxEmptyString, wxEmptyString,
600 wxEmptyString );
601}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:982
static std::unique_ptr< BOARD > CreateEmptyBoard(PROJECT *aProject)
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
constexpr size_type GetWidth() const
Definition box2.h:211
constexpr size_type GetHeight() const
Definition box2.h:212
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition eda_item.h:158
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
void SetPosition(const VECTOR2I &aPos) override
void SetLink(const KIID &aLink)
Definition footprint.h:1151
void SetOrientation(const EDA_ANGLE &aNewAngle)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
std::deque< PAD * > & Pads()
Definition footprint.h:355
wxString m_pdfBackgroundColor
The background color specified in a hex string.
bool m_useDrillOrigin
Used by SVG/DXF/PDF/Gerbers.
LSEQ m_plotOnAllLayersSequence
Layers to include on all individual layer prints.
DRILL_MARKS m_drillShapeOption
Used by SVG & PDF.
bool m_mirror
Common Options.
wxString GetConfiguredOutputPath() const
Returns the configured output path for the job.
Definition job.h:235
wxString GetFilename() const
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition lseq.h:47
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition lset.cpp:595
Definition pad.h:61
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
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.
BOARD * m_board
Definition pcb_plotter.h:86
static void PlotJobToPlotOpts(PCB_PLOT_PARAMS &aOpts, JOB_EXPORT_PCB_PLOT *aJob, REPORTER &aReporter)
True when the board's out-of-date-chart policy regenerated charts during the last Plot().
PCB_PLOTTER(BOARD *aBoard, REPORTER *aReporter, PCB_PLOT_PARAMS &aParams)
PCB_PLOT_PARAMS m_plotOpts
Definition pcb_plotter.h:87
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)
REPORTER * m_reporter
Definition pcb_plotter.h:88
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 SetSkipPlotNPTH_Pads(bool aSkip)
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)
COLOR4D m_backgroundColor
Background color to use for PNG and PDF plotting.
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)
void SetPngDPI(int aDPI)
void SetUseGerberProtelExtensions(bool aUse)
void SetDXFPlotUnits(DXF_UNITS aUnit)
void SetPngAntialias(bool aFlag)
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 SetTextMode(PLOT_TEXT_MODE aVal)
void SetSvgFitPageToBoard(int aSvgFitPageToBoard)
void SetSvgPrecision(unsigned aPrecision)
void SetCrossoutDNPFPsOnFabLayers(bool aFlag)
void SetFormat(PLOT_FORMAT aFormat)
void SetBackgroundColor(const COLOR4D &aColor)
void SetFineScaleAdjustY(double aVal)
void SetWidthAdjust(int aVal)
Base plotter engine class.
Definition plotter.h:138
virtual void SetAuthor(const wxString &aAuthor)
Definition plotter.h:192
void SetLayer(PCB_LAYER_ID aLayer)
Sets the ID of the current layer.
Definition plotter.h:257
virtual void SetTitle(const wxString &aTitle)
Definition plotter.h:191
virtual bool EndPlot()=0
RENDER_SETTINGS * RenderSettings()
Definition plotter.h:169
virtual void SetSubject(const wxString &aSubject)
Definition plotter.h:193
Container for project specific data.
Definition project.h:63
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Definition reporter.h:102
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, RESOLUTION_CONTEXT aContext)
Definition common.cpp:60
@ FOR_GUI
Definition common.h:93
wxString GetDefaultPlotExtension(PLOT_FORMAT aFormat)
Return the default plot extension for a format.
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:448
#define IS_NEW
New item, just created.
int RefreshGeneratedTables(BOARD &aBoard)
Bring every generated table on the board up to date and return how many were rebuilt.
Classes used to generate a Gerber job file in JSON.
static const std::string GerberJobFileExtension
KIID niluuid(0)
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition layer_ids.h:277
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
static int scaleToSelection(double scale)
bool PlotFootprintToSVG(const FOOTPRINT &aFootprint, PROJECT &aProject, const std::map< wxString, wxString > *aVarOverrides, PCB_PLOT_PARAMS &aPlotOpts, const LSEQ &aLayersToPlot, const LSEQ &aLayersOnAll, const wxString &aFileName, REPORTER *aReporter)
Plot a footprint to an SVG file, with the footprint origin at the SVG origin and the page/viewBox siz...
const wxString GetGerberProtelExtension(int aLayer)
Definition pcbplot.cpp:39
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.) for the footprints the page drew.
see class PGM_BASE
@ SKETCH
Definition plotter.h:83
@ FILLED
Definition plotter.h:84
PLOT_FORMAT
The set of supported output plot formats.
Definition plotter.h:65
Plotting engines similar to ps (PostScript, Gerber, svg)
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_INFO
@ RPT_SEVERITY_ACTION
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetAppSettings(const char *aFilename)
const int scale
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708