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 <[email protected]>
6 * Copyright (C) 1992-2022 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
26#include <sch_screen.h>
27#include <sch_item.h>
28#include <sch_marker.h>
29#include <sch_label.h>
30#include <sch_reference_list.h>
31#include <symbol_library.h>
32#include <sch_sheet_path.h>
33#include <sch_symbol.h>
34#include <sch_sheet.h>
35#include <schematic.h>
36#include <template_fieldnames.h>
37#include <trace_helpers.h>
38
39#include <boost/functional/hash.hpp>
40#include <wx/filename.h>
41#include <wx/log.h>
42
43
49{
50public:
52 SCH_ITEM( nullptr, NOT_USED )
53 {}
54
55 wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override
56 {
57 return _( "(Deleted Item)" );
58 }
59
60 wxString GetClass() const override
61 {
62 return wxT( "DELETED_SHEET_ITEM" );
63 }
64
66 {
67 static DELETED_SHEET_ITEM* item = nullptr;
68
69 if( !item )
70 item = new DELETED_SHEET_ITEM();
71
72 return item;
73 }
74
75 // pure virtuals:
76 void SetPosition( const VECTOR2I& ) override {}
77 void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override {}
78 void Move( const VECTOR2I& aMoveVector ) override {}
79 void MirrorHorizontally( int aCenter ) override {}
80 void MirrorVertically( int aCenter ) override {}
81 void Rotate( const VECTOR2I& aCenter ) override {}
82
83#if defined(DEBUG)
84 void Show( int , std::ostream& ) const override {}
85#endif
86};
87
88
90 const SYMBOL_INSTANCE_REFERENCE& aRhs )
91{
92 wxCHECK( !aLhs.m_Path.empty() && !aRhs.m_Path.empty(), false );
93
94 return aLhs.m_Path[0] < aRhs.m_Path[0];
95}
96
97
98namespace std
99{
101 {
102 return path.GetCurrentHash();
103 }
104}
105
106
108{
110 m_current_hash = 0;
111}
112
113
115{
116 initFromOther( aOther );
117}
118
119
121{
122 initFromOther( aOther );
123 return *this;
124}
125
126
128{
129 SCH_SHEET_PATH retv = *this;
130
131 size_t size = aOther.size();
132
133 for( size_t i = 0; i < size; i++ )
134 retv.push_back( aOther.at( i ) );
135
136 return retv;
137}
138
139
141{
142 m_sheets = aOther.m_sheets;
145
146 // Note: don't copy m_recursion_test_cache as it is slow and we want SCH_SHEET_PATHS to be
147 // very fast to construct for use in the connectivity algorithm.
148}
149
150
152{
153 // The root sheet path is empty. All other sheet paths must start with the root sheet path.
154 return ( m_sheets.size() == 0 ) || ( GetSheet( 0 )->IsRootSheet() );
155}
156
157
159{
160 m_current_hash = 0;
161
162 for( SCH_SHEET* sheet : m_sheets )
163 boost::hash_combine( m_current_hash, sheet->m_Uuid.Hash() );
164}
165
166
167int SCH_SHEET_PATH::Cmp( const SCH_SHEET_PATH& aSheetPathToTest ) const
168{
169 if( size() > aSheetPathToTest.size() )
170 return 1;
171
172 if( size() < aSheetPathToTest.size() )
173 return -1;
174
175 //otherwise, same number of sheets.
176 for( unsigned i = 0; i < size(); i++ )
177 {
178 if( at( i )->m_Uuid < aSheetPathToTest.at( i )->m_Uuid )
179 return -1;
180
181 if( at( i )->m_Uuid != aSheetPathToTest.at( i )->m_Uuid )
182 return 1;
183 }
184
185 return 0;
186}
187
188
189int SCH_SHEET_PATH::ComparePageNum( const SCH_SHEET_PATH& aSheetPathToTest ) const
190{
191 wxString pageA = this->GetPageNumber();
192 wxString pageB = aSheetPathToTest.GetPageNumber();
193
194 int pageNumComp = SCH_SHEET::ComparePageNum( pageA, pageB );
195
196 if( pageNumComp == 0 )
197 {
198 int virtualPageA = GetVirtualPageNumber();
199 int virtualPageB = aSheetPathToTest.GetVirtualPageNumber();
200
201 if( virtualPageA > virtualPageB )
202 pageNumComp = 1;
203 else if( virtualPageA < virtualPageB )
204 pageNumComp = -1;
205 }
206
207 return pageNumComp;
208}
209
210
211bool SCH_SHEET_PATH::IsContainedWithin( const SCH_SHEET_PATH& aSheetPathToTest ) const
212{
213 if( aSheetPathToTest.size() > size() )
214 return false;
215
216 for( size_t i = 0; i < aSheetPathToTest.size(); ++i )
217 {
218 if( at( i )->m_Uuid != aSheetPathToTest.at( i )->m_Uuid )
219 {
220 wxLogTrace( traceSchSheetPaths, "Sheet path '%s' is not within path '%s'.",
221 aSheetPathToTest.Path().AsString(), Path().AsString() );
222
223 return false;
224 }
225 }
226
227 wxLogTrace( traceSchSheetPaths, "Sheet path '%s' is within path '%s'.",
228 aSheetPathToTest.Path().AsString(), Path().AsString() );
229
230 return true;
231}
232
233
235{
236 if( !empty() )
237 return m_sheets.back();
238
239 return nullptr;
240}
241
242
244{
245 SCH_SHEET* lastSheet = Last();
246
247 if( lastSheet )
248 return lastSheet->GetScreen();
249
250 return nullptr;
251}
252
253
255{
256 SCH_SHEET* lastSheet = Last();
257
258 if( lastSheet )
259 return lastSheet->GetScreen();
260
261 return nullptr;
262}
263
264
266{
267 wxString s;
268
269 s = wxT( "/" ); // This is the root path
270
271 // Start at 1 to avoid the root sheet, which does not need to be added to the path.
272 // Its timestamp changes anyway.
273 for( unsigned i = 1; i < size(); i++ )
274 s += at( i )->m_Uuid.AsString() + "/";
275
276 return s;
277}
278
279
281{
283
284 for( const SCH_SHEET* sheet : m_sheets )
285 path.push_back( sheet->m_Uuid );
286
287 return path;
288}
289
290
291wxString SCH_SHEET_PATH::PathHumanReadable( bool aUseShortRootName ) const
292{
293 wxString s;
294
295 if( aUseShortRootName )
296 {
297 s = wxS( "/" ); // Use only the short name in netlists
298 }
299 else
300 {
301 wxString fileName;
302
303 if( !empty() && at( 0 )->GetScreen() )
304 fileName = at( 0 )->GetScreen()->GetFileName();
305
306 wxFileName fn = fileName;
307
308 s = fn.GetName() + wxS( "/" );
309 }
310
311 // Start at 1 since we've already processed the root sheet.
312 for( unsigned i = 1; i < size(); i++ )
313 s << at( i )->GetFields()[SHEETNAME].GetShownText() << wxS( "/" );
314
315 return s;
316}
317
318
320{
321 std::vector<SCH_ITEM*> items;
322
323 std::copy_if( LastScreen()->Items().begin(), LastScreen()->Items().end(),
324 std::back_inserter( items ),
325 []( SCH_ITEM* aItem )
326 {
327 return ( aItem->Type() == SCH_SYMBOL_T || aItem->Type() == SCH_GLOBAL_LABEL_T );
328 } );
329
330 for( SCH_ITEM* item : items )
331 {
332 if( item->Type() == SCH_SYMBOL_T )
333 {
334 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
335
336 symbol->GetField( REFERENCE_FIELD )->SetText( symbol->GetRef( this ) );
337 symbol->UpdateUnit( symbol->GetUnitSelection( this ) );
338 LastScreen()->Update( item );
339 }
340 else if( item->Type() == SCH_GLOBAL_LABEL_T )
341 {
342 SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( item );
343
344 if( label->GetFields().size() > 0 ) // Can be not the case when reading a old .sch schematic
345 {
346 SCH_FIELD& intersheetRefs = label->GetFields()[0];
347
348 intersheetRefs.SetVisible( label->Schematic()->Settings().m_IntersheetRefsShow );
349 LastScreen()->Update( &intersheetRefs );
350 }
351 }
352 }
353}
354
355
356
357void SCH_SHEET_PATH::GetSymbols( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols,
358 bool aForceIncludeOrphanSymbols ) const
359{
360 for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
361 {
362 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
363 AppendSymbol( aReferences, symbol, aIncludePowerSymbols, aForceIncludeOrphanSymbols );
364 }
365}
366
367
369 bool aIncludePowerSymbols,
370 bool aForceIncludeOrphanSymbols ) const
371{
372 // Skip pseudo-symbols, which have a reference starting with #. This mainly
373 // affects power symbols.
374 if( aIncludePowerSymbols || aSymbol->GetRef( this )[0] != wxT( '#' ) )
375 {
376 LIB_SYMBOL* symbol = aSymbol->GetLibSymbolRef().get();
377
378 if( symbol || aForceIncludeOrphanSymbols )
379 {
380 SCH_REFERENCE schReference( aSymbol, symbol, *this );
381
382 schReference.SetSheetNumber( m_virtualPageNumber );
383 aReferences.AddItem( schReference );
384 }
385 }
386}
387
388
390 bool aIncludePowerSymbols ) const
391{
392 for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
393 {
394 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
395 AppendMultiUnitSymbol( aRefList, symbol, aIncludePowerSymbols );
396 }
397}
398
399
401 SCH_SYMBOL* aSymbol,
402 bool aIncludePowerSymbols ) const
403{
404 // Skip pseudo-symbols, which have a reference starting with #. This mainly
405 // affects power symbols.
406 if( !aIncludePowerSymbols && aSymbol->GetRef( this )[0] == wxT( '#' ) )
407 return;
408
409 LIB_SYMBOL* symbol = aSymbol->GetLibSymbolRef().get();
410
411 if( symbol && symbol->GetUnitCount() > 1 )
412 {
413 SCH_REFERENCE schReference = SCH_REFERENCE( aSymbol, symbol, *this );
414 schReference.SetSheetNumber( m_virtualPageNumber );
415 wxString reference_str = schReference.GetRef();
416
417 // Never lock unassigned references
418 if( reference_str[reference_str.Len() - 1] == '?' )
419 return;
420
421 aRefList[reference_str].AddItem( schReference );
422 }
423}
424
425
427{
428 return m_current_hash == d1.GetCurrentHash();
429}
430
431
432bool SCH_SHEET_PATH::TestForRecursion( const wxString& aSrcFileName, const wxString& aDestFileName )
433{
434 auto pair = std::make_pair( aSrcFileName, aDestFileName );
435
436 if( m_recursion_test_cache.count( pair ) )
437 return m_recursion_test_cache.at( pair );
438
439 SCHEMATIC* sch = LastScreen()->Schematic();
440
441 wxCHECK_MSG( sch, false, "No SCHEMATIC found in SCH_SHEET_PATH::TestForRecursion!" );
442
443 wxFileName rootFn = sch->GetFileName();
444 wxFileName srcFn = aSrcFileName;
445 wxFileName destFn = aDestFileName;
446
447 if( srcFn.IsRelative() )
448 srcFn.MakeAbsolute( rootFn.GetPath() );
449
450 if( destFn.IsRelative() )
451 destFn.MakeAbsolute( rootFn.GetPath() );
452
453
454 // The source and destination sheet file names cannot be the same.
455 if( srcFn == destFn )
456 {
457 m_recursion_test_cache[pair] = true;
458 return true;
459 }
460
464 unsigned i = 0;
465
466 while( i < size() )
467 {
468 wxFileName cmpFn = at( i )->GetFileName();
469
470 if( cmpFn.IsRelative() )
471 cmpFn.MakeAbsolute( rootFn.GetPath() );
472
473 // Test if the file name of the destination sheet is in anywhere in this sheet path.
474 if( cmpFn == destFn )
475 break;
476
477 i++;
478 }
479
480 // The destination sheet file name was not found in the sheet path or the destination
481 // sheet file name is the root sheet so no recursion is possible.
482 if( i >= size() || i == 0 )
483 {
484 m_recursion_test_cache[pair] = false;
485 return false;
486 }
487
488 // Walk back up to the root sheet to see if the source file name is already a parent in
489 // the sheet path. If so, recursion will occur.
490 do
491 {
492 i -= 1;
493
494 wxFileName cmpFn = at( i )->GetFileName();
495
496 if( cmpFn.IsRelative() )
497 cmpFn.MakeAbsolute( rootFn.GetPath() );
498
499 if( cmpFn == srcFn )
500 {
501 m_recursion_test_cache[pair] = true;
502 return true;
503 }
504
505 } while( i != 0 );
506
507 // The source sheet file name is not a parent of the destination sheet file name.
508 m_recursion_test_cache[pair] = false;
509 return false;
510}
511
512
514{
515 SCH_SHEET* sheet = Last();
516
517 wxCHECK( sheet, wxEmptyString );
518
519 SCH_SHEET_PATH tmpPath = *this;
520
521 tmpPath.pop_back();
522
523 return sheet->getPageNumber( tmpPath );
524}
525
526
527void SCH_SHEET_PATH::SetPageNumber( const wxString& aPageNumber )
528{
529 SCH_SHEET* sheet = Last();
530
531 wxCHECK( sheet, /* void */ );
532
533 SCH_SHEET_PATH tmpPath = *this;
534
535 tmpPath.pop_back();
536
537 sheet->AddInstance( tmpPath );
538 sheet->setPageNumber( tmpPath, aPageNumber );
539}
540
541
543{
544 for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
545 {
546 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
547
548 wxCHECK2( symbol, continue );
549
550 SYMBOL_INSTANCE_REFERENCE newSymbolInstance;
551 SCH_SHEET_PATH newSheetPath( aPrefixSheetPath );
552 SCH_SHEET_PATH currentSheetPath( *this );
553
554 // Remove the root sheet from this path.
555 currentSheetPath.m_sheets.erase( currentSheetPath.m_sheets.begin() );
556
557 // Prefix the new hierarchical path.
558 newSheetPath = newSheetPath + currentSheetPath;
559 newSymbolInstance.m_Path = newSheetPath.Path();
560
561 if( symbol->GetInstance( newSymbolInstance, Path() ) )
562 {
563 // Use an existing symbol instance for this path if it exists.
564 newSymbolInstance.m_Path = newSheetPath.Path();
565 symbol->AddHierarchicalReference( newSymbolInstance );
566 }
567 else if( !symbol->GetInstanceReferences().empty() )
568 {
569 // Use the first symbol instance if any symbol exists.
570 newSymbolInstance = symbol->GetInstanceReferences()[0];
571 newSymbolInstance.m_Path = newSheetPath.Path();
572 symbol->AddHierarchicalReference( newSymbolInstance );
573 }
574 else if( symbol->GetLibSymbolRef() )
575 {
576 // Fall back to library symbol reference prefix, value, and footprint fields and
577 // set the unit to 1 if the library symbol is valid.
578 newSymbolInstance.m_Reference = symbol->GetLibSymbolRef()->GetReferenceField().GetText();
579 newSymbolInstance.m_Reference += wxT( "?" );
580 newSymbolInstance.m_Unit = 1;
581 symbol->AddHierarchicalReference( newSymbolInstance );
582 }
583 else
584 {
585 // All hope is lost so set the reference to 'U' and the unit to 1.
586 newSymbolInstance.m_Reference += wxT( "U?" );
587 newSymbolInstance.m_Unit = 1;
588 symbol->AddHierarchicalReference( newSymbolInstance );
589 }
590 }
591}
592
593
595{
596 for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
597 {
598 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
599
600 wxCHECK2( symbol, continue );
601
602 SCH_SHEET_PATH fullSheetPath( aPrefixSheetPath );
603 SCH_SHEET_PATH currentSheetPath( *this );
604
605 // Prefix the hierarchical path of the symbol instance to be removed.
606 fullSheetPath = fullSheetPath + currentSheetPath;
607 symbol->RemoveInstance( fullSheetPath );
608 }
609}
610
611
613 int aNextVirtualPageNumber )
614{
615 int nextVirtualPageNumber = aNextVirtualPageNumber;
616
617 for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_SHEET_T ) )
618 {
619 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
620
621 wxCHECK2( sheet, continue );
622
623 SCH_SHEET_PATH newSheetPath( aPrefixSheetPath );
624 SCH_SHEET_PATH currentSheetPath( *this );
625
626 // Remove the root sheet from current sheet path.
627 currentSheetPath.m_sheets.erase( currentSheetPath.m_sheets.begin() );
628
629 // Prefix the new hierarchical path.
630 newSheetPath = newSheetPath + currentSheetPath;
631
632 wxString pageNumber;
633
634 pageNumber.Printf( wxT( "%d" ), nextVirtualPageNumber );
635 sheet->AddInstance( newSheetPath );
636 newSheetPath.SetVirtualPageNumber( nextVirtualPageNumber );
637 newSheetPath.SetPageNumber( pageNumber );
638 nextVirtualPageNumber += 1;
639 }
640
641 return nextVirtualPageNumber;
642}
643
644
646{
647 wxCHECK( m_sheets.size() > 1, /* void */ );
648
649 wxFileName sheetFileName = Last()->GetFileName();
650
651 // If the sheet file name is absolute, then the user requested is so don't make it relative.
652 if( sheetFileName.IsAbsolute() )
653 return;
654
655 SCH_SCREEN* screen = LastScreen();
656 SCH_SCREEN* parentScreen = m_sheets[ m_sheets.size() - 2 ]->GetScreen();
657
658 wxCHECK( screen && parentScreen, /* void */ );
659
660 wxFileName fileName = screen->GetFileName();
661 wxFileName parentFileName = parentScreen->GetFileName();
662
663 // SCH_SCREEN file names must be absolute. If they are not, someone set them incorrectly
664 // on load or on creation.
665 wxCHECK( fileName.IsAbsolute() && parentFileName.IsAbsolute(), /* void */ );
666
667 if( fileName.GetPath() == parentFileName.GetPath() )
668 {
669 Last()->SetFileName( fileName.GetFullName() );
670 }
671 else if( fileName.MakeRelativeTo( parentFileName.GetPath() ) )
672 {
673 Last()->SetFileName( fileName.GetFullPath() );
674 }
675 else
676 {
677 Last()->SetFileName( screen->GetFileName() );
678 }
679
680 wxLogTrace( tracePathsAndFiles,
681 wxT( "\n File name: '%s'"
682 "\n parent file name '%s',"
683 "\n sheet '%s' file name '%s'." ),
684 screen->GetFileName(), parentScreen->GetFileName(), PathHumanReadable(),
685 Last()->GetFileName() );
686}
687
688
689SCH_SHEET_LIST::SCH_SHEET_LIST( SCH_SHEET* aSheet, bool aCheckIntegrity )
690{
691 if( aSheet != nullptr )
692 {
693 BuildSheetList( aSheet, aCheckIntegrity );
694
695 if( aSheet->IsRootSheet() )
697 }
698}
699
700
701void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet, bool aCheckIntegrity )
702{
703 wxCHECK_RET( aSheet != nullptr, wxT( "Cannot build sheet list from undefined sheet." ) );
704
705 std::vector<SCH_SHEET*> badSheets;
706
708 m_currentSheetPath.SetVirtualPageNumber( static_cast<int>( size() ) + 1 );
709 push_back( m_currentSheetPath );
710
712 {
713 wxString parentFileName = aSheet->GetFileName();
714 std::vector<SCH_ITEM*> childSheets;
715 m_currentSheetPath.LastScreen()->GetSheets( &childSheets );
716
717 for( SCH_ITEM* item : childSheets )
718 {
719 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
720
721 if( aCheckIntegrity )
722 {
723 if( !m_currentSheetPath.TestForRecursion( sheet->GetFileName(), parentFileName ) )
724 BuildSheetList( sheet, true );
725 else
726 badSheets.push_back( sheet );
727 }
728 else
729 {
730 BuildSheetList( sheet, false );
731 }
732 }
733 }
734
735 if( aCheckIntegrity )
736 {
737 for( SCH_SHEET* sheet : badSheets )
738 {
741 }
742 }
743
745}
746
747
748void SCH_SHEET_LIST::SortByPageNumbers( bool aUpdateVirtualPageNums )
749{
750 std::sort( begin(), end(),
751 []( SCH_SHEET_PATH a, SCH_SHEET_PATH b ) -> bool
752 {
753 int retval = a.ComparePageNum( b );
754
755 if( retval < 0 )
756 return true;
757 else if( retval > 0 )
758 return false;
759 else
760 return a.GetCurrentHash() < b.GetCurrentHash();
761 } );
762
763 if( aUpdateVirtualPageNums )
764 {
765 int virtualPageNum = 1;
766
767 for( SCH_SHEET_PATH& sheet : *this )
768 {
769 sheet.SetVirtualPageNumber( virtualPageNum++ );
770 }
771 }
772}
773
774
775bool SCH_SHEET_LIST::NameExists( const wxString& aSheetName ) const
776{
777 for( const SCH_SHEET_PATH& sheet : *this )
778 {
779 if( sheet.Last()->GetName() == aSheetName )
780 return true;
781 }
782
783 return false;
784}
785
786
787bool SCH_SHEET_LIST::PageNumberExists( const wxString& aPageNumber ) const
788{
789 for( const SCH_SHEET_PATH& sheet : *this )
790 {
791 if( sheet.GetPageNumber() == aPageNumber )
792 return true;
793 }
794
795 return false;
796}
797
798
800{
801 for( const SCH_SHEET_PATH& sheet : *this )
802 {
803 if( sheet.LastScreen() && sheet.LastScreen()->IsContentModified() )
804 return true;
805 }
806
807 return false;
808}
809
810
812{
813 for( const SCH_SHEET_PATH& sheet : *this )
814 {
815 if( sheet.LastScreen() )
816 sheet.LastScreen()->SetContentModified( false );
817 }
818}
819
820
822{
823 for( const SCH_SHEET_PATH& sheet : *this )
824 {
825 SCH_SCREEN* screen = sheet.LastScreen();
826
827 for( SCH_ITEM* aItem : screen->Items() )
828 {
829 if( aItem->m_Uuid == aID )
830 {
831 if( aPathOut )
832 *aPathOut = sheet;
833
834 return aItem;
835 }
836
837 SCH_ITEM* childMatch = nullptr;
838
839 aItem->RunOnChildren(
840 [&]( SCH_ITEM* aChild )
841 {
842 if( aChild->m_Uuid == aID )
843 childMatch = aChild;
844 } );
845
846 if( childMatch )
847 {
848 if( aPathOut )
849 *aPathOut = sheet;
850
851 return childMatch;
852 }
853 }
854 }
855
856 // Not found; weak reference has been deleted.
858}
859
860
861void SCH_SHEET_LIST::FillItemMap( std::map<KIID, EDA_ITEM*>& aMap )
862{
863 for( const SCH_SHEET_PATH& sheet : *this )
864 {
865 SCH_SCREEN* screen = sheet.LastScreen();
866
867 for( SCH_ITEM* aItem : screen->Items() )
868 {
869 aMap[ aItem->m_Uuid ] = aItem;
870
871 aItem->RunOnChildren(
872 [&]( SCH_ITEM* aChild )
873 {
874 aMap[ aChild->m_Uuid ] = aChild;
875 } );
876 }
877 }
878}
879
880
882{
883 // List of reference for power symbols
884 SCH_REFERENCE_LIST references;
885 SCH_REFERENCE_LIST additionalreferences; // Todo: add as a parameter to this function
886
887 // Map of locked symbols (not used, but needed by Annotate()
888 SCH_MULTI_UNIT_REFERENCE_MAP lockedSymbols;
889
890 // Build the list of power symbols:
891 for( SCH_SHEET_PATH& sheet : *this )
892 {
893 for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
894 {
895 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
896 LIB_SYMBOL* libSymbol = symbol->GetLibSymbolRef().get();
897
898 if( libSymbol && libSymbol->IsPower() )
899 {
900 SCH_REFERENCE schReference( symbol, libSymbol, sheet );
901 references.AddItem( schReference );
902 }
903 }
904 }
905
906 // Find duplicate, and silently clear annotation of duplicate
907 std::map<wxString, int> ref_list; // stores the existing references
908
909 for( unsigned ii = 0; ii< references.GetCount(); ++ii )
910 {
911 wxString curr_ref = references[ii].GetRef();
912
913 if( ref_list.find( curr_ref ) == ref_list.end() )
914 {
915 ref_list[curr_ref] = ii;
916 continue;
917 }
918
919 // Possible duplicate, if the ref ends by a number:
920 if( curr_ref.Last() < '0' && curr_ref.Last() > '9' )
921 continue; // not annotated
922
923 // Duplicate: clear annotation by removing the number ending the ref
924 while( curr_ref.Last() >= '0' && curr_ref.Last() <= '9' )
925 curr_ref.RemoveLast();
926
927 references[ii].SetRef( curr_ref );
928 }
929
930 // Break full symbol reference into name (prefix) and number:
931 // example: IC1 become IC, and 1
932 references.SplitReferences();
933
934 // Ensure all power symbols have the reference starting by '#'
935 // (Not sure this is really useful)
936 for( unsigned ii = 0; ii< references.GetCount(); ++ii )
937 {
938 if( references[ii].GetRef()[0] != '#' )
939 {
940 wxString new_ref = "#" + references[ii].GetRef();
941 references[ii].SetRef( new_ref );
942 }
943 }
944
945 // Recalculate and update reference numbers in schematic
946 references.Annotate( false, 0, 100, lockedSymbols, additionalreferences );
947 references.UpdateAnnotation();
948}
949
950
951void SCH_SHEET_LIST::GetSymbols( SCH_REFERENCE_LIST& aReferences, bool aIncludePowerSymbols,
952 bool aForceIncludeOrphanSymbols ) const
953{
954 for( const SCH_SHEET_PATH& sheet : *this )
955 sheet.GetSymbols( aReferences, aIncludePowerSymbols, aForceIncludeOrphanSymbols );
956}
957
958
960 const SCH_SHEET_PATH& aSheetPath,
961 bool aIncludePowerSymbols,
962 bool aForceIncludeOrphanSymbols ) const
963{
964 for( const SCH_SHEET_PATH& sheet : *this )
965 {
966 if( sheet.IsContainedWithin( aSheetPath ) )
967 sheet.GetSymbols( aReferences, aIncludePowerSymbols, aForceIncludeOrphanSymbols );
968 }
969}
970
971
973 const SCH_SHEET_PATH& aSheetPath ) const
974{
975 for( const SCH_SHEET_PATH& sheet : *this )
976 {
977 if( sheet.IsContainedWithin( aSheetPath ) )
978 aSheets.push_back( sheet );
979 }
980}
981
982
983std::optional<SCH_SHEET_PATH> SCH_SHEET_LIST::GetSheetPathByKIIDPath( const KIID_PATH& aPath ) const
984{
985 for( const SCH_SHEET_PATH& sheet : *this )
986 {
987 if( sheet.Path() == aPath )
988 return SCH_SHEET_PATH( sheet );
989 }
990
991 return std::nullopt;
992}
993
994
996 bool aIncludePowerSymbols ) const
997{
998 for( SCH_SHEET_PATHS::const_iterator it = begin(); it != end(); ++it )
999 {
1001 ( *it ).GetMultiUnitSymbols( tempMap, aIncludePowerSymbols );
1002
1003 for( SCH_MULTI_UNIT_REFERENCE_MAP::value_type& pair : tempMap )
1004 {
1005 // Merge this list into the main one
1006 unsigned n_refs = pair.second.GetCount();
1007
1008 for( unsigned thisRef = 0; thisRef < n_refs; ++thisRef )
1009 aRefList[pair.first].AddItem( pair.second[thisRef] );
1010 }
1011 }
1012}
1013
1014
1015bool SCH_SHEET_LIST::TestForRecursion( const SCH_SHEET_LIST& aSrcSheetHierarchy,
1016 const wxString& aDestFileName )
1017{
1018 if( empty() )
1019 return false;
1020
1021 SCHEMATIC* sch = at( 0 ).LastScreen()->Schematic();
1022
1023 wxCHECK_MSG( sch, false, "No SCHEMATIC found in SCH_SHEET_LIST::TestForRecursion!" );
1024
1025 wxFileName rootFn = sch->GetFileName();
1026 wxFileName destFn = aDestFileName;
1027
1028 if( destFn.IsRelative() )
1029 destFn.MakeAbsolute( rootFn.GetPath() );
1030
1031 // Test each SCH_SHEET_PATH in this SCH_SHEET_LIST for potential recursion.
1032 for( unsigned i = 0; i < size(); i++ )
1033 {
1034 // Test each SCH_SHEET_PATH in the source sheet.
1035 for( unsigned j = 0; j < aSrcSheetHierarchy.size(); j++ )
1036 {
1037 const SCH_SHEET_PATH* sheetPath = &aSrcSheetHierarchy[j];
1038
1039 for( unsigned k = 0; k < sheetPath->size(); k++ )
1040 {
1041 if( at( i ).TestForRecursion( sheetPath->GetSheet( k )->GetFileName(),
1042 aDestFileName ) )
1043 {
1044 return true;
1045 }
1046 }
1047 }
1048 }
1049
1050 // The source sheet file can safely be added to the destination sheet file.
1051 return false;
1052}
1053
1054
1056{
1057 for( SCH_SHEET_PATH& path : *this )
1058 {
1059 if( path.Path() == aPath->Path() )
1060 return &path;
1061 }
1062
1063 return nullptr;
1064}
1065
1066
1068{
1069 for( SCH_SHEET_PATH& sheetpath : *this )
1070 {
1071 if( sheetpath.LastScreen() == aScreen )
1072 return &sheetpath;
1073 }
1074
1075 return nullptr;
1076}
1077
1078
1080{
1081 SCH_SHEET_LIST retval;
1082
1083 for( const SCH_SHEET_PATH& sheetpath : *this )
1084 {
1085 if( sheetpath.LastScreen() == aScreen )
1086 retval.push_back( sheetpath );
1087 }
1088
1089 return retval;
1090}
1091
1092
1094 const std::vector<SYMBOL_INSTANCE_REFERENCE>& aSymbolInstances )
1095{
1096 for( SCH_SHEET_PATH& sheetPath : *this )
1097 {
1098 for( SCH_ITEM* item : sheetPath.LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
1099 {
1100 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1101
1102 wxCHECK2( symbol, continue );
1103
1104 KIID_PATH sheetPathWithSymbolUuid = sheetPath.Path();
1105 sheetPathWithSymbolUuid.push_back( symbol->m_Uuid );
1106
1107 auto it = std::find_if( aSymbolInstances.begin(), aSymbolInstances.end(),
1108 [ sheetPathWithSymbolUuid ]( const SYMBOL_INSTANCE_REFERENCE& r ) -> bool
1109 {
1110 return sheetPathWithSymbolUuid == r.m_Path;
1111 } );
1112
1113 if( it == aSymbolInstances.end() )
1114 {
1115 wxLogTrace( traceSchSheetPaths, "No symbol instance found for symbol '%s'",
1116 sheetPathWithSymbolUuid.AsString() );
1117 continue;
1118 }
1119
1120 // Symbol instance paths are stored and looked up in memory with the root path so use
1121 // the full path here.
1122 symbol->AddHierarchicalReference( sheetPath.Path(), it->m_Reference, it->m_Unit );
1123 symbol->GetField( REFERENCE_FIELD )->SetText( it->m_Reference );
1124 symbol->SetValueFieldText( it->m_Value );
1125 symbol->SetFootprintFieldText( it->m_Footprint );
1126 symbol->UpdatePrefix();
1127 }
1128 }
1129}
1130
1131
1132void SCH_SHEET_LIST::UpdateSheetInstanceData( const std::vector<SCH_SHEET_INSTANCE>& aSheetInstances )
1133{
1134
1135 for( SCH_SHEET_PATH& path : *this )
1136 {
1137 SCH_SHEET* sheet = path.Last();
1138
1139 wxCHECK2( sheet && path.Last(), continue );
1140
1141 auto it = std::find_if( aSheetInstances.begin(), aSheetInstances.end(),
1142 [ path ]( const SCH_SHEET_INSTANCE& r ) -> bool
1143 {
1144 return path.Path() == r.m_Path;
1145 } );
1146
1147 if( it == aSheetInstances.end() )
1148 {
1149 wxLogTrace( traceSchSheetPaths, "No sheet instance found for path '%s'",
1150 path.Path().AsString() );
1151 continue;
1152 }
1153
1154 wxLogTrace( traceSchSheetPaths, "Setting sheet '%s' instance '%s' page number '%s'",
1155 ( sheet->GetName().IsEmpty() ) ? wxT( "root" ) : sheet->GetName(),
1156 path.Path().AsString(), it->m_PageNumber );
1157 path.SetPageNumber( it->m_PageNumber );
1158 }
1159}
1160
1161
1162std::vector<KIID_PATH> SCH_SHEET_LIST::GetPaths() const
1163{
1164 std::vector<KIID_PATH> paths;
1165
1166 for( const SCH_SHEET_PATH& sheetPath : *this )
1167 paths.emplace_back( sheetPath.Path() );
1168
1169 return paths;
1170}
1171
1172
1173std::vector<SCH_SHEET_INSTANCE> SCH_SHEET_LIST::GetSheetInstances() const
1174{
1175 std::vector<SCH_SHEET_INSTANCE> retval;
1176
1177 for( const SCH_SHEET_PATH& path : *this )
1178 {
1179 const SCH_SHEET* sheet = path.Last();
1180
1181 wxCHECK2( sheet, continue );
1182
1183 SCH_SHEET_INSTANCE instance;
1184 SCH_SHEET_PATH tmpPath = path;
1185
1186 tmpPath.pop_back();
1187 instance.m_Path = tmpPath.Path();
1188 instance.m_PageNumber = path.GetPageNumber();
1189
1190 retval.push_back( instance );
1191 }
1192
1193 return retval;
1194}
1195
1196
1198{
1199 for( const SCH_SHEET_PATH& instance : *this )
1200 {
1201 if( !instance.GetPageNumber().IsEmpty() )
1202 return false;
1203 }
1204
1205 return true;
1206}
1207
1208
1210{
1211 // Don't accidentally renumber existing sheets.
1212 wxCHECK( AllSheetPageNumbersEmpty(), /* void */ );
1213
1214 wxString tmp;
1215 int pageNumber = 1;
1216
1217 for( SCH_SHEET_PATH& instance : *this )
1218 {
1219 tmp.Printf( "%d", pageNumber );
1220 instance.SetPageNumber( tmp );
1221 pageNumber += 1;
1222 }
1223}
1224
1225
1227{
1228 for( SCH_SHEET_PATH& sheetPath : *this )
1229 sheetPath.AddNewSymbolInstances( aPrefixSheetPath );
1230}
1231
1232
1234{
1235 for( SCH_SHEET_PATH& sheetPath : *this )
1236 sheetPath.RemoveSymbolInstances( aPrefixSheetPath );
1237}
1238
1239
1241 int aLastVirtualPageNumber )
1242{
1243 int nextVirtualPageNumber = aLastVirtualPageNumber + 1;
1244
1245 for( SCH_SHEET_PATH& sheetPath : *this )
1246 nextVirtualPageNumber = sheetPath.AddNewSheetInstances( aPrefixSheetPath,
1247 nextVirtualPageNumber );
1248}
1249
1250
1252{
1253 int lastVirtualPageNumber = 1;
1254
1255 for( const SCH_SHEET_PATH& sheetPath : *this )
1256 {
1257 if( sheetPath.GetVirtualPageNumber() > lastVirtualPageNumber )
1258 lastVirtualPageNumber = sheetPath.GetVirtualPageNumber();
1259 }
1260
1261 return lastVirtualPageNumber;
1262}
1263
bool IsContentModified() const
Definition: base_screen.h:60
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
A singleton item of this class is returned for a weak reference that no longer exists.
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
wxString GetClass() const override
Return the class name.
void SetPosition(const VECTOR2I &) override
static DELETED_SHEET_ITEM * GetInstance()
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
const KIID m_Uuid
Definition: eda_item.h:494
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:217
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
wxString AsString() const
Definition: kiid.cpp:332
Definition: kiid.h:48
wxString AsString() const
Definition: kiid.cpp:251
Define a library symbol object.
Definition: lib_symbol.h:98
bool IsPower() const
Definition: lib_symbol.cpp:552
int GetUnitCount() const override
For items with units, return the number of units.
Holds all the data relating to one schematic.
Definition: schematic.h:61
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:166
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:172
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:50
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:112
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:444
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:90
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void Annotate(bool aUseSheetNum, int aSheetIntervalId, int aStartNumber, SCH_MULTI_UNIT_REFERENCE_MAP aLockedUnitMap, const SCH_REFERENCE_LIST &aAdditionalRefs, bool aStartAtCurrent=false)
Set the reference designators in the list that have not been annotated.
size_t GetCount() const
void SplitReferences()
Attempt to split all reference designators into a name (U) and number (1).
void AddItem(const SCH_REFERENCE &aItem)
void UpdateAnnotation()
Update the symbol references for the schematic project (or the current sheet).
A helper to define a symbol's reference designator in a schematic.
wxString GetRef() const
void SetSheetNumber(int aSheetNumber)
void Update(SCH_ITEM *aItem)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:265
bool Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:272
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
const wxString & GetFileName() const
Definition: sch_screen.h:144
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:92
void GetSheets(std::vector< SCH_ITEM * > *aItems) const
Similar to Items().OfType( SCH_SHEET_T ), but return the sheets in a deterministic order (L-R,...
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Fetch a SCH_ITEM by ID.
void GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the li...
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Fill an item cache for temporary use when many items need to be fetched.
SCH_SHEET_PATH m_currentSheetPath
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
bool NameExists(const wxString &aSheetName) const
std::vector< SCH_SHEET_INSTANCE > GetSheetInstances() const
Fetch the instance information for all of the sheets in the hiearchy.
void UpdateSheetInstanceData(const std::vector< SCH_SHEET_INSTANCE > &aSheetInstances)
Update all of the sheet instance information using aSheetInstances.
void SetInitialPageNumbers()
Set initial sheet page numbers.
void RemoveSymbolInstances(const SCH_SHEET_PATH &aPrefixSheetPath)
SCH_SHEET_LIST FindAllSheetsForScreen(const SCH_SCREEN *aScreen) const
Return a SCH_SHEET_LIST with a copy of all the SCH_SHEET_PATH using a particular screen.
bool AllSheetPageNumbersEmpty() const
Check all of the sheet instance for empty page numbers.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
bool IsModified() const
Check the entire hierarchy for any modifications.
void AnnotatePowerSymbols()
Silently annotate the not yet annotated power symbols of the entire hierarchy of the sheet path list.
SCH_SHEET_LIST(SCH_SHEET *aSheet=nullptr, bool aCheckIntegrity=false)
Construct a flattened list of SCH_SHEET_PATH objects from aSheet.
int GetLastVirtualPageNumber() const
SCH_SHEET_PATH * FindSheetForScreen(const SCH_SCREEN *aScreen)
Return a pointer to the first SCH_SHEET_PATH object (not necessarily the only one) using a particular...
bool PageNumberExists(const wxString &aPageNumber) const
std::optional< SCH_SHEET_PATH > GetSheetPathByKIIDPath(const KIID_PATH &aPath) const
Finds a SCH_SHEET_PATH that matches the provided KIID_PATH.
void AddNewSheetInstances(const SCH_SHEET_PATH &aPrefixSheetPath, int aLastVirtualPageNumber)
void UpdateSymbolInstanceData(const std::vector< SYMBOL_INSTANCE_REFERENCE > &aSymbolInstances)
Update all of the symbol instance information using aSymbolInstances.
std::vector< KIID_PATH > GetPaths() const
void AddNewSymbolInstances(const SCH_SHEET_PATH &aPrefixSheetPath)
Attempt to add new symbol instances for all symbols in this list of sheet paths prefixed with aPrefix...
void GetSymbolsWithinPath(SCH_REFERENCE_LIST &aReferences, const SCH_SHEET_PATH &aSheetPath, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets that are contained wi...
void BuildSheetList(SCH_SHEET *aSheet, bool aCheckIntegrity)
Build the list of sheets and their sheet path from aSheet.
void GetSheetsWithinPath(SCH_SHEET_PATHS &aSheets, const SCH_SHEET_PATH &aSheetPath) const
Add a SCH_SHEET_PATH object to aSheets for each sheet in the list that are contained within aSheetPat...
SCH_SHEET_PATH * FindSheetForPath(const SCH_SHEET_PATH *aPath)
Return a pointer to the first SCH_SHEET_PATH object (not necessarily the only one) matching the provi...
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName)
Test every SCH_SHEET_PATH in this SCH_SHEET_LIST to verify if adding the sheets stored in aSrcSheetHi...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void AppendMultiUnitSymbol(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, SCH_SYMBOL *aSymbol, bool aIncludePowerSymbols=true) const
Append a SCH_REFERENCE_LIST object to aRefList based on aSymbol, storing same-reference set of multi-...
const SCH_SHEET * GetSheet(unsigned aIndex) const
bool empty() const
Forwarded method from std::vector.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Adds SCH_REFERENCE object to aReferences for each symbol in the sheet.
int ComparePageNum(const SCH_SHEET_PATH &aSheetPathToTest) const
Compare sheets by their page number.
size_t GetCurrentHash() const
bool operator==(const SCH_SHEET_PATH &d1) const
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
bool TestForRecursion(const wxString &aSrcFileName, const wxString &aDestFileName)
Test the SCH_SHEET_PATH file names to check adding the sheet stored in the file aSrcFileName to the s...
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
bool IsFullPath() const
void AddNewSymbolInstances(const SCH_SHEET_PATH &aPrefixSheetPath)
Attempt to add new symbol instances for all symbols in this sheet path prefixed with aPrefixSheetPath...
void MakeFilePathRelativeToParentSheet()
Make the sheet file name relative to its parent sheet.
SCH_SCREEN * LastScreen()
int Cmp(const SCH_SHEET_PATH &aSheetPathToTest) const
Compare if this is the same sheet path as aSheetPathToTest.
void GetMultiUnitSymbols(SCH_MULTI_UNIT_REFERENCE_MAP &aRefList, bool aIncludePowerSymbols=true) const
Add a SCH_REFERENCE_LIST object to aRefList for each same-reference set of multi-unit parts in the sh...
void initFromOther(const SCH_SHEET_PATH &aOther)
wxString GetPageNumber() const
void RemoveSymbolInstances(const SCH_SHEET_PATH &aPrefixSheetPath)
bool IsContainedWithin(const SCH_SHEET_PATH &aSheetPathToTest) const
Check if this path is contained inside aSheetPathToTest.
int AddNewSheetInstances(const SCH_SHEET_PATH &aPrefixSheetPath, int aNextVirtualPageNumber)
std::vector< SCH_SHEET * > m_sheets
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
void SetVirtualPageNumber(int aPageNumber)
Set the sheet instance virtual page number.
void AppendSymbol(SCH_REFERENCE_LIST &aReferences, SCH_SYMBOL *aSymbol, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Append a SCH_REFERENCE object to aReferences based on aSymbol.
wxString PathHumanReadable(bool aUseShortRootName=true) const
Return the sheet path in a human readable form made from the sheet names.
std::map< std::pair< wxString, wxString >, bool > m_recursion_test_cache
Page numbers are maintained by the sheet load order.
wxString PathAsString() const
Return the path of time stamps which do not changes even when editing sheet parameters.
void SetPageNumber(const wxString &aPageNumber)
Set the sheet instance user definable page number.
SCH_SHEET_PATH & operator=(const SCH_SHEET_PATH &aOther)
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
SCH_SHEET_PATH operator+(const SCH_SHEET_PATH &aOther)
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
size_t size() const
Forwarded method from std::vector.
int GetVirtualPageNumber() const
void pop_back()
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:55
void SetFileName(const wxString &aFilename)
Definition: sch_sheet.h:306
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:300
bool IsRootSheet() const
Definition: sch_sheet.cpp:194
void setPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1252
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:91
wxString GetName() const
Definition: sch_sheet.h:101
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:104
static int ComparePageNum(const wxString &aPageNumberA, const wxString &aPageNumberB)
Compares page numbers of schematic sheets.
Definition: sch_sheet.cpp:1270
bool AddInstance(const SCH_SHEET_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Definition: sch_sheet.cpp:1205
wxString getPageNumber(const SCH_SHEET_PATH &aInstance) const
Return the sheet page number for aInstance.
Definition: sch_sheet.cpp:1231
Schematic symbol object.
Definition: sch_symbol.h:80
const std::vector< SYMBOL_INSTANCE_REFERENCE > & GetInstanceReferences()
Definition: sch_symbol.h:139
void UpdatePrefix()
Set the prefix based on the current reference designator.
Definition: sch_symbol.cpp:716
void UpdateUnit(int aUnit)
Change the unit number to aUnit without setting any internal flags.
Definition: sch_symbol.cpp:390
void RemoveInstance(const SCH_SHEET_PATH &aInstancePath)
Definition: sch_symbol.cpp:493
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:792
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:624
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:813
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:807
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
Definition: sch_symbol.cpp:522
bool GetInstance(SYMBOL_INSTANCE_REFERENCE &aInstance, const KIID_PATH &aSheetPath) const
Definition: sch_symbol.cpp:477
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:741
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:191
static bool empty(const wxTextEntryBase *aCtrl)
#define _(s)
E_SERIE r
Definition: eserie.cpp:41
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
static void hash_combine(std::size_t &seed)
This is a dummy function to take the final case of hash_combine below.
Definition: hash.h:34
_OUT_STRING AsString(const std::string &aString)
Definition: sexpr.h:131
Definition: bitmap.cpp:64
@ SHEETNAME
Definition: sch_sheet.h:43
bool SortSymbolInstancesByProjectUuid(const SYMBOL_INSTANCE_REFERENCE &aLhs, const SYMBOL_INSTANCE_REFERENCE &aRhs)
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::vector< SCH_SHEET_PATH > SCH_SHEET_PATHS
std::map< wxString, SCH_REFERENCE_LIST > SCH_MULTI_UNIT_REFERENCE_MAP
Container to map reference designators for multi-unit parts.
A simple container for sheet instance information.
A simple container for schematic symbol instance information.
size_t operator()(const SCH_SHEET_PATH &path) const
Definition for symbol library class.
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
wxLogTrace helper definitions.
@ SCH_SYMBOL_T
Definition: typeinfo.h:156
@ SCH_SHEET_T
Definition: typeinfo.h:158
@ NOT_USED
the 3d code uses this value
Definition: typeinfo.h:79
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:152