74 m_schematic( aSchematic )
81 m_schematic( &aFrame->Schematic() )
88 REPORTER* aReporter,
const wxString& aExt )
101 fname.Replace(
"/",
"_" );
102 fname.Replace(
"\\",
"_" );
137 if( sheetList.empty() )
156 wxFileName plotFileName;
159 for(
unsigned i = 0; i < sheetList.size(); i++ )
166 wxString sheetName = sheetList[i].Last()->GetField( FIELD_T::SHEET_NAME )->GetShownText(
false );
170 msg = wxS(
"AUTHOR" );
175 msg = wxS(
"SUBJECT" );
190 if( !plotFileName.IsOk() )
193 if( !plotter->
OpenFile( plotFileName.GetFullPath() ) )
197 msg.Printf(
_(
"Failed to create file '%s'." ),
198 plotFileName.GetFullPath() );
208 plotter->
StartPlot( sheetList[i].GetPageNumber(), sheetName );
215 msg.Printf( wxT(
"PDF Plotter exception: %s" ), e.
What() );
231 if( parentSheet.
size() > 1 )
238 wxString parentSheetName =
241 plotter->
StartPage( sheetList[i].GetPageNumber(), sheetName,
251 msg.Printf(
_(
"Plotted to '%s'.\n" ), plotFileName.GetFullPath() );
294 aScreen->
Plot( aPlotter, aPlotOpts );
309 plotPage.
SetType( wxT(
"A" ) );
314 plotPage.
SetType( wxT(
"A4" ) );
320 plotPage = actualPage;
326 double scale = std::min( scalex, scaley );
365 for(
unsigned i = 0; i < sheetList.size(); i++ )
377 plotPage.
SetType( wxT(
"A" ) );
382 plotPage.
SetType( wxT(
"A4" ) );
388 plotPage = actualPage;
394 double scale = std::min( scalex, scaley );
404 fname.Replace(
"/",
"_" );
405 fname.Replace(
"\\",
"_" );
411 if( !plotFileName.IsOk() )
416 msg.Printf(
_(
"Failed to create file '%s'." ), plotFileName.GetFullPath() );
420 else if(
plotOneSheetPS( plotFileName.GetFullPath(), screen, aRenderSettings,
421 actualPage, plot_offset,
scale, aPlotOpts ) )
425 msg.Printf(
_(
"Plotted to '%s'." ), plotFileName.GetFullPath() );
434 msg.Printf(
_(
"Failed to create file '%s'." ), plotFileName.GetFullPath() );
443 msg.Printf( wxT(
"PS Plotter exception: %s" ), e.
What() );
458 const VECTOR2I& aPlot0ffset,
double aScale,
472 if( !plotter->
OpenFile( aFileName ) )
508 aScreen->
Plot( plotter, aPlotOpts );
541 for(
unsigned i = 0; i < sheetList.size(); i++ )
558 fname.Replace(
"/",
"_" );
559 fname.Replace(
"\\",
"_" );
565 if( !plotFileName.IsOk() )
568 bool success =
plotOneSheetSVG( plotFileName.GetFullPath(), screen, aRenderSettings,
575 msg.Printf(
_(
"Failed to create file '%s'." ), plotFileName.GetFullPath() );
583 msg.Printf(
_(
"Plotted to '%s'." ), plotFileName.GetFullPath() );
593 msg.Printf( wxT(
"SVG Plotter exception: %s" ), e.
What() );
621 plotPage.
SetType( wxT(
"A" ) );
626 plotPage.
SetType( wxT(
"A4" ) );
632 plotPage = actualPage;
644 double scale = std::min( scalex, scaley );
652 if( !plotter->
OpenFile( aFileName ) )
688 aScreen->
Plot( plotter, aPlotOpts );
727 for(
unsigned i = 0; i < sheetList.size(); i++ )
752 if( aPlotOpts.
m_HPGLPlotOrigin == HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER )
764 fname.Replace(
"/",
"_" );
765 fname.Replace(
"\\",
"_" );
769 if( !plotFileName.IsOk() )
774 if(
plotOneSheetHpgl( plotFileName.GetFullPath(), screen, curPage, aRenderSettings,
775 plotOffset, plot_scale, aPlotOpts ) )
779 msg.Printf(
_(
"Plotted to '%s'." ), plotFileName.GetFullPath() );
787 msg.Printf(
_(
"Failed to create file '%s'." ), plotFileName.GetFullPath() );
796 msg.Printf( wxT(
"HPGL Plotter exception: %s" ), e.
What() );
813 const VECTOR2I& aPlot0ffset,
double aScale,
829 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT:
830 case HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER:
834 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE:
838 case HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT:
845 plotter->
SetCreator( wxT(
"Eeschema-HPGL" ) );
847 if( !plotter->
OpenFile( aFileName ) )
873 aScreen->
Plot( plotter, aPlotOpts );
910 for(
unsigned i = 0; i < sheetList.size(); i++ )
927 fname.Replace(
"/",
"_" );
928 fname.Replace(
"\\",
"_" );
934 if( !plotFileName.IsOk() )
937 if(
plotOneSheetDXF( plotFileName.GetFullPath(), screen, aRenderSettings, plot_offset,
942 msg.Printf(
_(
"Plotted to '%s'." ), plotFileName.GetFullPath() );
950 msg.Printf(
_(
"Failed to create file '%s'." ), plotFileName.GetFullPath() );
959 msg.Printf( wxT(
"DXF Plotter exception: %s" ), e.
What() );
997 if( !plotter->
OpenFile( aFileName ) )
1022 aScreen->
Plot( plotter, aPlotOpts );
1048 const wxString& aPlotFileName,
1049 const wxString& aExtension,
REPORTER* aReporter )
1055 retv.SetPath( tmp.GetPath() );
1057 if( !aPlotFileName.IsEmpty() )
1058 retv.SetName( aPlotFileName );
1060 retv.SetName(
_(
"Schematic" ) );
1062 retv.SetExt( aExtension );
1068 wxString msg = wxString::Format(
_(
"Failed to write plot files to folder '%s'." ),
1080 retv.SetPath( tmp.GetPath() );
1096 switch( aPlotFormat )
1099 case PLOT_FORMAT::POST:
createPSFiles( aPlotOpts, aRenderSettings, aReporter );
break;
1100 case PLOT_FORMAT::DXF:
createDXFFiles( aPlotOpts, aRenderSettings, aReporter );
break;
1101 case PLOT_FORMAT::PDF:
createPDFFile( aPlotOpts, aRenderSettings, aReporter );
break;
1102 case PLOT_FORMAT::SVG:
createSVGFiles( aPlotOpts, aRenderSettings, aReporter );
break;
1103 case PLOT_FORMAT::HPGL:
createHPGLFiles( aPlotOpts, 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.
double GetHeightMils() const
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
double GetWidthMils() const
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 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()
virtual void StartPage(const wxString &aPageNumber, const wxString &aPageName=wxEmptyString, const wxString &aParentPageNumber=wxEmptyString, const wxString &aParentPageName=wxEmptyString)
Start a new page in the PDF document.
virtual SETTINGS_MANAGER & GetSettingsManager() const
Base plotter engine class.
virtual bool OpenFile(const wxString &aFullFilename)
Open or create the plot file aFullFilename.
virtual void SetAuthor(const wxString &aAuthor)
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
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 SetSubject(const wxString &aSubject)
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 are loaded from Eeschema settings but then overwritten by the project settings.
wxString m_PlotDirectoryName
Holds all the data relating to one schematic.
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
SCHEMATIC_SETTINGS & Settings() const
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
bool ResolveTextVar(const SCH_SHEET_PATH *aSheetPath, wxString *token, int aDepth) const
const std::map< wxString, wxString > * GetProperties()
wxString GetUniqueFilenameForCurrentSheet()
Get the unique file name for the current sheet.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
SCH_SHEET_PATH & CurrentSheet() const
Schematic editor (Eeschema) main window.
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
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)
void createHPGLFiles(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
wxString m_lastOutputFilePath
void restoreEnvironment(PDF_PLOTTER *aPlotter, SCH_SHEET_PATH &aOldsheetpath)
Everything done, close the plot and restore the environment.
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 plotOneSheetHpgl(const wxString &aFileName, SCH_SCREEN *aScreen, const PAGE_INFO &aPageInfo, RENDER_SETTINGS *aRenderSettings, const VECTOR2I &aPlot0ffset, double aScale, const SCH_PLOT_OPTS &aPlotOpts)
void createPDFFile(const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter)
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)
const PAGE_INFO & GetPageSettings() const
const wxString & GetFileName() const
SCHEMATIC * Schematic() const
const TITLE_BLOCK & GetTitleBlock() const
void Plot(PLOTTER *aPlotter, const SCH_PLOT_OPTS &aPlotOpts) const
Plot all the schematic objects to aPlotter.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void TrimToPageNumbers(const std::vector< wxString > &aPageInclusions)
Truncates the list by removing sheet's with page numbers not in the given list.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
void SortByHierarchicalPageNumbers(bool aUpdateVirtualPageNums=true)
This works like SortByPageNumbers, but it sorts the sheets first by their hierarchical depth and then...
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.
size_t size() const
Forwarded method from std::vector.
void pop_back()
Forwarded method from std::vector.
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieve 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
static wxString GetDefaultFileExtension()
const wxString & GetTitle() const
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
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.
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
PGM_BASE & Pgm()
The global program "get" accessor.
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)
constexpr int mmToIU(double mm) const
std::vector< wxString > m_plotPages
wxString m_outputDirectory
HPGL_PLOT_ORIGIN_AND_UNITS m_HPGLPlotOrigin
HPGL_PAGE_SIZE m_HPGLPaperSizeSelect
bool m_useBackgroundColor
wxLogTrace helper definitions.
VECTOR2< int32_t > VECTOR2I