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;
137 for(
const auto& [ key, subgraphs ] :
m_schematic->ConnectionGraph()->GetNetMap() )
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 [](
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& a,
const 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 [](
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& a,
const 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",