76 m_cliSchematic( nullptr )
80 [](
JOB* job, wxWindow* aParent ) ->
bool
91 [](
JOB* job, wxWindow* aParent ) ->
bool
97 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
111 return dlg.GetReturnCode() == wxID_OK;
115 [aKiway](
JOB* job, wxWindow* aParent ) ->
bool
132 [](
JOB* job, wxWindow* aParent ) ->
bool
138 [](
JOB* job, wxWindow* aParent ) ->
bool
143 [](
JOB* job, wxWindow* aParent ) ->
bool
157 wxString schPath = aPath;
158 if( schPath.IsEmpty() )
163 schPath =
path.GetFullPath();
174 else if( !aPath.IsEmpty() )
190 const wxString& aDrawingSheetOverride )
210 [&](
const wxString&
path ) ->
bool
225 + wxS(
"\n" ) + msg + wxS(
"\n" ),
234 if( !aDrawingSheetOverride.IsEmpty() && loadSheet( aDrawingSheetOverride ) )
256 std::unique_ptr<SCH_RENDER_SETTINGS> renderSettings = std::make_unique<SCH_RENDER_SETTINGS>();
259 std::unique_ptr<SCH_PLOTTER> schPlotter = std::make_unique<SCH_PLOTTER>( sch );
264 case SCH_PLOT_FORMAT::DXF: format = PLOT_FORMAT::DXF;
break;
265 case SCH_PLOT_FORMAT::PDF: format = PLOT_FORMAT::PDF;
break;
266 case SCH_PLOT_FORMAT::SVG: format = PLOT_FORMAT::SVG;
break;
267 case SCH_PLOT_FORMAT::POST: format = PLOT_FORMAT::POST;
break;
268 case SCH_PLOT_FORMAT::HPGL: format = PLOT_FORMAT::HPGL;
break;
269 case SCH_PLOT_FORMAT::GERBER: format = PLOT_FORMAT::GERBER;
break;
275 case JOB_HPGL_PAGE_SIZE::DEFAULT: hpglPageSize = HPGL_PAGE_SIZE::DEFAULT;
break;
276 case JOB_HPGL_PAGE_SIZE::SIZE_A: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A;
break;
277 case JOB_HPGL_PAGE_SIZE::SIZE_A0: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A0;
break;
278 case JOB_HPGL_PAGE_SIZE::SIZE_A1: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A1;
break;
279 case JOB_HPGL_PAGE_SIZE::SIZE_A2: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A2;
break;
280 case JOB_HPGL_PAGE_SIZE::SIZE_A3: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A3;
break;
281 case JOB_HPGL_PAGE_SIZE::SIZE_A4: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A4;
break;
282 case JOB_HPGL_PAGE_SIZE::SIZE_A5: hpglPageSize = HPGL_PAGE_SIZE::SIZE_A5;
break;
283 case JOB_HPGL_PAGE_SIZE::SIZE_B: hpglPageSize = HPGL_PAGE_SIZE::SIZE_B;
break;
284 case JOB_HPGL_PAGE_SIZE::SIZE_C: hpglPageSize = HPGL_PAGE_SIZE::SIZE_C;
break;
285 case JOB_HPGL_PAGE_SIZE::SIZE_D: hpglPageSize = HPGL_PAGE_SIZE::SIZE_D;
break;
286 case JOB_HPGL_PAGE_SIZE::SIZE_E: hpglPageSize = HPGL_PAGE_SIZE::SIZE_E;
break;
292 case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT:
293 hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_BOT_LEFT;
295 case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER:
296 hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::PLOTTER_CENTER;
298 case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT:
299 hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_CONTENT;
301 case JOB_HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE:
302 hpglOrigin = HPGL_PLOT_ORIGIN_AND_UNITS::USER_FIT_PAGE;
306 int pageSizeSelect = PageFormatReq::PAGE_SIZE_AUTO;
310 case JOB_PAGE_SIZE::PAGE_SIZE_A: pageSizeSelect = PageFormatReq::PAGE_SIZE_A;
break;
311 case JOB_PAGE_SIZE::PAGE_SIZE_A4: pageSizeSelect = PageFormatReq::PAGE_SIZE_A4;
break;
312 case JOB_PAGE_SIZE::PAGE_SIZE_AUTO: pageSizeSelect = PageFormatReq::PAGE_SIZE_AUTO;
break;
332 schPlotter->Plot( format, plotOpts, renderSettings.get(),
m_reporter );
363 m_reporter->
Report(
_(
"Warning: schematic has annotation errors, please use the "
364 "schematic editor to fix them\n" ),
372 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
375 std::unique_ptr<NETLIST_EXPORTER_BASE> helper;
376 unsigned netlistOption = 0;
384 helper = std::make_unique<NETLIST_EXPORTER_KICAD>( sch );
389 helper = std::make_unique<NETLIST_EXPORTER_ORCADPCB2>( sch );
394 helper = std::make_unique<NETLIST_EXPORTER_CADSTAR>( sch );
400 helper = std::make_unique<NETLIST_EXPORTER_SPICE>( sch );
405 helper = std::make_unique<NETLIST_EXPORTER_SPICE_MODEL>( sch );
409 fileExt = wxS(
"xml" );
410 helper = std::make_unique<NETLIST_EXPORTER_XML>( sch );
414 fileExt = wxS(
"asc" );
415 helper = std::make_unique<NETLIST_EXPORTER_PADS>( sch );
419 fileExt = wxS(
"txt" );
420 helper = std::make_unique<NETLIST_EXPORTER_ALLEGRO>( sch );
431 fn.SetName( fn.GetName() );
432 fn.SetExt( fileExt );
469 if(
copy.CheckAnnotation(
477 _(
"Warning: schematic has annotation errors, please use the schematic "
478 "editor to fix them\n" ),
486 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
498 std::set<wxString> userFieldNames;
500 for(
size_t i = 0; i < referenceList.
GetCount(); ++i )
502 SCH_SYMBOL* symbol = referenceList[i].GetSymbol();
505 userFieldNames.insert( symbol->
GetFields()[j].GetName() );
508 for(
const wxString& fieldName : userFieldNames )
515 if( userFieldNames.count( templateFieldname.m_Name ) == 0 )
545 m_reporter->
Report( wxString::Format(
_(
"BOM preset '%s' not found" ) + wxS(
"\n" ),
562 if( fieldName == wxS(
"*" ) )
568 field.
name = modelField.name;
573 bool fieldAlreadyPresent =
false;
576 if( presetField.
name == field.
name )
578 fieldAlreadyPresent =
true;
583 bool fieldLaterInList =
false;
586 if( fieldInList == field.
name )
588 fieldLaterInList =
true;
593 if( !fieldAlreadyPresent && !fieldLaterInList )
602 field.
name = fieldName;
632 fn.SetName( fn.GetName() );
673 wxString::Format(
_(
"BOM format preset '%s' not found" ) + wxS(
"\n" ),
692 bool res = f.Write( dataModel.
Export( fmt ) );
727 _(
"Warning: schematic has annotation errors, please use the schematic "
728 "editor to fix them\n" ),
736 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
739 std::unique_ptr<NETLIST_EXPORTER_XML> xmlNetlist =
740 std::make_unique<NETLIST_EXPORTER_XML>( sch );
745 fn.SetName( fn.GetName() +
"-bom" );
764 wxASSERT( symbol !=
nullptr );
766 if( symbol ==
nullptr )
776 symbolToPlot = parent.get();
785 for(
int unit = 1; unit < symbol->
GetUnitCount() + 1; unit++ )
791 size_t forbidden_char;
796 filename = symbol->
GetName().Lower();
798 while( wxString::npos
799 != ( forbidden_char = filename.find_first_of(
800 wxFileName::GetForbiddenChars( wxPATH_DOS ) ) ) )
802 filename = filename.replace( forbidden_char, 1, wxS(
'_' ) );
808 filename += wxString::Format(
"_%d", unit );
811 filename += wxS(
"_demorgan" );
813 fn.SetName( filename );
814 m_reporter->
Report( wxString::Format(
_(
"Plotting symbol '%s' unit %d to '%s'\n" ),
815 symbol->
GetName(), unit, fn.GetFullPath() ),
821 filename += wxS(
"_demorgan" );
823 fn.SetName( filename );
825 symbol->
GetName(), fn.GetFullPath() ),
841 const double scale = 1.0;
848 if( !plotter->
OpenFile( fn.GetFullPath() ) )
851 wxString::Format(
_(
"Unable to open destination '%s'" ) + wxS(
"\n" ),
864 bool background =
true;
869 symbolToPlot->
Plot( plotter, background, plotOpts, unit, bodyStyle, offset,
false );
870 symbol->
PlotFields( plotter, background, plotOpts, unit, bodyStyle, offset,
false );
872 symbolToPlot->
Plot( plotter, !background, plotOpts, unit, bodyStyle, offset,
false );
873 symbol->
PlotFields( plotter, !background, plotOpts, unit, bodyStyle, offset,
false );
944 for(
const std::pair<const wxString, LIB_SYMBOL*>& entry : libSymMap )
946 exitCode =
doSymExportSvg( svgJob, &renderSettings, entry.second );
979 else if(
fileType != SCH_IO_MGR::SCH_KICAD )
981 m_reporter->
Report(
_(
"Output path must be specified to convert legacy and non-KiCad libraries\n" ),
987 if(
fileType == SCH_IO_MGR::SCH_KICAD )
1062 fn.SetName( fn.GetName() );
1079 default: units = EDA_UNITS::MILLIMETRES;
break;
1082 std::shared_ptr<SHEETLIST_ERC_ITEMS_PROVIDER> markersProvider =
1083 std::make_shared<SHEETLIST_ERC_ITEMS_PROVIDER>( sch );
1093 markersProvider->SetSeverities( ercJob->
m_severity );
1096 markersProvider->GetCount() ),
1101 bool wroteReport =
false;
1121 if( markersProvider->GetCount() > 0 )
1146 return drawingSheet;
constexpr EDA_IU_SCALE schIUScale
int GetVirtualPageNumber() const
const wxString & GetPageNumber() const
constexpr size_type GetWidth() const
constexpr const Vec GetCenter() const
constexpr size_type GetHeight() const
Color settings are a bit different than most of the settings objects in that there can be more than o...
bool LoadDrawingSheet(const wxString &aFullFileName, wxString *aMsg, bool aAppend=false)
Populates the list with a custom layout or the default layout if no custom layout is available.
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
void SetSheetPath(const std::string &aSheetPath)
Set the sheet path displayed in the title block.
void SetSheetCount(int aSheetCount)
Changes the sheet-count number displayed in the title block.
void SetPageNumber(const std::string &aPageNumber)
Changes the page number displayed in the title block.
void SetSheetName(const std::string &aSheetName)
Set the sheet name displayed in the title block.
void SetPageBorderColorLayer(int aLayerId)
Overrides the layer used to pick the color of the page border (normally LAYER_GRID)
void SetIsFirstPage(bool aIsFirstPage)
Change if this is first page.
void SetFileName(const std::string &aFileName)
Set the file name displayed in the title block.
void SetColorLayer(int aLayerId)
Can be used to override which layer ID is used for drawing sheet item colors.
static SCHEMATIC * LoadSchematic(const wxString &aFileName, bool aSetActive, bool aForceDefaultProject, PROJECT *aProject=nullptr)
int JobExportNetlist(JOB *aJob)
void InitRenderSettings(SCH_RENDER_SETTINGS *aRenderSettings, const wxString &aTheme, SCHEMATIC *aSch, const wxString &aDrawingSheetOverride=wxEmptyString)
Configure the SCH_RENDER_SETTINGS object with the correct data to be used with plotting.
int JobSymUpgrade(JOB *aJob)
int JobExportBom(JOB *aJob)
int JobSymExportSvg(JOB *aJob)
SCHEMATIC * getSchematic(const wxString &aPath)
DS_PROXY_VIEW_ITEM * getDrawingSheetProxyView(SCHEMATIC *aSch)
int JobExportPythonBom(JOB *aJob)
EESCHEMA_JOBS_HANDLER(KIWAY *aKiway)
int JobExportPlot(JOB *aJob)
SCHEMATIC * m_cliSchematic
int doSymExportSvg(JOB_SYM_EXPORT_SVG *aSvgJob, SCH_RENDER_SETTINGS *aRenderSettings, LIB_SYMBOL *symbol)
bool WriteJsonReport(const wxString &aFullFileName)
Writes a JSON formatted ERC Report to the given file path.
bool WriteTextReport(const wxString &aFullFileName)
Writes the text report also available via GetTextReport directly to a given file path.
void RunTests(DS_PROXY_VIEW_ITEM *aDrawingSheet, SCH_EDIT_FRAME *aEditFrame, KIFACE *aCvPcb, PROJECT *aProject, PROGRESS_REPORTER *aProgressReporter)
void ApplyBomPreset(const BOM_PRESET &preset)
wxString Export(const BOM_FMT_PRESET &settings)
void AddColumn(const wxString &aFieldName, const wxString &aLabel, bool aAddedByUser)
const std::vector< BOM_FIELD > GetFieldsOrdered()
Provide an extensible class to resolve 3D model paths.
bool SetProject(PROJECT *aProject, bool *flgChanged=nullptr)
Set the current KiCad project directory as the first entry in the model path list.
void SetProgramBase(PGM_BASE *aBase)
Set a pointer to the application's PGM_BASE instance used to extract the local env vars.
wxString ResolvePath(const wxString &aFileName, const wxString &aWorkingPath, const EMBEDDED_FILES *aFiles)
Determines the full path of the given file name.
void Register(const std::string &aJobTypeName, std::function< int(JOB *job)> aHandler, std::function< bool(JOB *job, wxWindow *aParent)> aConfigHandler)
PROGRESS_REPORTER * m_progressReporter
bool m_includeExcludedFromBOM
std::vector< wxString > m_fieldsLabels
std::vector< wxString > m_fieldsOrdered
wxString m_refRangeDelimiter
std::vector< wxString > m_fieldsGroupBy
wxString m_stringDelimiter
wxString m_fieldDelimiter
wxString m_bomFmtPresetName
JOB_PAGE_SIZE m_pageSizeSelect
SCH_PLOT_FORMAT m_plotFormat
bool m_useBackgroundColor
wxString m_outputDirectory
bool m_PDFHierarchicalLinks
JOB_HPGL_PLOT_ORIGIN_AND_UNITS m_HPGLPlotOrigin
std::vector< wxString > m_plotPages
JOB_HPGL_PAGE_SIZE m_HPGLPaperSizeSelect
bool m_exitCodeViolations
wxString m_outputDirectory
bool m_includeHiddenFields
wxString m_outputLibraryPath
An simple container class that lets us dispatch output jobs to kifaces.
void SetOutputPath(const wxString &aPath)
const std::map< wxString, wxString > & GetVarOverrides() const
wxString GetOutputPath() const
void SetDefaultPenWidth(int aWidth)
void SetGapLengthRatio(double aRatio)
void SetDashLengthRatio(double aRatio)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
virtual KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Return the KIFACE* given a FACE_T.
Define a library symbol object.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
bool HasAlternateBodyStyle() const override
Test if symbol has more than one body conversion type (DeMorgan).
void PlotFields(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed)
Plot symbol fields.
wxString GetName() const override
int GetUnitCount() const override
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
LIB_SYMBOL_SPTR GetRootSymbol() const
Get the parent symbol that does not have another parent.
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.
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
static const wxChar Custom[]
"User" defined page type
void SetHeightMils(double aHeightInMils)
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
void SetWidthMils(double aWidthInMils)
virtual SETTINGS_MANAGER & GetSettingsManager() const
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 SetCreator(const wxString &aCreator)
virtual void SetColorMode(bool aColorMode)
Plot in B/W or color.
Container for project specific data.
virtual void ApplyTextVars(const std::map< wxString, wxString > &aVarsMap)
Applies the given var map, it will create or update existing vars.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
wxString m_SchDrawingSheetFileName
TEMPLATES m_TemplateFieldNames
std::vector< BOM_PRESET > m_BomPresets
double m_DashedLineGapRatio
std::vector< BOM_FMT_PRESET > m_BomFmtPresets
double m_DashedLineDashRatio
Holds all the data relating to one schematic.
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
SCHEMATIC_SETTINGS & Settings() const
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
EMBEDDED_FILES * GetEmbeddedFiles() override
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
const std::map< wxString, wxString > * GetProperties()
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Schematic editor (Eeschema) main window.
A cache assistant for the KiCad s-expression symbol libraries.
int GetFileFormatVersionAtLoad() const
void Save(const std::optional< bool > &aOpt=std::nullopt) override
Save the entire library to file m_libFileName;.
virtual LIB_SYMBOL * GetSymbol(const wxString &aName)
void SetFileName(const wxString &aFileName)
const LIB_SYMBOL_MAP & GetSymbolMap() const
void SetModified(bool aModified=true)
static bool ConvertLibrary(std::map< std::string, UTF8 > *aOldFileProps, const wxString &aOldFilePath, const wxString &aNewFilepath)
Convert a schematic symbol library to the latest KiCad format.
static SCH_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
Return a plugin type given a symbol library using the file extension of aLibPath.
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
int CheckAnnotation(ANNOTATION_ERROR_HANDLER aErrorHandler)
Check for annotations errors.
A helper to define a symbol's reference designator in a schematic.
void LoadColors(const COLOR_SETTINGS *aSettings) override
const PAGE_INFO & GetPageSettings() const
const wxString & GetFileName() const
const TITLE_BLOCK & GetTitleBlock() const
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
int GetFieldCount() const
Return the number of fields in this symbol.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
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
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Return a template field name list for read only access.
bool IsTextVar(const wxString &aSource)
Returns true if the string is a text var, e.g starts with ${.
wxString GetTextVars(const wxString &aSource)
Returns any variables unexpanded, e.g.
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
static const std::string CadstarNetlistFileExtension
static const std::string NetlistFileExtension
static const std::string ReportFileExtension
static const std::string JsonFileExtension
static const std::string XmlFileExtension
static const std::string KiCadSchematicFileExtension
static const std::string OrCadPcb2NetlistFileExtension
static const std::string CsvFileExtension
static const std::string SpiceFileExtension
static const std::string SVGFileExtension
@ LAYER_SCHEMATIC_DRAWINGSHEET
@ LAYER_SCHEMATIC_PAGE_LIMITS
std::shared_ptr< LIB_SYMBOL > LIB_SYMBOL_SPTR
shared pointer to LIB_SYMBOL
static const int ERR_ARGS
static const int ERR_RC_VIOLATIONS
static const int ERR_INVALID_INPUT_FILE
static const int ERR_INVALID_OUTPUT_CONFLICT
Rules check violation count was greater than 0.
static const int ERR_UNKNOWN
SETTINGS_MANAGER * GetSettingsManager()
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)
#define SEXPR_SYMBOL_LIB_FILE_VERSION
This file contains the file format version information for the s-expression schematic and symbol libr...
HPGL_PLOT_ORIGIN_AND_UNITS
MODEL3D_FORMAT_TYPE fileType(const char *aFileName)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
static std::vector< BOM_FMT_PRESET > BuiltInPresets()
wxString refRangeDelimiter
std::vector< BOM_FIELD > fieldsOrdered
bool includeExcludedFromBOM
static std::vector< BOM_PRESET > BuiltInPresets()
constexpr int IUToMils(int iu) const
std::vector< wxString > m_plotPages
wxString m_outputDirectory
HPGL_PLOT_ORIGIN_AND_UNITS m_HPGLPlotOrigin
HPGL_PAGE_SIZE m_HPGLPaperSizeSelect
bool m_PDFHierarchicalLinks
bool m_useBackgroundColor
Hold a name of a symbol's field, field value, and default visibility.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.
std::map< wxString, LIB_SYMBOL *, LibSymbolMapSort > LIB_SYMBOL_MAP
@ MANDATORY_FIELDS
The first 5 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
Definition of file extensions used in Kicad.