KiCad PCB EDA Suite
SCH Namespace Reference

Classes

struct  IFACE
 

Functions

static std::unique_ptr< SCHEMATICreadSchematicFromFile (const std::string &aFilename)
 
bool generateSchematicNetlist (const wxString &aFilename, wxString &aNetlist)
 
SCH::IFACE KIFACE_I kiface ("eeschema", KIWAY::FACE_SCH)
 

Function Documentation

◆ generateSchematicNetlist()

bool SCH::generateSchematicNetlist ( const wxString &  aFilename,
wxString &  aNetlist 
)

Definition at line 101 of file eeschema.cpp.

102 {
103  std::unique_ptr<SCHEMATIC> schematic = readSchematicFromFile( aFilename.ToStdString() );
104  NETLIST_EXPORTER_KICAD exporter( schematic.get() );
105  STRING_FORMATTER formatter;
106 
107  exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
108  aNetlist = formatter.GetString();
109 
110  return true;
111 }
static std::unique_ptr< SCHEMATIC > readSchematicFromFile(const std::string &aFilename)
Definition: eeschema.cpp:62
Generate the KiCad netlist format supported by Pcbnew.
const std::string & GetString()
Definition: richio.h:435
#define GNL_ALL
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:411

References readSchematicFromFile().

Referenced by SCH::IFACE::IfaceOrAddress().

◆ kiface()

SCH::IFACE KIFACE_I SCH::kiface ( "eeschema"  ,
KIWAY::FACE_SCH   
)
static

Referenced by Kiface().

◆ readSchematicFromFile()

static std::unique_ptr<SCHEMATIC> SCH::readSchematicFromFile ( const std::string &  aFilename)
static

Definition at line 62 of file eeschema.cpp.

63 {
64  auto pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD );
65  std::unique_ptr<SCHEMATIC> schematic = std::make_unique<SCHEMATIC>( nullptr );
66 
67  auto &manager = Pgm().GetSettingsManager();
68 
69  manager.LoadProject( "" );
70  schematic->Reset();
71  schematic->SetProject( &manager.Prj() );
72  schematic->SetRoot( pi->Load( aFilename, schematic.get() ) );
73  schematic->CurrentSheet().push_back( &schematic->Root() );
74 
75  SCH_SCREENS screens( schematic->Root() );
76 
77  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
78  screen->UpdateLocalLibSymbolLinks();
79 
80  SCH_SHEET_LIST sheets = schematic->GetSheets();
81 
82  // Restore all of the loaded symbol instances from the root sheet screen.
83  sheets.UpdateSymbolInstances( schematic->RootScreen()->GetSymbolInstances() );
84 
85  sheets.AnnotatePowerSymbols();
86 
87  // NOTE: This is required for multi-unit symbols to be correct
88  // Normally called from SCH_EDIT_FRAME::FixupJunctions() but could be refactored
89  for( SCH_SHEET_PATH& sheet : sheets )
90  sheet.UpdateAllScreenReferences();
91 
92  // NOTE: SchematicCleanUp is not called; QA schematics must already be clean or else
93  // SchematicCleanUp must be freed from its UI dependencies.
94 
95  schematic->ConnectionGraph()->Recalculate( sheets, true );
96 
97  return schematic;
98 }
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:166
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void UpdateSymbolInstances(const std::vector< SYMBOL_INSTANCE_REFERENCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Loads a project or sets up a new project with a specified path.
void AnnotatePowerSymbols()
Silently annotate the not yet annotated power symbols of the entire hierarchy of the sheet path list.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: eeschema.cpp:223
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:549

References SCH_SHEET_LIST::AnnotatePowerSymbols(), PGM_BASE::GetSettingsManager(), SETTINGS_MANAGER::LoadProject(), Pgm(), and SCH_SHEET_LIST::UpdateSymbolInstances().

Referenced by generateSchematicNetlist().