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...
 
void FixLegacyPowerSymbolMismatches ()
 Fix legacy power symbols that have mismatched value text fields and invisible power pin names. 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 661 of file sch_screen.h.

Constructor & Destructor Documentation

◆ SCH_SCREENS() [1/2]

SCH_SCREENS::SCH_SCREENS ( SCH_SHEET aSheet)

Definition at line 1636 of file sch_screen.cpp.

1637{
1638 m_index = 0;
1639 buildScreenList( aSheet );
1640}
unsigned int m_index
Definition: sch_screen.h:803
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 665 of file sch_screen.h.

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

◆ ~SCH_SCREENS()

SCH_SCREENS::~SCH_SCREENS ( )

Definition at line 1643 of file sch_screen.cpp.

1644{
1645}

Member Function Documentation

◆ addScreenToList()

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

Definition at line 1686 of file sch_screen.cpp.

1687{
1688 if( aScreen == nullptr )
1689 return;
1690
1691 for( const SCH_SCREEN* screen : m_screens )
1692 {
1693 if( screen == aScreen )
1694 return;
1695 }
1696
1697 m_screens.push_back( aScreen );
1698 m_sheets.push_back( aSheet );
1699}
std::vector< SCH_SHEET * > m_sheets
Definition: sch_screen.h:802
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:801

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 1987 of file sch_screen.cpp.

1988{
1989 SCH_SCREEN* first = GetFirst();
1990
1991 if( !first )
1992 return;
1993
1994 SCHEMATIC* sch = first->Schematic();
1995
1996 wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::BuildClientSheetPathList" );
1997
1998 for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1999 curr_screen->GetClientSheetPaths().clear();
2000
2001 for( SCH_SHEET_PATH& sheetpath : sch->GetSheets() )
2002 {
2003 SCH_SCREEN* used_screen = sheetpath.LastScreen();
2004
2005 // Search for the used_screen in list and add this unique sheet path:
2006 for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
2007 {
2008 if( used_screen == curr_screen )
2009 {
2010 curr_screen->GetClientSheetPaths().push_back( sheetpath );
2011 break;
2012 }
2013 }
2014 }
2015}
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:92
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_FIND_REPLACE_TOOL::FindNext(), and SCH_EDIT_FRAME::SaveProject().

◆ buildScreenList()

void SCH_SCREENS::buildScreenList ( SCH_SHEET aSheet)
private

Definition at line 1702 of file sch_screen.cpp.

1703{
1704 if( aSheet && aSheet->Type() == SCH_SHEET_T )
1705 {
1706 SCH_SCREEN* screen = aSheet->GetScreen();
1707
1708 wxCHECK_RET( screen, "No screen for aSheet" );
1709
1710 addScreenToList( screen, aSheet );
1711
1712 for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
1713 buildScreenList( static_cast<SCH_SHEET*>( item ) );
1714 }
1715}
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:57
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:106
@ 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 1960 of file sch_screen.cpp.

1961{
1962 wxString lhsLower;
1963 wxString rhsLower;
1964 wxFileName lhs;
1965 wxFileName rhs = aSchematicFileName;
1966
1967 wxCHECK( rhs.IsAbsolute(), false );
1968
1969 for( const SCH_SCREEN* screen : m_screens )
1970 {
1971 lhs = screen->GetFileName();
1972
1973 if( lhs.GetPath() != rhs.GetPath() )
1974 continue;
1975
1976 lhsLower = lhs.GetFullName().Lower();
1977 rhsLower = rhs.GetFullName().Lower();
1978
1979 if( lhsLower == rhsLower && lhs.GetFullName() != rhs.GetFullName() )
1980 return true;
1981 }
1982
1983 return false;
1984}

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 1923 of file sch_screen.cpp.

1924{
1925 SCH_SCREEN* screen;
1926 int cnt = 0;
1927
1928 for( screen = GetFirst(); screen; screen = GetNext() )
1929 {
1930 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1931 {
1932 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1933
1934 if( symbol->GetLibId().GetLibNickname() != aFrom )
1935 continue;
1936
1937 LIB_ID id = symbol->GetLibId();
1938 id.SetLibNickname( aTo );
1939 symbol->SetLibId( id );
1940 cnt++;
1941 }
1942 }
1943
1944 return cnt;
1945}
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:81
void SetLibId(const LIB_ID &aName)
Definition: sch_symbol.cpp:284
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:175
@ 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 1718 of file sch_screen.cpp.

1719{
1720 SCH_SCREEN* first = GetFirst();
1721
1722 if( !first )
1723 return;
1724
1725 SCHEMATIC* sch = first->Schematic();
1726
1727 wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::ClearAnnotationOfNewSheetPaths" );
1728
1729 // Clear the annotation for symbols inside new sheetpaths not already in aInitialSheetList
1730 SCH_SCREENS screensList( sch->Root() ); // The list of screens, shared by sheet paths
1731 screensList.BuildClientSheetPathList(); // build the shared by sheet paths, by screen
1732
1733 // Search for new sheet paths, not existing in aInitialSheetPathList
1734 // and existing in sheetpathList
1735 for( SCH_SHEET_PATH& sheetpath : sch->GetSheets() )
1736 {
1737 bool path_exists = false;
1738
1739 for( const SCH_SHEET_PATH& existing_sheetpath: aInitialSheetPathList )
1740 {
1741 if( existing_sheetpath.Path() == sheetpath.Path() )
1742 {
1743 path_exists = true;
1744 break;
1745 }
1746 }
1747
1748 if( !path_exists )
1749 {
1750 // A new sheet path is found: clear the annotation corresponding to this new path:
1751 SCH_SCREEN* curr_screen = sheetpath.LastScreen();
1752
1753 // Clear annotation and create the AR for this path, if not exists,
1754 // when the screen is shared by sheet paths.
1755 // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1756 // reference default value and takes the latest displayed value
1757 curr_screen->EnsureAlternateReferencesExist();
1758 curr_screen->ClearAnnotation( &sheetpath, false );
1759 }
1760 }
1761}
SCH_SHEET & Root() const
Definition: schematic.h:91
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:662
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 1802 of file sch_screen.cpp.

1803{
1804 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1805 {
1806 for( SCH_ITEM* item : screen->Items() )
1807 item->ClearEditFlags();
1808 }
1809}

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 1854 of file sch_screen.cpp.

1856{
1857 DeleteMarkers( aMarkerType, ERCE_UNSPECIFIED, aIncludeExclusions );
1858}
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 1812 of file sch_screen.cpp.

1813{
1814 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1815 {
1816 for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1817 {
1818 if( item == aMarker )
1819 {
1820 screen->DeleteItem( item );
1821 return;
1822 }
1823 }
1824 }
1825}
@ 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 1828 of file sch_screen.cpp.

1830{
1831 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1832 {
1833 std::vector<SCH_ITEM*> markers;
1834
1835 for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1836 {
1837 SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
1838 std::shared_ptr<RC_ITEM>rcItem = marker->GetRCItem();
1839
1840 if( marker->GetMarkerType() == aMarkerType
1841 && ( aErrorCode == ERCE_UNSPECIFIED || rcItem->GetErrorCode() == aErrorCode )
1842 && ( !marker->IsExcluded() || aIncludeExclusions ) )
1843 {
1844 markers.push_back( item );
1845 }
1846 }
1847
1848 for( SCH_ITEM* marker : markers )
1849 screen->DeleteItem( marker );
1850 }
1851}
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().

◆ FixLegacyPowerSymbolMismatches()

void SCH_SCREENS::FixLegacyPowerSymbolMismatches ( )

Fix legacy power symbols that have mismatched value text fields and invisible power pin names.

Definition at line 2025 of file sch_screen.cpp.

2026{
2027 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
2028 screen->FixLegacyPowerSymbolMismatches();
2029}

References GetFirst(), and GetNext().

Referenced by KI_TEST::LoadSchematic(), and EESCHEMA_HELPERS::LoadSchematic().

◆ GetCount()

size_t SCH_SCREENS::GetCount ( ) const
inline

Definition at line 667 of file sch_screen.h.

667{ return m_screens.size(); }

References m_screens.

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

◆ GetFirst()

SCH_SCREEN * SCH_SCREENS::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 1905 of file sch_screen.cpp.

1906{
1907 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1908 {
1909 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1910 {
1911 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1912 const UTF8& nickname = symbol->GetLibId().GetLibNickname();
1913
1914 if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1915 aLibNicknames.Add( nickname );
1916 }
1917 }
1918
1919 return aLibNicknames.GetCount();
1920}
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()

SCH_SCREEN * SCH_SCREENS::GetNext ( )

Definition at line 1659 of file sch_screen.cpp.

1660{
1661 if( m_index < m_screens.size() )
1662 m_index++;
1663
1664 return GetScreen( m_index );
1665}
SCH_SCREEN * GetScreen(unsigned int aIndex) const

References GetScreen(), m_index, and m_screens.

Referenced by SCH_EDIT_FRAME::AskToSaveChanges(), DIALOG_SYMBOL_REMAP::backupProject(), BuildClientSheetPathList(), ChangeSymbolLibNickname(), ClearEditFlags(), SCH_EDIT_FRAME::CreateArchiveLibrary(), DeleteMarker(), DeleteMarkers(), SCH_EDIT_FRAME::doCloseWindow(), SCH_FIND_REPLACE_TOOL::FindNext(), FixLegacyPowerSymbolMismatches(), GetLibNicknames(), getSymbols(), HasNoFullyDefinedLibIds(), HasSchematic(), KI_TEST::SCHEMATIC_TEST_FIXTURE::LoadSchematic(), KI_TEST::LoadSchematic(), EESCHEMA_HELPERS::LoadSchematic(), DIALOG_EESCHEMA_PAGE_SETTINGS::onSavePageSettings(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH::readSchematicFromFile(), SCHEMATIC::RecomputeIntersheetRefs(), DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable(), SCH_FIND_REPLACE_TOOL::ReplaceAll(), SCH_EDITOR_CONTROL::Revert(), SetLegacySymbolInstanceData(), SCHEMATIC::SetSheetNumberAndCount(), ERC_TESTER::TestConflictingBusAliases(), ERC_TESTER::TestDuplicateSheetNames(), ERC_TESTER::TestLibSymbolIssues(), TEST_NETLIST_EXPORTER_FIXTURE< NETLIST_EXPORTER_KICAD >::TestNetlist(), ERC_TESTER::TestOffGridEndpoints(), PANEL_SETUP_BUSES::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), PANEL_SETUP_BUSES::TransferDataToWindow(), and UpdateSymbolLinks().

◆ GetScreen()

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

Definition at line 1668 of file sch_screen.cpp.

1669{
1670 if( aIndex < m_screens.size() )
1671 return m_screens[ aIndex ];
1672
1673 return nullptr;
1674}

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 1677 of file sch_screen.cpp.

1678{
1679 if( aIndex < m_sheets.size() )
1680 return m_sheets[ aIndex ];
1681
1682 return nullptr;
1683}

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 1884 of file sch_screen.cpp.

1885{
1886 bool has_symbols = false;
1887
1888 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1889 {
1890 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1891 {
1892 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1893 has_symbols = true;
1894
1895 if( !symbol->GetLibId().GetLibNickname().empty() )
1896 return false;
1897 }
1898 }
1899
1900 // return true (i.e. has no fully defined symbol) only if at least one symbol is found
1901 return has_symbols ? true : false;
1902}

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 1948 of file sch_screen.cpp.

1949{
1950 for( const SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1951 {
1952 if( screen->GetFileName() == aSchematicFileName )
1953 return true;
1954 }
1955
1956 return false;
1957}

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 1764 of file sch_screen.cpp.

1765{
1766 std::vector<SCH_ITEM*> items;
1767 int count = 0;
1768
1769 auto timestamp_cmp = []( const EDA_ITEM* a, const EDA_ITEM* b ) -> bool
1770 {
1771 return a->m_Uuid < b->m_Uuid;
1772 };
1773
1774 std::set<EDA_ITEM*, decltype( timestamp_cmp )> unique_stamps( timestamp_cmp );
1775
1776 for( SCH_SCREEN* screen : m_screens )
1777 screen->GetHierarchicalItems( &items );
1778
1779 if( items.size() < 2 )
1780 return 0;
1781
1782 for( EDA_ITEM* item : items )
1783 {
1784 if( !unique_stamps.insert( item ).second )
1785 {
1786 // Reset to fully random UUID. This may lose reference, but better to be
1787 // deterministic about it rather than to have duplicate UUIDs with random
1788 // side-effects.
1789 const_cast<KIID&>( item->m_Uuid ) = KIID();
1790 count++;
1791
1792 // @todo If the item is a sheet, we need to decend the heirarchy from the sheet
1793 // and repace all instances of the changed UUID in sheet paths. Otherwise,
1794 // all instance paths with the sheet's UUID will get clobbered.
1795 }
1796 }
1797
1798 return count;
1799}
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:492
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 2018 of file sch_screen.cpp.

2019{
2020 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
2021 screen->SetLegacySymbolInstanceData();
2022}

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 1861 of file sch_screen.cpp.

1862{
1863 for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1864 screen->UpdateSymbolLinks( aReporter );
1865
1866 SCH_SCREEN* first = GetFirst();
1867
1868 if( !first )
1869 return;
1870
1871 SCHEMATIC* sch = first->Schematic();
1872
1873 wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::UpdateSymbolLinks" );
1874
1875 SCH_SHEET_LIST sheets = sch->GetSheets();
1876
1877 // All of the library symbols have been replaced with copies so the connection graph
1878 // pointers are stale.
1879 if( sch->ConnectionGraph() )
1880 sch->ConnectionGraph()->Recalculate( sheets, true );
1881}
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:132
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 803 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 802 of file sch_screen.h.

Referenced by addScreenToList(), and GetSheet().


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