46 if( ( f = wxFopen( aOutFileName, wxT(
"wt" ) ) ) ==
nullptr )
48 wxString msg = wxString::Format(
_(
"Failed to create file '%s'." ), aOutFileName );
53 wxString StartCmpDesc =
StartLine + wxT(
"ADD_COM" );
62 ret |= fprintf( f,
"\"%s\"\n",
TO_UTF8( title ) );
63 ret |= fprintf( f,
".TYP FULL\n\n" );
73 std::vector<EDA_ITEM*> sheetItems;
76 sheetItems.push_back( item );
80 return item1->
m_Uuid < item2->m_Uuid;
83 std::sort( sheetItems.begin(), sheetItems.end(), pred );
98 if( footprint.IsEmpty() )
99 footprint =
"$noname";
101 msg = symbol->
GetRef( &sheet );
102 ret |= fprintf( f,
"%s ",
TO_UTF8( StartCmpDesc ) );
103 ret |= fprintf( f,
"%s",
TO_UTF8( msg ) );
105 msg = symbol->
GetValue(
true, &sheet,
false );
106 msg.Replace( wxT(
" " ), wxT(
"_" ) );
107 ret |= fprintf( f,
" \"%s\"",
TO_UTF8( msg ) );
108 ret |= fprintf( f,
" \"%s\"",
TO_UTF8( footprint ) );
109 ret |= fprintf( f,
"\n" );
113 ret |= fprintf( f,
"\n" );
131 wxString InitNetDesc =
StartLine + wxT(
"ADD_TER" );
132 wxString StartNetDesc =
StartLine + wxT(
"TER" );
133 wxString InitNetDescLine;
135 std::vector<std::pair<wxString, std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>>>> all_nets;
140 netName.Printf( wxT(
"\"%s\"" ), key.Name );
142 all_nets.emplace_back( netName, std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>>{} );
143 std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>>& sorted_items = all_nets.back().second;
149 for(
SCH_ITEM* item : subgraph->GetItems() )
152 sorted_items.emplace_back(
static_cast<SCH_PIN*
>( item ), sheet );
157 std::sort( sorted_items.begin(), sorted_items.end(),
158 []( std::pair<SCH_PIN*, SCH_SHEET_PATH> a, std::pair<SCH_PIN*, SCH_SHEET_PATH> b )
160 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
161 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
164 return a.first->GetShownNumber() < b.first->GetShownNumber();
166 return ref_a < ref_b;
172 sorted_items.erase( std::unique( sorted_items.begin(), sorted_items.end(),
173 []( std::pair<SCH_PIN*, SCH_SHEET_PATH> a, std::pair<SCH_PIN*, SCH_SHEET_PATH> b )
175 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
176 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
178 return ref_a == ref_b && a.first->GetShownNumber() == b.first->GetShownNumber();
180 sorted_items.end() );
184 std::sort( all_nets.begin(), all_nets.end(),
185 [](
const auto& a,
const auto& b )
187 return a.first < b.first;
190 for(
const auto& [netName, sorted_items] : all_nets )
194 for(
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& pair : sorted_items )
199 wxString refText =
pin->GetParentSymbol()->GetRef( &sheet );
200 wxString pinText =
pin->GetShownNumber();
203 if( refText[0] == wxChar(
'#' ) )
209 InitNetDescLine.Printf( wxT(
"\n%s %s %.4s %s" ),
218 ret |= fprintf( f,
"%s\n",
TO_UTF8( InitNetDescLine ) );
219 ret |= fprintf( f,
"%s %s %.4s\n",
227 ret |= fprintf( f,
" %s %.4s\n",
wxString GetBuildVersion()
Get the full KiCad version string.
const NET_MAP & GetNetMap() const
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.
SCH_SYMBOL * findNextSymbol(EDA_ITEM *aItem, const SCH_SHEET_PATH &aSheetPath)
Check if the given symbol should be processed for netlisting.
UNIQUE_STRINGS m_referencesAlreadyFound
Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than once.
SCHEMATIC_IFACE * m_schematic
The schematic we're generating a netlist for.
bool writeListOfNets(FILE *f)
Write a net list (ranked by Netcode), and pins connected to it.
bool WriteNetlist(const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter) override
Write to specified output file.
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
virtual CONNECTION_GRAPH * ConnectionGraph() const =0
virtual SCH_SHEET_LIST Hierarchy() const =0
Base class for any item which can be embedded within the SCHEMATIC container class,...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
const SCH_SHEET * GetSheet(unsigned aIndex) const
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const override
const wxString GetFootprintFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
bool GetExcludedFromBoard() const
void Clear()
Erase the record.
This file is part of the common library.
static wxString StartLine(wxT("."))
wxString GetISO8601CurrentDateTime()
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.