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...
 
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...
 

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 551 of file sch_screen.h.

Constructor & Destructor Documentation

◆ SCH_SCREENS() [1/2]

SCH_SCREENS::SCH_SCREENS ( SCH_SHEET aSheet)

Definition at line 1089 of file sch_screen.cpp.

1090 {
1091  m_index = 0;
1092  buildScreenList( aSheet );
1093 }
unsigned int m_index
Definition: sch_screen.h:680
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 555 of file sch_screen.h.

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

◆ ~SCH_SCREENS()

SCH_SCREENS::~SCH_SCREENS ( )

Definition at line 1096 of file sch_screen.cpp.

1097 {
1098 }

Member Function Documentation

◆ addScreenToList()

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

Definition at line 1139 of file sch_screen.cpp.

1140 {
1141  if( aScreen == NULL )
1142  return;
1143 
1144  for( const SCH_SCREEN* screen : m_screens )
1145  {
1146  if( screen == aScreen )
1147  return;
1148  }
1149 
1150  m_screens.push_back( aScreen );
1151  m_sheets.push_back( aSheet );
1152 }
std::vector< SCH_SHEET * > m_sheets
Definition: sch_screen.h:679
#define NULL
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:678

References m_screens, m_sheets, and NULL.

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

1425 {
1426  SCH_SCREEN* first = GetFirst();
1427 
1428  if( !first )
1429  return;
1430 
1431  SCHEMATIC* sch = first->Schematic();
1432 
1433  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::BuildClientSheetPathList" );
1434 
1435  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1436  curr_screen->GetClientSheetPaths().clear();
1437 
1438  for( SCH_SHEET_PATH& sheetpath : sch->GetSheets() )
1439  {
1440  SCH_SCREEN* used_screen = sheetpath.LastScreen();
1441 
1442  // SEarch for the used_screen in list and add this unique sheet path:
1443  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1444  {
1445  if( used_screen == curr_screen )
1446  {
1447  curr_screen->GetClientSheetPaths().push_back( sheetpath );
1448  break;
1449  }
1450  }
1451  }
1452 }
SCH_SCREEN * GetNext()
Holds all the data relating to one schematic.
Definition: schematic.h:59
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:90
std::vector< SCH_SHEET_PATH > & GetClientSheetPaths()
Return the number of times this screen is used.
Definition: sch_screen.h:163
SCH_SCREEN * GetFirst()

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

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

◆ buildScreenList()

void SCH_SCREENS::buildScreenList ( SCH_SHEET aSheet)
private

Definition at line 1155 of file sch_screen.cpp.

1156 {
1157  if( aSheet && aSheet->Type() == SCH_SHEET_T )
1158  {
1159  SCH_SCREEN* screen = aSheet->GetScreen();
1160 
1161  addScreenToList( screen, aSheet );
1162 
1163  for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
1164  buildScreenList( static_cast<SCH_SHEET*>( item ) );
1165  }
1166 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:216
void addScreenToList(SCH_SCREEN *aScreen, SCH_SHEET *aSheet)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
void buildScreenList(SCH_SHEET *aSheet)
EE_RTREE & Items()
Definition: sch_screen.h:102
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

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

Referenced by 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 1397 of file sch_screen.cpp.

1398 {
1399  wxString lhsLower;
1400  wxString rhsLower;
1401  wxFileName lhs;
1402  wxFileName rhs = aSchematicFileName;
1403 
1404  wxCHECK( rhs.IsAbsolute(), false );
1405 
1406  for( const SCH_SCREEN* screen : m_screens )
1407  {
1408  lhs = screen->GetFileName();
1409 
1410  if( lhs.GetPath() != rhs.GetPath() )
1411  continue;
1412 
1413  lhsLower = lhs.GetFullName().Lower();
1414  rhsLower = rhs.GetFullName().Lower();
1415 
1416  if( lhsLower == rhsLower && lhs.GetFullName() != rhs.GetFullName() )
1417  return true;
1418  }
1419 
1420  return false;
1421 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:678

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

1361 {
1362  SCH_SCREEN* screen;
1363  int cnt = 0;
1364 
1365  for( screen = GetFirst(); screen; screen = GetNext() )
1366  {
1367  for( auto item : screen->Items().OfType( SCH_SYMBOL_T ) )
1368  {
1369  auto symbol = static_cast<SCH_SYMBOL*>( item );
1370 
1371  if( symbol->GetLibId().GetLibNickname() != aFrom )
1372  continue;
1373 
1374  LIB_ID id = symbol->GetLibId();
1375  id.SetLibNickname( aTo );
1376  symbol->SetLibId( id );
1377  cnt++;
1378  }
1379  }
1380 
1381  return cnt;
1382 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:216
SCH_SCREEN * GetNext()
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:193
EE_RTREE & Items()
Definition: sch_screen.h:102
SCH_SCREEN * GetFirst()

References GetFirst(), GetNext(), SCH_SCREEN::Items(), EE_RTREE::OfType(), SCH_SYMBOL_T, 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 1169 of file sch_screen.cpp.

1170 {
1171  SCH_SCREEN* first = GetFirst();
1172 
1173  if( !first )
1174  return;
1175 
1176  SCHEMATIC* sch = first->Schematic();
1177 
1178  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::ClearAnnotationOfNewSheetPaths" );
1179 
1180  // Clear the annotation for symbols inside new sheetpaths not already in aInitialSheetList
1181  SCH_SCREENS screensList( sch->Root() ); // The list of screens, shared by sheet paths
1182  screensList.BuildClientSheetPathList(); // build the shared by sheet paths, by screen
1183 
1184  // Search for new sheet paths, not existing in aInitialSheetPathList
1185  // and existing in sheetpathList
1186  for( SCH_SHEET_PATH& sheetpath : sch->GetSheets() )
1187  {
1188  bool path_exists = false;
1189 
1190  for( const SCH_SHEET_PATH& existing_sheetpath: aInitialSheetPathList )
1191  {
1192  if( existing_sheetpath.Path() == sheetpath.Path() )
1193  {
1194  path_exists = true;
1195  break;
1196  }
1197  }
1198 
1199  if( !path_exists )
1200  {
1201  // A new sheet path is found: clear the annotation corresponding to this new path:
1202  SCH_SCREEN* curr_screen = sheetpath.LastScreen();
1203 
1204  // Clear annotation and create the AR for this path, if not exists,
1205  // when the screen is shared by sheet paths.
1206  // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1207  // reference default value and takes the latest displayed value
1208  curr_screen->EnsureAlternateReferencesExist();
1209  curr_screen->ClearAnnotation( &sheetpath );
1210  }
1211  }
1212 }
Holds all the data relating to one schematic.
Definition: schematic.h:59
void EnsureAlternateReferencesExist()
For screens shared by many sheetpaths (complex hierarchies): to be able to clear or modify any refere...
Definition: sch_screen.cpp:928
void BuildClientSheetPathList()
built the list of sheet paths sharing a screen for each screen in use
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
SCH_SHEET & Root() const
Definition: schematic.h:92
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:90
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the symbols in aSheetPath on the screen.
Definition: sch_screen.cpp:916
SCH_SCREEN * GetFirst()
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:551

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

Referenced by SCH_EDIT_TOOL::Properties().

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

1293 {
1294  DeleteMarkers( aMarkerType, ERCE_UNSPECIFIED, aIncludeExclusions );
1295 }
void DeleteMarkers(enum MARKER_BASE::TYPEMARKER aMarkerTyp, int aErrorCode, bool aIncludeExclusions=true)
Delete all markers of a particular type and error code.

References DeleteMarkers(), and ERCE_UNSPECIFIED.

Referenced by SHEETLIST_ERC_ITEMS_PROVIDER::DeleteAllItems().

◆ DeleteMarker()

void SCH_SCREENS::DeleteMarker ( SCH_MARKER aMarker)

Delete a specific marker.

Definition at line 1249 of file sch_screen.cpp.

1250 {
1251  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1252  {
1253  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1254  {
1255  if( item == aMarker )
1256  {
1257  screen->DeleteItem( item );
1258  return;
1259  }
1260  }
1261  }
1262 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197

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

1267 {
1268  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1269  {
1270  std::vector<SCH_ITEM*> markers;
1271 
1272  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1273  {
1274  SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
1275  std::shared_ptr<RC_ITEM>rcItem = marker->GetRCItem();
1276 
1277  if( marker->GetMarkerType() == aMarkerType
1278  && ( aErrorCode == ERCE_UNSPECIFIED || rcItem->GetErrorCode() == aErrorCode )
1279  && ( !marker->IsExcluded() || aIncludeExclusions ) )
1280  {
1281  markers.push_back( item );
1282  }
1283  }
1284 
1285  for( SCH_ITEM* marker : markers )
1286  screen->DeleteItem( marker );
1287  }
1288 }
SCH_SCREEN * GetNext()
bool IsExcluded() const
Definition: marker_base.h:94
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:92
SCH_SCREEN * GetFirst()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
std::shared_ptr< RC_ITEM > GetRCItem() const
Definition: marker_base.h:100

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 557 of file sch_screen.h.

557 { return m_screens.size(); }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:678

References m_screens.

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

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

1343 {
1344  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1345  {
1346  for( auto item : screen->Items().OfType( SCH_SYMBOL_T ) )
1347  {
1348  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1349  const UTF8& nickname = symbol->GetLibId().GetLibNickname();
1350 
1351  if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1352  aLibNicknames.Add( nickname );
1353  }
1354  }
1355 
1356  return aLibNicknames.GetCount();
1357 }
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:70
SCH_SCREEN * GetNext()
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:92
Schematic symbol object.
Definition: sch_symbol.h:78
SCH_SCREEN * GetFirst()
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:147
bool empty() const
Definition: utf8.h:103

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

◆ GetNext()

◆ GetScreen()

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

Definition at line 1121 of file sch_screen.cpp.

1122 {
1123  if( aIndex < m_screens.size() )
1124  return m_screens[ aIndex ];
1125 
1126  return NULL;
1127 }
#define NULL
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:678

References m_screens, and NULL.

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

◆ GetSheet()

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

Definition at line 1130 of file sch_screen.cpp.

1131 {
1132  if( aIndex < m_sheets.size() )
1133  return m_sheets[ aIndex ];
1134 
1135  return NULL;
1136 }
std::vector< SCH_SHEET * > m_sheets
Definition: sch_screen.h:679
#define NULL

References m_sheets, and NULL.

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

1322 {
1323  SCH_SCREEN* screen;
1324  unsigned cnt = 0;
1325 
1326  for( screen = GetFirst(); screen; screen = GetNext() )
1327  {
1328  for( auto item : screen->Items().OfType( SCH_SYMBOL_T ) )
1329  {
1330  cnt++;
1331  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1332 
1333  if( !symbol->GetLibId().GetLibNickname().empty() )
1334  return false;
1335  }
1336  }
1337 
1338  return cnt != 0;
1339 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:216
SCH_SCREEN * GetNext()
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:92
Schematic symbol object.
Definition: sch_symbol.h:78
EE_RTREE & Items()
Definition: sch_screen.h:102
SCH_SCREEN * GetFirst()
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:147
bool empty() const
Definition: utf8.h:103

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

Referenced by SCH_EDIT_FRAME::checkForNoFullyDefinedLibIds(), SCH_EDIT_FRAME::OpenProjectFiles(), 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 1385 of file sch_screen.cpp.

1386 {
1387  for( const SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1388  {
1389  if( screen->GetFileName() == aSchematicFileName )
1390  return true;
1391  }
1392 
1393  return false;
1394 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()

References GetFirst(), and GetNext().

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

1216 {
1217  std::vector<SCH_ITEM*> items;
1218  int count = 0;
1219 
1220  auto timestamp_cmp = []( const EDA_ITEM* a, const EDA_ITEM* b ) -> bool
1221  {
1222  return a->m_Uuid < b->m_Uuid;
1223  };
1224 
1225  std::set<EDA_ITEM*, decltype( timestamp_cmp )> unique_stamps( timestamp_cmp );
1226 
1227  for( SCH_SCREEN* screen : m_screens )
1228  screen->GetHierarchicalItems( &items );
1229 
1230  if( items.size() < 2 )
1231  return 0;
1232 
1233  for( EDA_ITEM* item : items )
1234  {
1235  if( !unique_stamps.insert( item ).second )
1236  {
1237  // Reset to fully random UUID. This may lose reference, but better to be
1238  // deterministic about it rather than to have duplicate UUIDs with random
1239  // side-effects.
1240  const_cast<KIID&>( item->m_Uuid ) = KIID();
1241  count++;
1242  }
1243  }
1244 
1245  return count;
1246 }
Definition: kiid.h:44
const KIID m_Uuid
Definition: eda_item.h:475
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:678
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100

References m_screens, and EDA_ITEM::m_Uuid.

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

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

1299 {
1300  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1301  screen->UpdateSymbolLinks( aReporter );
1302 
1303  SCH_SCREEN* first = GetFirst();
1304 
1305  if( !first )
1306  return;
1307 
1308  SCHEMATIC* sch = first->Schematic();
1309 
1310  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::UpdateSymbolLinks" );
1311 
1312  SCH_SHEET_LIST sheets = sch->GetSheets();
1313 
1314  // All of the library symbols have been replaced with copies so the connection graph
1315  // pointers are stale.
1316  if( sch->ConnectionGraph() )
1317  sch->ConnectionGraph()->Recalculate( sheets, true );
1318 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_SCREEN * GetNext()
Holds all the data relating to one schematic.
Definition: schematic.h:59
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:129
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.
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:90
SCH_SCREEN * GetFirst()

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

Referenced by SCH_ALTIUM_PLUGIN::Load(), SCH_EAGLE_PLUGIN::Load(), SCH_EDIT_FRAME::OpenProjectFiles(), 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 680 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 679 of file sch_screen.h.

Referenced by addScreenToList(), and GetSheet().


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