KiCad PCB EDA Suite
Loading...
Searching...
No Matches
symbol_editor_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
21#include <sch_painter.h>
22#include <symbol_edit_frame.h>
23#include <locale_io.h>
25#include <sch_plotter.h>
26
27void SYMBOL_EDIT_FRAME::SVGPlotSymbol( const wxString& aFullFileName, const VECTOR2I& aOffset )
28{
29 SCH_RENDER_SETTINGS renderSettings;
30 renderSettings.LoadColors( GetColorSettings() );
31 renderSettings.SetDefaultPenWidth( GetRenderSettings()->GetDefaultPenWidth() );
32
33 const PAGE_INFO& pageInfo = GetScreen()->GetPageSettings();
34
35 SVG_PLOTTER* plotter = new SVG_PLOTTER();
36 plotter->SetRenderSettings( &renderSettings );
37 plotter->SetPageSettings( pageInfo );
38 plotter->SetColorMode( true );
39
40 VECTOR2I plot_offset;
41 const double scale = 1.0;
42
43 // Currently, plot units are in decimil
44 plotter->SetViewport( plot_offset, schIUScale.IU_PER_MILS/10, scale, false );
45
46 // Init :
47 plotter->SetCreator( wxT( "Eeschema-SVG" ) );
48
49 if( !plotter->OpenFile( aFullFileName ) )
50 {
51 delete plotter;
52 return;
53 }
54
55 LOCALE_IO toggle;
56 SCH_PLOT_OPTS plotOpts;
57
58 plotter->StartPlot( wxT( "1" ) );
59
60 if( m_symbol )
61 {
62 constexpr bool background = true;
63
64 m_symbol->Plot( plotter, background, plotOpts, GetUnit(), GetBodyStyle(), aOffset, false );
65 m_symbol->Plot( plotter, !background, plotOpts, GetUnit(), GetBodyStyle(), aOffset, false );
66 m_symbol->PlotFields( plotter, !background, plotOpts, GetUnit(), GetBodyStyle(), aOffset,
67 false );
68 }
69
70 plotter->EndPlot();
71 delete plotter;
72}
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
void SetDefaultPenWidth(int aWidth)
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
Definition plotter.cpp:73
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition plotter.h:166
void SetRenderSettings(RENDER_SETTINGS *aSettings)
Definition plotter.h:163
virtual void SetCreator(const wxString &aCreator)
Definition plotter.h:185
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
Definition plotter.h:160
SCH_RENDER_SETTINGS * GetRenderSettings()
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void LoadColors(const COLOR_SETTINGS *aSettings) override
const PAGE_INFO & GetPageSettings() const
Definition sch_screen.h:137
virtual bool StartPlot(const wxString &aPageNumber) override
Create SVG file header.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual bool EndPlot() override
void SVGPlotSymbol(const wxString &aFullFileName, const VECTOR2I &aOffset)
Create the SVG print file for the current edited symbol.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
Plotting engines similar to ps (PostScript, Gerber, svg)
const int scale
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683