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" );
82 if( footprint.IsEmpty() )
83 footprint =
"$noname";
85 msg = symbol->
GetRef( &sheet );
86 ret |= fprintf( f,
"%s ",
TO_UTF8( StartCmpDesc ) );
87 ret |= fprintf( f,
"%s",
TO_UTF8( msg ) );
89 msg = symbol->
GetValue(
true, &sheet,
false );
90 msg.Replace( wxT(
" " ), wxT(
"_" ) );
91 ret |= fprintf( f,
" \"%s\"",
TO_UTF8( msg ) );
92 ret |= fprintf( f,
" \"%s\"",
TO_UTF8( footprint ) );
93 ret |= fprintf( f,
"\n" );
97 ret |= fprintf( f,
"\n" );
115 wxString InitNetDesc =
StartLine + wxT(
"ADD_TER" );
116 wxString StartNetDesc =
StartLine + wxT(
"TER" );
117 wxString InitNetDescLine;
122 netName.Printf( wxT(
"\"%s\"" ), key.Name );
124 std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>> sorted_items;
130 for(
SCH_ITEM* item : subgraph->GetItems() )
133 sorted_items.emplace_back(
static_cast<SCH_PIN*
>( item ), sheet );
138 std::sort( sorted_items.begin(), sorted_items.end(),
139 []( std::pair<SCH_PIN*, SCH_SHEET_PATH> a, std::pair<SCH_PIN*, SCH_SHEET_PATH> b )
141 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
142 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
145 return a.first->GetShownNumber() < b.first->GetShownNumber();
147 return ref_a < ref_b;
153 sorted_items.erase( std::unique( sorted_items.begin(), sorted_items.end(),
154 []( std::pair<SCH_PIN*, SCH_SHEET_PATH> a, std::pair<SCH_PIN*, SCH_SHEET_PATH> b )
156 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
157 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
159 return ref_a == ref_b && a.first->GetShownNumber() == b.first->GetShownNumber();
161 sorted_items.end() );
165 for(
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& pair : sorted_items )
170 wxString refText =
pin->GetParentSymbol()->GetRef( &sheet );
171 wxString pinText =
pin->GetShownNumber();
174 if( refText[0] == wxChar(
'#' ) )
180 InitNetDescLine.Printf( wxT(
"\n%s %s %.4s %s" ),
189 ret |= fprintf( f,
"%s\n",
TO_UTF8( InitNetDescLine ) );
190 ret |= fprintf( f,
"%s %s %.4s\n",
198 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.
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.