KiCad PCB EDA Suite
sch_sheet_path.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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 1992-2017 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 
31 #include <fctsys.h>
32 
33 #include <dlist.h>
34 #include <sch_screen.h>
35 #include <sch_item_struct.h>
36 
37 #include <sch_reference_list.h>
38 #include <class_library.h>
39 #include <sch_sheet_path.h>
40 #include <sch_component.h>
41 #include <sch_sheet.h>
42 #include <template_fieldnames.h>
43 
45 
46 #include <boost/functional/hash.hpp>
47 #include <wx/filename.h>
48 
49 
50 namespace std
51 {
53  {
54  return path.GetCurrentHash();
55  }
56 }
57 
58 
60 {
61  m_pageNumber = 0;
62  m_current_hash = 0;
63 }
64 
65 
67 {
68  m_current_hash = 0;
69 
70  for( auto sheet : m_sheets )
71  boost::hash_combine( m_current_hash, sheet->GetTimeStamp() );
72 }
73 
74 
75 int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const
76 {
77  if( size() > aSheetPathToTest.size() )
78  return 1;
79 
80  if( size() < aSheetPathToTest.size() )
81  return -1;
82 
83  //otherwise, same number of sheets.
84  for( unsigned i = 0; i < size(); i++ )
85  {
86  if( at( i )->GetTimeStamp() > aSheetPathToTest.at( i )->GetTimeStamp() )
87  return 1;
88 
89  if( at( i )->GetTimeStamp() < aSheetPathToTest.at( i )->GetTimeStamp() )
90  return -1;
91  }
92 
93  return 0;
94 }
95 
96 
98 {
99  if( !empty() )
100  return at( size() - 1 );
101 
102  return NULL;
103 }
104 
105 
107 {
108  SCH_SHEET* lastSheet = Last();
109 
110  if( lastSheet )
111  return lastSheet->GetScreen();
112 
113  return NULL;
114 }
115 
116 
118 {
119  SCH_SHEET* lastSheet = Last();
120 
121  if( lastSheet && lastSheet->GetScreen() )
122  return lastSheet->GetScreen()->GetDrawItems();
123 
124  return NULL;
125 }
126 
127 
129 {
130  SCH_ITEM* item = NULL;
131 
132  if( !empty() && at( 0 )->GetScreen() )
133  item = at( 0 )->GetScreen()->GetDrawItems();
134 
135  /* @fixme - These lists really should be one of the boost pointer containers. This
136  * is a brain dead hack to allow reverse iteration of EDA_ITEM linked
137  * list.
138  */
139  SCH_ITEM* lastItem = NULL;
140 
141  while( item )
142  {
143  lastItem = item;
144  item = item->Next();
145  }
146 
147  return lastItem;
148 }
149 
150 
151 wxString SCH_SHEET_PATH::Path() const
152 {
153  wxString s, t;
154 
155  s = wxT( "/" ); // This is the root path
156 
157  // start at 1 to avoid the root sheet,
158  // which does not need to be added to the path
159  // it's timestamp changes anyway.
160  for( unsigned i = 1; i < size(); i++ )
161  {
162  t.Printf( _( "%8.8lX/" ), (long unsigned) at( i )->GetTimeStamp() );
163  s = s + t;
164  }
165 
166  return s;
167 }
168 
169 
171 {
172  wxString s;
173 
174  s = wxT( "/" );
175 
176  // start at 1 to avoid the root sheet, as above.
177  for( unsigned i = 1; i < size(); i++ )
178  {
179  s = s + at( i )->GetName() + wxT( "/" );
180  }
181 
182  return s;
183 }
184 
185 
187 {
188  EDA_ITEM* t = LastDrawList();
189 
190  while( t )
191  {
192  if( t->Type() == SCH_COMPONENT_T )
193  {
194  SCH_COMPONENT* component = (SCH_COMPONENT*) t;
195  component->GetField( REFERENCE )->SetText( component->GetRef( this ) );
196  component->UpdateUnit( component->GetUnitSelection( this ) );
197  }
198 
199  t = t->Next();
200  }
201 }
202 
203 
204 
205 void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols,
206  bool aForceIncludeOrphanComponents )
207 {
208  for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
209  {
210  if( item->Type() == SCH_COMPONENT_T )
211  {
212  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
213 
214  // Skip pseudo components, which have a reference starting with #. This mainly
215  // affects power symbols.
216  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
217  continue;
218 
219  LIB_PART* part = component->GetPartRef().lock().get();
220 
221  if( part || aForceIncludeOrphanComponents )
222  {
223  SCH_REFERENCE schReference( component, part, *this );
224 
225  schReference.SetSheetNumber( m_pageNumber );
226  aReferences.AddItem( schReference );
227  }
228  }
229  }
230 }
231 
232 
234  bool aIncludePowerSymbols )
235 {
236 
237  for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
238  {
239  if( item->Type() != SCH_COMPONENT_T )
240  continue;
241 
242  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
243 
244  // Skip pseudo components, which have a reference starting with #. This mainly
245  // affects power symbols.
246  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
247  continue;
248 
249  LIB_PART* part = component->GetPartRef().lock().get();
250 
251  if( part && part->GetUnitCount() > 1 )
252  {
253  SCH_REFERENCE schReference = SCH_REFERENCE( component, part, *this );
254  schReference.SetSheetNumber( m_pageNumber );
255  wxString reference_str = schReference.GetRef();
256 
257  // Never lock unassigned references
258  if( reference_str[reference_str.Len() - 1] == '?' )
259  continue;
260 
261  aRefList[reference_str].AddItem( schReference );
262  }
263  }
264 }
265 
266 
267 SCH_ITEM* SCH_SHEET_PATH::FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem, bool aWrap ) const
268 {
269  bool hasWrapped = false;
270  bool firstItemFound = false;
271  SCH_ITEM* drawItem = LastDrawList();
272 
273  while( drawItem )
274  {
275  if( drawItem->Type() == aType )
276  {
277  if( !aLastItem || firstItemFound )
278  {
279  return drawItem;
280  }
281  else if( !firstItemFound && drawItem == aLastItem )
282  {
283  firstItemFound = true;
284  }
285  }
286 
287  drawItem = drawItem->Next();
288 
289  if( !drawItem && aLastItem && aWrap && !hasWrapped )
290  {
291  hasWrapped = true;
292  drawItem = LastDrawList();
293  }
294  }
295 
296  return NULL;
297 }
298 
299 
300 SCH_ITEM* SCH_SHEET_PATH::FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem, bool aWrap ) const
301 {
302  bool hasWrapped = false;
303  bool firstItemFound = false;
304  SCH_ITEM* drawItem = FirstDrawList();
305 
306  while( drawItem )
307  {
308  if( drawItem->Type() == aType )
309  {
310  if( aLastItem == NULL || firstItemFound )
311  {
312  return drawItem;
313  }
314  else if( !firstItemFound && drawItem == aLastItem )
315  {
316  firstItemFound = true;
317  }
318  }
319 
320  drawItem = drawItem->Back();
321 
322  if( drawItem == NULL && aLastItem && aWrap && !hasWrapped )
323  {
324  hasWrapped = true;
325  drawItem = FirstDrawList();
326  }
327  }
328 
329  return NULL;
330 }
331 
332 
333 bool SCH_SHEET_PATH::SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
334  bool aSetVisible )
335 {
336  SCH_SCREEN* screen = LastScreen();
337 
338  if( screen == NULL )
339  return false;
340 
341  return screen->SetComponentFootprint( this, aReference, aFootPrint, aSetVisible );
342 }
343 
344 
346 {
347  return m_current_hash == d1.GetCurrentHash();
348 }
349 
350 
351 bool SCH_SHEET_PATH::TestForRecursion( const wxString& aSrcFileName,
352  const wxString& aDestFileName ) const
353 {
354  wxFileName rootFn = g_RootSheet->GetFileName();
355  wxFileName srcFn = aSrcFileName;
356  wxFileName destFn = aDestFileName;
357 
358  if( srcFn.IsRelative() )
359  srcFn.MakeAbsolute( rootFn.GetPath() );
360 
361  if( destFn.IsRelative() )
362  destFn.MakeAbsolute( rootFn.GetPath() );
363 
364 
365  // The source and destination sheet file names cannot be the same.
366  if( srcFn == destFn )
367  return true;
368 
372  unsigned i = 0;
373 
374  while( i < size() )
375  {
376  wxFileName cmpFn = at( i )->GetFileName();
377 
378  if( cmpFn.IsRelative() )
379  cmpFn.MakeAbsolute( rootFn.GetPath() );
380 
381  // Test if the file name of the destination sheet is in anywhere in this sheet path.
382  if( cmpFn == destFn )
383  break;
384 
385  i++;
386  }
387 
388  // The destination sheet file name was not found in the sheet path or the destination
389  // sheet file name is the root sheet so no recursion is possible.
390  if( i >= size() || i == 0 )
391  return false;
392 
393  // Walk back up to the root sheet to see if the source file name is already a parent in
394  // the sheet path. If so, recursion will occur.
395  do
396  {
397  i -= 1;
398 
399  wxFileName cmpFn = at( i )->GetFileName();
400 
401  if( cmpFn.IsRelative() )
402  cmpFn.MakeAbsolute( rootFn.GetPath() );
403 
404  if( cmpFn == srcFn )
405  return true;
406 
407  } while( i != 0 );
408 
409  // The source sheet file name is not a parent of the destination sheet file name.
410  return false;
411 }
412 
413 
414 int SCH_SHEET_PATH::FindSheet( const wxString& aFileName ) const
415 {
416  for( unsigned i = 0; i < size(); i++ )
417  {
418  if( at( i )->GetFileName().CmpNoCase( aFileName ) == 0 )
419  return (int)i;
420  }
421 
422  return SHEET_NOT_FOUND;
423 }
424 
425 
426 SCH_SHEET* SCH_SHEET_PATH::FindSheetByName( const wxString& aSheetName )
427 {
428  for( unsigned i = 0; i < size(); i++ )
429  {
430  if( at( i )->GetName().CmpNoCase( aSheetName ) == 0 )
431  return at( i );
432  }
433 
434  return NULL;
435 }
436 
437 
438 /********************************************************************/
439 /* Class SCH_SHEET_LIST to handle the list of Sheets in a hierarchy */
440 /********************************************************************/
442 {
443  m_isRootSheet = false;
444 
445  if( aSheet != NULL )
446  BuildSheetList( aSheet );
447 }
448 
449 
450 SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheetByPath( const wxString& aPath, bool aHumanReadable )
451 {
452  wxString sheetPath;
453 
454  for( unsigned i = 0; i < size(); i++ )
455  {
456  sheetPath = ( aHumanReadable ) ? at( i ).PathHumanReadable() : at( i ).Path();
457 
458  if( sheetPath == aPath )
459  return &at( i );
460  }
461 
462  return NULL;
463 }
464 
465 
467 {
468  wxCHECK_RET( aSheet != NULL, wxT( "Cannot build sheet list from undefined sheet." ) );
469 
470  if( aSheet == g_RootSheet )
471  m_isRootSheet = true;
472 
473  m_currentSheetPath.push_back( aSheet );
474 
480  m_currentSheetPath.SetPageNumber( size() + 1 );
481  push_back( m_currentSheetPath );
482 
483  if( aSheet->GetScreen() )
484  {
486 
487  while( item )
488  {
489  if( item->Type() == SCH_SHEET_T )
490  {
491  SCH_SHEET* sheet = (SCH_SHEET*) item;
492  BuildSheetList( sheet );
493  }
494 
495  item = item->Next();
496  }
497  }
498 
500 }
501 
502 
504 {
505  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
506  {
507  if( (*it).LastScreen() && (*it).LastScreen()->IsModify() )
508  return true;
509  }
510 
511  return false;
512 }
513 
514 
516 {
517  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
518  {
519  if( (*it).LastScreen() )
520  (*it).LastScreen()->ClrModify();
521  }
522 }
523 
524 
526 {
527  // List of reference for power symbols
528  SCH_REFERENCE_LIST references;
529 
530  // Map of locked components (not used, but needed by Annotate()
531  SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents;
532 
533  // Build the list of power components:
534  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
535  {
536  SCH_SHEET_PATH& spath = *it;
537 
538  for( EDA_ITEM* item = spath.LastDrawList(); item; item = item->Next() )
539  {
540  if( item->Type() != SCH_COMPONENT_T )
541  continue;
542 
543  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
544  LIB_PART* part = component->GetPartRef().lock().get();
545 
546  if( !part || !part->IsPower() )
547  continue;
548 
549  if( part )
550  {
551  SCH_REFERENCE schReference( component, part, spath );
552  references.AddItem( schReference );
553  }
554  }
555  }
556 
557  // Find duplicate, and silently clear annotation of duplicate
558  std::map<wxString, int> ref_list; // stores the existing references
559 
560  for( unsigned ii = 0; ii< references.GetCount(); ++ii )
561  {
562  wxString curr_ref = references[ii].GetRef();
563 
564  if( ref_list.find( curr_ref ) == ref_list.end() )
565  {
566  ref_list[curr_ref] = ii;
567  continue;
568  }
569 
570  // Possible duplicate, if the ref ends by a number:
571  if( curr_ref.Last() < '0' && curr_ref.Last() > '9' )
572  continue; // not annotated
573 
574  // Duplicate: clear annotation by removing the number ending the ref
575  while( curr_ref.Last() >= '0' && curr_ref.Last() <= '9' )
576  curr_ref.RemoveLast();
577 
578  references[ii].SetRef( curr_ref );
579  }
580 
581 
582  // Break full components reference in name (prefix) and number:
583  // example: IC1 become IC, and 1
584  references.SplitReferences();
585 
586  // Ensure all power symbols have the reference starting by '#'
587  // (No sure this is really useful)
588  for( unsigned ii = 0; ii< references.GetCount(); ++ii )
589  {
590  if( references[ii].GetRef()[0] != '#' )
591  {
592  wxString new_ref = "#" + references[ii].GetRef();
593  references[ii].SetRef( new_ref );
594  }
595  }
596 
597  // Recalculate and update reference numbers in schematic
598  references.Annotate( false, 0, 100, lockedComponents );
599  references.UpdateAnnotation();
600 }
601 
602 
603 void SCH_SHEET_LIST::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols,
604  bool aForceIncludeOrphanComponents )
605 {
606  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
607  (*it).GetComponents( aReferences, aIncludePowerSymbols, aForceIncludeOrphanComponents );
608 }
609 
611  bool aIncludePowerSymbols )
612 {
613  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
614  {
616  (*it).GetMultiUnitComponents( tempMap );
617 
618  for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
619  {
620  // Merge this list into the main one
621  unsigned n_refs = pair.second.GetCount();
622 
623  for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
624  {
625  aRefList[pair.first].AddItem( pair.second[thisRef] );
626  }
627  }
628  }
629 }
630 
631 
633  SCH_ITEM* aLastItem, bool aWrap )
634 {
635  bool hasWrapped = false;
636  bool firstItemFound = false;
637 
638  SCH_ITEM* drawItem = NULL;
639  SCH_SHEET_PATHS_ITER it = begin();
640 
641  while( it != end() )
642  {
643  drawItem = (*it).LastDrawList();
644 
645  while( drawItem )
646  {
647  if( drawItem->Type() == aType )
648  {
649  if( aLastItem == NULL || firstItemFound )
650  {
651  if( aSheetFoundIn )
652  *aSheetFoundIn = &(*it);
653 
654  return drawItem;
655  }
656  else if( !firstItemFound && drawItem == aLastItem )
657  {
658  firstItemFound = true;
659  }
660  }
661 
662  drawItem = drawItem->Next();
663  }
664 
665  ++it;
666 
667  if( it == end() && aLastItem && aWrap && !hasWrapped )
668  {
669  hasWrapped = true;
670  it = begin();
671  }
672  }
673 
674  return NULL;
675 }
676 
677 
679  SCH_ITEM* aLastItem, bool aWrap )
680 {
681  bool hasWrapped = false;
682  bool firstItemFound = false;
683  SCH_ITEM* drawItem = NULL;
684  SCH_SHEET_PATHS_RITER it = rbegin();
685 
686  while( it != rend() )
687  {
688  drawItem = (*it).FirstDrawList();
689 
690  while( drawItem )
691  {
692  if( drawItem->Type() == aType )
693  {
694  if( aLastItem == NULL || firstItemFound )
695  {
696  if( aSheetFoundIn )
697  *aSheetFoundIn = &(*it);
698 
699  return drawItem;
700  }
701  else if( !firstItemFound && drawItem == aLastItem )
702  {
703  firstItemFound = true;
704  }
705  }
706 
707  drawItem = drawItem->Back();
708  }
709 
710  ++it;
711 
712  if( it == rend() && aLastItem && aWrap && !hasWrapped )
713  {
714  hasWrapped = true;
715  it = rbegin();
716  }
717  }
718 
719  return NULL;
720 }
721 
722 
723 bool SCH_SHEET_LIST::SetComponentFootprint( const wxString& aReference,
724  const wxString& aFootPrint, bool aSetVisible )
725 {
726  bool found = false;
727 
728  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
729  found = (*it).SetComponentFootprint( aReference, aFootPrint, aSetVisible );
730 
731  return found;
732 }
733 
734 
736 {
737  wxString fileName;
738 
739  for( unsigned i = 0; i < size(); i++ )
740  {
741  fileName = at( i ).Last()->GetFileName();
742 
743  for( unsigned j = 0; j < size(); j++ )
744  {
745  if( i == j )
746  continue;
747 
748  if( fileName == at( j ).Last()->GetFileName() )
749  return true;
750  }
751  }
752 
753  return false;
754 }
755 
756 
757 bool SCH_SHEET_LIST::TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
758  const wxString& aDestFileName ) const
759 {
760  wxFileName rootFn = g_RootSheet->GetFileName();
761  wxFileName destFn = aDestFileName;
762 
763  if( destFn.IsRelative() )
764  destFn.MakeAbsolute( rootFn.GetPath() );
765 
766  // Test each SCH_SHEET_PATH in this SCH_SHEET_LIST for potential recursion.
767  for( unsigned i = 0; i < size(); i++ )
768  {
769  // Test each SCH_SHEET_PATH in the source sheet.
770  for( unsigned j = 0; j < aSrcSheetHierarchy.size(); j++ )
771  {
772  const SCH_SHEET_PATH* sheetPath = &aSrcSheetHierarchy[j];
773 
774  for( unsigned k = 0; k < sheetPath->size(); k++ )
775  {
776  if( at( i ).TestForRecursion( sheetPath->GetSheet( k )->GetFileName(),
777  aDestFileName ) )
778  return true;
779  }
780  }
781  }
782 
783  // The source sheet file can safely be added to the destination sheet file.
784  return false;
785 }
786 
787 
788 SCH_SHEET* SCH_SHEET_LIST::FindSheetByName( const wxString& aSheetName )
789 {
790  for( unsigned i = 0; i < size(); i++ )
791  {
792  SCH_SHEET* sheet = at( i ).FindSheetByName( aSheetName );
793 
794  if( sheet )
795  return sheet;
796  }
797 
798  return NULL;
799 }
void GetComponents(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanComponents=false)
Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the sheet.
Definition of the SCH_SHEET class for Eeschema.
void SetSheetNumber(int aSheetNumber)
Class SCH_SHEET_LIST.
int GetUnitCount() const
bool TestForRecursion(const wxString &aSrcFileName, const wxString &aDestFileName) const
Function TestForRecursion.
bool IsModified()
Function IsModified checks the entire hierarchy for any modifications.
SCH_SHEET * FindSheetByName(const wxString &aSheetName)
Function FindSheetByName.
SCH_ITEM * FindPreviousItem(KICAD_T aType, SCH_SHEET_PATH **aSheetFound=NULL, SCH_ITEM *aLastItem=NULL, bool aWrap=true)
Function FindPreviousItem searches the entire schematic for the previous schematic item.
PART_REF & GetPartRef()
void UpdateUnit(int aUnit)
Change the unit number to aUnit without setting any internal flags.
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER
Base schematic object class definition.
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
SCH_ITEM * FindNextItem(KICAD_T aType, SCH_SHEET_PATH **aSheetFound=NULL, SCH_ITEM *aLastItem=NULL, bool aWrap=true)
Function FindNextItem searches the entire schematic for the next schematic object.
SCH_ITEM * Next() const
bool operator==(const SCH_SHEET_PATH &d1) const
void SetPageNumber(int aPageNumber)
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
void SetText(const wxString &aText) override
Definition: sch_field.cpp:125
void AddItem(SCH_REFERENCE &aItem)
Function AddItem adds a SCH_REFERENCE object to the list of references.
int GetUnitSelection(SCH_SHEET_PATH *aSheet)
Template specialization to enable wxStrings for certain containers (e.g. unordered_map)
SCH_ITEM * FirstDrawList() const
Get the last schematic item relative to the first sheet in the list.
SCH_SHEET_PATH * GetSheetByPath(const wxString &aPath, bool aHumanReadable=true)
Function GetSheetByPath returns a sheet matching the path name in aPath.
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:278
Field Reference of part, i.e. "IC21".
#define SHEET_NOT_FOUND
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
SCH_SHEET_LIST(SCH_SHEET *aSheet=NULL)
Constructor build a flattened list of SCH_SHEET_PATH objects from aSheet.
Class SCH_REFERENCE_LIST is used to create a flattened list of components because in a complex hierar...
void pop_back()
Forwarded method from std::vector.
EDA_ITEM * Next() const
Definition: base_struct.h:212
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
SCH_ITEM * Back() const
wxString GetRef() const
void UpdateAnnotation()
function UpdateAnnotation Updates the reference components for the schematic project (or the current ...
SCH_SHEET * FindSheetByName(const wxString &aSheetName)
Function FindSheetByName.
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
wxString GetName() const
Definition: sch_sheet.h:266
wxString Path() const
Function Path the path uses the time stamps which do not changes even when editing sheet parameters a...
size_t size() const
Forwarded method from std::vector.
SCH_SHEET_PATH m_currentSheetPath
Subclass of DIALOG_SCH_FIND_BASE, which is generated by wxFormBuilder.
bool SetComponentFootprint(const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
Function SetFootprintField searches all the sheets for a component with aReference and set the footpr...
std::vector< SCH_SHEET * > m_sheets
size_t operator()(const SCH_SHEET_PATH &path) const
bool SetComponentFootprint(const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
Function SetFootprintField searches last sheet in the path for a component with aReference and set th...
Define a library symbol object.
timestamp_t GetTimeStamp() const
Definition: base_struct.h:210
void Annotate(bool aUseSheetNum, int aSheetIntervalId, int aStartNumber, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap)
Function Annotate set the reference designators in the list that have not been annotated.
SCH_SHEET_PATH()
Page numbers are maintained by the sheet load order.
Class SCH_SHEET_PATH.
void BuildSheetList(SCH_SHEET *aSheet)
Function BuildSheetList builds the list of sheets and their sheet path from aSheet.
SCH_ITEM * FindPreviousItem(KICAD_T aType, SCH_ITEM *aLastItem=NULL, bool aWrap=false) const
Find the previous schematic item in this sheet path object.
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return the reference for the given sheet path.
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Type SCH_MULTI_UNIT_REFERENCE_MAP is used to create a map of reference designators for multi-unit par...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:208
SCH_ITEM * LastDrawList() const
Function LastDrawList.
void GetMultiUnitComponents(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true)
Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference ...
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:627
Definitions for the Eeschema program SCH_SCREEN class.
SCH_ITEM * FindNextItem(KICAD_T aType, SCH_ITEM *aLastItem=NULL, bool aWrap=false) const
Find the next schematic item in this sheet object.
int FindSheet(const wxString &aFileName) const
const SCH_SHEET * GetSheet(unsigned aIndex) const
bool IsPower() const
void SplitReferences()
Function SplitReferences attempts to split all reference designators into a name (U) and number (1).
SCH_SHEET_PATHS::reverse_iterator SCH_SHEET_PATHS_RITER
size_t GetCurrentHash() const
size_t i
Definition: json11.cpp:597
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
bool IsComplexHierarchy() const
Function IsComplexHierarchy searches all of the sheets for duplicate files names which indicates a co...
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:72
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
bool empty() const
Forwarded method from std::vector.
void AnnotatePowerSymbols()
Function AnnotatePowerSymbols Silently annotates the not yet annotated power symbols of the entire hi...
void GetMultiUnitComponents(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true)
Function GetMultiUnitComponents adds a SCH_REFERENCE_LIST object to aRefList for each same-reference ...
Definition for part library class.
void GetComponents(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanComponents=false)
Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the list of...
wxString PathHumanReadable() const
Function PathHumanReadable returns the sheet path in a human readable form, i.e.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
unsigned GetCount()
Function GetCount.
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName) const
Function TestForRecursion.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
int Cmp(const SCH_SHEET_PATH &aSheetPathToTest) const
Function Cmp Compare if this is the same sheet path as aSheetPathToTest.
Class SCH_REFERENCE is used as a helper to define a component's reference designator in a schematic.
SCH_SCREEN * LastScreen() const
Function LastScreen.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
bool SetComponentFootprint(SCH_SHEET_PATH *aSheetPath, const wxString &aReference, const wxString &aFootPrint, bool aSetVisible)
Search this screen for a symbol with aReference and set the footprint field to aFootPrint if found.
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:167