KiCad PCB EDA Suite
netlist_exporter_generic.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 1992-2013 jp.charras at wanadoo.fr
5  * Copyright (C) 2013-2017 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
27 
28 #include <build_version.h>
29 #include <sch_base_frame.h>
30 #include <class_library.h>
31 #include <connection_graph.h>
32 #include <refdes_utils.h>
33 
34 #include <class_library.h>
35 #include <sch_base_frame.h>
36 #include <symbol_lib_table.h>
37 
38 
39 static bool sortPinsByNumber( LIB_PIN* aPin1, LIB_PIN* aPin2 );
40 
41 bool NETLIST_EXPORTER_GENERIC::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
42 {
43  // Prepare list of nets generation
44  for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
45  m_masterList->GetItem( ii )->m_Flag = 0;
46 
47  // output the XML format netlist.
48  wxXmlDocument xdoc;
49 
50  xdoc.SetRoot( makeRoot( GNL_ALL ) );
51 
52  return xdoc.Save( aOutFileName, 2 /* indent bug, today was ignored by wxXml lib */ );
53 }
54 
55 
57 {
58  XNODE* xroot = node( "export" );
59 
60  xroot->AddAttribute( "version", "D" );
61 
62  if( aCtl & GNL_HEADER )
63  // add the "design" header
64  xroot->AddChild( makeDesignHeader() );
65 
66  if( aCtl & GNL_COMPONENTS )
67  xroot->AddChild( makeComponents() );
68 
69  if( aCtl & GNL_PARTS )
70  xroot->AddChild( makeLibParts() );
71 
72  if( aCtl & GNL_LIBRARIES )
73  // must follow makeGenericLibParts()
74  xroot->AddChild( makeLibraries() );
75 
76  if( aCtl & GNL_NETS )
77  xroot->AddChild( makeListOfNets() );
78 
79  return xroot;
80 }
81 
82 
85 {
86  wxString value;
87  wxString datasheet;
88  wxString footprint;
89 
90  std::map< wxString, wxString > f;
91 };
92 
93 
95 {
96  COMP_FIELDS fields;
97 
98  if( comp->GetUnitCount() > 1 )
99  {
100  // Sadly, each unit of a component can have its own unique fields. This
101  // block finds the unit with the lowest number having a non blank field
102  // value and records it. Therefore user is best off setting fields
103  // into only the first unit. But this scavenger algorithm will find
104  // any non blank fields in all units and use the first non-blank field
105  // for each unique field name.
106 
107  wxString ref = comp->GetRef( aSheet );
108 
109  SCH_SHEET_LIST sheetList( g_RootSheet );
110  int minUnit = comp->GetUnit();
111 
112  for( unsigned i = 0; i < sheetList.size(); i++ )
113  {
114  for( auto item : sheetList[i].LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
115  {
116  SCH_COMPONENT* comp2 = (SCH_COMPONENT*) item;
117 
118  wxString ref2 = comp2->GetRef( &sheetList[i] );
119 
120  if( ref2.CmpNoCase( ref ) != 0 )
121  continue;
122 
123  int unit = comp2->GetUnit();
124 
125  // The lowest unit number wins. User should only set fields in any one unit.
126  // remark: IsVoid() returns true for empty strings or the "~" string (empty field value)
127  if( !comp2->GetField( VALUE )->IsVoid()
128  && ( unit < minUnit || fields.value.IsEmpty() ) )
129  fields.value = comp2->GetField( VALUE )->GetText();
130 
131  if( !comp2->GetField( FOOTPRINT )->IsVoid()
132  && ( unit < minUnit || fields.footprint.IsEmpty() ) )
133  fields.footprint = comp2->GetField( FOOTPRINT )->GetText();
134 
135  if( !comp2->GetField( DATASHEET )->IsVoid()
136  && ( unit < minUnit || fields.datasheet.IsEmpty() ) )
137  fields.datasheet = comp2->GetField( DATASHEET )->GetText();
138 
139  for( int fldNdx = MANDATORY_FIELDS; fldNdx < comp2->GetFieldCount(); ++fldNdx )
140  {
141  SCH_FIELD* f = comp2->GetField( fldNdx );
142 
143  if( f->GetText().size()
144  && ( unit < minUnit || fields.f.count( f->GetName() ) == 0 ) )
145  {
146  fields.f[ f->GetName() ] = f->GetText();
147  }
148  }
149 
150  minUnit = std::min( unit, minUnit );
151  }
152  }
153 
154  }
155  else
156  {
157  fields.value = comp->GetField( VALUE )->GetText();
158  fields.footprint = comp->GetField( FOOTPRINT )->GetText();
159  fields.datasheet = comp->GetField( DATASHEET )->GetText();
160 
161  for( int fldNdx = MANDATORY_FIELDS; fldNdx < comp->GetFieldCount(); ++fldNdx )
162  {
163  SCH_FIELD* f = comp->GetField( fldNdx );
164 
165  if( f->GetText().size() )
166  fields.f[ f->GetName() ] = f->GetText();
167  }
168  }
169 
170  // Do not output field values blank in netlist:
171  if( fields.value.size() )
172  xcomp->AddChild( node( "value", fields.value ) );
173  else // value field always written in netlist
174  xcomp->AddChild( node( "value", "~" ) );
175 
176  if( fields.footprint.size() )
177  xcomp->AddChild( node( "footprint", fields.footprint ) );
178 
179  if( fields.datasheet.size() )
180  xcomp->AddChild( node( "datasheet", fields.datasheet ) );
181 
182  if( fields.f.size() )
183  {
184  XNODE* xfields;
185  xcomp->AddChild( xfields = node( "fields" ) );
186 
187  // non MANDATORY fields are output alphabetically
188  for( std::map< wxString, wxString >::const_iterator it = fields.f.begin();
189  it != fields.f.end(); ++it )
190  {
191  XNODE* xfield;
192  xfields->AddChild( xfield = node( "field", it->second ) );
193  xfield->AddAttribute( "name", it->first );
194  }
195  }
196 
197 }
198 
199 
201 {
202  XNODE* xcomps = node( "components" );
203 
204  wxString timeStamp;
205 
207 
208  SCH_SHEET_LIST sheetList( g_RootSheet );
209 
210  // Output is xml, so there is no reason to remove spaces from the field values.
211  // And XML element names need not be translated to various languages.
212 
213  for( unsigned i = 0; i < sheetList.size(); i++ )
214  {
215  for( auto item : sheetList[i].LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
216  {
217  SCH_COMPONENT* comp = findNextComponent( item, &sheetList[i] );
218 
219  if( !comp )
220  continue;
221 
222  XNODE* xcomp; // current component being constructed
223 
224  // Output the component's elements in order of expected access frequency.
225  // This may not always look best, but it will allow faster execution
226  // under XSL processing systems which do sequential searching within
227  // an element.
228 
229  xcomps->AddChild( xcomp = node( "comp" ) );
230  xcomp->AddAttribute( "ref", comp->GetRef( &sheetList[i] ) );
231 
232  addComponentFields( xcomp, comp, &sheetList[i] );
233 
234  XNODE* xlibsource;
235  xcomp->AddChild( xlibsource = node( "libsource" ) );
236 
237  // "logical" library name, which is in anticipation of a better search
238  // algorithm for parts based on "logical_lib.part" and where logical_lib
239  // is merely the library name minus path and extension.
240  if( comp->GetPartRef() )
241  xlibsource->AddAttribute( "lib", comp->GetPartRef()->GetLibId().GetLibNickname() );
242 
243  // We only want the symbol name, not the full LIB_ID.
244  xlibsource->AddAttribute( "part", comp->GetLibId().GetLibItemName() );
245 
246  xlibsource->AddAttribute( "description", comp->GetDescription() );
247 
248  XNODE* xsheetpath;
249 
250  xcomp->AddChild( xsheetpath = node( "sheetpath" ) );
251  xsheetpath->AddAttribute( "names", sheetList[i].PathHumanReadable() );
252  xsheetpath->AddAttribute( "tstamps", sheetList[i].Path() );
253 
254  timeStamp.Printf( "%8.8lX", (unsigned long)comp->GetTimeStamp() );
255  xcomp->AddChild( node( "tstamp", timeStamp ) );
256  }
257  }
258 
259  return xcomps;
260 }
261 
262 
264 {
265  SCH_SCREEN* screen;
266  XNODE* xdesign = node( "design" );
267  XNODE* xtitleBlock;
268  XNODE* xsheet;
269  XNODE* xcomment;
270  wxString sheetTxt;
271  wxFileName sourceFileName;
272 
273  // the root sheet is a special sheet, call it source
274  xdesign->AddChild( node( "source", g_RootSheet->GetScreen()->GetFileName() ) );
275 
276  xdesign->AddChild( node( "date", DateAndTime() ) );
277 
278  // which Eeschema tool
279  xdesign->AddChild( node( "tool", wxString( "Eeschema " ) + GetBuildVersion() ) );
280 
281  /*
282  Export the sheets information
283  */
284  SCH_SHEET_LIST sheetList( g_RootSheet );
285 
286  for( unsigned i = 0; i < sheetList.size(); i++ )
287  {
288  screen = sheetList[i].LastScreen();
289 
290  xdesign->AddChild( xsheet = node( "sheet" ) );
291 
292  // get the string representation of the sheet index number.
293  // Note that sheet->GetIndex() is zero index base and we need to increment the
294  // number by one to make it human readable
295  sheetTxt.Printf( "%u", i + 1 );
296  xsheet->AddAttribute( "number", sheetTxt );
297  xsheet->AddAttribute( "name", sheetList[i].PathHumanReadable() );
298  xsheet->AddAttribute( "tstamps", sheetList[i].Path() );
299 
300 
301  TITLE_BLOCK tb = screen->GetTitleBlock();
302 
303  xsheet->AddChild( xtitleBlock = node( "title_block" ) );
304 
305  xtitleBlock->AddChild( node( "title", tb.GetTitle() ) );
306  xtitleBlock->AddChild( node( "company", tb.GetCompany() ) );
307  xtitleBlock->AddChild( node( "rev", tb.GetRevision() ) );
308  xtitleBlock->AddChild( node( "date", tb.GetDate() ) );
309 
310  // We are going to remove the fileName directories.
311  sourceFileName = wxFileName( screen->GetFileName() );
312  xtitleBlock->AddChild( node( "source", sourceFileName.GetFullName() ) );
313 
314  xtitleBlock->AddChild( xcomment = node( "comment" ) );
315  xcomment->AddAttribute( "number", "1" );
316  xcomment->AddAttribute( "value", tb.GetComment( 0 ) );
317 
318  xtitleBlock->AddChild( xcomment = node( "comment" ) );
319  xcomment->AddAttribute( "number", "2" );
320  xcomment->AddAttribute( "value", tb.GetComment( 1 ) );
321 
322  xtitleBlock->AddChild( xcomment = node( "comment" ) );
323  xcomment->AddAttribute( "number", "3" );
324  xcomment->AddAttribute( "value", tb.GetComment( 2 ) );
325 
326  xtitleBlock->AddChild( xcomment = node( "comment" ) );
327  xcomment->AddAttribute( "number", "4" );
328  xcomment->AddAttribute( "value", tb.GetComment( 3 ) );
329 
330  xtitleBlock->AddChild( xcomment = node( "comment" ) );
331  xcomment->AddAttribute( "number", "5" );
332  xcomment->AddAttribute( "value", tb.GetComment( 4 ) );
333 
334  xtitleBlock->AddChild( xcomment = node( "comment" ) );
335  xcomment->AddAttribute( "number", "6" );
336  xcomment->AddAttribute( "value", tb.GetComment( 5 ) );
337 
338  xtitleBlock->AddChild( xcomment = node( "comment" ) );
339  xcomment->AddAttribute( "number", "7" );
340  xcomment->AddAttribute( "value", tb.GetComment( 6 ) );
341 
342  xtitleBlock->AddChild( xcomment = node( "comment" ) );
343  xcomment->AddAttribute( "number", "8" );
344  xcomment->AddAttribute( "value", tb.GetComment( 7 ) );
345 
346  xtitleBlock->AddChild( xcomment = node( "comment" ) );
347  xcomment->AddAttribute( "number", "9" );
348  xcomment->AddAttribute( "value", tb.GetComment( 8 ) );
349  }
350 
351  return xdesign;
352 }
353 
354 
356 {
357  XNODE* xlibs = node( "libraries" ); // auto_ptr
358 
359  for( std::set<wxString>::iterator it = m_libraries.begin(); it!=m_libraries.end(); ++it )
360  {
361  wxString libNickname = *it;
362  XNODE* xlibrary;
363 
364  if( m_libTable->HasLibrary( libNickname ) )
365  {
366  xlibs->AddChild( xlibrary = node( "library" ) );
367  xlibrary->AddAttribute( "logical", libNickname );
368  xlibrary->AddChild( node( "uri", m_libTable->GetFullURI( libNickname ) ) );
369  }
370 
371  // @todo: add more fun stuff here
372  }
373 
374  return xlibs;
375 }
376 
377 
379 {
380  XNODE* xlibparts = node( "libparts" ); // auto_ptr
381 
382  LIB_PINS pinList;
383  LIB_FIELDS fieldList;
384 
385  m_libraries.clear();
386 
387  for( auto lcomp : m_LibParts )
388  {
389  wxString libNickname = lcomp->GetLibId().GetLibNickname();;
390 
391  // The library nickname will be empty if the cache library is used.
392  if( !libNickname.IsEmpty() )
393  m_libraries.insert( libNickname ); // inserts component's library if unique
394 
395  XNODE* xlibpart;
396  xlibparts->AddChild( xlibpart = node( "libpart" ) );
397  xlibpart->AddAttribute( "lib", libNickname );
398  xlibpart->AddAttribute( "part", lcomp->GetName() );
399 
400  //----- show the important properties -------------------------
401  if( !lcomp->GetDescription().IsEmpty() )
402  xlibpart->AddChild( node( "description", lcomp->GetDescription() ) );
403 
404  if( !lcomp->GetDocFileName().IsEmpty() )
405  xlibpart->AddChild( node( "docs", lcomp->GetDocFileName() ) );
406 
407  // Write the footprint list
408  if( lcomp->GetFootprints().GetCount() )
409  {
410  XNODE* xfootprints;
411  xlibpart->AddChild( xfootprints = node( "footprints" ) );
412 
413  for( unsigned i=0; i<lcomp->GetFootprints().GetCount(); ++i )
414  {
415  xfootprints->AddChild( node( "fp", lcomp->GetFootprints()[i] ) );
416  }
417  }
418 
419  //----- show the fields here ----------------------------------
420  fieldList.clear();
421  lcomp->GetFields( fieldList );
422 
423  XNODE* xfields;
424  xlibpart->AddChild( xfields = node( "fields" ) );
425 
426  for( unsigned i=0; i<fieldList.size(); ++i )
427  {
428  if( !fieldList[i].GetText().IsEmpty() )
429  {
430  XNODE* xfield;
431  xfields->AddChild( xfield = node( "field", fieldList[i].GetText() ) );
432  xfield->AddAttribute( "name", fieldList[i].GetName(false) );
433  }
434  }
435 
436  //----- show the pins here ------------------------------------
437  pinList.clear();
438  lcomp->GetPins( pinList, 0, 0 );
439 
440  /* we must erase redundant Pins references in pinList
441  * These redundant pins exist because some pins
442  * are found more than one time when a component has
443  * multiple parts per package or has 2 representations (DeMorgan conversion)
444  * For instance, a 74ls00 has DeMorgan conversion, with different pin shapes,
445  * and therefore each pin appears 2 times in the list.
446  * Common pins (VCC, GND) can also be found more than once.
447  */
448  sort( pinList.begin(), pinList.end(), sortPinsByNumber );
449  for( int ii = 0; ii < (int)pinList.size()-1; ii++ )
450  {
451  if( pinList[ii]->GetNumber() == pinList[ii+1]->GetNumber() )
452  { // 2 pins have the same number, remove the redundant pin at index i+1
453  pinList.erase(pinList.begin() + ii + 1);
454  ii--;
455  }
456  }
457 
458  if( pinList.size() )
459  {
460  XNODE* pins;
461 
462  xlibpart->AddChild( pins = node( "pins" ) );
463  for( unsigned i=0; i<pinList.size(); ++i )
464  {
465  XNODE* pin;
466 
467  pins->AddChild( pin = node( "pin" ) );
468  pin->AddAttribute( "num", pinList[i]->GetNumber() );
469  pin->AddAttribute( "name", pinList[i]->GetName() );
470  pin->AddAttribute( "type", pinList[i]->GetCanonicalElectricalTypeName() );
471 
472  // caution: construction work site here, drive slowly
473  }
474  }
475  }
476 
477  return xlibparts;
478 }
479 
480 
482 {
483  XNODE* xnets = node( "nets" ); // auto_ptr if exceptions ever get used.
484  wxString netCodeTxt;
485  wxString netName;
486  wxString ref;
487 
488  XNODE* xnet = 0;
489  int netCode;
490  int lastNetCode = -1;
491  int sameNetcodeCount = 0;
492 
493 
494  /* output:
495  <net code="123" name="/cfcard.sch/WAIT#">
496  <node ref="R23" pin="1"/>
497  <node ref="U18" pin="12"/>
498  </net>
499  */
500 
501  m_LibParts.clear(); // must call this function before using m_LibParts.
502 
503  if( aUseGraph )
504  {
505  wxASSERT( m_graph );
506  int code = 0;
507 
508  for( const auto& it : m_graph->GetNetMap() )
509  {
510  bool added = false;
511  wxString net_name = it.first.first;
512  auto subgraphs = it.second;
513 
514  // Code starts at 1
515  code++;
516 
517  XNODE* xnode;
518  std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>> sorted_items;
519 
520  for( auto subgraph : subgraphs )
521  {
522  auto sheet = subgraph->m_sheet;
523 
524  for( auto item : subgraph->m_items )
525  if( item->Type() == SCH_PIN_T )
526  sorted_items.emplace_back(
527  std::make_pair( static_cast<SCH_PIN*>( item ), sheet ) );
528  }
529 
530  // Netlist ordering: Net name, then ref des, then pin name
531  std::sort( sorted_items.begin(), sorted_items.end(), []( auto a, auto b ) {
532  auto ref_a = a.first->GetParentComponent()->GetRef( &a.second );
533  auto ref_b = b.first->GetParentComponent()->GetRef( &b.second );
534 
535  if( ref_a == ref_b )
536  return a.first->GetNumber() < b.first->GetNumber();
537 
538  return ref_a < ref_b;
539  } );
540 
541  for( const auto& pair : sorted_items )
542  {
543  SCH_PIN* pin = pair.first;
544  SCH_SHEET_PATH sheet = pair.second;
545 
546  auto refText = pin->GetParentComponent()->GetRef( &sheet );
547  const auto& pinText = pin->GetNumber();
548 
549  // Skip power symbols and virtual components
550  if( refText[0] == wxChar( '#' ) )
551  continue;
552 
553  if( !added )
554  {
555  xnets->AddChild( xnet = node( "net" ) );
556  netCodeTxt.Printf( "%d", code );
557  xnet->AddAttribute( "code", netCodeTxt );
558  xnet->AddAttribute( "name", net_name );
559 
560  added = true;
561  }
562 
563  xnet->AddChild( xnode = node( "node" ) );
564  xnode->AddAttribute( "ref", refText );
565  xnode->AddAttribute( "pin", pinText );
566 
567  wxString pinName;
568 
569  if( pin->GetName() != "~" ) // ~ is a char used to code empty strings in libs.
570  pinName = pin->GetName();
571 
572  if( !pinName.IsEmpty() )
573  xnode->AddAttribute( "pinfunction", pinName );
574 
575  }
576  }
577  }
578  else
579  {
580  for( unsigned ii = 0; ii < m_masterList->size(); ii++ )
581  {
582  NETLIST_OBJECT* nitem = m_masterList->GetItem( ii );
583  SCH_COMPONENT* comp;
584 
585  // New net found, write net id;
586  if( ( netCode = nitem->GetNet() ) != lastNetCode )
587  {
588  sameNetcodeCount = 0; // item count for this net
589  netName = nitem->GetNetName();
590  lastNetCode = netCode;
591  }
592 
593  if( nitem->m_Type != NETLIST_ITEM::PIN )
594  continue;
595 
596  if( nitem->m_Flag != 0 ) // Redundant pin, skip it
597  continue;
598 
599  comp = nitem->GetComponentParent();
600 
601  // Get the reference for the net name and the main parent component
602  ref = comp->GetRef( &nitem->m_SheetPath );
603  if( ref[0] == wxChar( '#' ) )
604  continue;
605 
606  if( ++sameNetcodeCount == 1 )
607  {
608  xnets->AddChild( xnet = node( "net" ) );
609  netCodeTxt.Printf( "%d", netCode );
610  xnet->AddAttribute( "code", netCodeTxt );
611  xnet->AddAttribute( "name", netName );
612  }
613 
614  XNODE* xnode;
615  xnet->AddChild( xnode = node( "node" ) );
616  xnode->AddAttribute( "ref", ref );
617  xnode->AddAttribute( "pin", nitem->GetPinNumText() );
618 
619  if( !nitem->GetPinNameText().IsEmpty() )
620  xnode->AddAttribute( "pinfunction", nitem->GetPinNameText() );
621  }
622  }
623 
624  return xnets;
625 }
626 
627 
628 XNODE* NETLIST_EXPORTER_GENERIC::node( const wxString& aName, const wxString& aTextualContent /* = wxEmptyString*/ )
629 {
630  XNODE* n = new XNODE( wxXML_ELEMENT_NODE, aName );
631 
632  if( aTextualContent.Len() > 0 ) // excludes wxEmptyString, the parameter's default value
633  n->AddChild( new XNODE( wxXML_TEXT_NODE, wxEmptyString, aTextualContent ) );
634 
635  return n;
636 }
637 
638 
639 static bool sortPinsByNumber( LIB_PIN* aPin1, LIB_PIN* aPin2 )
640 {
641  // return "lhs < rhs"
642  return UTIL::RefDesStringCompare( aPin1->GetNumber(), aPin2->GetNumber() ) < 0;
643 }
SCH_SHEET_LIST.
bool WriteNetlist(const wxString &aOutFileName, unsigned aNetlistOptions) override
Function WriteNetlist writes to specified output file.
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
const wxString & GetFileName() const
Definition: sch_screen.h:157
SCH_COMPONENT * GetComponentParent() const
For Pins (NET_PINS):
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
name of datasheet
const wxString & GetName() const
Definition: sch_pin.h:101
XNODE * makeComponents()
Function makeComponents.
UNIQUE_STRINGS m_ReferencesAlreadyFound
Used for "multi parts per package" components, avoids processing a lib component more than once.
XNODE * node(const wxString &aName, const wxString &aTextualContent=wxEmptyString)
Function node is a convenience function that creates a new XNODE with an optional textual child.
XNODE * makeListOfNets(bool aUseGraph=true)
Function makeListOfNets fills out an XML node with a list of nets and returns it.
const wxString & GetComment(int aIdx) const
Definition: title_block.h:110
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:54
int GetNet() const
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
int GetUnitCount() const
Return the number of units per package of the symbol.
Collection of utility functions for component reference designators (refdes)
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:162
wxString GetDescription() const
Return information about the aliased parts.
SCH_SHEET_PATH m_SheetPath
void Clear()
Function Clear erases the record.
SCH_COMPONENT * findNextComponent(EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath)
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:278
TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout,...
Definition: title_block.h:40
NETLIST_OBJECT_LIST * m_masterList
Field Name Module PCB, i.e. "16DIP300".
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.cpp:257
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
int RefDesStringCompare(const wxString &aFirst, const wxString &aSecond)
Acts just like the strcmp function but treats numbers within the string text correctly for sorting.
XNODE * makeRoot(int aCtl=GNL_ALL)
Function makeGenericRoot builds the entire document tree for the generic export.
const wxString & GetNumber() const
Definition: sch_pin.h:103
std::set< LIB_PART *, LIB_PART_LESS_THAN > m_LibParts
unique library parts used. LIB_PART items are sorted by names
std::set< wxString > m_libraries
Set of library nicknames.
#define VALUE
int GetUnit() const
const wxString GetPinNameText() const
returns the pin name, for NET_PIN (usual pin) item.
void addComponentFields(XNODE *xcomp, SCH_COMPONENT *comp, SCH_SHEET_PATH *aSheet)
wxString GetBuildVersion()
Function GetBuildVersion Return the build version string.
const wxString & GetRevision() const
Definition: title_block.h:89
wxString GetFullURI(const wxString &aLibNickname, bool aExpandEnvVars=true) const
Return the full URI of the library mapped to aLibNickname.
const wxString & GetCompany() const
Definition: title_block.h:99
wxString GetText(GRAPHIC_PINSHAPE aShape)
Definition: pin_shape.cpp:58
XNODE * makeDesignHeader()
Function makeDesignHeader fills out a project "design" header into an XML node.
const NET_MAP & GetNetMap() const
Holder for multi-unit component fields.
timestamp_t GetTimeStamp() const
Definition: base_struct.h:213
SCH_SHEET_PATH.
std::unique_ptr< LIB_PART > & GetPartRef()
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return the reference for the given sheet path.
const wxString & GetPinNumText() const
returns a pin number in wxString form.
int GetFieldCount() const
Return the number of fields in this symbol.
XNODE holds an XML or S-expression element.
Definition: xnode.h:43
const wxString & GetDate() const
Definition: title_block.h:79
const wxString & GetNumber() const
Definition: lib_pin.h:177
NETLIST_OBJECT * GetItem(unsigned aIdx) const
Acces to an item in list.
wxString GetNetName(bool adoptTimestamp=false) const
Function GetNetName.
std::vector< LIB_FIELD > LIB_FIELDS
Definition: lib_field.h:214
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:371
#define GNL_ALL
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:89
XNODE * makeLibraries()
Function makeLibraries fills out an XML node with a list of used libraries and returns it.
std::map< wxString, wxString > f
const wxString & GetTitle() const
Definition: title_block.h:65
SCH_SHEET * g_RootSheet
Definition for part library class.
static bool sortPinsByNumber(LIB_PIN *aPin1, LIB_PIN *aPin2)
const LIB_ID & GetLibId() const
NETLIST_ITEM m_Type
SCH_COMPONENT * GetParentComponent() const
Definition: sch_pin.cpp:64
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
wxString DateAndTime()
Definition: string.cpp:345
XNODE * makeLibParts()
Function makeLibParts fills out an XML node with the unique library parts and returns it.