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 components 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 component 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_PART reference for each SCH_COMPONENT found in the full schematic. More...
 
void TestDanglingEnds ()
 
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 nickames 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 515 of file sch_screen.h.

Constructor & Destructor Documentation

◆ SCH_SCREENS() [1/2]

SCH_SCREENS::SCH_SCREENS ( SCH_SHEET aSheet)

Definition at line 1120 of file sch_screen.cpp.

1121 {
1122  m_index = 0;
1123  buildScreenList( aSheet );
1124 }
unsigned int m_index
Definition: sch_screen.h:520
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 524 of file sch_screen.h.

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

◆ ~SCH_SCREENS()

SCH_SCREENS::~SCH_SCREENS ( )

Definition at line 1127 of file sch_screen.cpp.

1128 {
1129 }

Member Function Documentation

◆ addScreenToList()

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

Definition at line 1170 of file sch_screen.cpp.

1171 {
1172  if( aScreen == NULL )
1173  return;
1174 
1175  for( const SCH_SCREEN* screen : m_screens )
1176  {
1177  if( screen == aScreen )
1178  return;
1179  }
1180 
1181  m_screens.push_back( aScreen );
1182  m_sheets.push_back( aSheet );
1183 }
std::vector< SCH_SHEET * > m_sheets
Definition: sch_screen.h:519
#define NULL
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:518

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

1491 {
1492  SCH_SCREEN* first = GetFirst();
1493 
1494  if( !first )
1495  return;
1496 
1497  SCHEMATIC* sch = first->Schematic();
1498 
1499  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::BuildClientSheetPathList" );
1500 
1501  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1502  curr_screen->GetClientSheetPaths().clear();
1503 
1504  for( SCH_SHEET_PATH& sheetpath : sch->GetSheets() )
1505  {
1506  SCH_SCREEN* used_screen = sheetpath.LastScreen();
1507 
1508  // SEarch for the used_screen in list and add this unique sheet path:
1509  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1510  {
1511  if( used_screen == curr_screen )
1512  {
1513  curr_screen->GetClientSheetPaths().push_back( sheetpath );
1514  break;
1515  }
1516  }
1517  }
1518 }
SCH_SCREEN * GetNext()
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:89
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:42
SCH_SHEET_PATH.
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:91
std::vector< SCH_SHEET_PATH > & GetClientSheetPaths()
Definition: sch_screen.h:205
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 1186 of file sch_screen.cpp.

1187 {
1188  if( aSheet && aSheet->Type() == SCH_SHEET_T )
1189  {
1190  SCH_SCREEN* screen = aSheet->GetScreen();
1191 
1192  addScreenToList( screen, aSheet );
1193 
1194  for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
1195  buildScreenList( static_cast<SCH_SHEET*>( item ) );
1196  }
1197 }
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
void addScreenToList(SCH_SCREEN *aScreen, SCH_SHEET *aSheet)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:282
void buildScreenList(SCH_SHEET *aSheet)
EE_RTREE & Items()
Definition: sch_screen.h:158
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

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
aSchematicFileNameis the absolute path and file name of the file to test.
Returns
true if aSchematicFileName would cause an issue.

Definition at line 1463 of file sch_screen.cpp.

1464 {
1465  wxString lhsLower;
1466  wxString rhsLower;
1467  wxFileName lhs;
1468  wxFileName rhs = aSchematicFileName;
1469 
1470  wxCHECK( rhs.IsAbsolute(), false );
1471 
1472  for( const SCH_SCREEN* screen : m_screens )
1473  {
1474  lhs = screen->GetFileName();
1475 
1476  if( lhs.GetPath() != rhs.GetPath() )
1477  continue;
1478 
1479  lhsLower = lhs.GetFullName().Lower();
1480  rhsLower = rhs.GetFullName().Lower();
1481 
1482  if( lhsLower == rhsLower && lhs.GetFullName() != rhs.GetFullName() )
1483  return true;
1484  }
1485 
1486  return false;
1487 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:518

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
aFromthe current symbol library name to change.
aTothe new symbol library name.
Returns
the number of symbol library nicknames that were changed.

Definition at line 1426 of file sch_screen.cpp.

1427 {
1428  SCH_SCREEN* screen;
1429  int cnt = 0;
1430 
1431  for( screen = GetFirst(); screen; screen = GetNext() )
1432  {
1433  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
1434  {
1435  auto symbol = static_cast<SCH_COMPONENT*>( item );
1436 
1437  if( symbol->GetLibId().GetLibNickname() != aFrom )
1438  continue;
1439 
1440  LIB_ID id = symbol->GetLibId();
1441  id.SetLibNickname( aTo );
1442  symbol->SetLibId( id );
1443  cnt++;
1444  }
1445  }
1446 
1447  return cnt;
1448 }
SCH_SCREEN * GetNext()
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
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:158
SCH_SCREEN * GetFirst()

References GetFirst(), GetNext(), SCH_SCREEN::Items(), EE_RTREE::OfType(), SCH_COMPONENT_T, and LIB_ID::SetLibNickname().

◆ ClearAnnotationOfNewSheetPaths()

void SCH_SCREENS::ClearAnnotationOfNewSheetPaths ( SCH_SHEET_LIST aInitialSheetPathList)

Clear the annotation for the components 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 1200 of file sch_screen.cpp.

1201 {
1202  SCH_SCREEN* first = GetFirst();
1203 
1204  if( !first )
1205  return;
1206 
1207  SCHEMATIC* sch = first->Schematic();
1208 
1209  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::ClearAnnotationOfNewSheetPaths" );
1210 
1211  // Clear the annotation for the components inside new sheetpaths
1212  // not already in aInitialSheetList
1213  SCH_SCREENS screensList( sch->Root() ); // The list of screens, shared by sheet paths
1214  screensList.BuildClientSheetPathList(); // build the shared by sheet paths, by screen
1215 
1216  // Search for new sheet paths, not existing in aInitialSheetPathList
1217  // and existing in sheetpathList
1218  for( SCH_SHEET_PATH& sheetpath : sch->GetSheets() )
1219  {
1220  bool path_exists = false;
1221 
1222  for( const SCH_SHEET_PATH& existing_sheetpath: aInitialSheetPathList )
1223  {
1224  if( existing_sheetpath.Path() == sheetpath.Path() )
1225  {
1226  path_exists = true;
1227  break;
1228  }
1229  }
1230 
1231  if( !path_exists )
1232  {
1233  // A new sheet path is found: clear the annotation corresponding to this new path:
1234  SCH_SCREEN* curr_screen = sheetpath.LastScreen();
1235 
1236  // Clear annotation and create the AR for this path, if not exists,
1237  // when the screen is shared by sheet paths.
1238  // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1239  // reference default value and takes the latest displayed value
1240  curr_screen->EnsureAlternateReferencesExist();
1241  curr_screen->ClearAnnotation( &sheetpath );
1242  }
1243  }
1244 }
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:89
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:42
void EnsureAlternateReferencesExist()
For screens shared by many sheetpaths (complex hierarchies): to be able to clear or modify any refere...
Definition: sch_screen.cpp:936
void BuildClientSheetPathList()
built the list of sheet paths sharing a screen for each screen in use
SCH_SHEET_PATH.
SCH_SHEET & Root() const
Definition: schematic.h:94
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:91
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the components in aSheetPath on the screen.
Definition: sch_screen.cpp:924
SCH_SCREEN * GetFirst()
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:515

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

Referenced by SCH_EDIT_TOOL::Duplicate(), and 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 1323 of file sch_screen.cpp.

1325 {
1326  DeleteMarkers( aMarkerType, ERCE_UNSPECIFIED, aIncludeExclusions );
1327 }
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 1281 of file sch_screen.cpp.

1282 {
1283  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1284  {
1285  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1286  {
1287  if( item == aMarker )
1288  {
1289  screen->DeleteItem( item );
1290  return;
1291  }
1292  }
1293  }
1294 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194

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

1299 {
1300  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1301  {
1302  std::vector<SCH_ITEM*> markers;
1303 
1304  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1305  {
1306  SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
1307  std::shared_ptr<RC_ITEM>rcItem = marker->GetRCItem();
1308 
1309  if( marker->GetMarkerType() == aMarkerType
1310  && ( aErrorCode == ERCE_UNSPECIFIED || rcItem->GetErrorCode() == aErrorCode )
1311  && ( !marker->IsExcluded() || aIncludeExclusions ) )
1312  {
1313  markers.push_back( item );
1314  }
1315  }
1316 
1317  for( SCH_ITEM* marker : markers )
1318  screen->DeleteItem( marker );
1319  }
1320 }
SCH_SCREEN * GetNext()
bool IsExcluded() const
Definition: marker_base.h:109
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:107
SCH_SCREEN * GetFirst()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
std::shared_ptr< RC_ITEM > GetRCItem() const
Function GetReporter returns the DRC_ITEM held within this MARKER so that its interface may be used.
Definition: marker_base.h:120

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

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

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 nickames into aLibNicknames.

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

Definition at line 1408 of file sch_screen.cpp.

1409 {
1410  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1411  {
1412  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
1413  {
1414  auto symbol = static_cast<SCH_COMPONENT*>( item );
1415  auto& nickname = symbol->GetLibId().GetLibNickname();
1416 
1417  if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1418  aLibNicknames.Add( nickname );
1419  }
1420  }
1421 
1422  return aLibNicknames.GetCount();
1423 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()

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

◆ GetNext()

◆ GetScreen()

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

Definition at line 1152 of file sch_screen.cpp.

1153 {
1154  if( aIndex < m_screens.size() )
1155  return m_screens[ aIndex ];
1156 
1157  return NULL;
1158 }
#define NULL
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:518

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

1162 {
1163  if( aIndex < m_sheets.size() )
1164  return m_sheets[ aIndex ];
1165 
1166  return NULL;
1167 }
std::vector< SCH_SHEET * > m_sheets
Definition: sch_screen.h:519
#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 1387 of file sch_screen.cpp.

1388 {
1389  SCH_SCREEN* screen;
1390  unsigned cnt = 0;
1391 
1392  for( screen = GetFirst(); screen; screen = GetNext() )
1393  {
1394  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
1395  {
1396  cnt++;
1397  auto symbol = static_cast<SCH_COMPONENT*>( item );
1398 
1399  if( !symbol->GetLibId().GetLibNickname().empty() )
1400  return false;
1401  }
1402  }
1403 
1404  return cnt != 0;
1405 }
SCH_SCREEN * GetNext()
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
EE_RTREE & Items()
Definition: sch_screen.h:158
SCH_SCREEN * GetFirst()

References GetFirst(), GetNext(), SCH_SCREEN::Items(), EE_RTREE::OfType(), and SCH_COMPONENT_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
aSchematicFileNameis the schematic file name to search.
Returns
true if the a schematic matching the file name has been found.

Definition at line 1451 of file sch_screen.cpp.

1452 {
1453  for( const SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1454  {
1455  if( screen->GetFileName() == aSchematicFileName )
1456  return true;
1457  }
1458 
1459  return false;
1460 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()

References GetFirst(), and GetNext().

◆ ReplaceDuplicateTimeStamps()

int SCH_SCREENS::ReplaceDuplicateTimeStamps ( )

Test all sheet and component 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 components go to which sheets.

Returns
The number of duplicate time stamps replaced.

Definition at line 1247 of file sch_screen.cpp.

1248 {
1249  std::vector<SCH_ITEM*> items;
1250  int count = 0;
1251 
1252  auto timestamp_cmp = []( const EDA_ITEM* a, const EDA_ITEM* b ) -> bool
1253  {
1254  return a->m_Uuid < b->m_Uuid;
1255  };
1256 
1257  std::set<EDA_ITEM*, decltype( timestamp_cmp )> unique_stamps( timestamp_cmp );
1258 
1259  for( SCH_SCREEN* screen : m_screens )
1260  screen->GetHierarchicalItems( &items );
1261 
1262  if( items.size() < 2 )
1263  return 0;
1264 
1265  for( EDA_ITEM* item : items )
1266  {
1267  if( !unique_stamps.insert( item ).second )
1268  {
1269  // Reset to fully random UUID. This may lose reference, but better to be
1270  // deterministic about it rather than to have duplicate UUIDs with random
1271  // side-effects.
1272  const_cast<KIID&>( item->m_Uuid ) = KIID();
1273  count++;
1274  }
1275  }
1276 
1277  return count;
1278 }
Definition: common.h:68
const KIID m_Uuid
Definition: base_struct.h:162
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:518
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159

References m_screens, and EDA_ITEM::m_Uuid.

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

◆ TestDanglingEnds()

void SCH_SCREENS::TestDanglingEnds ( )

Definition at line 1353 of file sch_screen.cpp.

1354 {
1355  std::vector<SCH_SCREEN*> screens;
1356  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1357  screens.push_back( screen );
1358 
1359  size_t parallelThreadCount = std::min<size_t>( std::thread::hardware_concurrency(),
1360  screens.size() );
1361 
1362  std::atomic<size_t> nextScreen( 0 );
1363  std::vector<std::future<size_t>> returns( parallelThreadCount );
1364 
1365  auto update_lambda = [&screens, &nextScreen]() -> size_t
1366  {
1367  for( auto i = nextScreen++; i < screens.size(); i = nextScreen++ )
1368  screens[i]->TestDanglingEnds();
1369 
1370  return 1;
1371  };
1372 
1373  if( parallelThreadCount == 1 )
1374  update_lambda();
1375  else
1376  {
1377  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
1378  returns[ii] = std::async( std::launch::async, update_lambda );
1379 
1380  // Finalize the threads
1381  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
1382  returns[ii].wait();
1383  }
1384 }
SCH_SCREEN * GetNext()
void TestDanglingEnds()
SCH_SCREEN * GetFirst()

References GetFirst(), and GetNext().

Referenced by SCH_EDIT_FRAME::AppendSchematic(), and SCH_EDIT_FRAME::KiwayMailIn().

◆ UpdateSymbolLinks()

void SCH_SCREENS::UpdateSymbolLinks ( REPORTER aReporter = nullptr)

Initialize the LIB_PART reference for each SCH_COMPONENT 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
aReporterAn optional REPORTER object pointer to write warning and error messages into.

Definition at line 1330 of file sch_screen.cpp.

1331 {
1332  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1333  screen->UpdateSymbolLinks( aReporter );
1334 
1335  SCH_SCREEN* first = GetFirst();
1336 
1337  if( !first )
1338  return;
1339 
1340  SCHEMATIC* sch = first->Schematic();
1341 
1342  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::UpdateSymbolLinks" );
1343 
1344  SCH_SHEET_LIST sheets = sch->GetSheets();
1345 
1346  // All of the library symbols have been replaced with copies so the connection graph
1347  // pointer are stale.
1348  if( sch->ConnectionGraph() )
1349  sch->ConnectionGraph()->Recalculate( sheets, true );
1350 }
SCH_SHEET_LIST.
SCH_SCREEN * GetNext()
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:89
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:42
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:129
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false)
Updates the connection graph for the given list of sheets.
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:91
SCH_SCREEN * GetFirst()

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

Referenced by SCH_EDIT_FRAME::importFile(), 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 520 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 519 of file sch_screen.h.

Referenced by addScreenToList(), and GetSheet().


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