41 if( ( f = wxFopen( aOutFileName, wxT(
"wt" ) ) ) ==
nullptr )
43 wxString msg = wxString::Format(
_(
"Failed to create file '%s'." ), aOutFileName );
52 ret |= fputs(
"*PADS-PCB*\n", f );
53 ret |= fputs(
"*PART*\n", f );
60 for(
unsigned i = 0; i < sheetList.size(); i++ )
74 footprint = footprint.Trim(
true );
75 footprint = footprint.Trim(
false );
76 footprint.Replace( wxT(
" " ), wxT(
"_" ) );
78 if( footprint.IsEmpty() )
81 footprint = symbol->
GetValue(
true, &sheetList[i],
false );
82 footprint.Replace( wxT(
" " ), wxT(
"_" ) );
83 footprint = footprint.Trim(
true );
84 footprint = footprint.Trim(
false );
87 msg = symbol->
GetRef( &sheetList[i] );
88 ret |= fprintf( f,
"%-16s %s\n",
TO_UTF8( msg ),
TO_UTF8( footprint ) );
92 ret |= fputs(
"\n", f );
107 wxString initialSignalLine;
110 ret |= fputs(
"*NET*\n", f );
116 std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>> sorted_items;
122 for(
SCH_ITEM* item : subgraph->GetItems() )
125 sorted_items.emplace_back(
static_cast<SCH_PIN*
>( item ), sheet );
130 std::sort( sorted_items.begin(), sorted_items.end(),
131 []( std::pair<SCH_PIN*, SCH_SHEET_PATH> a, std::pair<SCH_PIN*, SCH_SHEET_PATH> b )
133 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
134 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
137 return a.first->GetShownNumber() < b.first->GetShownNumber();
139 return ref_a < ref_b;
145 sorted_items.erase( std::unique( sorted_items.begin(), sorted_items.end(),
146 []( std::pair<SCH_PIN*, SCH_SHEET_PATH> a, std::pair<SCH_PIN*, SCH_SHEET_PATH> b )
148 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
149 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
151 return ref_a == ref_b && a.first->GetShownNumber() == b.first->GetShownNumber();
153 sorted_items.end() );
155 std::vector<wxString> netConns;
157 for(
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& pair : sorted_items )
162 wxString refText =
pin->GetParentSymbol()->GetRef( &sheet );
163 wxString pinText =
pin->GetShownNumber();
166 if( refText[0] == wxChar(
'#' ) )
170 wxString::Format(
"%s.%.4s", refText, pinText ) );
175 if( netConns .size() > 1 )
177 ret |= fprintf( f,
"*SIGNAL* %s\n",
TO_UTF8(netName) );
179 for( wxString& netConn : netConns )
181 ret |= fputs(
TO_UTF8( netConn ), f );
182 if( cnt != 0 && cnt % 6 == 0 )
184 ret |= fputc(
'\n', f );
188 ret |= fputc(
' ', f );
194 ret |= fputc(
'\n', f );
198 ret |= fprintf( f,
"*END*\n" );
const NET_MAP & GetNetMap() const
A subgraph is a set of items that are electrically connected on a single sheet.
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 WriteNetlist(const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter) override
Write to specified output file.
bool writeListOfNets(FILE *f)
Write a net list (ranked by Netcode), and pins connected to it.
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 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.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.