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 );
72 footprint = footprint.Trim(
true );
73 footprint = footprint.Trim(
false );
74 footprint.Replace( wxT(
" " ), wxT(
"_" ) );
76 if( footprint.IsEmpty() )
79 footprint = symbol->
GetValue(
true, &sheet,
false );
80 footprint.Replace( wxT(
" " ), wxT(
"_" ) );
81 footprint = footprint.Trim(
true );
82 footprint = footprint.Trim(
false );
85 msg = symbol->
GetRef( &sheet );
86 ret |= fprintf( f,
"%-16s %s\n",
TO_UTF8( msg ),
TO_UTF8( footprint ) );
90 ret |= fputs(
"\n", f );
105 wxString initialSignalLine;
108 ret |= fputs(
"*NET*\n", f );
114 std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>> sorted_items;
120 for(
SCH_ITEM* item : subgraph->GetItems() )
123 sorted_items.emplace_back(
static_cast<SCH_PIN*
>( item ), sheet );
128 std::sort( sorted_items.begin(), sorted_items.end(),
129 []( std::pair<SCH_PIN*, SCH_SHEET_PATH> a, std::pair<SCH_PIN*, SCH_SHEET_PATH> b )
131 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
132 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
135 return a.first->GetShownNumber() < b.first->GetShownNumber();
137 return ref_a < ref_b;
143 sorted_items.erase( std::unique( sorted_items.begin(), sorted_items.end(),
144 []( std::pair<SCH_PIN*, SCH_SHEET_PATH> a, std::pair<SCH_PIN*, SCH_SHEET_PATH> b )
146 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
147 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
149 return ref_a == ref_b && a.first->GetShownNumber() == b.first->GetShownNumber();
151 sorted_items.end() );
153 std::vector<wxString> netConns;
155 for(
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& pair : sorted_items )
160 wxString refText =
pin->GetParentSymbol()->GetRef( &sheet );
161 wxString pinText =
pin->GetShownNumber();
164 if( refText[0] == wxChar(
'#' ) )
168 wxString::Format(
"%s.%.4s", refText, pinText ) );
173 if( netConns .size() > 1 )
175 ret |= fprintf( f,
"*SIGNAL* %s\n",
TO_UTF8(netName) );
177 for( wxString& netConn : netConns )
179 ret |= fputs(
TO_UTF8( netConn ), f );
180 if( cnt != 0 && cnt % 6 == 0 )
182 ret |= fputc(
'\n', f );
186 ret |= fputc(
' ', f );
192 ret |= fputc(
'\n', f );
196 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.
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 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 BuildSheetListSortedByPageNumbers() 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.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.