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 <symbol_lib_table.h>
35 
36 
37 static bool sortPinsByNumber( LIB_PIN* aPin1, LIB_PIN* aPin2 );
38 
39 bool NETLIST_EXPORTER_GENERIC::WriteNetlist( const wxString& aOutFileName, unsigned aNetlistOptions )
40 {
41  // output the XML format netlist.
42  wxXmlDocument xdoc;
43 
44  xdoc.SetRoot( makeRoot( GNL_ALL ) );
45 
46  return xdoc.Save( aOutFileName, 2 /* indent bug, today was ignored by wxXml lib */ );
47 }
48 
49 
51 {
52  XNODE* xroot = node( "export" );
53 
54  xroot->AddAttribute( "version", "D" );
55 
56  if( aCtl & GNL_HEADER )
57  // add the "design" header
58  xroot->AddChild( makeDesignHeader() );
59 
60  if( aCtl & GNL_COMPONENTS )
61  xroot->AddChild( makeComponents() );
62 
63  if( aCtl & GNL_PARTS )
64  xroot->AddChild( makeLibParts() );
65 
66  if( aCtl & GNL_LIBRARIES )
67  // must follow makeGenericLibParts()
68  xroot->AddChild( makeLibraries() );
69 
70  if( aCtl & GNL_NETS )
71  xroot->AddChild( makeListOfNets() );
72 
73  return xroot;
74 }
75 
76 
79 {
80  wxString value;
81  wxString datasheet;
82  wxString footprint;
83 
84  std::map< wxString, wxString > f;
85 };
86 
87 
89 {
90  COMP_FIELDS fields;
91 
92  if( comp->GetUnitCount() > 1 )
93  {
94  // Sadly, each unit of a component can have its own unique fields. This
95  // block finds the unit with the lowest number having a non blank field
96  // value and records it. Therefore user is best off setting fields
97  // into only the first unit. But this scavenger algorithm will find
98  // any non blank fields in all units and use the first non-blank field
99  // for each unique field name.
100 
101  wxString ref = comp->GetRef( aSheet );
102 
103  SCH_SHEET_LIST sheetList = m_schematic->GetSheets();
104  int minUnit = comp->GetUnit();
105 
106  for( unsigned i = 0; i < sheetList.size(); i++ )
107  {
108  for( auto item : sheetList[i].LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
109  {
110  SCH_COMPONENT* comp2 = (SCH_COMPONENT*) item;
111 
112  wxString ref2 = comp2->GetRef( &sheetList[i] );
113 
114  if( ref2.CmpNoCase( ref ) != 0 )
115  continue;
116 
117  int unit = comp2->GetUnit();
118 
119  // The lowest unit number wins. User should only set fields in any one unit.
120  // remark: IsVoid() returns true for empty strings or the "~" string (empty field value)
121  if( !comp2->GetField( VALUE )->IsVoid()
122  && ( unit < minUnit || fields.value.IsEmpty() ) )
123  fields.value = comp2->GetField( VALUE )->GetText();
124 
125  if( !comp2->GetField( FOOTPRINT )->IsVoid()
126  && ( unit < minUnit || fields.footprint.IsEmpty() ) )
127  fields.footprint = comp2->GetField( FOOTPRINT )->GetText();
128 
129  if( !comp2->GetField( DATASHEET )->IsVoid()
130  && ( unit < minUnit || fields.datasheet.IsEmpty() ) )
131  fields.datasheet = comp2->GetField( DATASHEET )->GetText();
132 
133  for( int fldNdx = MANDATORY_FIELDS; fldNdx < comp2->GetFieldCount(); ++fldNdx )
134  {
135  SCH_FIELD* f = comp2->GetField( fldNdx );
136 
137  if( f->GetText().size()
138  && ( unit < minUnit || fields.f.count( f->GetName() ) == 0 ) )
139  {
140  fields.f[ f->GetName() ] = f->GetText();
141  }
142  }
143 
144  minUnit = std::min( unit, minUnit );
145  }
146  }
147 
148  }
149  else
150  {
151  fields.value = comp->GetField( VALUE )->GetText();
152  fields.footprint = comp->GetField( FOOTPRINT )->GetText();
153  fields.datasheet = comp->GetField( DATASHEET )->GetText();
154 
155  for( int fldNdx = MANDATORY_FIELDS; fldNdx < comp->GetFieldCount(); ++fldNdx )
156  {
157  SCH_FIELD* f = comp->GetField( fldNdx );
158 
159  if( f->GetText().size() )
160  fields.f[ f->GetName() ] = f->GetText();
161  }
162  }
163 
164  // Do not output field values blank in netlist:
165  if( fields.value.size() )
166  xcomp->AddChild( node( "value", fields.value ) );
167  else // value field always written in netlist
168  xcomp->AddChild( node( "value", "~" ) );
169 
170  if( fields.footprint.size() )
171  xcomp->AddChild( node( "footprint", fields.footprint ) );
172 
173  if( fields.datasheet.size() )
174  xcomp->AddChild( node( "datasheet", fields.datasheet ) );
175 
176  if( fields.f.size() )
177  {
178  XNODE* xfields;
179  xcomp->AddChild( xfields = node( "fields" ) );
180 
181  // non MANDATORY fields are output alphabetically
182  for( std::map< wxString, wxString >::const_iterator it = fields.f.begin();
183  it != fields.f.end(); ++it )
184  {
185  XNODE* xfield;
186  xfields->AddChild( xfield = node( "field", it->second ) );
187  xfield->AddAttribute( "name", it->first );
188  }
189  }
190 }
191 
192 
194 {
195  XNODE* xcomps = node( "components" );
196 
198  m_LibParts.clear();
199 
200  SCH_SHEET_LIST sheetList = m_schematic->GetSheets();
201 
202  // Output is xml, so there is no reason to remove spaces from the field values.
203  // And XML element names need not be translated to various languages.
204 
205  for( unsigned i = 0; i < sheetList.size(); i++ )
206  {
207  SCH_SHEET_PATH sheet = sheetList[i];
208 
209  auto cmp =
210  [sheet]( SCH_COMPONENT* a, SCH_COMPONENT* b )
211  {
212  return ( UTIL::RefDesStringCompare( a->GetRef( &sheet ),
213  b->GetRef( &sheet ) ) < 0 );
214  };
215 
216  std::set<SCH_COMPONENT*, decltype( cmp )> ordered_components( cmp );
217 
218  for( auto item : sheetList[i].LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
219  {
220  auto comp = static_cast<SCH_COMPONENT*>( item );
221  auto test = ordered_components.insert( comp );
222 
223  if( !test.second )
224  {
225  if( ( *( test.first ) )->GetUnit() > comp->GetUnit() )
226  {
227  ordered_components.erase( test.first );
228  ordered_components.insert( comp );
229  }
230  }
231  }
232 
233  for( auto item : ordered_components )
234  {
235  SCH_COMPONENT* comp = findNextComponent( item, &sheet );
236 
237  if( !comp )
238  continue;
239 
240  XNODE* xcomp; // current component being constructed
241 
242  // Output the component's elements in order of expected access frequency.
243  // This may not always look best, but it will allow faster execution
244  // under XSL processing systems which do sequential searching within
245  // an element.
246 
247  xcomps->AddChild( xcomp = node( "comp" ) );
248  xcomp->AddAttribute( "ref", comp->GetRef( &sheet ) );
249 
250  addComponentFields( xcomp, comp, &sheetList[i] );
251 
252  XNODE* xlibsource;
253  xcomp->AddChild( xlibsource = node( "libsource" ) );
254 
255  // "logical" library name, which is in anticipation of a better search
256  // algorithm for parts based on "logical_lib.part" and where logical_lib
257  // is merely the library name minus path and extension.
258  if( comp->GetPartRef() )
259  xlibsource->AddAttribute( "lib", comp->GetPartRef()->GetLibId().GetLibNickname() );
260 
261  // We only want the symbol name, not the full LIB_ID.
262  xlibsource->AddAttribute( "part", comp->GetLibId().GetLibItemName() );
263 
264  xlibsource->AddAttribute( "description", comp->GetDescription() );
265 
266  XNODE* xsheetpath;
267 
268  xcomp->AddChild( xsheetpath = node( "sheetpath" ) );
269  xsheetpath->AddAttribute( "names", sheet.PathHumanReadable() );
270  xsheetpath->AddAttribute( "tstamps", sheet.PathAsString() );
271  xcomp->AddChild( node( "tstamp", comp->m_Uuid.AsString() ) );
272  }
273  }
274 
275  return xcomps;
276 }
277 
278 
280 {
281  SCH_SCREEN* screen;
282  XNODE* xdesign = node( "design" );
283  XNODE* xtitleBlock;
284  XNODE* xsheet;
285  XNODE* xcomment;
286  wxString sheetTxt;
287  wxFileName sourceFileName;
288 
289  // the root sheet is a special sheet, call it source
290  xdesign->AddChild( node( "source", m_schematic->GetFileName() ) );
291 
292  xdesign->AddChild( node( "date", DateAndTime() ) );
293 
294  // which Eeschema tool
295  xdesign->AddChild( node( "tool", wxString( "Eeschema " ) + GetBuildVersion() ) );
296 
297  /*
298  Export the sheets information
299  */
300  SCH_SHEET_LIST sheetList = m_schematic->GetSheets();
301 
302  for( unsigned i = 0; i < sheetList.size(); i++ )
303  {
304  screen = sheetList[i].LastScreen();
305 
306  xdesign->AddChild( xsheet = node( "sheet" ) );
307 
308  // get the string representation of the sheet index number.
309  // Note that sheet->GetIndex() is zero index base and we need to increment the
310  // number by one to make it human readable
311  sheetTxt.Printf( "%u", i + 1 );
312  xsheet->AddAttribute( "number", sheetTxt );
313  xsheet->AddAttribute( "name", sheetList[i].PathHumanReadable() );
314  xsheet->AddAttribute( "tstamps", sheetList[i].PathAsString() );
315 
316 
317  TITLE_BLOCK tb = screen->GetTitleBlock();
318 
319  xsheet->AddChild( xtitleBlock = node( "title_block" ) );
320 
321  xtitleBlock->AddChild( node( "title", tb.GetTitle() ) );
322  xtitleBlock->AddChild( node( "company", tb.GetCompany() ) );
323  xtitleBlock->AddChild( node( "rev", tb.GetRevision() ) );
324  xtitleBlock->AddChild( node( "date", tb.GetDate() ) );
325 
326  // We are going to remove the fileName directories.
327  sourceFileName = wxFileName( screen->GetFileName() );
328  xtitleBlock->AddChild( node( "source", sourceFileName.GetFullName() ) );
329 
330  xtitleBlock->AddChild( xcomment = node( "comment" ) );
331  xcomment->AddAttribute( "number", "1" );
332  xcomment->AddAttribute( "value", tb.GetComment( 0 ) );
333 
334  xtitleBlock->AddChild( xcomment = node( "comment" ) );
335  xcomment->AddAttribute( "number", "2" );
336  xcomment->AddAttribute( "value", tb.GetComment( 1 ) );
337 
338  xtitleBlock->AddChild( xcomment = node( "comment" ) );
339  xcomment->AddAttribute( "number", "3" );
340  xcomment->AddAttribute( "value", tb.GetComment( 2 ) );
341 
342  xtitleBlock->AddChild( xcomment = node( "comment" ) );
343  xcomment->AddAttribute( "number", "4" );
344  xcomment->AddAttribute( "value", tb.GetComment( 3 ) );
345 
346  xtitleBlock->AddChild( xcomment = node( "comment" ) );
347  xcomment->AddAttribute( "number", "5" );
348  xcomment->AddAttribute( "value", tb.GetComment( 4 ) );
349 
350  xtitleBlock->AddChild( xcomment = node( "comment" ) );
351  xcomment->AddAttribute( "number", "6" );
352  xcomment->AddAttribute( "value", tb.GetComment( 5 ) );
353 
354  xtitleBlock->AddChild( xcomment = node( "comment" ) );
355  xcomment->AddAttribute( "number", "7" );
356  xcomment->AddAttribute( "value", tb.GetComment( 6 ) );
357 
358  xtitleBlock->AddChild( xcomment = node( "comment" ) );
359  xcomment->AddAttribute( "number", "8" );
360  xcomment->AddAttribute( "value", tb.GetComment( 7 ) );
361 
362  xtitleBlock->AddChild( xcomment = node( "comment" ) );
363  xcomment->AddAttribute( "number", "9" );
364  xcomment->AddAttribute( "value", tb.GetComment( 8 ) );
365  }
366 
367  return xdesign;
368 }
369 
370 
372 {
373  XNODE* xlibs = node( "libraries" ); // auto_ptr
374 
375  for( std::set<wxString>::iterator it = m_libraries.begin(); it!=m_libraries.end(); ++it )
376  {
377  wxString libNickname = *it;
378  XNODE* xlibrary;
379 
380  if( m_schematic->Prj().SchSymbolLibTable()->HasLibrary( libNickname ) )
381  {
382  xlibs->AddChild( xlibrary = node( "library" ) );
383  xlibrary->AddAttribute( "logical", libNickname );
384  xlibrary->AddChild( node(
385  "uri", m_schematic->Prj().SchSymbolLibTable()->GetFullURI( libNickname ) ) );
386  }
387 
388  // @todo: add more fun stuff here
389  }
390 
391  return xlibs;
392 }
393 
394 
396 {
397  XNODE* xlibparts = node( "libparts" ); // auto_ptr
398 
399  LIB_PINS pinList;
400  LIB_FIELDS fieldList;
401 
402  m_libraries.clear();
403 
404  for( auto lcomp : m_LibParts )
405  {
406  wxString libNickname = lcomp->GetLibId().GetLibNickname();;
407 
408  // The library nickname will be empty if the cache library is used.
409  if( !libNickname.IsEmpty() )
410  m_libraries.insert( libNickname ); // inserts component's library if unique
411 
412  XNODE* xlibpart;
413  xlibparts->AddChild( xlibpart = node( "libpart" ) );
414  xlibpart->AddAttribute( "lib", libNickname );
415  xlibpart->AddAttribute( "part", lcomp->GetName() );
416 
417  //----- show the important properties -------------------------
418  if( !lcomp->GetDescription().IsEmpty() )
419  xlibpart->AddChild( node( "description", lcomp->GetDescription() ) );
420 
421  if( !lcomp->GetDocFileName().IsEmpty() )
422  xlibpart->AddChild( node( "docs", lcomp->GetDocFileName() ) );
423 
424  // Write the footprint list
425  if( lcomp->GetFootprints().GetCount() )
426  {
427  XNODE* xfootprints;
428  xlibpart->AddChild( xfootprints = node( "footprints" ) );
429 
430  for( unsigned i=0; i<lcomp->GetFootprints().GetCount(); ++i )
431  {
432  xfootprints->AddChild( node( "fp", lcomp->GetFootprints()[i] ) );
433  }
434  }
435 
436  //----- show the fields here ----------------------------------
437  fieldList.clear();
438  lcomp->GetFields( fieldList );
439 
440  XNODE* xfields;
441  xlibpart->AddChild( xfields = node( "fields" ) );
442 
443  for( unsigned i=0; i<fieldList.size(); ++i )
444  {
445  if( !fieldList[i].GetText().IsEmpty() )
446  {
447  XNODE* xfield;
448  xfields->AddChild( xfield = node( "field", fieldList[i].GetText() ) );
449  xfield->AddAttribute( "name", fieldList[i].GetCanonicalName() );
450  }
451  }
452 
453  //----- show the pins here ------------------------------------
454  pinList.clear();
455  lcomp->GetPins( pinList, 0, 0 );
456 
457  /* we must erase redundant Pins references in pinList
458  * These redundant pins exist because some pins
459  * are found more than one time when a component has
460  * multiple parts per package or has 2 representations (DeMorgan conversion)
461  * For instance, a 74ls00 has DeMorgan conversion, with different pin shapes,
462  * and therefore each pin appears 2 times in the list.
463  * Common pins (VCC, GND) can also be found more than once.
464  */
465  sort( pinList.begin(), pinList.end(), sortPinsByNumber );
466  for( int ii = 0; ii < (int)pinList.size()-1; ii++ )
467  {
468  if( pinList[ii]->GetNumber() == pinList[ii+1]->GetNumber() )
469  { // 2 pins have the same number, remove the redundant pin at index i+1
470  pinList.erase(pinList.begin() + ii + 1);
471  ii--;
472  }
473  }
474 
475  if( pinList.size() )
476  {
477  XNODE* pins;
478 
479  xlibpart->AddChild( pins = node( "pins" ) );
480  for( unsigned i=0; i<pinList.size(); ++i )
481  {
482  XNODE* pin;
483 
484  pins->AddChild( pin = node( "pin" ) );
485  pin->AddAttribute( "num", pinList[i]->GetNumber() );
486  pin->AddAttribute( "name", pinList[i]->GetName() );
487  pin->AddAttribute( "type", pinList[i]->GetCanonicalElectricalTypeName() );
488 
489  // caution: construction work site here, drive slowly
490  }
491  }
492  }
493 
494  return xlibparts;
495 }
496 
497 
499 {
500  XNODE* xnets = node( "nets" ); // auto_ptr if exceptions ever get used.
501  wxString netCodeTxt;
502  wxString netName;
503  wxString ref;
504 
505  XNODE* xnet = 0;
506 
507  /* output:
508  <net code="123" name="/cfcard.sch/WAIT#">
509  <node ref="R23" pin="1"/>
510  <node ref="U18" pin="12"/>
511  </net>
512  */
513 
514  int code = 0;
515 
516  for( const auto& it : m_schematic->ConnectionGraph()->GetNetMap() )
517  {
518  bool added = false;
519  wxString net_name = it.first.first;
520  auto subgraphs = it.second;
521 
522  // Code starts at 1
523  code++;
524 
525  XNODE* xnode;
526  std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>> sorted_items;
527 
528  for( auto subgraph : subgraphs )
529  {
530  auto sheet = subgraph->m_sheet;
531 
532  for( auto item : subgraph->m_items )
533  if( item->Type() == SCH_PIN_T )
534  sorted_items.emplace_back(
535  std::make_pair( static_cast<SCH_PIN*>( item ), sheet ) );
536  }
537 
538  // Netlist ordering: Net name, then ref des, then pin name
539  std::sort( sorted_items.begin(), sorted_items.end(), [] ( auto a, auto b ) {
540  auto ref_a = a.first->GetParentComponent()->GetRef( &a.second );
541  auto ref_b = b.first->GetParentComponent()->GetRef( &b.second );
542 
543  if( ref_a == ref_b )
544  return a.first->GetNumber() < b.first->GetNumber();
545 
546  return ref_a < ref_b;
547  } );
548 
549  // Some duplicates can exist, for example on multi-unit parts with duplicated
550  // pins across units. If the user connects the pins on each unit, they will
551  // appear on separate subgraphs. Remove those here:
552  sorted_items.erase( std::unique( sorted_items.begin(), sorted_items.end(),
553  [] ( auto a, auto b ) {
554  auto ref_a = a.first->GetParentComponent()->GetRef( &a.second );
555  auto ref_b = b.first->GetParentComponent()->GetRef( &b.second );
556 
557  return ref_a == ref_b && a.first->GetNumber() == b.first->GetNumber();
558  } ), sorted_items.end() );
559 
560  for( const auto& pair : sorted_items )
561  {
562  SCH_PIN* pin = pair.first;
563  SCH_SHEET_PATH sheet = pair.second;
564 
565  auto refText = pin->GetParentComponent()->GetRef( &sheet );
566  const auto& pinText = pin->GetNumber();
567 
568  // Skip power symbols and virtual components
569  if( refText[0] == wxChar( '#' ) )
570  continue;
571 
572  if( !added )
573  {
574  xnets->AddChild( xnet = node( "net" ) );
575  netCodeTxt.Printf( "%d", code );
576  xnet->AddAttribute( "code", netCodeTxt );
577  xnet->AddAttribute( "name", net_name );
578 
579  added = true;
580  }
581 
582  xnet->AddChild( xnode = node( "node" ) );
583  xnode->AddAttribute( "ref", refText );
584  xnode->AddAttribute( "pin", pinText );
585 
586  wxString pinName;
587 
588  if( pin->GetName() != "~" ) // ~ is a char used to code empty strings in libs.
589  pinName = pin->GetName();
590 
591  if( !pinName.IsEmpty() )
592  xnode->AddAttribute( "pinfunction", pinName );
593  }
594  }
595 
596  return xnets;
597 }
598 
599 
600 XNODE* NETLIST_EXPORTER_GENERIC::node( const wxString& aName, const wxString& aTextualContent /* = wxEmptyString*/ )
601 {
602  XNODE* n = new XNODE( wxXML_ELEMENT_NODE, aName );
603 
604  if( aTextualContent.Len() > 0 ) // excludes wxEmptyString, the parameter's default value
605  n->AddChild( new XNODE( wxXML_TEXT_NODE, wxEmptyString, aTextualContent ) );
606 
607  return n;
608 }
609 
610 
611 static bool sortPinsByNumber( LIB_PIN* aPin1, LIB_PIN* aPin2 )
612 {
613  // return "lhs < rhs"
614  return UTIL::RefDesStringCompare( aPin1->GetNumber(), aPin2->GetNumber() ) < 0;
615 }
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:196
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
name of datasheet
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:99
const wxString & GetName() const
Definition: sch_pin.h:102
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.
SCHEMATIC * m_schematic
The schematic we're generating a netlist for.
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:139
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:55
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)
wxString AsString() const
Definition: common.cpp:157
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:201
wxString PathAsString() const
Function PathAsString the path uses the time stamps which do not changes even when editing sheet para...
wxString GetDescription() const
Return information about the aliased parts.
void Clear()
Function Clear erases the record.
SCH_COMPONENT * findNextComponent(EDA_ITEM *aItem, SCH_SHEET_PATH *aSheetPath)
Checks if the given component should be processed for netlisting.
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:74
TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout,...
Definition: title_block.h:40
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:293
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:104
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
void addComponentFields(XNODE *xcomp, SCH_COMPONENT *comp, SCH_SHEET_PATH *aSheet)
wxString GetBuildVersion()
Get the full KiCad version string.
const wxString & GetRevision() const
Definition: title_block.h:89
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.
SCH_SHEET_PATH.
std::unique_ptr< LIB_PART > & GetPartRef()
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false)
Return the reference for the given sheet path.
int GetFieldCount() const
Return the number of fields in this symbol.
const KIID m_Uuid
Definition: base_struct.h:166
XNODE holds an XML or S-expression element.
Definition: xnode.h:43
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
const wxString & GetDate() const
Definition: title_block.h:79
const wxString & GetNumber() const
Definition: lib_pin.h:179
std::vector< LIB_FIELD > LIB_FIELDS
Definition: lib_field.h:218
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:420
#define GNL_ALL
Schematic symbol object.
Definition: sch_component.h:88
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
Definition: schematic.h:84
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
Definition for part library class.
wxString PathHumanReadable() const
Function PathHumanReadable returns the sheet path in a human readable form, i.e.
static bool sortPinsByNumber(LIB_PIN *aPin1, LIB_PIN *aPin2)
const LIB_ID & GetLibId() const
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:126
XNODE * makeListOfNets()
Function makeListOfNets fills out an XML node with a list of nets and returns it.
wxString DateAndTime()
Definition: string.cpp:379
XNODE * makeLibParts()
Function makeLibParts fills out an XML node with the unique library parts and returns it.