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.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, which does not need to be added to the path.
158  // It's timestamp changes anyway.
159  for( unsigned i = 1; i < size(); i++ )
160  {
161  t.Printf( _( "%8.8lX/" ), (long unsigned) at( i )->GetTimeStamp() );
162  s = s + t;
163  }
164 
165  return s;
166 }
167 
168 
169 wxString SCH_SHEET_PATH::GetRootPathName( bool aUseShortName )
170 {
171  // return a PathName for the root sheet (like "/" or "<root>"
172  // DO NOT use it in netlists, because it can easily break these netlists
173  // especially after translation, because many netlists (i.e. spice) do not accept any char
174  // Use only the short name ("/") and the full name only in messages
175  return aUseShortName ? wxT( "/" ) : _( "<root_sheet>" );
176 }
177 
178 
180 {
181  wxString s;
182 
183  if( size() == 1 )
184  return GetRootPathName( true ); // Use only the short name in netlists
185 
186  s = wxT( "/" );
187 
188  // Start at 1 to avoid the root sheet, as above.
189  for( unsigned i = 1; i < size(); i++ )
190  s = s + at( i )->GetName() + wxT( "/" );
191 
192  return s;
193 }
194 
195 
197 {
198  EDA_ITEM* t = LastDrawList();
199 
200  while( t )
201  {
202  if( t->Type() == SCH_COMPONENT_T )
203  {
204  SCH_COMPONENT* component = (SCH_COMPONENT*) t;
205  component->GetField( REFERENCE )->SetText( component->GetRef( this ) );
206  component->UpdateUnit( component->GetUnitSelection( this ) );
207  }
208 
209  t = t->Next();
210  }
211 }
212 
213 
214 
215 void SCH_SHEET_PATH::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols,
216  bool aForceIncludeOrphanComponents )
217 {
218  for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
219  {
220  if( item->Type() == SCH_COMPONENT_T )
221  {
222  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
223 
224  // Skip pseudo components, which have a reference starting with #. This mainly
225  // affects power symbols.
226  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
227  continue;
228 
229  LIB_PART* part = component->GetPartRef().get();
230 
231  if( part || aForceIncludeOrphanComponents )
232  {
233  SCH_REFERENCE schReference( component, part, *this );
234 
235  schReference.SetSheetNumber( m_pageNumber );
236  aReferences.AddItem( schReference );
237  }
238  }
239  }
240 }
241 
242 
244  bool aIncludePowerSymbols )
245 {
246 
247  for( SCH_ITEM* item = LastDrawList(); item; item = item->Next() )
248  {
249  if( item->Type() != SCH_COMPONENT_T )
250  continue;
251 
252  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
253 
254  // Skip pseudo components, which have a reference starting with #. This mainly
255  // affects power symbols.
256  if( !aIncludePowerSymbols && component->GetRef( this )[0] == wxT( '#' ) )
257  continue;
258 
259  LIB_PART* part = component->GetPartRef().get();
260 
261  if( part && part->GetUnitCount() > 1 )
262  {
263  SCH_REFERENCE schReference = SCH_REFERENCE( component, part, *this );
264  schReference.SetSheetNumber( m_pageNumber );
265  wxString reference_str = schReference.GetRef();
266 
267  // Never lock unassigned references
268  if( reference_str[reference_str.Len() - 1] == '?' )
269  continue;
270 
271  aRefList[reference_str].AddItem( schReference );
272  }
273  }
274 }
275 
276 
277 SCH_ITEM* SCH_SHEET_PATH::FindNextItem( KICAD_T aType, SCH_ITEM* aLastItem, bool aWrap ) const
278 {
279  bool hasWrapped = false;
280  bool firstItemFound = false;
281  SCH_ITEM* drawItem = LastDrawList();
282 
283  while( drawItem )
284  {
285  if( drawItem->Type() == aType )
286  {
287  if( !aLastItem || firstItemFound )
288  {
289  return drawItem;
290  }
291  else if( !firstItemFound && drawItem == aLastItem )
292  {
293  firstItemFound = true;
294  }
295  }
296 
297  drawItem = drawItem->Next();
298 
299  if( !drawItem && aLastItem && aWrap && !hasWrapped )
300  {
301  hasWrapped = true;
302  drawItem = LastDrawList();
303  }
304  }
305 
306  return NULL;
307 }
308 
309 
310 SCH_ITEM* SCH_SHEET_PATH::FindPreviousItem( KICAD_T aType, SCH_ITEM* aLastItem, bool aWrap ) const
311 {
312  bool hasWrapped = false;
313  bool firstItemFound = false;
314  SCH_ITEM* drawItem = FirstDrawList();
315 
316  while( drawItem )
317  {
318  if( drawItem->Type() == aType )
319  {
320  if( aLastItem == NULL || firstItemFound )
321  {
322  return drawItem;
323  }
324  else if( !firstItemFound && drawItem == aLastItem )
325  {
326  firstItemFound = true;
327  }
328  }
329 
330  drawItem = drawItem->Back();
331 
332  if( drawItem == NULL && aLastItem && aWrap && !hasWrapped )
333  {
334  hasWrapped = true;
335  drawItem = FirstDrawList();
336  }
337  }
338 
339  return NULL;
340 }
341 
342 
343 bool SCH_SHEET_PATH::SetComponentFootprint( const wxString& aReference, const wxString& aFootPrint,
344  bool aSetVisible )
345 {
346  SCH_SCREEN* screen = LastScreen();
347 
348  if( screen == NULL )
349  return false;
350 
351  return screen->SetComponentFootprint( this, aReference, aFootPrint, aSetVisible );
352 }
353 
354 
356 {
357  return m_current_hash == d1.GetCurrentHash();
358 }
359 
360 
361 bool SCH_SHEET_PATH::TestForRecursion( const wxString& aSrcFileName,
362  const wxString& aDestFileName ) const
363 {
364  wxFileName rootFn = g_RootSheet->GetFileName();
365  wxFileName srcFn = aSrcFileName;
366  wxFileName destFn = aDestFileName;
367 
368  if( srcFn.IsRelative() )
369  srcFn.MakeAbsolute( rootFn.GetPath() );
370 
371  if( destFn.IsRelative() )
372  destFn.MakeAbsolute( rootFn.GetPath() );
373 
374 
375  // The source and destination sheet file names cannot be the same.
376  if( srcFn == destFn )
377  return true;
378 
382  unsigned i = 0;
383 
384  while( i < size() )
385  {
386  wxFileName cmpFn = at( i )->GetFileName();
387 
388  if( cmpFn.IsRelative() )
389  cmpFn.MakeAbsolute( rootFn.GetPath() );
390 
391  // Test if the file name of the destination sheet is in anywhere in this sheet path.
392  if( cmpFn == destFn )
393  break;
394 
395  i++;
396  }
397 
398  // The destination sheet file name was not found in the sheet path or the destination
399  // sheet file name is the root sheet so no recursion is possible.
400  if( i >= size() || i == 0 )
401  return false;
402 
403  // Walk back up to the root sheet to see if the source file name is already a parent in
404  // the sheet path. If so, recursion will occur.
405  do
406  {
407  i -= 1;
408 
409  wxFileName cmpFn = at( i )->GetFileName();
410 
411  if( cmpFn.IsRelative() )
412  cmpFn.MakeAbsolute( rootFn.GetPath() );
413 
414  if( cmpFn == srcFn )
415  return true;
416 
417  } while( i != 0 );
418 
419  // The source sheet file name is not a parent of the destination sheet file name.
420  return false;
421 }
422 
423 
424 int SCH_SHEET_PATH::FindSheet( const wxString& aFileName ) const
425 {
426  for( unsigned i = 0; i < size(); i++ )
427  {
428  if( at( i )->GetFileName().CmpNoCase( aFileName ) == 0 )
429  return (int)i;
430  }
431 
432  return SHEET_NOT_FOUND;
433 }
434 
435 
436 SCH_SHEET* SCH_SHEET_PATH::FindSheetByName( const wxString& aSheetName )
437 {
438  for( unsigned i = 0; i < size(); i++ )
439  {
440  if( at( i )->GetName().CmpNoCase( aSheetName ) == 0 )
441  return at( i );
442  }
443 
444  return NULL;
445 }
446 
447 
448 /********************************************************************/
449 /* Class SCH_SHEET_LIST to handle the list of Sheets in a hierarchy */
450 /********************************************************************/
452 {
453  m_isRootSheet = false;
454 
455  if( aSheet != NULL )
456  BuildSheetList( aSheet );
457 }
458 
459 
460 SCH_SHEET_PATH* SCH_SHEET_LIST::GetSheetByPath( const wxString& aPath, bool aHumanReadable )
461 {
462  wxString sheetPath;
463 
464  for( unsigned i = 0; i < size(); i++ )
465  {
466  sheetPath = ( aHumanReadable ) ? at( i ).PathHumanReadable() : at( i ).Path();
467 
468  if( sheetPath == aPath )
469  return &at( i );
470  }
471 
472  return NULL;
473 }
474 
475 
477 {
478  wxCHECK_RET( aSheet != NULL, wxT( "Cannot build sheet list from undefined sheet." ) );
479 
480  if( aSheet == g_RootSheet )
481  m_isRootSheet = true;
482 
483  m_currentSheetPath.push_back( aSheet );
484 
490  m_currentSheetPath.SetPageNumber( size() + 1 );
491  push_back( m_currentSheetPath );
492 
493  if( aSheet->GetScreen() )
494  {
496 
497  while( item )
498  {
499  if( item->Type() == SCH_SHEET_T )
500  {
501  SCH_SHEET* sheet = (SCH_SHEET*) item;
502  BuildSheetList( sheet );
503  }
504 
505  item = item->Next();
506  }
507  }
508 
510 }
511 
512 
514 {
515  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
516  {
517  if( (*it).LastScreen() && (*it).LastScreen()->IsModify() )
518  return true;
519  }
520 
521  return false;
522 }
523 
524 
526 {
527  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
528  {
529  if( (*it).LastScreen() )
530  (*it).LastScreen()->ClrModify();
531  }
532 }
533 
534 
536 {
537  // List of reference for power symbols
538  SCH_REFERENCE_LIST references;
539 
540  // Map of locked components (not used, but needed by Annotate()
541  SCH_MULTI_UNIT_REFERENCE_MAP lockedComponents;
542 
543  // Build the list of power components:
544  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
545  {
546  SCH_SHEET_PATH& spath = *it;
547 
548  for( EDA_ITEM* item = spath.LastDrawList(); item; item = item->Next() )
549  {
550  if( item->Type() != SCH_COMPONENT_T )
551  continue;
552 
553  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
554  LIB_PART* part = component->GetPartRef().get();
555 
556  if( !part || !part->IsPower() )
557  continue;
558 
559  if( part )
560  {
561  SCH_REFERENCE schReference( component, part, spath );
562  references.AddItem( schReference );
563  }
564  }
565  }
566 
567  // Find duplicate, and silently clear annotation of duplicate
568  std::map<wxString, int> ref_list; // stores the existing references
569 
570  for( unsigned ii = 0; ii< references.GetCount(); ++ii )
571  {
572  wxString curr_ref = references[ii].GetRef();
573 
574  if( ref_list.find( curr_ref ) == ref_list.end() )
575  {
576  ref_list[curr_ref] = ii;
577  continue;
578  }
579 
580  // Possible duplicate, if the ref ends by a number:
581  if( curr_ref.Last() < '0' && curr_ref.Last() > '9' )
582  continue; // not annotated
583 
584  // Duplicate: clear annotation by removing the number ending the ref
585  while( curr_ref.Last() >= '0' && curr_ref.Last() <= '9' )
586  curr_ref.RemoveLast();
587 
588  references[ii].SetRef( curr_ref );
589  }
590 
591 
592  // Break full components reference in name (prefix) and number:
593  // example: IC1 become IC, and 1
594  references.SplitReferences();
595 
596  // Ensure all power symbols have the reference starting by '#'
597  // (No sure this is really useful)
598  for( unsigned ii = 0; ii< references.GetCount(); ++ii )
599  {
600  if( references[ii].GetRef()[0] != '#' )
601  {
602  wxString new_ref = "#" + references[ii].GetRef();
603  references[ii].SetRef( new_ref );
604  }
605  }
606 
607  // Recalculate and update reference numbers in schematic
608  references.Annotate( false, 0, 100, lockedComponents );
609  references.UpdateAnnotation();
610 }
611 
612 
613 void SCH_SHEET_LIST::GetComponents( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols,
614  bool aForceIncludeOrphanComponents )
615 {
616  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
617  (*it).GetComponents( aReferences, aIncludePowerSymbols, aForceIncludeOrphanComponents );
618 }
619 
621  bool aIncludePowerSymbols )
622 {
623  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
624  {
626  (*it).GetMultiUnitComponents( tempMap );
627 
628  for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
629  {
630  // Merge this list into the main one
631  unsigned n_refs = pair.second.GetCount();
632 
633  for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
634  {
635  aRefList[pair.first].AddItem( pair.second[thisRef] );
636  }
637  }
638  }
639 }
640 
641 
643  SCH_ITEM* aLastItem, bool aWrap )
644 {
645  bool hasWrapped = false;
646  bool firstItemFound = false;
647 
648  SCH_ITEM* drawItem = NULL;
649  SCH_SHEET_PATHS_ITER it = begin();
650 
651  while( it != end() )
652  {
653  drawItem = (*it).LastDrawList();
654 
655  while( drawItem )
656  {
657  if( drawItem->Type() == aType )
658  {
659  if( aLastItem == NULL || firstItemFound )
660  {
661  if( aSheetFoundIn )
662  *aSheetFoundIn = &(*it);
663 
664  return drawItem;
665  }
666  else if( !firstItemFound && drawItem == aLastItem )
667  {
668  firstItemFound = true;
669  }
670  }
671 
672  drawItem = drawItem->Next();
673  }
674 
675  ++it;
676 
677  if( it == end() && aLastItem && aWrap && !hasWrapped )
678  {
679  hasWrapped = true;
680  it = begin();
681  }
682  }
683 
684  return NULL;
685 }
686 
687 
689  SCH_ITEM* aLastItem, bool aWrap )
690 {
691  bool hasWrapped = false;
692  bool firstItemFound = false;
693  SCH_ITEM* drawItem = NULL;
694  SCH_SHEET_PATHS_RITER it = rbegin();
695 
696  while( it != rend() )
697  {
698  drawItem = (*it).FirstDrawList();
699 
700  while( drawItem )
701  {
702  if( drawItem->Type() == aType )
703  {
704  if( aLastItem == NULL || firstItemFound )
705  {
706  if( aSheetFoundIn )
707  *aSheetFoundIn = &(*it);
708 
709  return drawItem;
710  }
711  else if( !firstItemFound && drawItem == aLastItem )
712  {
713  firstItemFound = true;
714  }
715  }
716 
717  drawItem = drawItem->Back();
718  }
719 
720  ++it;
721 
722  if( it == rend() && aLastItem && aWrap && !hasWrapped )
723  {
724  hasWrapped = true;
725  it = rbegin();
726  }
727  }
728 
729  return NULL;
730 }
731 
732 
733 bool SCH_SHEET_LIST::SetComponentFootprint( const wxString& aReference,
734  const wxString& aFootPrint, bool aSetVisible )
735 {
736  bool found = false;
737 
738  for( SCH_SHEET_PATHS_ITER it = begin(); it != end(); ++it )
739  found = (*it).SetComponentFootprint( aReference, aFootPrint, aSetVisible );
740 
741  return found;
742 }
743 
744 
746 {
747  wxString fileName;
748 
749  for( unsigned i = 0; i < size(); i++ )
750  {
751  fileName = at( i ).Last()->GetFileName();
752 
753  for( unsigned j = 0; j < size(); j++ )
754  {
755  if( i == j )
756  continue;
757 
758  if( fileName == at( j ).Last()->GetFileName() )
759  return true;
760  }
761  }
762 
763  return false;
764 }
765 
766 
767 bool SCH_SHEET_LIST::TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
768  const wxString& aDestFileName ) const
769 {
770  wxFileName rootFn = g_RootSheet->GetFileName();
771  wxFileName destFn = aDestFileName;
772 
773  if( destFn.IsRelative() )
774  destFn.MakeAbsolute( rootFn.GetPath() );
775 
776  // Test each SCH_SHEET_PATH in this SCH_SHEET_LIST for potential recursion.
777  for( unsigned i = 0; i < size(); i++ )
778  {
779  // Test each SCH_SHEET_PATH in the source sheet.
780  for( unsigned j = 0; j < aSrcSheetHierarchy.size(); j++ )
781  {
782  const SCH_SHEET_PATH* sheetPath = &aSrcSheetHierarchy[j];
783 
784  for( unsigned k = 0; k < sheetPath->size(); k++ )
785  {
786  if( at( i ).TestForRecursion( sheetPath->GetSheet( k )->GetFileName(),
787  aDestFileName ) )
788  return true;
789  }
790  }
791  }
792 
793  // The source sheet file can safely be added to the destination sheet file.
794  return false;
795 }
796 
797 
798 SCH_SHEET* SCH_SHEET_LIST::FindSheetByName( const wxString& aSheetName )
799 {
800  for( unsigned i = 0; i < size(); i++ )
801  {
802  SCH_SHEET* sheet = at( i ).FindSheetByName( aSheetName );
803 
804  if( sheet )
805  return sheet;
806  }
807 
808  return NULL;
809 }
810 
811 
813 {
814  for( SCH_SHEET_PATH& sheetpath : *this )
815  {
816  if( sheetpath.LastScreen() == aScreen )
817  return &sheetpath;
818  }
819 
820  return nullptr;
821 }
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.
void SetSheetNumber(int aSheetNumber)
Class SCH_SHEET_LIST.
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.
void UpdateUnit(int aUnit)
Change the unit number to aUnit without setting any internal flags.
SCH_SHEET_PATHS::iterator SCH_SHEET_PATHS_ITER
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
Definition: sch_item.h:153
bool operator==(const SCH_SHEET_PATH &d1) const
void SetPageNumber(int aPageNumber)
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
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:281
SCH_SHEET_PATH * FindSheetForScreen(SCH_SCREEN *aScreen)
Function FindSheetForScreen.
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:218
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
SCH_ITEM * Back() const
Definition: sch_item.h:154
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.
static wxString GetRootPathName(bool aUseShortName=true)
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:47
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:126
wxString GetName() const
Definition: sch_sheet.h:272
int GetUnitCount() const override
For items with units, return the number of units.
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:216
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.
std::unique_ptr< LIB_PART > & GetPartRef()
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.
#define _(s)
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:209
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:661
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:649
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:73
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
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...
Definition: sch_item.h:114
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:210
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.
Definition: sch_screen.cpp:867
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:152