60 return writeNetlist( aOutFileName, aNetlistOptions, aReporter );
67 catch(
const std::exception& error )
69 aReporter.
Report( wxString::Format(
_(
"Failed to export schematic: %s" ), error.
what() ),
88 itemNets.emplace( item->m_Uuid, connection->Name() );
98 for(
const auto& [key, subgraphs] :
m_schematic->ConnectionGraph()->GetNetMap() )
104 result.hasNoConnect |= subgraph->GetNoConnect()
108 for(
SCH_ITEM* item : subgraph->GetItems() )
127 const auto found = sheet->second.find( aItem.
m_Uuid );
128 return found == sheet->second.end() ? std::nullopt : std::optional( found->second );
142 const wxString& aNetlistFile,
143 const wxString& aFinalFile,
144 const wxString& aProjectPath )
152 wxString ret = aFormatString;
153 wxFileName in = aNetlistFile;
154 wxFileName out = aFinalFile;
155 wxString str_out = out.GetFullPath();
157 ret.Replace(
"%P", aProjectPath,
true );
158 ret.Replace(
"%B", out.GetName(),
true );
159 ret.Replace(
"%I", in.GetFullPath(),
true );
167 if( !str_out.StartsWith(
"\\\\" ) )
168 str_out.Replace(
"\\",
"/" );
171 ret.Replace(
"%O", str_out,
true );
180 wxCHECK( aItem,
nullptr );
192 ref = symbol->
GetRef( &aSheetPath );
194 if( ref[0] == wxChar(
'#' ) )
199 wxCHECK( screen,
nullptr );
226 std::vector<PIN_INFO> pins;
231 wxString ref( aSymbol->
GetRef( &aSheetPath ) );
235 if( ( ref[0] == wxChar(
'#' ) ) || aSymbol->
IsPower() )
264 std::sort( pins.begin(), pins.end(),
267 return StrNumCmp( lhs.num, rhs.num, true ) < 0;
290 wxString fpText = symbol->GetFootprintFieldText( &aSheetPath,
RESOLVED, variantName );
293 if( !fpText.IsEmpty() && fpId.
Parse( fpText,
true ) < 0 )
302 if( state == SCH_PIN::PAD_RESOLUTION::UNMAPPED )
324 if(
m_kiway && !aFootprintId.IsEmpty() )
328 typedef void ( *PAD_NUMBERS_FN_PTR )(
const wxString&,
PROJECT*, std::set<wxString>& );
331 fetch( aFootprintId, &
m_schematic->Project(), pads );
346 wxString pinName = baseName.IsEmpty() ? padNum : baseName + wxT(
"_" ) + padNum;
347 aPins.emplace_back( padNum, aNetName, pinName, aPin->
GetNumber() );
354 for(
unsigned ii = 0; ii < aPins.size(); ii++ )
356 if( aPins[ii].num.empty() )
365 unsigned idxBest = ii;
367 for(
unsigned jj = ii + 1; jj < aPins.size(); jj++ )
369 if( aPins[jj].num.empty() )
372 if( aPins[idxBest].num != aPins[jj].num )
379 if( aPins[idxBest].netName != aPins[jj].netName && !aPins[idxBest].srcPin.IsEmpty()
380 && !aPins[jj].srcPin.IsEmpty() && aPins[idxBest].srcPin != aPins[jj].srcPin )
390 if( bestIsAuto && !jjIsAuto )
393 aPins[idxBest].num.clear();
398 aPins[jj].num.clear();
407 std::vector<PIN_INFO>& aPins )
409 const wxString ref = aSchSymbol->
GetRef( &aSheetPath );
415 auto* symbol =
static_cast<SCH_SYMBOL*
>( item );
417 if( symbol->GetRef( &sheet ).CmpNoCase( ref ) != 0 )
420 for(
const SCH_PIN*
pin : symbol->GetPins( &sheet ) )
A subgraph is a set of items that are electrically connected on a single sheet.
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
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()
virtual const char * what() const override
std::exception interface, returned as UTF-8
A logical library item identifier and consists of various portions much like a URI.
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
wxString GetUniStringLibId() const
Define a library symbol object.
const LIB_ID & GetLibId() const override
int GetUnitCount() const override
CONNECTIVITY_SCOPE(NETLIST_EXPORTER_BASE &aExporter)
NETLIST_EXPORTER_BASE & m_exporter
SCHEMATIC * m_schematic
The schematic we're generating a netlist for.
virtual bool writeNetlist(const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter)
std::optional< wxString > itemNetName(const SCH_ITEM &aItem, const SCH_SHEET_PATH &aPath) const
const std::set< wxString > & footprintPads(const wxString &aFootprintId) const
void findAllUnitsOfSymbol(SCH_SYMBOL *aSchSymbol, const SCH_SHEET_PATH &aSheetPath, std::vector< PIN_INFO > &aPins)
Find all units for symbols with multiple symbols per package.
void rebuildConnectivity()
SCH_SYMBOL * findNextSymbol(EDA_ITEM *aItem, const SCH_SHEET_PATH &aSheetPath)
Check if the given symbol should be processed for netlisting.
std::map< wxString, std::set< wxString > > m_footprintPadCache
std::set< LIB_SYMBOL *, LIB_SYMBOL_LESS_THAN > m_libParts
unique library symbols used. LIB_SYMBOL items are sorted by names
void eraseDuplicatePins(std::vector< PIN_INFO > &pins)
Erase duplicate pins.
std::vector< wxString > resolvePadNumbers(const SCH_PIN *aPin, const SCH_SHEET_PATH &aSheetPath) const
Resolve aPin to its effective pad number(s) for every netlist path (issue #2282).
NETLIST_EXPORTER_BASE(SCHEMATIC *aSchematic)
std::map< SCH_SHEET_PATH, std::unordered_map< KIID, wxString > > m_exportItemNets
UNIQUE_STRINGS m_referencesAlreadyFound
Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than once.
SCH_SHEET_LIST m_exportSheets
std::vector< EXPORT_NET > m_exportNets
bool WriteNetlist(const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter)
Write to specified output file.
static wxString MakeCommandLine(const wxString &aFormatString, const wxString &aNetlistFile, const wxString &aFinalFile, const wxString &aProjectDirectory)
Build up a string that describes a command line for executing a child process.
void appendResolvedPins(std::vector< PIN_INFO > &aPins, const SCH_PIN *aPin, const SCH_SHEET_PATH &aSheetPath, const wxString &aNetName)
Resolve aPin to its pad number(s) and append a PIN_INFO for each (issue #2282).
std::vector< PIN_INFO > CreatePinList(SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aSheetPath)
Find a symbol from the DrawList and builds its pin list.
Container for project specific data.
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
Base class for any item which can be embedded within the SCHEMATIC container class,...
const SYMBOL * GetParentSymbol() const
PAD_RESOLUTION
Outcome of pin-to-pad resolution (issue #2282).
const wxString & GetShownName() const
wxString GetEffectivePadNumber(const SCH_SHEET_PATH &aSheet, const wxString &aVariantName, const LIB_ID &aFootprintLibId, const std::set< wxString > *aFootprintPadNumbers, PAD_RESOLUTION *aState=nullptr) const
Resolve the footprint pad number this symbol pin lands on (issue #2282).
const wxString & GetNumber() const
const std::map< wxString, LIB_SYMBOL * > & GetLibSymbols() const
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SCREEN * LastScreen()
wxString GetSchSymbolLibraryName() const
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
bool IsPower() const override
@ KIFACE_FOOTPRINT_PAD_NUMBERS
Function pointer type: void (*)( const wxString& aFootprint, PROJECT* aProject, std::set<wxString>& a...
std::vector< wxString > ExpandStackedPinNotation(const wxString &aPinName, bool *aValid)
Expand stacked pin notation like [1,2,3], [1-4], [A1-A4], or [AA1-AA3,AB4,CD12-CD14] into individual ...
bool IsAutoGeneratedNetName(const wxString &aNetName)
Recognize the reserved prefixes used for generated pin-net names.
Implement a participant in the KIWAY alchemy.
bool operator()(LIB_SYMBOL *const &libsymbol1, LIB_SYMBOL *const &libsymbol2) const
wxString result
Test unit parsing edge cases and error handling.
wxLogTrace helper definitions.