67 m_schFrame( nullptr ),
68 m_schematic( aSchematic )
76 m_schematic( &aFrame->Schematic() )
83 REPORTER* aReporter,
const wxString& aExt )
94 fname.Replace(
"/",
"_" );
95 fname.Replace(
"\\",
"_" );
134 wxFileName plotFileName;
137 for(
unsigned i = 0; i < sheetList.size(); i++ )
159 if( !plotFileName.IsOk() )
162 if( !plotter->
OpenFile( plotFileName.GetFullPath() ) )
166 msg.Printf(
_(
"Failed to create file '%s'." ),
167 plotFileName.GetFullPath() );
176 plotter->
StartPlot( sheetList[i].GetPageNumber(),
_(
"Root" ) );
183 msg.Printf( wxT(
"PDF Plotter exception: %s" ), e.
What() );
197 plotter->
StartPage( sheetList[i].GetPageNumber(),
198 sheetList[i].Last()->GetFields()[
SHEETNAME].GetShownText(
false ) );
207 msg.Printf(
_(
"Plotted to '%s'.\n" ), plotFileName.GetFullPath() );
224 aPlotter->
Rect(
VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
246 aScreen->
Plot( aPlotter );
261 plotPage.
SetType( wxT(
"A" ) );
266 plotPage.
SetType( wxT(
"A4" ) );
272 plotPage = actualPage;
278 double scale = std::min( scalex, scaley );
311 for(
unsigned i = 0; i < sheetList.size(); i++ )
328 plotPage.
SetType( wxT(
"A" ) );
333 plotPage.
SetType( wxT(
"A4" ) );
338 default: plotPage = actualPage;
break;
343 double scale = std::min( scalex, scaley );
353 fname.Replace(
"/",
"_" );
354 fname.Replace(
"\\",
"_" );
360 if( !plotFileName.IsOk() )
363 if(
plotOneSheetPS( plotFileName.GetFullPath(), screen, aRenderSettings, actualPage,
364 plot_offset,
scale, aPlotSettings ) )
368 msg.Printf(
_(
"Plotted to '%s'." ), plotFileName.GetFullPath() );
377 msg.Printf(
_(
"Failed to create file '%s'." ), plotFileName.GetFullPath() );
386 msg.Printf( wxT(
"PS Plotter exception: %s" ), e.
What() );
424 if( !plotter->
OpenFile( aFileName ) )
440 plotter->
Rect(
VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
457 aScreen->
Plot( plotter );
483 for(
unsigned i = 0; i < sheetList.size(); i++ )
504 fname.Replace(
"/",
"_" );
505 fname.Replace(
"\\",
"_" );
511 if( !plotFileName.IsOk() )
514 bool success =
plotOneSheetSVG( plotFileName.GetFullPath(), screen, aRenderSettings,
521 msg.Printf(
_(
"Failed to create file '%s'." ), plotFileName.GetFullPath() );
529 msg.Printf(
_(
"Plotted to '%s'." ), plotFileName.GetFullPath() );
539 msg.Printf( wxT(
"SVG Plotter exception: %s" ), e.
What() );
573 plotPage.
SetType( wxT(
"A" ) );
578 plotPage.
SetType( wxT(
"A4" ) );
584 plotPage = actualPage;
596 double scale = std::min( scalex, scaley );
604 if( !plotter->
OpenFile( aFileName ) )
619 plotter->
Rect(
VECTOR2I( 0, 0 ), end, FILL_T::FILLED_SHAPE, 1.0 );
636 aScreen->
Plot( plotter );
668 for(
unsigned i = 0; i < sheetList.size(); i++ )
697 if( aPlotSettings.
m_HPGLPlotOrigin == HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER )
709 fname.Replace(
"/",
"_" );
710 fname.Replace(
"\\",
"_" );
714 if( !plotFileName.IsOk() )
719 if(
plotOneSheetHpgl( plotFileName.GetFullPath(), screen, curPage, aRenderSettings,
720 plotOffset, plot_scale, aPlotSettings ) )
724 msg.Printf(
_(
"Plotted to '%s'." ), plotFileName.GetFullPath() );
732 msg.Printf(
_(
"Failed to create file '%s'." ), plotFileName.GetFullPath() );
741 msg.Printf( wxT(
"HPGL Plotter exception: %s" ), e.
What() );
785 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT:
786 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER:
790 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE:
794 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT:
801 plotter->
SetCreator( wxT(
"Eeschema-HPGL" ) );
803 if( !plotter->
OpenFile( aFileName ) )
829 aScreen->
Plot( plotter );
861 for(
unsigned i = 0; i < sheetList.size(); i++ )
882 fname.Replace(
"/",
"_" );
883 fname.Replace(
"\\",
"_" );
889 if( !plotFileName.IsOk() )
892 if(
plotOneSheetDXF( plotFileName.GetFullPath(), screen, aRenderSettings, plot_offset,
893 1.0, aPlotSettings ) )
897 msg.Printf(
_(
"Plotted to '%s'." ), plotFileName.GetFullPath() );
905 msg.Printf(
_(
"Failed to create file '%s'." ), plotFileName.GetFullPath() );
914 msg.Printf( wxT(
"DXF Plotter exception: %s" ), e.
What() );
964 if( !plotter->
OpenFile( aFileName ) )
989 aScreen->
Plot( plotter );
1017 const wxString& aPlotFileName,
1018 const wxString& aExtension,
REPORTER* aReporter )
1024 retv.SetPath( tmp.GetPath() );
1026 if( !aPlotFileName.IsEmpty() )
1027 retv.SetName( aPlotFileName );
1029 retv.SetName(
_(
"Schematic" ) );
1031 retv.SetExt( aExtension );
1037 wxString msg = wxString::Format(
_(
"Failed to write plot files to folder '%s'." ),
1048 retv.SetPath( tmp.GetPath() );
1064 switch( aPlotFormat )
1067 case PLOT_FORMAT::POST:
createPSFiles( aPlotSettings, aRenderSettings, aReporter );
break;
1068 case PLOT_FORMAT::DXF:
createDXFFiles( aPlotSettings, aRenderSettings, aReporter );
break;
1069 case PLOT_FORMAT::PDF:
createPDFFile( aPlotSettings, aRenderSettings, aReporter );
break;
1070 case PLOT_FORMAT::SVG:
createSVGFiles( aPlotSettings, aRenderSettings, aReporter );
break;
1071 case PLOT_FORMAT::HPGL:
createHPGLFiles( aPlotSettings, aRenderSettings, aReporter );
break;
constexpr EDA_IU_SCALE schIUScale
int GetVirtualPageNumber() const
const wxString & GetPageNumber() const
static wxString GetDefaultFileExtension()
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the scale/position for the DXF plot.
virtual bool StartPlot(const wxString &aPageNumber) override
Open the DXF plot with a skeleton header.
virtual bool EndPlot() override
void SetUserCoordsFit(bool user_coords_fit)
Set whether the user coordinate system is fit to content.
void SetTargetChordLength(double chord_len)
Set the target length of chords used to draw approximated circles and arcs.
static wxString GetDefaultFileExtension()
void SetUserCoords(bool user_coords)
Switch to the user coordinate system.
virtual bool StartPlot(const wxString &aPageNumber) override
At the start of the HPGL plot pen speed and number are requested.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual void SetPenDiameter(double diameter)
virtual bool EndPlot() override
HPGL end of plot: sort and emit graphics, pen return and release.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
A color representation with 4 components: red, green, blue, alpha.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetDefaultPenWidth(int aWidth)
virtual void LoadColors(const COLOR_SETTINGS *aSettings)
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Describe the page size and margins of a paper page on which to eventually print or plot.
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
int GetHeightMils() const
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
virtual void StartPage(const wxString &aPageNumber, const wxString &aPageName=wxEmptyString)
Start a new page in the PDF document.
virtual void ClosePage()
Close the current page in the PDF document (and emit its compressed stream).
virtual bool EndPlot() override
virtual bool OpenFile(const wxString &aFullFilename) override
Open or create the plot file aFullFilename.
virtual bool StartPlot(const wxString &aPageNumber) override
The PDF engine supports multiple pages; the first one is opened 'for free' the following are to be cl...
static wxString GetDefaultFileExtension()
Base plotter engine class.
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)
void SetRenderSettings(RENDER_SETTINGS *aSettings)
virtual void SetTitle(const wxString &aTitle)
RENDER_SETTINGS * RenderSettings()
virtual void SetCreator(const wxString &aCreator)
bool GetColorMode() const
PAGE_INFO & PageSettings()
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror)=0
Set the plot offset and scaling for the current plot.
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void SetColor(const COLOR4D &color)=0
virtual void SetColor(const COLOR4D &color) override
The SetColor implementation is split with the subclasses: The PSLIKE computes the rgb values,...
virtual bool EndPlot() override
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
Set the plot offset and scaling for the current plot.
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
virtual bool StartPlot(const wxString &aPageNumber) override
The code within this function (and the CloseFilePS function) creates postscript files whose contents ...
static wxString GetDefaultFileExtension()
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Places the report at the end of the list, for objects that support report ordering.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
These settings were stored in SCH_BASE_FRAME previously.
wxString m_PlotDirectoryName
Holds all the data relating to one schematic.
SCH_SHEET_PATH & CurrentSheet() const override
SCHEMATIC_SETTINGS & Settings() const
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
const std::map< wxString, wxString > * GetProperties()
wxString GetUniqueFilenameForCurrentSheet()
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Schematic editor (Eeschema) main window.
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
void createSVGFiles(const SCH_PLOT_SETTINGS &aPlotSettings, RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
void createDXFFiles(const SCH_PLOT_SETTINGS &aPlotSettings, RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
void createPSFiles(const SCH_PLOT_SETTINGS &aPlotSettings, RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
wxFileName getOutputFilenameSingle(const SCH_PLOT_SETTINGS &aPlotSettings, REPORTER *aReporter, const wxString &ext)
Returns the output filename for formats where the output is a single file.
wxFileName createPlotFileName(const SCH_PLOT_SETTINGS &aPlotSettings, const wxString &aPlotFileName, const wxString &aExtension, REPORTER *aReporter=nullptr)
Create a file name with an absolute path name.
bool plotOneSheetHpgl(const wxString &aFileName, SCH_SCREEN *aScreen, const PAGE_INFO &aPageInfo, RENDER_SETTINGS *aRenderSettings, const VECTOR2I &aPlot0ffset, double aScale, const SCH_PLOT_SETTINGS &aPlotSettings)
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_SETTINGS &aPlotSettings)
bool plotOneSheetSVG(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const SCH_PLOT_SETTINGS &aPlotSettings)
void Plot(PLOT_FORMAT aPlotFormat, const SCH_PLOT_SETTINGS &aPlotSettings, RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter=nullptr)
Perform the plotting of the schematic using the given aPlotFormat and aPlotSettings.
wxString m_lastOutputFilePath
void restoreEnvironment(PDF_PLOTTER *aPlotter, SCH_SHEET_PATH &aOldsheetpath)
Everything done, close the plot and restore the environment.
SCH_EDIT_FRAME * m_schFrame
void setupPlotPagePDF(PLOTTER *aPlotter, SCH_SCREEN *aScreen, const SCH_PLOT_SETTINGS &aPlotSettings)
bool plotOneSheetPS(const wxString &aFileName, SCH_SCREEN *aScreen, RENDER_SETTINGS *aRenderSettings, const PAGE_INFO &aPageInfo, const VECTOR2I &aPlot0ffset, double aScale, const SCH_PLOT_SETTINGS &aPlotSettings)
COLOR_SETTINGS * m_colorSettings
void createPDFFile(const SCH_PLOT_SETTINGS &aPlotSettings, RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
void plotOneSheetPDF(PLOTTER *aPlotter, SCH_SCREEN *aScreen, const SCH_PLOT_SETTINGS &aPlotSettings)
void createHPGLFiles(const SCH_PLOT_SETTINGS &aPlotSettings, RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
const PAGE_INFO & GetPageSettings() const
const wxString & GetFileName() const
SCHEMATIC * Schematic() const
void Plot(PLOTTER *aPlotter) const
Plot all the schematic objects to aPlotter.
const TITLE_BLOCK & GetTitleBlock() const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
void BuildSheetList(SCH_SHEET *aSheet, bool aCheckIntegrity)
Build the list of sheets and their sheet path from aSheet.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
wxString GetPageNumber() const
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
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 void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
virtual bool EndPlot() override
virtual void SetColor(const COLOR4D &color) override
The SetColor implementation is split with the subclasses: The PSLIKE computes the rgb values,...
static wxString GetDefaultFileExtension()
const wxString & GetTitle() const
bool EnsureFileDirectoryExists(wxFileName *aTargetFullFileName, const wxString &aBaseFilename, REPORTER *aReporter)
Make aTargetFullFileName absolute and create the path of this file if it doesn't yet exist.
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
void PlotDrawingSheet(PLOTTER *plotter, const PROJECT *aProject, const TITLE_BLOCK &aTitleBlock, const PAGE_INFO &aPageInfo, const std::map< wxString, wxString > *aProperties, const wxString &aSheetNumber, int aSheetCount, const wxString &aSheetName, const wxString &aSheetPath, const wxString &aFilename, COLOR4D aColor, bool aIsFirstPage)
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
@ LAYER_SCHEMATIC_DRAWINGSHEET
@ LAYER_SCHEMATIC_BACKGROUND
PLOT_FORMAT
The set of supported output plot formats.
Plotting engines similar to ps (PostScript, Gerber, svg)
static const wxChar * plot_sheet_list(HPGL_PAGE_SIZE aSize)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
constexpr int mmToIU(double mm) const
HPGL_PAGE_SIZE m_HPGLPaperSizeSelect
HPGL_PLOT_ORIGIN_AND_UNITS m_HPGLPlotOrigin
bool m_useBackgroundColor
wxString m_outputDirectory
wxLogTrace helper definitions.