KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_plotter.h
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 (C) 1992-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2010 Lorenzo Marcantonio
6 * Copyright (C) 2011 Wayne Stambaugh <[email protected]>
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifndef SCH_PLOTTER_H
24#define SCH_PLOTTER_H
25
26#include <wx/filename.h>
27#include <wx/string.h>
28#include <wx/gdicmn.h>
29#include <page_info.h>
30#include <sch_render_settings.h>
31#include <sch_sheet_path.h>
32#include <optional>
33#include <plotters/plotter.h>
35
36class SCH_EDIT_FRAME;
37class PLOTTER;
38class SCHEMATIC;
39class SCH_SCREEN;
41class PDF_PLOTTER;
42class REPORTER;
43class LIB_SYMBOL;
44
51
52
54{
57 std::vector<wxString> m_plotPages;
58
59 // Sheet to plot in single-sheet mode; unset plots the schematic's current sheet
60 std::optional<SCH_SHEET_PATH> m_sheetPath;
61
69 wxString m_theme;
70
72 wxString m_outputFile;
73 wxString m_variant;
74
75 // has meaning only with DXF plotter: set DXF units in DXF file
77
80
82 m_plotAll( true ),
83 m_plotDrawingSheet( true ),
84 m_plotHopOver( false ),
85 m_blackAndWhite( false ),
88 m_PDFPropertyPopups( false ),
90 m_PDFMetadata( false ),
91 m_theme(),
96 m_pngAntialias( true )
97 {
98
99 }
100};
101
102
107{
108public:
112 SCH_PLOTTER( SCH_EDIT_FRAME* aFrame );
113
117 SCH_PLOTTER( SCHEMATIC* aSch );
118
127 void Plot( PLOT_FORMAT aPlotFormat, const SCH_PLOT_OPTS& aPlotOpts,
128 SCH_RENDER_SETTINGS* aRenderSettings, REPORTER* aReporter = nullptr );
129
134 wxString GetLastOutputFilePath() const { return m_lastOutputFilePath; }
135
139 const std::vector<wxString>& GetOutputFilePaths() const { return m_outputFilePaths; }
140
141protected:
145 wxFileName getOutputFilenameSingle( const SCH_PLOT_OPTS& aPlotOpts, REPORTER* aReporter,
146 const wxString& ext );
147
148 // PDF
149 void createPDFFile( const SCH_PLOT_OPTS& aPlotOpts, SCH_RENDER_SETTINGS* aRenderSettings,
150 REPORTER* aReporter );
151 void plotOneSheetPDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen, const SCH_PLOT_OPTS& aPlotOpts );
152 void setupPlotPagePDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen, const SCH_PLOT_OPTS& aPlotOpts );
153
154 // DXF
155 void createDXFFiles( const SCH_PLOT_OPTS& aPlotOpts, SCH_RENDER_SETTINGS* aRenderSettings,
156 REPORTER* aReporter );
157 bool plotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScreen,
158 RENDER_SETTINGS* aRenderSettings, const VECTOR2I& aPlotOffset,
159 double aScale, const SCH_PLOT_OPTS& aPlotOpts );
160
161
162 // PS
163 void createPSFiles( const SCH_PLOT_OPTS& aPlotOpts, SCH_RENDER_SETTINGS* aRenderSettings,
164 REPORTER* aReporter );
165 bool plotOneSheetPS( const wxString& aFileName, SCH_SCREEN* aScreen,
166 RENDER_SETTINGS* aRenderSettings, const PAGE_INFO& aPageInfo,
167 const VECTOR2I& aPlot0ffset, double aScale,
168 const SCH_PLOT_OPTS& aPlotOpts );
169
170 // SVG
171 void createSVGFiles( const SCH_PLOT_OPTS& aPlotOpts, SCH_RENDER_SETTINGS* aRenderSettings,
172 REPORTER* aReporter );
173 bool plotOneSheetSVG( const wxString& aFileName, SCH_SCREEN* aScreen,
174 RENDER_SETTINGS* aRenderSettings, const SCH_PLOT_OPTS& aPlotOpts );
175
176 // PNG
177 void createPNGFiles( const SCH_PLOT_OPTS& aPlotOpts, SCH_RENDER_SETTINGS* aRenderSettings,
178 REPORTER* aReporter );
179 bool plotOneSheetPNG( const wxString& aFileName, SCH_SCREEN* aScreen,
180 RENDER_SETTINGS* aRenderSettings, const SCH_PLOT_OPTS& aPlotOpts );
181
192 wxFileName createPlotFileName( const SCH_PLOT_OPTS& aPlotOpts, const wxString& aPlotFileName,
193 const wxString& aExtension, REPORTER* aReporter = nullptr );
194
195private:
199 std::vector<wxString> m_outputFilePaths;
200};
201
202
214BOX2I GetSymbolPlotBBox( const LIB_SYMBOL& aSymbol, int aUnit, int aBodyStyle, bool aIncludeHiddenFields );
215
216
237bool PlotSymbolToSVG( LIB_SYMBOL& aDrawSymbol, LIB_SYMBOL& aFieldsSymbol, int aUnit, int aBodyStyle, const BOX2I& aBBox,
238 SCH_RENDER_SETTINGS& aRenderSettings, bool aBlackAndWhite, const wxString& aFileName,
239 REPORTER* aReporter = nullptr );
240
241#endif
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
Color settings are a bit different than most of the settings objects in that there can be more than o...
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Define a library symbol object.
Definition lib_symbol.h:114
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
Base plotter engine class.
Definition plotter.h:136
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Holds all the data relating to one schematic.
Definition schematic.h:149
Schematic editor (Eeschema) main window.
void Plot(PLOT_FORMAT aPlotFormat, const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter=nullptr)
Perform the plotting of the schematic using the given aPlotFormat and a\ aPlotSettings.
wxFileName getOutputFilenameSingle(const SCH_PLOT_OPTS &aPlotOpts, REPORTER *aReporter, const wxString &ext)
Return the output filename for formats where the output is a single file.
void createSVGFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
void createPSFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
void plotOneSheetPDF(PLOTTER *aPlotter, SCH_SCREEN *aScreen, const SCH_PLOT_OPTS &aPlotOpts)
wxFileName createPlotFileName(const SCH_PLOT_OPTS &aPlotOpts, const wxString &aPlotFileName, const wxString &aExtension, REPORTER *aReporter=nullptr)
Create a file name with an absolute path name.
SCH_PLOTTER(SCH_EDIT_FRAME *aFrame)
Constructor for usage with a frame having the schematic we want to print loaded.
bool plotOneSheetDXF(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const VECTOR2I &aPlotOffset, double aScale, const SCH_PLOT_OPTS &aPlotOpts)
void createDXFFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
const std::vector< wxString > & GetOutputFilePaths() const
Get all output file paths generated by the last Plot() call.
wxString m_lastOutputFilePath
std::vector< wxString > m_outputFilePaths
void createPNGFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
bool plotOneSheetSVG(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const SCH_PLOT_OPTS &aPlotOpts)
void setupPlotPagePDF(PLOTTER *aPlotter, SCH_SCREEN *aScreen, const SCH_PLOT_OPTS &aPlotOpts)
bool plotOneSheetPNG(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const SCH_PLOT_OPTS &aPlotOpts)
void createPDFFile(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
wxString GetLastOutputFilePath() const
Get the last output file path, this is mainly intended for PDFs with the open after plot GUI option.
COLOR_SETTINGS * m_colorSettings
bool plotOneSheetPS(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const PAGE_INFO &aPageInfo, const VECTOR2I &aPlot0ffset, double aScale, const SCH_PLOT_OPTS &aPlotOpts)
SCHEMATIC * m_schematic
DXF_UNITS
Definition plotter.h:51
PLOT_FORMAT
The set of supported output plot formats.
Definition plotter.h:63
constexpr int DEFAULT_PNG_DPI
Definition plotter_png.h:28
@ INCH
Definition rs274x.cpp:61
PageFormatReq
Definition sch_plotter.h:46
@ PAGE_SIZE_AUTO
Definition sch_plotter.h:47
@ PAGE_SIZE_A
Definition sch_plotter.h:49
@ PAGE_SIZE_A4
Definition sch_plotter.h:48
bool PlotSymbolToSVG(LIB_SYMBOL &aDrawSymbol, LIB_SYMBOL &aFieldsSymbol, int aUnit, int aBodyStyle, const BOX2I &aBBox, SCH_RENDER_SETTINGS &aRenderSettings, bool aBlackAndWhite, const wxString &aFileName, REPORTER *aReporter=nullptr)
Plot a single symbol variant (unit and body style) to an SVG file.
BOX2I GetSymbolPlotBBox(const LIB_SYMBOL &aSymbol, int aUnit, int aBodyStyle, bool aIncludeHiddenFields)
Compute the bounding box used to size a symbol SVG plot.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::vector< wxString > m_plotPages
Definition sch_plotter.h:57
wxString m_theme
Definition sch_plotter.h:69
DXF_UNITS m_DXF_File_Unit
Definition sch_plotter.h:76
bool m_PDFPropertyPopups
Definition sch_plotter.h:66
wxString m_outputDirectory
Definition sch_plotter.h:71
std::optional< SCH_SHEET_PATH > m_sheetPath
Definition sch_plotter.h:60
bool m_pngAntialias
Definition sch_plotter.h:79
wxString m_outputFile
Definition sch_plotter.h:72
bool m_blackAndWhite
Definition sch_plotter.h:63
wxString m_variant
Definition sch_plotter.h:73
bool m_PDFHierarchicalLinks
Definition sch_plotter.h:67
bool m_useBackgroundColor
Definition sch_plotter.h:65
bool m_plotDrawingSheet
Definition sch_plotter.h:56
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708