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=NULL)
 
 ~SCH_SCREENS ()
 
int GetCount () const
 
SCH_SCREENGetFirst ()
 
SCH_SCREENGetNext ()
 
SCH_SCREENGetScreen (unsigned int aIndex) const
 
void ClearAnnotation ()
 Clear the annotation for all components in the hierarchy. More...
 
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)
 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)
 Delete all markers of a particular type and error code. More...
 
void DeleteMarker (SCH_MARKER *aMarker)
 Delete a specific marker. More...
 
void UpdateSymbolLinks (bool aForce=false)
 Initialize or reinitialize the weak reference to the LIB_PART 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)
 
void buildScreenList (SCH_SHEET *aSheet)
 

Private Attributes

std::vector< SCH_SCREEN * > m_screens
 
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.

Definition at line 491 of file sch_screen.h.

Constructor & Destructor Documentation

◆ SCH_SCREENS()

SCH_SCREENS::SCH_SCREENS ( SCH_SHEET aSheet = NULL)

Definition at line 947 of file sch_screen.cpp.

948 {
949  m_index = 0;
950  buildScreenList( ( !aSheet ) ? g_RootSheet : aSheet );
951 }
unsigned int m_index
Definition: sch_screen.h:495
void buildScreenList(SCH_SHEET *aSheet)
SCH_SHEET * g_RootSheet

References buildScreenList(), g_RootSheet, and m_index.

◆ ~SCH_SCREENS()

SCH_SCREENS::~SCH_SCREENS ( )

Definition at line 954 of file sch_screen.cpp.

955 {
956 }

Member Function Documentation

◆ addScreenToList()

void SCH_SCREENS::addScreenToList ( SCH_SCREEN aScreen)
private

Definition at line 988 of file sch_screen.cpp.

989 {
990  if( aScreen == NULL )
991  return;
992 
993  for( const SCH_SCREEN* screen : m_screens )
994  {
995  if( screen == aScreen )
996  return;
997  }
998 
999  m_screens.push_back( aScreen );
1000 }
#define NULL
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:494

References m_screens, 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 1295 of file sch_screen.cpp.

1296 {
1297  SCH_SHEET_LIST sheetList( g_RootSheet );
1298 
1299  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1300  curr_screen->GetClientSheetPaths().Clear();
1301 
1302  for( SCH_SHEET_PATH& sheetpath: sheetList )
1303  {
1304  SCH_SCREEN* used_screen = sheetpath.LastScreen();
1305 
1306  // SEarch for the used_screen in list and add this unique sheet path:
1307  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1308  {
1309  if( used_screen == curr_screen )
1310  {
1311  curr_screen->GetClientSheetPaths().Add( sheetpath.PathAsString() );
1312  break;
1313  }
1314  }
1315  }
1316 }
SCH_SHEET_LIST.
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
wxArrayString & GetClientSheetPaths()
Definition: sch_screen.h:181
SCH_SHEET_PATH.
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959
SCH_SHEET * g_RootSheet

References g_RootSheet, SCH_SCREEN::GetClientSheetPaths(), GetFirst(), and GetNext().

Referenced by ClearAnnotationOfNewSheetPaths().

◆ buildScreenList()

void SCH_SCREENS::buildScreenList ( SCH_SHEET aSheet)
private

Definition at line 1003 of file sch_screen.cpp.

1004 {
1005  if( aSheet && aSheet->Type() == SCH_SHEET_T )
1006  {
1007  SCH_SCREEN* screen = aSheet->GetScreen();
1008 
1009  addScreenToList( screen );
1010 
1011  for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
1012  buildScreenList( static_cast<SCH_SHEET*>( item ) );
1013  }
1014 }
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:282
void buildScreenList(SCH_SHEET *aSheet)
void addScreenToList(SCH_SCREEN *aScreen)
Definition: sch_screen.cpp:988
EE_RTREE & Items()
Definition: sch_screen.h:127
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212

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

1269 {
1270  wxString lhsLower;
1271  wxString rhsLower;
1272  wxFileName lhs;
1273  wxFileName rhs = aSchematicFileName;
1274 
1275  wxCHECK( rhs.IsAbsolute(), false );
1276 
1277  for( const SCH_SCREEN* screen : m_screens )
1278  {
1279  lhs = screen->GetFileName();
1280 
1281  if( lhs.GetPath() != rhs.GetPath() )
1282  continue;
1283 
1284  lhsLower = lhs.GetFullName().Lower();
1285  rhsLower = rhs.GetFullName().Lower();
1286 
1287  if( lhsLower == rhsLower && lhs.GetFullName() != rhs.GetFullName() )
1288  return true;
1289  }
1290 
1291  return false;
1292 }
YYCODETYPE lhs
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:494

References numEval::lhs, and 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 1231 of file sch_screen.cpp.

1232 {
1233  SCH_SCREEN* screen;
1234  int cnt = 0;
1235 
1236  for( screen = GetFirst(); screen; screen = GetNext() )
1237  {
1238  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
1239  {
1240  auto symbol = static_cast<SCH_COMPONENT*>( item );
1241 
1242  if( symbol->GetLibId().GetLibNickname() != aFrom )
1243  continue;
1244 
1245  LIB_ID id = symbol->GetLibId();
1246  id.SetLibNickname( aTo );
1247  symbol->SetLibId( id );
1248  cnt++;
1249  }
1250  }
1251 
1252  return cnt;
1253 }
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
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:127
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959

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

◆ ClearAnnotation()

void SCH_SCREENS::ClearAnnotation ( )

Clear the annotation for all components in the hierarchy.

Definition at line 1017 of file sch_screen.cpp.

1018 {
1019  for( SCH_SCREEN* screen : m_screens )
1020  screen->ClearAnnotation( NULL );
1021 }
#define NULL
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:494

References m_screens, and NULL.

Referenced by SCH_EDIT_FRAME::DeleteAnnotation().

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

1025 {
1026  // Clear the annotation for the components inside new sheetpaths
1027  // not already in aInitialSheetList
1028  SCH_SCREENS screensList( g_RootSheet ); // The list of screens, shared by sheet paths
1029  screensList.BuildClientSheetPathList(); // build the shared by sheet paths, by screen
1030 
1031  // Search for new sheet paths, not existing in aInitialSheetPathList
1032  // and existing in sheetpathList
1033  SCH_SHEET_LIST sheetpathList( g_RootSheet );
1034 
1035  for( SCH_SHEET_PATH& sheetpath: sheetpathList )
1036  {
1037  bool path_exists = false;
1038 
1039  for( const SCH_SHEET_PATH& existing_sheetpath: aInitialSheetPathList )
1040  {
1041  if( existing_sheetpath.Path() == sheetpath.Path() )
1042  {
1043  path_exists = true;
1044  break;
1045  }
1046  }
1047 
1048  if( !path_exists )
1049  {
1050  // A new sheet path is found: clear the annotation corresponding to this new path:
1051  SCH_SCREEN* curr_screen = sheetpath.LastScreen();
1052 
1053  // Clear annotation and create the AR for this path, if not exists,
1054  // when the screen is shared by sheet paths.
1055  // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1056  // reference default value and takes the latest displayed value
1057  curr_screen->EnsureAlternateReferencesExist();
1058  curr_screen->ClearAnnotation( &sheetpath );
1059  }
1060  }
1061 }
SCH_SHEET_LIST.
void EnsureAlternateReferencesExist()
For screens shared by many sheetpaths (complex hierarchies): to be able to clear or modify any refere...
Definition: sch_screen.cpp:749
SCH_SHEET_PATH.
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the components in aSheetPath on the screen.
Definition: sch_screen.cpp:732
SCH_SHEET * g_RootSheet
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491

References BuildClientSheetPathList(), SCH_SCREEN::ClearAnnotation(), SCH_SCREEN::EnsureAlternateReferencesExist(), and g_RootSheet.

Referenced by SCH_EDIT_TOOL::Duplicate(), and SCH_EDIT_TOOL::Properties().

◆ DeleteAllMarkers()

void SCH_SCREENS::DeleteAllMarkers ( enum MARKER_BASE::TYPEMARKER  aMarkerType)

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

1139 {
1140  DeleteMarkers( aMarkerType, ERCE_UNSPECIFIED );
1141 }
void DeleteMarkers(enum MARKER_BASE::TYPEMARKER aMarkerTyp, int aErrorCode)
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 1098 of file sch_screen.cpp.

1099 {
1100  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1101  {
1102  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1103  {
1104  if( item == aMarker )
1105  {
1106  screen->DeleteItem( item );
1107  return;
1108  }
1109  }
1110  }
1111 }
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147

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 
)

Delete all markers of a particular type and error code.

Definition at line 1114 of file sch_screen.cpp.

1115 {
1116  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1117  {
1118  std::vector<SCH_ITEM*> markers;
1119 
1120  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1121  {
1122  SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
1123  RC_ITEM* rcItem = marker->GetRCItem();
1124 
1125  if( marker->GetMarkerType() == aMarkerType &&
1126  ( aErrorCode == ERCE_UNSPECIFIED || rcItem->GetErrorCode() == aErrorCode ) )
1127  {
1128  markers.push_back( item );
1129  }
1130  }
1131 
1132  for( SCH_ITEM* marker : markers )
1133  screen->DeleteItem( marker );
1134  }
1135 }
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
RC_ITEM * GetRCItem()
Function GetReporter returns the DRC_ITEM held within this MARKER so that its interface may be used.
Definition: marker_base.h:181
RC_ITEM is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item.
Definition: rc_item.h:82
int GetErrorCode() const
Definition: rc_item.h:273
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:98
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147

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

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

◆ GetCount()

int SCH_SCREENS::GetCount ( ) const
inline

Definition at line 500 of file sch_screen.h.

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

References m_screens.

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

1214 {
1215  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1216  {
1217  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
1218  {
1219  auto symbol = static_cast<SCH_COMPONENT*>( item );
1220  auto& nickname = symbol->GetLibId().GetLibNickname();
1221 
1222  if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1223  aLibNicknames.Add( nickname );
1224  }
1225  }
1226 
1227  return aLibNicknames.GetCount();
1228 }
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959

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

◆ GetNext()

◆ GetScreen()

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

Definition at line 979 of file sch_screen.cpp.

980 {
981  if( aIndex < m_screens.size() )
982  return m_screens[ aIndex ];
983 
984  return NULL;
985 }
#define NULL
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:494

References m_screens, and NULL.

Referenced by GetNext().

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

1193 {
1194  SCH_SCREEN* screen;
1195  unsigned cnt = 0;
1196 
1197  for( screen = GetFirst(); screen; screen = GetNext() )
1198  {
1199  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
1200  {
1201  cnt++;
1202  auto symbol = static_cast<SCH_COMPONENT*>( item );
1203 
1204  if( !symbol->GetLibId().GetLibNickname().empty() )
1205  return false;
1206  }
1207  }
1208 
1209  return cnt != 0;
1210 }
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
EE_RTREE & Items()
Definition: sch_screen.h:127
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959

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

Referenced by SCH_EDIT_FRAME::checkForNoFullyDefinedLibIds(), SCH_EDIT_FRAME::OnRescueProject(), SCH_EDIT_FRAME::OpenProjectFiles(), and SCH_EDIT_FRAME::ReCreateMenuBar().

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

1257 {
1258  for( const SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1259  {
1260  if( screen->GetFileName() == aSchematicFileName )
1261  return true;
1262  }
1263 
1264  return false;
1265 }
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959

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

1065 {
1066  EDA_ITEMS items;
1067  int count = 0;
1068 
1069  auto timestamp_cmp = []( const EDA_ITEM* a, const EDA_ITEM* b ) -> bool
1070  {
1071  return a->m_Uuid < b->m_Uuid;
1072  };
1073 
1074  std::set<EDA_ITEM*, decltype( timestamp_cmp )> unique_stamps( timestamp_cmp );
1075 
1076  for( SCH_SCREEN* screen : m_screens )
1077  screen->GetHierarchicalItems( items );
1078 
1079  if( items.size() < 2 )
1080  return 0;
1081 
1082  for( EDA_ITEM* item : items )
1083  {
1084  if( !unique_stamps.insert( item ).second )
1085  {
1086  // Reset to fully random UUID. This may lose reference, but better to be
1087  // deterministic about it rather than to have duplicate UUIDs with random
1088  // side-effects.
1089  const_cast<KIID&>( item->m_Uuid ) = KIID();
1090  count++;
1091  }
1092  }
1093 
1094  return count;
1095 }
Definition: common.h:65
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:603
const KIID m_Uuid
Definition: base_struct.h:169
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:494
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166

References m_screens, and EDA_ITEM::m_Uuid.

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

◆ TestDanglingEnds()

void SCH_SCREENS::TestDanglingEnds ( )

Definition at line 1158 of file sch_screen.cpp.

1159 {
1160  std::vector<SCH_SCREEN*> screens;
1161  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1162  screens.push_back( screen );
1163 
1164  size_t parallelThreadCount = std::min<size_t>( std::thread::hardware_concurrency(),
1165  screens.size() );
1166 
1167  std::atomic<size_t> nextScreen( 0 );
1168  std::vector<std::future<size_t>> returns( parallelThreadCount );
1169 
1170  auto update_lambda = [&screens, &nextScreen]() -> size_t
1171  {
1172  for( auto i = nextScreen++; i < screens.size(); i = nextScreen++ )
1173  screens[i]->TestDanglingEnds();
1174 
1175  return 1;
1176  };
1177 
1178  if( parallelThreadCount == 1 )
1179  update_lambda();
1180  else
1181  {
1182  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
1183  returns[ii] = std::async( std::launch::async, update_lambda );
1184 
1185  // Finalize the threads
1186  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
1187  returns[ii].wait();
1188  }
1189 }
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
void TestDanglingEnds()
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959

References GetFirst(), and GetNext().

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

◆ UpdateSymbolLinks()

void SCH_SCREENS::UpdateSymbolLinks ( bool  aForce = false)

Initialize or reinitialize the weak reference to the LIB_PART for each SCH_COMPONENT found in the full schematic.

It must be called from:

  • draw functions
  • when loading a schematic file
  • before creating a netlist (in case a library is modified)
  • whenever any of the libraries are modified.
  • whenever the symbol library table is modified.

Definition at line 1144 of file sch_screen.cpp.

1145 {
1146  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1147  screen->UpdateSymbolLinks( aForce );
1148 
1149  SCH_SHEET_LIST sheets( g_RootSheet );
1150 
1151  // All of the library symbols have been replaced with copies so the connection graph
1152  // pointer are stale.
1153  if( g_ConnectionGraph )
1154  g_ConnectionGraph->Recalculate( sheets, true );
1155 }
SCH_SHEET_LIST.
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false)
Updates the connection graph for the given list of sheets.
CONNECTION_GRAPH * g_ConnectionGraph
This also wants to live in the eventual SCHEMATIC object.
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959
SCH_SHEET * g_RootSheet

References g_ConnectionGraph, g_RootSheet, GetFirst(), GetNext(), and CONNECTION_GRAPH::Recalculate().

Referenced by SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile(), SCH_EDIT_FRAME::CreateNetlist(), SCH_EDIT_FRAME::importFile(), InvokeSchEditSymbolLibTable(), SCH_EDIT_FRAME::KiwayMailIn(), SCH_EDIT_FRAME::LoadSheetFromFile(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::prepareForNetlist(), DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable(), SCH_EDIT_FRAME::rescueProject(), DIALOG_EDIT_COMPONENTS_LIBID::revertChanges(), DIALOG_EDIT_COMPONENTS_LIBID::TransferDataFromWindow(), LEGACY_RESCUER::WriteRescueLibrary(), and SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary().

Member Data Documentation

◆ m_index

unsigned int SCH_SCREENS::m_index
private

Definition at line 495 of file sch_screen.h.

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

◆ m_screens

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

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