99 wxFprintf( stderr,
_(
"Error loading drawing sheet." ) );
106 wxFprintf( stderr, wxS(
"%s\n" ), aText );
108 wxPrintf( wxS(
"%s\n" ), aText );
125 wxFprintf( stderr,
_(
"Failed to load schematic file\n" ) );
129 std::unique_ptr<KIGFX::SCH_RENDER_SETTINGS> renderSettings =
130 std::make_unique<KIGFX::SCH_RENDER_SETTINGS>();
133 std::unique_ptr<SCH_PLOTTER> schPlotter = std::make_unique<SCH_PLOTTER>( sch );
151 wxFprintf( stderr,
_(
"Failed to load schematic file\n" ) );
168 wxPrintf(
_(
"Warning: schematic has annotation errors, please use the schematic editor to fix them\n" ) );
175 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
177 wxPrintf(
_(
"Warning: duplicate sheet names.\n" ) );
181 std::unique_ptr<NETLIST_EXPORTER_BASE> helper;
182 unsigned netlistOption = 0;
190 helper = std::make_unique<NETLIST_EXPORTER_KICAD>( sch );
195 helper = std::make_unique<NETLIST_EXPORTER_ORCADPCB2>( sch );
200 helper = std::make_unique<NETLIST_EXPORTER_CADSTAR>( sch );
206 helper = std::make_unique<NETLIST_EXPORTER_SPICE>( sch );
211 helper = std::make_unique<NETLIST_EXPORTER_SPICE_MODEL>( sch );
215 fileExt = wxS(
"xml" );
216 helper = std::make_unique<NETLIST_EXPORTER_XML>( sch );
219 wxFprintf( stderr,
_(
"Unknown netlist format.\n" ) );
227 fn.SetName( fn.GetName() );
228 fn.SetExt( fileExt );
233 bool res = helper->WriteNetlist( aNetJob->
m_outputFile, netlistOption, *
this );
255 wxFprintf( stderr,
_(
"Failed to load schematic file\n" ) );
268 if(
copy.CheckAnnotation(
275 wxPrintf(
_(
"Warning: schematic has annotation errors, please use the schematic "
276 "editor to fix them\n" ) );
283 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
285 wxPrintf(
_(
"Warning: duplicate sheet names.\n" ) );
297 dataModel.
AddColumn( wxS(
"Quantity" ),
_(
"Qty" ),
false );
300 std::set<wxString> userFieldNames;
302 for(
size_t i = 0; i < referenceList.
GetCount(); ++i )
304 SCH_SYMBOL* symbol = referenceList[i].GetSymbol();
307 userFieldNames.insert( symbol->
GetFields()[j].GetName() );
310 for(
const wxString& fieldName : userFieldNames )
311 dataModel.
AddColumn( fieldName, fieldName,
true );
317 if( userFieldNames.count( templateFieldname.m_Name ) == 0 )
318 dataModel.
AddColumn( templateFieldname.m_Name, templateFieldname.m_Name,
false );
328 field.
name = fieldName;
352 fn.SetName( fn.GetName() );
361 wxFprintf( stderr,
_(
"Unable to open destination '%s'" ), aBomJob->
m_outputFile );
373 bool res = f.Write( dataModel.
Export( fmt ) );
395 wxFprintf( stderr,
_(
"Failed to load schematic file\n" ) );
412 wxPrintf(
_(
"Warning: schematic has annotation errors, please use the schematic "
413 "editor to fix them\n" ) );
420 if(
erc.TestDuplicateSheetNames(
false ) > 0 )
421 wxPrintf(
_(
"Warning: duplicate sheet names.\n" ) );
423 std::unique_ptr<NETLIST_EXPORTER_XML> xmlNetlist =
424 std::make_unique<NETLIST_EXPORTER_XML>( sch );
429 fn.SetName( fn.GetName() +
"-bom" );
448 wxASSERT( symbol !=
nullptr );
450 if( symbol ==
nullptr )
459 symbolToPlot = parent.get();
471 pin.SetVisible(
true );
476 for(
int unit = 1; unit < symbol->
GetUnitCount() + 1; unit++ )
489 filename = wxString::Format(
"%s_%d", symbol->
GetName().Lower(), unit );
492 filename += wxS(
"_demorgan" );
494 fn.SetName( filename );
495 wxPrintf(
_(
"Plotting symbol '%s' unit %d to '%s'\n" ), symbol->
GetName(), unit,
500 filename = symbol->
GetName().Lower();
503 filename += wxS(
"_demorgan" );
505 wxPrintf(
_(
"Plotting symbol '%s' to '%s'\n" ), symbol->
GetName(), fn.GetFullPath() );
520 const double scale = 1.0;
527 if( !plotter->
OpenFile( fn.GetFullPath() ) )
529 wxFprintf( stderr,
_(
"Unable to open destination '%s'" ), fn.GetFullPath() );
539 bool background =
true;
547 symbolToPlot->
Plot( plotter, unit,
convert, background, plotPos, temp,
false );
551 symbolToPlot->
Plot( plotter, unit,
convert, !background, plotPos, temp,
false );
582 wxFprintf( stderr,
_(
"Unable to load library\n" ) );
595 wxFprintf( stderr,
_(
"There is no symbol selected to save." ) );
621 for(
const std::pair<const wxString, LIB_SYMBOL*>& entry : libSymMap )
623 exitCode =
doSymExportSvg( svgJob, &renderSettings, entry.second );
652 wxFprintf( stderr,
_(
"Unable to load library\n" ) );
660 wxFprintf( stderr,
_(
"Output path must not conflict with existing path\n" ) );
665 bool shouldSave = upgradeJob->
m_force
670 wxPrintf(
_(
"Saving symbol library in updated format\n" ) );
684 wxFprintf( stderr,
_(
"Unable to save library\n" ) );
690 wxPrintf(
_(
"Symbol library was not updated\n" ) );
constexpr EDA_IU_SCALE schIUScale
coord_type GetHeight() const
coord_type GetWidth() const
Color settings are a bit different than most of the settings objects in that there can be more than o...
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
static const wxString ResolvePath(const wxString &aPath, const wxString &aProjectPath)
Resolve a path which might be project-relative or contain env variable references.
static SCHEMATIC * LoadSchematic(wxString &aFileName)
int JobExportNetlist(JOB *aJob)
int JobSymUpgrade(JOB *aJob)
int JobExportBom(JOB *aJob)
int JobSymExportSvg(JOB *aJob)
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
int JobExportPythonBom(JOB *aJob)
int doSymExportSvg(JOB_SYM_EXPORT_SVG *aSvgJob, KIGFX::SCH_RENDER_SETTINGS *aRenderSettings, LIB_SYMBOL *symbol)
int JobExportPlot(JOB *aJob)
void InitRenderSettings(KIGFX::SCH_RENDER_SETTINGS *aRenderSettings, const wxString &aTheme, SCHEMATIC *aSch)
Configures the SCH_RENDER_SETTINGS object with the correct data to be used with plotting.
void ApplyBomPreset(const BOM_PRESET &preset)
wxString Export(const BOM_FMT_PRESET &settings)
void AddColumn(const wxString &aFieldName, const wxString &aLabel, bool aAddedByUser)
void Register(const std::string &aJobTypeName, std::function< int(JOB *job)> aHandler)
std::vector< wxString > m_fieldsLabels
std::vector< wxString > m_fieldsOrdered
wxString m_refRangeDelimiter
std::vector< wxString > m_fieldsGroupBy
wxString m_stringDelimiter
wxString m_fieldDelimiter
SCH_PLOT_SETTINGS settings
wxString m_outputDirectory
bool m_includeHiddenFields
wxString m_outputLibraryPath
An simple container class that lets us dispatch output jobs to kifaces.
void SetDefaultPenWidth(int aWidth)
void SetGapLengthRatio(double aRatio)
void SetDashLengthRatio(double aRatio)
Store schematic specific render settings.
void LoadColors(const COLOR_SETTINGS *aSettings) override
The base class for drawable items used by schematic library symbols.
Define a library symbol object.
void Plot(PLOTTER *aPlotter, int aUnit, int aConvert, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const
Plot lib symbol to plotter.
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
wxString GetName() const override
void PlotLibFields(PLOTTER *aPlotter, int aUnit, int aConvert, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed, bool aPlotHidden=true)
Plot Lib Fields only of the symbol to plotter.
int GetUnitCount() const override
For items with units, return the number of units.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
bool HasConversion() const
Test if symbol has more than one body conversion type (DeMorgan).
LIB_SYMBOL_REF & GetParent()
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 SetWidthMils(int aWidthInMils)
int GetHeightIU(double aIUScale) const
Gets the page height in IU.
static const wxChar Custom[]
"User" defined page type
void SetHeightMils(int aHeightInMils)
int GetWidthIU(double aIUScale) const
Gets the page width in IU.
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.
virtual const wxString GetProjectPath() const
Return the full path of the project.
A pure virtual class used to derive REPORTER objects from.
wxString m_SchDrawingSheetFileName
TEMPLATES m_TemplateFieldNames
double m_DashedLineGapRatio
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 GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
virtual LIB_SYMBOL * GetSymbol(const wxString &aName)
const LIB_SYMBOL_MAP & GetSymbolMap() const
void SetFileName(const wxString &aFileName)
void SetModified(bool aModified=true)
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.
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;.
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.
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.
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
const std::string SpiceFileExtension
const std::string CadstarNetlistFileExtension
const std::string SVGFileExtension
const std::string CsvFileExtension
const std::string NetlistFileExtension
const std::string OrCadPcb2NetlistFileExtension
const std::string XmlFileExtension
std::shared_ptr< LIB_SYMBOL > LIB_SYMBOL_SPTR
shared pointer to LIB_SYMBOL
static const int ERR_ARGS
static const int ERR_INVALID_INPUT_FILE
static const int ERR_INVALID_OUTPUT_CONFLICT
static const int ERR_UNKNOWN
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...
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
wxString refRangeDelimiter
std::vector< BOM_FIELD > fieldsOrdered
constexpr int IUToMils(int iu) const
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 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
Definition of file extensions used in Kicad.