KiCad PCB EDA Suite
PCB_PLOT_SVG Class Reference

#include <pcb_plot_svg.h>

Static Public Member Functions

static bool Plot (BOARD *aBoard, const PCB_PLOT_SVG_OPTIONS &aSvgPlotOptions)
 

Detailed Description

Definition at line 38 of file pcb_plot_svg.h.

Member Function Documentation

◆ Plot()

bool PCB_PLOT_SVG::Plot ( BOARD aBoard,
const PCB_PLOT_SVG_OPTIONS aSvgPlotOptions 
)
static

Definition at line 32 of file pcb_plot_svg.cpp.

33{
34 PCB_PLOT_PARAMS plot_opts;
35 wxString outputFile = aSvgPlotOptions.m_outputFile;
36
37 plot_opts.SetPlotFrameRef( aSvgPlotOptions.m_plotFrame );
38
39 // Adding drill marks, for copper layers
40 if( ( aSvgPlotOptions.m_printMaskLayer & LSET::AllCuMask() ).any() )
42 else
44
45 plot_opts.SetSkipPlotNPTH_Pads( false );
46
47 plot_opts.SetMirror( aSvgPlotOptions.m_mirror );
48 plot_opts.SetFormat( PLOT_FORMAT::SVG );
49 // coord format: 4 digits in mantissa (units always in mm). This is a good choice.
50 plot_opts.SetSvgPrecision( 4 );
51
52 PAGE_INFO savedPageInfo = aBoard->GetPageSettings();
53 VECTOR2I savedAuxOrigin = aBoard->GetDesignSettings().GetAuxOrigin();
54
55 if( aSvgPlotOptions.m_pageSizeMode == 2 ) // Page is board boundary size
56 {
57 BOX2I bbox = aBoard->ComputeBoundingBox();
58 PAGE_INFO currpageInfo = aBoard->GetPageSettings();
59
60 currpageInfo.SetWidthMils( bbox.GetWidth() / pcbIUScale.IU_PER_MILS );
61 currpageInfo.SetHeightMils( bbox.GetHeight() / pcbIUScale.IU_PER_MILS );
62 aBoard->SetPageSettings( currpageInfo );
63 plot_opts.SetUseAuxOrigin( true );
64 VECTOR2I origin = bbox.GetOrigin();
65 aBoard->GetDesignSettings().SetAuxOrigin( origin );
66 }
67
68 if( outputFile.IsEmpty() )
69 {
70 wxFileName fn = aBoard->GetFileName();
71 fn.SetName( fn.GetName() );
72 fn.SetExt( wxS("svg") );
73
74 outputFile = fn.GetFullName();
75 }
76
77 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
78
79 plot_opts.SetColorSettings( mgr.GetColorSettings( aSvgPlotOptions.m_colorTheme ) );
80
81 LOCALE_IO toggle;
82
83 //@todo allow controlling the sheet name and path that will be displayed in the title block
84 // Leave blank for now
85 SVG_PLOTTER* plotter = (SVG_PLOTTER*) StartPlotBoard( aBoard, &plot_opts, UNDEFINED_LAYER, outputFile,
86 wxEmptyString, wxEmptyString );
87
88 if( plotter )
89 {
90 plotter->SetColorMode( !aSvgPlotOptions.m_blackAndWhite );
91 PlotBoardLayers( aBoard, plotter, aSvgPlotOptions.m_printMaskLayer.SeqStackupBottom2Top(),
92 plot_opts );
93 plotter->EndPlot();
94 }
95
96 delete plotter;
97
98 // reset to the values saved earlier
99 aBoard->GetDesignSettings().SetAuxOrigin( savedAuxOrigin );
100 aBoard->SetPageSettings( savedPageInfo );
101
102 return true;
103}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
const VECTOR2I & GetAuxOrigin()
void SetAuxOrigin(const VECTOR2I &aOrigin)
const PAGE_INFO & GetPageSettings() const
Definition: board.h:626
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1231
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: board.h:627
const wxString & GetFileName() const
Definition: board.h:302
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:682
const Vec & GetOrigin() const
Definition: box2.h:183
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
LSEQ SeqStackupBottom2Top() const
Return the sequence that is typical for a bottom-to-top stack-up.
Definition: lset.cpp:475
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:244
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:258
Parameters and options when plotting/printing a board.
void SetDrillMarksType(DRILL_MARKS aVal)
void SetSkipPlotNPTH_Pads(bool aSkip)
void SetPlotFrameRef(bool aFlag)
void SetMirror(bool aFlag)
void SetColorSettings(COLOR_SETTINGS *aSettings)
void SetUseAuxOrigin(bool aAux)
void SetSvgPrecision(unsigned aPrecision)
void SetFormat(PLOT_FORMAT aFormat)
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
Definition: plotter.h:137
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
virtual bool EndPlot() override
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
PLOTTER * StartPlotBoard(BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aLayer, const wxString &aFullFileName, const wxString &aSheetName, const wxString &aSheetPath)
Open a new plotfile using the options (and especially the format) specified in the options and prepar...
void PlotBoardLayers(BOARD *aBoard, PLOTTER *aPlotter, const LSEQ &aLayerSequence, const PCB_PLOT_PARAMS &aPlotOptions)
Plot a sequence of board layer IDs.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
const double IU_PER_MILS
Definition: base_units.h:78

References LSET::AllCuMask(), BOARD::ComputeBoundingBox(), SVG_PLOTTER::EndPlot(), FULL_DRILL_SHAPE, BOARD_DESIGN_SETTINGS::GetAuxOrigin(), SETTINGS_MANAGER::GetColorSettings(), BOARD::GetDesignSettings(), BOARD::GetFileName(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetOrigin(), BOARD::GetPageSettings(), BOX2< Vec >::GetWidth(), EDA_IU_SCALE::IU_PER_MILS, PCB_PLOT_SVG_OPTIONS::m_blackAndWhite, PCB_PLOT_SVG_OPTIONS::m_colorTheme, PCB_PLOT_SVG_OPTIONS::m_mirror, PCB_PLOT_SVG_OPTIONS::m_outputFile, PCB_PLOT_SVG_OPTIONS::m_pageSizeMode, PCB_PLOT_SVG_OPTIONS::m_plotFrame, PCB_PLOT_SVG_OPTIONS::m_printMaskLayer, NO_DRILL_SHAPE, pcbIUScale, Pgm(), PlotBoardLayers(), LSET::SeqStackupBottom2Top(), BOARD_DESIGN_SETTINGS::SetAuxOrigin(), PLOTTER::SetColorMode(), PCB_PLOT_PARAMS::SetColorSettings(), PCB_PLOT_PARAMS::SetDrillMarksType(), PCB_PLOT_PARAMS::SetFormat(), PAGE_INFO::SetHeightMils(), PCB_PLOT_PARAMS::SetMirror(), BOARD::SetPageSettings(), PCB_PLOT_PARAMS::SetPlotFrameRef(), PCB_PLOT_PARAMS::SetSkipPlotNPTH_Pads(), PCB_PLOT_PARAMS::SetSvgPrecision(), PCB_PLOT_PARAMS::SetUseAuxOrigin(), PAGE_INFO::SetWidthMils(), StartPlotBoard(), SVG, and UNDEFINED_LAYER.

Referenced by PCBNEW_JOBS_HANDLER::doFpExportSvg(), DIALOG_EXPORT_SVG::ExportSVGFile(), and PCBNEW_JOBS_HANDLER::JobExportSvg().


The documentation for this class was generated from the following files: