KiCad PCB EDA Suite
SCH_SCREENS Class Reference

Container class that holds multiple SCH_SCREEN objects in a hierarchy. More...

#include <sch_screen.h>

Public Member Functions

 SCH_SCREENS (SCH_SHEET *aSheet)
 
 SCH_SCREENS (SCH_SHEET &aSheet)
 
 ~SCH_SCREENS ()
 
size_t GetCount () const
 
SCH_SCREENGetFirst ()
 
SCH_SCREENGetNext ()
 
SCH_SCREENGetScreen (unsigned int aIndex) const
 
SCH_SHEETGetSheet (unsigned int aIndex) const
 
void ClearAnnotationOfNewSheetPaths (SCH_SHEET_LIST &aInitialSheetPathList)
 Clear the annotation for the symbols inside new sheetpaths when a complex hierarchy is modified and new sheetpaths added when a screen shares more than one sheet path, missing alternate references are added and alternate references of new sheet paths are cleared. More...
 
int ReplaceDuplicateTimeStamps ()
 Test all sheet and symbol objects in the schematic for duplicate time stamps and replaces them as necessary. More...
 
void DeleteAllMarkers (enum MARKER_BASE::TYPEMARKER aMarkerType, bool aIncludeExclusions)
 Delete all electronic rules check markers of aMarkerType from all the screens in the list. More...
 
void DeleteMarkers (enum MARKER_BASE::TYPEMARKER aMarkerTyp, int aErrorCode, bool aIncludeExclusions=true)
 Delete all markers of a particular type and error code. More...
 
void DeleteMarker (SCH_MARKER *aMarker)
 Delete a specific marker. More...
 
void UpdateSymbolLinks (REPORTER *aReporter=nullptr)
 Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in the full schematic. More...
 
void ClearEditFlags ()
 
bool HasNoFullyDefinedLibIds ()
 Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set. More...
 
size_t GetLibNicknames (wxArrayString &aLibNicknames)
 Fetch all of the symbol library nicknames into aLibNicknames. More...
 
int ChangeSymbolLibNickname (const wxString &aFrom, const wxString &aTo)
 Change all of the symbol library nicknames. More...
 
bool HasSchematic (const wxString &aSchematicFileName)
 Check if one of the schematics in the list of screens is aSchematicFileName. More...
 
void BuildClientSheetPathList ()
 built the list of sheet paths sharing a screen for each screen in use More...
 
bool CanCauseCaseSensitivityIssue (const wxString &aSchematicFileName) const
 Check aSchematicFileName for a potential file name case sensitivity issue. More...
 
void SetLegacySymbolInstanceData ()
 Update the symbol value and footprint instance data for legacy designs. More...
 

Private Member Functions

void addScreenToList (SCH_SCREEN *aScreen, SCH_SHEET *aSheet)
 
void buildScreenList (SCH_SHEET *aSheet)
 

Private Attributes

std::vector< SCH_SCREEN * > m_screens
 
std::vector< SCH_SHEET * > m_sheets
 
unsigned int m_index
 

Detailed Description

Container class that holds multiple SCH_SCREEN objects in a hierarchy.

Individual SCH_SCREEN objects are unique and correspond to .sch files.

NOTE: It may be desirable to fold the functionality of SCH_SCREENS into the new SCHEMATIC class at some point, since SCHEMATIC can also be thought of as owning the collection of all the SCH_SCREEN objects.

Definition at line 607 of file sch_screen.h.

Constructor & Destructor Documentation

◆ SCH_SCREENS() [1/2]

SCH_SCREENS::SCH_SCREENS ( SCH_SHEET aSheet)

Definition at line 1456 of file sch_screen.cpp.

1457{
1458 m_index = 0;
1459 buildScreenList( aSheet );
1460}
unsigned int m_index
Definition: sch_screen.h:743
void buildScreenList(SCH_SHEET *aSheet)

References buildScreenList(), and m_index.

◆ SCH_SCREENS() [2/2]

SCH_SCREENS::SCH_SCREENS ( SCH_SHEET aSheet)
inline

Definition at line 611 of file sch_screen.h.

611: SCH_SCREENS( &aSheet ) {}
SCH_SCREENS(SCH_SHEET *aSheet)

◆ ~SCH_SCREENS()

SCH_SCREENS::~SCH_SCREENS ( )

Definition at line 1463 of file sch_screen.cpp.

1464{
1465}

Member Function Documentation

◆ addScreenToList()

void SCH_SCREENS::addScreenToList ( SCH_SCREEN aScreen,
SCH_SHEET aSheet 
)
private

Definition at line 1506 of file sch_screen.cpp.

1507{
1508 if( aScreen == nullptr )
1509 return;
1510
1511 for( const SCH_SCREEN* screen : m_screens )
1512 {
1513 if( screen == aScreen )
1514 return;
1515 }
1516
1517 m_screens.push_back( aScreen );
1518 m_sheets.push_back( aSheet );
1519}
std::vector< SCH_SHEET * > m_sheets
Definition: sch_screen.h:742
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:741

References m_screens, and m_sheets.

Referenced by buildScreenList().

◆ BuildClientSheetPathList()

void SCH_SCREENS::BuildClientSheetPathList ( )

built the list of sheet paths sharing a screen for each screen in use

Definition at line 1807 of file sch_screen.cpp.

1808{
1809 SCH_SCREEN* first = GetFirst();
1810
1811 if( !first )
1812 return;
1813
1814 SCHEMATIC* sch = first->Schematic();
1815
1816 wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::BuildClientSheetPathList" );
1817
1818 for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1819 curr_screen->GetClientSheetPaths().clear();
1820
1821 for( SCH_SHEET_PATH& sheetpath : sch->GetSheets() )
1822 {
1823 SCH_SCREEN* used_screen = sheetpath.LastScreen();
1824
1825 // Search for the used_screen in list and add this unique sheet path:
1826 for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1827 {
1828 if( used_screen == curr_screen )
1829 {
1830 curr_screen->GetClientSheetPaths().push_back( sheetpath );
1831 break;
1832 }
1833 }
1834 }
1835}
Holds all the data relating to one schematic.
Definition: schematic.h:61
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:86
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
std::vector< SCH_SHEET_PATH > & GetClientSheetPaths()
Return the number of times this screen is used.
Definition: sch_screen.h:178
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:88
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...

References SCH_SCREEN::GetClientSheetPaths(), GetFirst(), GetNext(), SCHEMATIC::GetSheets(), and SCH_SCREEN::Schematic().

Referenced by ClearAnnotationOfNewSheetPaths(), SCH_EDITOR_CONTROL::FindNext(), and SCH_EDIT_FRAME::SaveProject().

◆ buildScreenList()

void SCH_SCREENS::buildScreenList ( SCH_SHEET aSheet)
private

Definition at line 1522 of file sch_screen.cpp.

1523{
1524 if( aSheet && aSheet->Type() == SCH_SHEET_T )
1525 {
1526 SCH_SCREEN* screen = aSheet->GetScreen();
1527
1528 wxCHECK_RET( screen, "No screen for aSheet" );
1529
1530 addScreenToList( screen, aSheet );
1531
1532 for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
1533 buildScreenList( static_cast<SCH_SHEET*>( item ) );
1534 }
1535}
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
void addScreenToList(SCH_SCREEN *aScreen, SCH_SHEET *aSheet)
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:55
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:104
@ SCH_SHEET_T
Definition: typeinfo.h:158

References addScreenToList(), buildScreenList(), SCH_SHEET::GetScreen(), SCH_SCREEN::Items(), EE_RTREE::OfType(), SCH_SHEET_T, and EDA_ITEM::Type().

Referenced by buildScreenList(), and SCH_SCREENS().

◆ CanCauseCaseSensitivityIssue()

bool SCH_SCREENS::CanCauseCaseSensitivityIssue ( const wxString &  aSchematicFileName) const

Check aSchematicFileName for a potential file name case sensitivity issue.

On platforms where file names are case sensitive, it is possible to schematic sheet file names that would cause issues on platforms where file name are case insensitive. File names foo.sch and Foo.sch are unique files on Linux and MacOS but on Windows this would result in a broken schematic.

Parameters
[in]aSchematicFileNameis the absolute path and file name of the file to test.
Returns
true if aSchematicFileName would cause an issue.

Definition at line 1780 of file sch_screen.cpp.

1781{
1782 wxString lhsLower;
1783 wxString rhsLower;
1784 wxFileName lhs;
1785 wxFileName rhs = aSchematicFileName;
1786
1787 wxCHECK( rhs.IsAbsolute(), false );
1788
1789 for( const SCH_SCREEN* screen : m_screens )
1790 {
1791 lhs = screen->GetFileName();
1792
1793 if( lhs.GetPath() != rhs.GetPath() )
1794 continue;
1795
1796 lhsLower = lhs.GetFullName().Lower();
1797 rhsLower = rhs.GetFullName().Lower();
1798
1799 if( lhsLower == rhsLower && lhs.GetFullName() != rhs.GetFullName() )
1800 return true;
1801 }
1802
1803 return false;
1804}

References m_screens.

Referenced by SCH_EDIT_FRAME::AllowCaseSensitiveFileNameClashes().

◆ ChangeSymbolLibNickname()

int SCH_SCREENS::ChangeSymbolLibNickname ( const wxString &  aFrom,
const wxString &  aTo 
)

Change all of the symbol library nicknames.

Parameters
[in]aFromthe current symbol library name to change.
[in]aTothe new symbol library name.
Returns
the number of symbol library nicknames that were changed.

Definition at line 1743 of file sch_screen.cpp.

1744{
1745 SCH_SCREEN* screen;
1746 int cnt = 0;
1747
1748 for( screen = GetFirst(); screen; screen = GetNext() )
1749 {
1750 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1751 {
1752 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1753
1754 if( symbol->GetLibId().GetLibNickname() != aFrom )
1755 continue;
1756
1757 LIB_ID id = symbol->GetLibId();
1758 id.SetLibNickname( aTo );
1759 symbol->SetLibId( id );
1760 cnt++;
1761 }
1762 }
1763
1764 return cnt;
1765}
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:98
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
Schematic symbol object.
Definition: sch_symbol.h:80
void SetLibId(const LIB_ID &aName)
Definition: sch_symbol.cpp:276
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:174
@ SCH_SYMBOL_T
Definition: typeinfo.h:156

References GetFirst(), SCH_SYMBOL::GetLibId(), LIB_ID::GetLibNickname(), GetNext(), SCH_SCREEN::Items(), EE_RTREE::OfType(), SCH_SYMBOL_T, SCH_SYMBOL::SetLibId(), and LIB_ID::SetLibNickname().

◆ ClearAnnotationOfNewSheetPaths()

void SCH_SCREENS::ClearAnnotationOfNewSheetPaths ( SCH_SHEET_LIST aInitialSheetPathList)

Clear the annotation for the symbols inside new sheetpaths when a complex hierarchy is modified and new sheetpaths added when a screen shares more than one sheet path, missing alternate references are added and alternate references of new sheet paths are cleared.

Parameters
aInitialSheetPathListis the initial sheet paths list of hierarchy before changes.

Definition at line 1538 of file sch_screen.cpp.

1539{
1540 SCH_SCREEN* first = GetFirst();
1541
1542 if( !first )
1543 return;
1544
1545 SCHEMATIC* sch = first->Schematic();
1546
1547 wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::ClearAnnotationOfNewSheetPaths" );
1548
1549 // Clear the annotation for symbols inside new sheetpaths not already in aInitialSheetList
1550 SCH_SCREENS screensList( sch->Root() ); // The list of screens, shared by sheet paths
1551 screensList.BuildClientSheetPathList(); // build the shared by sheet paths, by screen
1552
1553 // Search for new sheet paths, not existing in aInitialSheetPathList
1554 // and existing in sheetpathList
1555 for( SCH_SHEET_PATH& sheetpath : sch->GetSheets() )
1556 {
1557 bool path_exists = false;
1558
1559 for( const SCH_SHEET_PATH& existing_sheetpath: aInitialSheetPathList )
1560 {
1561 if( existing_sheetpath.Path() == sheetpath.Path() )
1562 {
1563 path_exists = true;
1564 break;
1565 }
1566 }
1567
1568 if( !path_exists )
1569 {
1570 // A new sheet path is found: clear the annotation corresponding to this new path:
1571 SCH_SCREEN* curr_screen = sheetpath.LastScreen();
1572
1573 // Clear annotation and create the AR for this path, if not exists,
1574 // when the screen is shared by sheet paths.
1575 // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1576 // reference default value and takes the latest displayed value
1577 curr_screen->EnsureAlternateReferencesExist();
1578 curr_screen->ClearAnnotation( &sheetpath, false );
1579 }
1580 }
1581}
SCH_SHEET & Root() const
Definition: schematic.h:91
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:608
void EnsureAlternateReferencesExist()
For screens shared by many sheetpaths (complex hierarchies): to be able to clear or modify any refere...
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear the annotation for the symbols in aSheetPath on the screen.

References BuildClientSheetPathList(), SCH_SCREEN::ClearAnnotation(), SCH_SCREEN::EnsureAlternateReferencesExist(), GetFirst(), SCHEMATIC::GetSheets(), SCHEMATIC::Root(), and SCH_SCREEN::Schematic().

Referenced by SCH_EDIT_TOOL::Properties().

◆ ClearEditFlags()

void SCH_SCREENS::ClearEditFlags ( )

Definition at line 1622 of file sch_screen.cpp.

1623{
1624 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1625 {
1626 for( SCH_ITEM* item : screen->Items() )
1627 item->ClearEditFlags();
1628 }
1629}

References GetFirst(), and GetNext().

Referenced by SCH_ALTIUM_PLUGIN::Load().

◆ DeleteAllMarkers()

void SCH_SCREENS::DeleteAllMarkers ( enum MARKER_BASE::TYPEMARKER  aMarkerType,
bool  aIncludeExclusions 
)

Delete all electronic rules check markers of aMarkerType from all the screens in the list.

Parameters
aMarkerTypeType of markers to be deleted.

Definition at line 1674 of file sch_screen.cpp.

1676{
1677 DeleteMarkers( aMarkerType, ERCE_UNSPECIFIED, aIncludeExclusions );
1678}
void DeleteMarkers(enum MARKER_BASE::TYPEMARKER aMarkerTyp, int aErrorCode, bool aIncludeExclusions=true)
Delete all markers of a particular type and error code.
@ ERCE_UNSPECIFIED
Definition: erc_settings.h:38

References DeleteMarkers(), and ERCE_UNSPECIFIED.

Referenced by DIALOG_ERC::deleteAllMarkers().

◆ DeleteMarker()

void SCH_SCREENS::DeleteMarker ( SCH_MARKER aMarker)

Delete a specific marker.

Definition at line 1632 of file sch_screen.cpp.

1633{
1634 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1635 {
1636 for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1637 {
1638 if( item == aMarker )
1639 {
1640 screen->DeleteItem( item );
1641 return;
1642 }
1643 }
1644 }
1645}
@ SCH_MARKER_T
Definition: typeinfo.h:141

References GetFirst(), GetNext(), and SCH_MARKER_T.

Referenced by SHEETLIST_ERC_ITEMS_PROVIDER::DeleteItem().

◆ DeleteMarkers()

void SCH_SCREENS::DeleteMarkers ( enum MARKER_BASE::TYPEMARKER  aMarkerTyp,
int  aErrorCode,
bool  aIncludeExclusions = true 
)

Delete all markers of a particular type and error code.

Definition at line 1648 of file sch_screen.cpp.

1650{
1651 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1652 {
1653 std::vector<SCH_ITEM*> markers;
1654
1655 for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1656 {
1657 SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
1658 std::shared_ptr<RC_ITEM>rcItem = marker->GetRCItem();
1659
1660 if( marker->GetMarkerType() == aMarkerType
1661 && ( aErrorCode == ERCE_UNSPECIFIED || rcItem->GetErrorCode() == aErrorCode )
1662 && ( !marker->IsExcluded() || aIncludeExclusions ) )
1663 {
1664 markers.push_back( item );
1665 }
1666 }
1667
1668 for( SCH_ITEM* marker : markers )
1669 screen->DeleteItem( marker );
1670 }
1671}
bool IsExcluded() const
Definition: marker_base.h:97
std::shared_ptr< RC_ITEM > GetRCItem() const
Definition: marker_base.h:105
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:95

References ERCE_UNSPECIFIED, GetFirst(), MARKER_BASE::GetMarkerType(), GetNext(), MARKER_BASE::GetRCItem(), MARKER_BASE::IsExcluded(), and SCH_MARKER_T.

Referenced by DeleteAllMarkers(), and DIALOG_ERC::OnERCItemRClick().

◆ GetCount()

size_t SCH_SCREENS::GetCount ( ) const
inline

Definition at line 613 of file sch_screen.h.

613{ return m_screens.size(); }

References m_screens.

Referenced by SCH_EDIT_FRAME::doAutoSave(), SCH_EDIT_FRAME::SaveProject(), and SCH_EDIT_FRAME::updateAutoSaveFile().

◆ GetFirst()

◆ GetLibNicknames()

size_t SCH_SCREENS::GetLibNicknames ( wxArrayString &  aLibNicknames)

Fetch all of the symbol library nicknames into aLibNicknames.

Parameters
[out]aLibNicknamesis the array to populate with all of the unique library nicknames.
Returns
the number of symbol library nicknames found.

Definition at line 1725 of file sch_screen.cpp.

1726{
1727 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1728 {
1729 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1730 {
1731 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1732 const UTF8& nickname = symbol->GetLibId().GetLibNickname();
1733
1734 if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1735 aLibNicknames.Add( nickname );
1736 }
1737 }
1738
1739 return aLibNicknames.GetCount();
1740}
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:71
bool empty() const
Definition: utf8.h:103

References UTF8::empty(), GetFirst(), SCH_SYMBOL::GetLibId(), LIB_ID::GetLibNickname(), GetNext(), and SCH_SYMBOL_T.

Referenced by SCH_EDIT_FRAME::LoadSheetFromFile().

◆ GetNext()

◆ GetScreen()

SCH_SCREEN * SCH_SCREENS::GetScreen ( unsigned int  aIndex) const

Definition at line 1488 of file sch_screen.cpp.

1489{
1490 if( aIndex < m_screens.size() )
1491 return m_screens[ aIndex ];
1492
1493 return nullptr;
1494}

References m_screens.

Referenced by SCH_EDIT_FRAME::doAutoSave(), GetNext(), SCH_EDIT_FRAME::SaveProject(), and SCH_EDIT_FRAME::updateAutoSaveFile().

◆ GetSheet()

SCH_SHEET * SCH_SCREENS::GetSheet ( unsigned int  aIndex) const

Definition at line 1497 of file sch_screen.cpp.

1498{
1499 if( aIndex < m_sheets.size() )
1500 return m_sheets[ aIndex ];
1501
1502 return nullptr;
1503}

References m_sheets.

Referenced by SCH_EDIT_FRAME::doAutoSave(), and SCH_EDIT_FRAME::SaveProject().

◆ HasNoFullyDefinedLibIds()

bool SCH_SCREENS::HasNoFullyDefinedLibIds ( )

Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.

If none of the LIB_ID object library nicknames are not set, this indicates that the project was created before the symbol library implementation.

Returns
true in there are any symbols and if all of the LIB_ID object library nicknames are empty, otherwise false.

Definition at line 1704 of file sch_screen.cpp.

1705{
1706 bool has_symbols = false;
1707
1708 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1709 {
1710 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1711 {
1712 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1713 has_symbols = true;
1714
1715 if( !symbol->GetLibId().GetLibNickname().empty() )
1716 return false;
1717 }
1718 }
1719
1720 // return true (i.e. has no fully defined symbol) only if at least one symbol is found
1721 return has_symbols ? true : false;
1722}

References UTF8::empty(), GetFirst(), SCH_SYMBOL::GetLibId(), LIB_ID::GetLibNickname(), GetNext(), and SCH_SYMBOL_T.

Referenced by SCH_EDIT_FRAME::checkForNoFullyDefinedLibIds(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDITOR_CONTROL::RescueSymbols(), and SCH_EDIT_FRAME::setupUIConditions().

◆ HasSchematic()

bool SCH_SCREENS::HasSchematic ( const wxString &  aSchematicFileName)

Check if one of the schematics in the list of screens is aSchematicFileName.

Schematic file names in SCH_SCREEN object are stored with the absolute path to the schematic file.

Parameters
[in]aSchematicFileNameis the schematic file name to search.
Returns
true if the a schematic matching the file name has been found.

Definition at line 1768 of file sch_screen.cpp.

1769{
1770 for( const SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1771 {
1772 if( screen->GetFileName() == aSchematicFileName )
1773 return true;
1774 }
1775
1776 return false;
1777}

References GetFirst(), and GetNext().

Referenced by SCH_EDIT_FRAME::LoadSheetFromFile().

◆ ReplaceDuplicateTimeStamps()

int SCH_SCREENS::ReplaceDuplicateTimeStamps ( )

Test all sheet and symbol objects in the schematic for duplicate time stamps and replaces them as necessary.

Time stamps must be unique in order for complex hierarchies know which symbols go to which sheets.

Returns
The number of duplicate time stamps replaced.

Definition at line 1584 of file sch_screen.cpp.

1585{
1586 std::vector<SCH_ITEM*> items;
1587 int count = 0;
1588
1589 auto timestamp_cmp = []( const EDA_ITEM* a, const EDA_ITEM* b ) -> bool
1590 {
1591 return a->m_Uuid < b->m_Uuid;
1592 };
1593
1594 std::set<EDA_ITEM*, decltype( timestamp_cmp )> unique_stamps( timestamp_cmp );
1595
1596 for( SCH_SCREEN* screen : m_screens )
1597 screen->GetHierarchicalItems( &items );
1598
1599 if( items.size() < 2 )
1600 return 0;
1601
1602 for( EDA_ITEM* item : items )
1603 {
1604 if( !unique_stamps.insert( item ).second )
1605 {
1606 // Reset to fully random UUID. This may lose reference, but better to be
1607 // deterministic about it rather than to have duplicate UUIDs with random
1608 // side-effects.
1609 const_cast<KIID&>( item->m_Uuid ) = KIID();
1610 count++;
1611
1612 // @todo If the item is a sheet, we need to decend the heirarchy from the sheet
1613 // and repace all instances of the changed UUID in sheet paths. Otherwise,
1614 // all instance paths with the sheet's UUID will get clobbered.
1615 }
1616 }
1617
1618 return count;
1619}
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
const KIID m_Uuid
Definition: eda_item.h:494
Definition: kiid.h:48

References m_screens, and EDA_ITEM::m_Uuid.

Referenced by SCH_EDIT_FRAME::AnnotateSymbols(), SCH_EDIT_FRAME::LoadSheetFromFile(), and SCH_EDIT_FRAME::OpenProjectFiles().

◆ SetLegacySymbolInstanceData()

void SCH_SCREENS::SetLegacySymbolInstanceData ( )

Update the symbol value and footprint instance data for legacy designs.

Definition at line 1838 of file sch_screen.cpp.

1839{
1840 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1841 screen->SetLegacySymbolInstanceData();
1842}

References GetFirst(), and GetNext().

Referenced by SCHEMATIC::SetLegacySymbolInstanceData().

◆ UpdateSymbolLinks()

void SCH_SCREENS::UpdateSymbolLinks ( REPORTER aReporter = nullptr)

Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in the full schematic.

Note
This should only be called when the user specifically requests all library symbol links to be update or when the legacy schematic is opened for the last time. All subsequent schematic loads with the new s-expression will contain the library symbols.
Parameters
[in]aReporterAn optional REPORTER object pointer to write warning and error messages into.

Definition at line 1681 of file sch_screen.cpp.

1682{
1683 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1684 screen->UpdateSymbolLinks( aReporter );
1685
1686 SCH_SCREEN* first = GetFirst();
1687
1688 if( !first )
1689 return;
1690
1691 SCHEMATIC* sch = first->Schematic();
1692
1693 wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::UpdateSymbolLinks" );
1694
1695 SCH_SHEET_LIST sheets = sch->GetSheets();
1696
1697 // All of the library symbols have been replaced with copies so the connection graph
1698 // pointers are stale.
1699 if( sch->ConnectionGraph() )
1700 sch->ConnectionGraph()->Recalculate( sheets, true );
1701}
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr)
Updates the connection graph for the given list of sheets.
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:130
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.

References SCHEMATIC::ConnectionGraph(), GetFirst(), GetNext(), SCHEMATIC::GetSheets(), CONNECTION_GRAPH::Recalculate(), and SCH_SCREEN::Schematic().

Referenced by SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile(), SCH_ALTIUM_PLUGIN::Load(), SCH_EAGLE_PLUGIN::Load(), SCH_EDIT_FRAME::OpenProjectFiles(), DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable(), SCH_EDITOR_CONTROL::rescueProject(), LEGACY_RESCUER::WriteRescueLibrary(), and SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary().

Member Data Documentation

◆ m_index

unsigned int SCH_SCREENS::m_index
private

Definition at line 743 of file sch_screen.h.

Referenced by GetFirst(), GetNext(), and SCH_SCREENS().

◆ m_screens

std::vector< SCH_SCREEN* > SCH_SCREENS::m_screens
private

◆ m_sheets

std::vector< SCH_SHEET* > SCH_SCREENS::m_sheets
private

Definition at line 742 of file sch_screen.h.

Referenced by addScreenToList(), and GetSheet().


The documentation for this class was generated from the following files: