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" );
70 for(
unsigned i = 0; i < sheetList.size(); i++ )
84 if( footprint.IsEmpty() )
85 footprint =
"$noname";
87 msg = symbol->
GetRef( &sheetList[i] );
88 ret |= fprintf( f,
"%s ",
TO_UTF8( StartCmpDesc ) );
89 ret |= fprintf( f,
"%s",
TO_UTF8( msg ) );
92 msg.Replace( wxT(
" " ), wxT(
"_" ) );
93 ret |= fprintf( f,
" \"%s\"",
TO_UTF8( msg ) );
94 ret |= fprintf( f,
" \"%s\"",
TO_UTF8( footprint ) );
95 ret |= fprintf( f,
"\n" );
99 ret |= fprintf( f,
"\n" );
117 wxString InitNetDesc =
StartLine + wxT(
"ADD_TER" );
118 wxString StartNetDesc =
StartLine + wxT(
"TER" );
119 wxString InitNetDescLine;
124 netName.Printf( wxT(
"\"%s\"" ), key.Name );
126 std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>> sorted_items;
132 for(
SCH_ITEM* item : subgraph->m_items )
135 sorted_items.emplace_back(
static_cast<SCH_PIN*
>( item ), sheet );
140 std::sort( sorted_items.begin(), sorted_items.end(),
141 []( std::pair<SCH_PIN*, SCH_SHEET_PATH> a, std::pair<SCH_PIN*, SCH_SHEET_PATH> b )
143 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
144 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
147 return a.first->GetShownNumber() < b.first->GetShownNumber();
149 return ref_a < ref_b;
155 sorted_items.erase( std::unique( sorted_items.begin(), sorted_items.end(),
156 []( std::pair<SCH_PIN*, SCH_SHEET_PATH> a, std::pair<SCH_PIN*, SCH_SHEET_PATH> b )
158 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
159 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
161 return ref_a == ref_b && a.first->GetShownNumber() == b.first->GetShownNumber();
163 sorted_items.end() );
167 for(
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& pair : sorted_items )
172 wxString refText =
pin->GetParentSymbol()->GetRef( &sheet );
173 wxString pinText =
pin->GetShownNumber();
176 if( refText[0] == wxChar(
'#' ) )
182 InitNetDescLine.Printf( wxT(
"\n%s %s %.4s %s" ),
191 ret |= fprintf( f,
"%s\n",
TO_UTF8( InitNetDescLine ) );
192 ret |= fprintf( f,
"%s %s %.4s\n",
200 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.
KICAD_T Type() const
Returns the type of object.
UNIQUE_STRINGS m_referencesAlreadyFound
Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than once.
SCH_SYMBOL * findNextSymbol(EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath)
Check if the given symbol should be processed for netlisting.
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 GetSheets() const =0
Base class for any item which can be embedded within the SCHEMATIC container class,...
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...
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
bool GetIncludeOnBoard() const
const wxString GetFootprintFieldText(bool aResolve) const
const wxString GetValueFieldText(bool aResolve) const
void Clear()
Erase the record.
This file is part of the common library.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
static wxString StartLine(wxT("."))
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.