43 const wxString& aNetlistFile,
44 const wxString& aFinalFile,
45 const wxString& aProjectPath )
53 wxString ret = aFormatString;
54 wxFileName in = aNetlistFile;
55 wxFileName out = aFinalFile;
56 wxString str_out = out.GetFullPath();
58 ret.Replace(
"%P", aProjectPath,
true );
59 ret.Replace(
"%B", out.GetName(),
true );
60 ret.Replace(
"%I", in.GetFullPath(),
true );
68 if( !str_out.StartsWith(
"\\\\" ) )
69 str_out.Replace(
"\\",
"/" );
72 ret.Replace(
"%O", str_out,
true );
81 wxCHECK( aItem,
nullptr );
93 ref = symbol->
GetRef( &aSheetPath );
95 if( ref[0] == wxChar(
'#' ) )
100 wxCHECK( screen,
nullptr );
126 bool aKeepUnconnectedPins )
128 std::vector<PIN_INFO> pins;
133 wxString ref( aSymbol->
GetRef( &aSheetPath ) );
137 if( ( ref[0] == wxChar(
'#' ) ) || aSymbol->
IsPower() )
154 wxLogTrace(
traceStackedPins,
"CreatePinList(multi): ref='%s' pins=%zu", aSymbol->
GetRef( &aSheetPath ), pins.size() );
165 const wxString& netName = conn->Name();
167 if( !aKeepUnconnectedPins )
176 std::vector<wxString> numbers =
pin->GetStackedPinNumbers( &valid );
177 wxString baseName =
pin->GetShownName();
179 wxString::Format(
"CreatePinList(single): ref='%s' pinNameBase='%s' shownNum='%s' net='%s' "
180 "valid=%d expand=%zu",
181 ref, baseName,
pin->GetShownNumber(), netName, valid, numbers.size() ) );
183 for(
const wxString& num : numbers )
185 wxString pinName = baseName.IsEmpty() ? num : baseName + wxT(
"_" ) + num;
187 wxString::Format(
" -> emit pin num='%s' name='%s' net='%s'", num, pinName, netName ) );
188 pins.emplace_back( num, netName, pinName );
195 std::sort( pins.begin(), pins.end(),
198 return StrNumCmp( lhs.num, rhs.num, true ) < 0;
215 auto isAutoGeneratedNet = [](
const wxString& aNetName ) ->
bool
217 return aNetName.StartsWith( wxT(
"unconnected-(" ) )
218 || aNetName.StartsWith( wxT(
"Net-(" ) );
221 for(
unsigned ii = 0; ii < aPins.size(); ii++ )
223 if( aPins[ii].num.empty() )
232 unsigned idxBest = ii;
234 for(
unsigned jj = ii + 1; jj < aPins.size(); jj++ )
236 if( aPins[jj].num.empty() )
239 if( aPins[idxBest].num != aPins[jj].num )
244 bool bestIsAuto = isAutoGeneratedNet( aPins[idxBest].netName );
245 bool jjIsAuto = isAutoGeneratedNet( aPins[jj].netName );
247 if( bestIsAuto && !jjIsAuto )
250 aPins[idxBest].num.clear();
255 aPins[jj].num.clear();
264 std::vector<PIN_INFO>& aPins,
265 bool aKeepUnconnectedPins )
267 wxString ref = aSchSymbol->
GetRef( &aSheetPath );
278 ref2 = comp2->
GetRef( &sheet );
280 if( ref2.CmpNoCase( ref ) != 0 )
287 const wxString& netName = conn->Name();
289 if( !aKeepUnconnectedPins )
298 std::vector<wxString> numbers =
pin->GetStackedPinNumbers( &valid );
299 wxString baseName =
pin->GetShownName();
301 wxString::Format(
"CreatePinList(multi): ref='%s' pinNameBase='%s' shownNum='%s' net='%s' valid=%d expand=%zu",
302 ref2, baseName,
pin->GetShownNumber(), netName, valid, numbers.size() ) );
304 for(
const wxString& num : numbers )
306 wxString pinName = baseName.IsEmpty() ? num : baseName + wxT(
"_" ) + num;
308 wxString::Format(
" -> emit pin num='%s' name='%s' net='%s'", num, pinName, netName ) );
309 aPins.emplace_back( num, netName, pinName );
Calculate the connectivity of a schematic and generates netlists.
CONNECTION_SUBGRAPH * FindSubgraphByName(const wxString &aNetName, const SCH_SHEET_PATH &aPath)
Return the subgraph for a given net name on a given sheet.
A subgraph is a set of items that are electrically connected on a single sheet.
const std::set< SCH_ITEM * > & GetItems() const
Provide a read-only reference to the items in the subgraph.
const SCH_ITEM * GetNoConnect() const
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
Define a library symbol object.
const LIB_ID & GetLibId() const override
int GetUnitCount() const override
SCHEMATIC * m_schematic
The schematic we're generating a netlist for.
std::vector< PIN_INFO > CreatePinList(SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aSheetPath, bool aKeepUnconnectedPins)
Find a symbol from the DrawList and builds its pin list.
void findAllUnitsOfSymbol(SCH_SYMBOL *aSchSymbol, const SCH_SHEET_PATH &aSheetPath, std::vector< PIN_INFO > &aPins, bool aKeepUnconnectedPins)
Find all units for symbols with multiple symbols per package.
SCH_SYMBOL * findNextSymbol(EDA_ITEM *aItem, const SCH_SHEET_PATH &aSheetPath)
Check if the given symbol should be processed for netlisting.
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.
UNIQUE_STRINGS m_referencesAlreadyFound
Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than once.
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.
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 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
const wxChar *const traceStackedPins
Flag to enable debug output for stacked pins handling in symbol/pin code.
bool operator()(LIB_SYMBOL *const &libsymbol1, LIB_SYMBOL *const &libsymbol2) const
wxLogTrace helper definitions.