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...
 
int GetMarkerCount (enum MARKER_BASE::TYPEMARKER aMarkerType, enum MARKER_BASE::MARKER_SEVERITY aSeverity)
 Return the number of ERC markers of aMarkerType from all of the screens in the list. 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...
 
void BuildClientSheetPathList ()
 built the list of sheet paths sharing a screen for each screen in use 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 493 of file sch_screen.h.

Constructor & Destructor Documentation

◆ SCH_SCREENS()

SCH_SCREENS::SCH_SCREENS ( SCH_SHEET aSheet = NULL)

Definition at line 984 of file sch_screen.cpp.

985 {
986  m_index = 0;
987  buildScreenList( ( !aSheet ) ? g_RootSheet : aSheet );
988 }
unsigned int m_index
Definition: sch_screen.h:497
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
void buildScreenList(SCH_SHEET *aSheet)

References buildScreenList(), g_RootSheet, and m_index.

◆ ~SCH_SCREENS()

SCH_SCREENS::~SCH_SCREENS ( )

Definition at line 991 of file sch_screen.cpp.

992 {
993 }

Member Function Documentation

◆ addScreenToList()

void SCH_SCREENS::addScreenToList ( SCH_SCREEN aScreen)
private

Definition at line 1025 of file sch_screen.cpp.

1026 {
1027  if( aScreen == NULL )
1028  return;
1029 
1030  for( unsigned int i = 0; i < m_screens.size(); i++ )
1031  {
1032  if( m_screens[i] == aScreen )
1033  return;
1034  }
1035 
1036  m_screens.push_back( aScreen );
1037 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:496
size_t i
Definition: json11.cpp:597

References i, and m_screens.

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

1352 {
1353  SCH_SHEET_LIST sheetList( g_RootSheet );
1354 
1355  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1356  curr_screen->GetClientSheetPaths().Clear();
1357 
1358  for( SCH_SHEET_PATH& sheetpath: sheetList )
1359  {
1360  SCH_SCREEN* used_screen = sheetpath.LastScreen();
1361 
1362  // SEarch for the used_screen in list and add this unique sheet path:
1363  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1364  {
1365  if( used_screen == curr_screen )
1366  {
1367  curr_screen->GetClientSheetPaths().Add( sheetpath.Path() );
1368  break;
1369  }
1370  }
1371  }
1372 }
Class SCH_SHEET_LIST.
SCH_SCREEN * GetNext()
wxArrayString & GetClientSheetPaths()
Definition: sch_screen.h:148
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
Class SCH_SHEET_PATH.
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:996

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

Referenced by ClearAnnotationOfNewSheetPaths().

◆ buildScreenList()

void SCH_SCREENS::buildScreenList ( SCH_SHEET aSheet)
private

Definition at line 1040 of file sch_screen.cpp.

1041 {
1042  if( aSheet && aSheet->Type() == SCH_SHEET_T )
1043  {
1044  SCH_SCREEN* screen = aSheet->GetScreen();
1045 
1046  addScreenToList( screen );
1047 
1048  EDA_ITEM* strct = screen->GetDrawItems();
1049 
1050  while( strct )
1051  {
1052  if( strct->Type() == SCH_SHEET_T )
1053  {
1054  buildScreenList( ( SCH_SHEET* )strct );
1055  }
1056 
1057  strct = strct->Next();
1058  }
1059  }
1060 }
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:268
EDA_ITEM * Next() const
Definition: base_struct.h:212
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:201
void buildScreenList(SCH_SHEET *aSheet)
void addScreenToList(SCH_SCREEN *aScreen)
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:153

References addScreenToList(), SCH_SCREEN::GetDrawItems(), SCH_SHEET::GetScreen(), EDA_ITEM::Next(), SCH_SHEET_T, and EDA_ITEM::Type().

Referenced by SCH_SCREENS().

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

1318 {
1319  SCH_COMPONENT* symbol;
1320  SCH_ITEM* item;
1321  SCH_ITEM* nextItem;
1322  SCH_SCREEN* screen;
1323  int cnt = 0;
1324 
1325  for( screen = GetFirst(); screen; screen = GetNext() )
1326  {
1327  for( item = screen->GetDrawItems(); item; item = nextItem )
1328  {
1329  nextItem = item->Next();
1330 
1331  if( item->Type() != SCH_COMPONENT_T )
1332  continue;
1333 
1334  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1335  wxASSERT( symbol );
1336 
1337  if( symbol->GetLibId().GetLibNickname() != aFrom )
1338  continue;
1339 
1340  LIB_ID id = symbol->GetLibId();
1341  id.SetLibNickname( aTo );
1342  symbol->SetLibId( id );
1343  cnt++;
1344  }
1345  }
1346 
1347  return cnt;
1348 }
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
Definition: sch_item.h:153
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void SetLibId(const LIB_ID &aName, PART_LIBS *aLibs=NULL)
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:193
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:996
const LIB_ID & GetLibId() const
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:153

References SCH_SCREEN::GetDrawItems(), GetFirst(), SCH_COMPONENT::GetLibId(), LIB_ID::GetLibNickname(), GetNext(), SCH_ITEM::Next(), SCH_COMPONENT_T, SCH_COMPONENT::SetLibId(), LIB_ID::SetLibNickname(), and EDA_ITEM::Type().

◆ ClearAnnotation()

void SCH_SCREENS::ClearAnnotation ( )

Clear the annotation for all components in the hierarchy.

Definition at line 1063 of file sch_screen.cpp.

1064 {
1065  for( size_t i = 0; i < m_screens.size(); i++ )
1066  m_screens[i]->ClearAnnotation( NULL );
1067 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:496
void ClearAnnotation()
Clear the annotation for all components in the hierarchy.
size_t i
Definition: json11.cpp:597

References i, and m_screens.

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

1071 {
1072  // Clear the annotation for the components inside new sheetpaths
1073  // not already in aInitialSheetList
1074  SCH_SCREENS screensList( g_RootSheet ); // The list of screens, shared by sheet paths
1075  screensList.BuildClientSheetPathList(); // build the shared by sheet paths, by screen
1076 
1077  // Search for new sheet paths, not existing in aInitialSheetPathList
1078  // and existing in sheetpathList
1079  SCH_SHEET_LIST sheetpathList( g_RootSheet );
1080 
1081  for( SCH_SHEET_PATH& sheetpath: sheetpathList )
1082  {
1083  bool path_exists = false;
1084 
1085  for( const SCH_SHEET_PATH& existing_sheetpath: aInitialSheetPathList )
1086  {
1087  if( existing_sheetpath.Path() == sheetpath.Path() )
1088  {
1089  path_exists = true;
1090  break;
1091  }
1092  }
1093 
1094  if( !path_exists )
1095  {
1096  // A new sheet path is found: clear the annotation corresponding to this new path:
1097  SCH_SCREEN* curr_screen = sheetpath.LastScreen();
1098 
1099  // Clear annotation and create the AR for this path, if not exists,
1100  // when the screen is shared by sheet paths.
1101  // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1102  // reference default value and takes the latest displayed value
1103  curr_screen->EnsureAlternateReferencesExist();
1104  curr_screen->ClearAnnotation( &sheetpath );
1105  }
1106  }
1107 }
Class 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:741
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
Class SCH_SHEET_PATH.
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the components in aSheetPath on the screen.
Definition: sch_screen.cpp:722
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:493

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

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

1154 {
1155  SCH_ITEM* item;
1156  SCH_ITEM* nextItem;
1157  SCH_MARKER* marker;
1158  SCH_SCREEN* screen;
1159 
1160  for( screen = GetFirst(); screen; screen = GetNext() )
1161  {
1162  for( item = screen->GetDrawItems(); item; item = nextItem )
1163  {
1164  nextItem = item->Next();
1165 
1166  if( item->Type() != SCH_MARKER_T )
1167  continue;
1168 
1169  marker = (SCH_MARKER*) item;
1170 
1171  if( marker->GetMarkerType() != aMarkerType )
1172  continue;
1173 
1174  screen->DeleteItem( marker );
1175  }
1176  }
1177 }
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
Definition: sch_item.h:153
void DeleteItem(SCH_ITEM *aItem)
Removes aItem from the linked list and deletes the object.
Definition: sch_screen.cpp:195
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:187
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:996
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:153

References SCH_SCREEN::DeleteItem(), SCH_SCREEN::GetDrawItems(), GetFirst(), MARKER_BASE::GetMarkerType(), GetNext(), SCH_ITEM::Next(), SCH_MARKER_T, and EDA_ITEM::Type().

Referenced by DIALOG_ERC::OnEraseDrcMarkersClick(), and DIALOG_ERC::TestErc().

◆ GetCount()

int SCH_SCREENS::GetCount ( ) const
inline

Definition at line 502 of file sch_screen.h.

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

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

1284 {
1285  SCH_COMPONENT* symbol;
1286  SCH_ITEM* item;
1287  SCH_ITEM* nextItem;
1288  SCH_SCREEN* screen;
1289  wxString nickname;
1290 
1291  for( screen = GetFirst(); screen; screen = GetNext() )
1292  {
1293  for( item = screen->GetDrawItems(); item; item = nextItem )
1294  {
1295  nextItem = item->Next();
1296 
1297  if( item->Type() != SCH_COMPONENT_T )
1298  continue;
1299 
1300  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1301  wxASSERT( symbol );
1302 
1303  if( !symbol )
1304  continue;
1305 
1306  nickname = symbol->GetLibId().GetLibNickname();
1307 
1308  if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1309  aLibNicknames.Add( nickname );;
1310  }
1311  }
1312 
1313  return aLibNicknames.GetCount();
1314 }
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
Definition: sch_item.h:153
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:996
const LIB_ID & GetLibId() const
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:153

References SCH_SCREEN::GetDrawItems(), GetFirst(), SCH_COMPONENT::GetLibId(), LIB_ID::GetLibNickname(), GetNext(), SCH_ITEM::Next(), SCH_COMPONENT_T, and EDA_ITEM::Type().

◆ GetMarkerCount()

int SCH_SCREENS::GetMarkerCount ( enum MARKER_BASE::TYPEMARKER  aMarkerType,
enum MARKER_BASE::MARKER_SEVERITY  aSeverity 
)

Return the number of ERC markers of aMarkerType from all of the screens in the list.

Parameters
aMarkerTypeIndicates the type of marker to count. if MARKER_UNSPEC all markers are counted.
aSeverityIndicates the error level of marker to count. useMARKER_SEVERITY_UNSPEC to count all markersof the specified type
Returns
int count of the markers found.

Definition at line 1180 of file sch_screen.cpp.

1182 {
1183  int count = 0;
1184 
1185  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1186  {
1187  for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
1188  {
1189  if( item->Type() != SCH_MARKER_T )
1190  continue;
1191 
1192  SCH_MARKER* marker = (SCH_MARKER*) item;
1193 
1194  if( ( aMarkerType != MARKER_BASE::MARKER_UNSPEC ) &&
1195  ( marker->GetMarkerType() != aMarkerType ) )
1196  continue;
1197 
1198  if( aSeverity == MARKER_BASE::MARKER_SEVERITY_UNSPEC ||
1199  aSeverity == marker->GetErrorLevel() )
1200  count++;
1201  }
1202  }
1203 
1204  return count;
1205 }
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
Definition: sch_item.h:153
MARKER_SEVERITY GetErrorLevel() const
Definition: marker_base.h:175
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:187
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:996
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114

References MARKER_BASE::GetErrorLevel(), GetFirst(), MARKER_BASE::GetMarkerType(), GetNext(), MARKER_BASE::MARKER_SEVERITY_UNSPEC, MARKER_BASE::MARKER_UNSPEC, SCH_ITEM::Next(), and SCH_MARKER_T.

Referenced by DIALOG_ERC::updateMarkerCounts().

◆ GetNext()

◆ GetScreen()

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

Definition at line 1016 of file sch_screen.cpp.

1017 {
1018  if( aIndex < m_screens.size() )
1019  return m_screens[ aIndex ];
1020 
1021  return NULL;
1022 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:496

References m_screens.

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

1251 {
1252  SCH_COMPONENT* symbol;
1253  SCH_ITEM* item;
1254  SCH_ITEM* nextItem;
1255  SCH_SCREEN* screen;
1256  unsigned cnt = 0;
1257 
1258  for( screen = GetFirst(); screen; screen = GetNext() )
1259  {
1260  for( item = screen->GetDrawItems(); item; item = nextItem )
1261  {
1262  nextItem = item->Next();
1263 
1264  if( item->Type() != SCH_COMPONENT_T )
1265  continue;
1266 
1267  cnt += 1;
1268  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1269  wxASSERT( symbol );
1270 
1271  if( !symbol->GetLibId().GetLibNickname().empty() )
1272  return false;
1273  }
1274  }
1275 
1276  if( cnt == 0 )
1277  return false;
1278 
1279  return true;
1280 }
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
Definition: sch_item.h:153
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:996
const LIB_ID & GetLibId() const
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
bool empty() const
Definition: utf8.h:108
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:153

References UTF8::empty(), SCH_SCREEN::GetDrawItems(), GetFirst(), SCH_COMPONENT::GetLibId(), LIB_ID::GetLibNickname(), GetNext(), SCH_ITEM::Next(), SCH_COMPONENT_T, and EDA_ITEM::Type().

Referenced by SCH_EDIT_FRAME::EditSheet(), SCH_EDIT_FRAME::OnRescueProject(), SCH_EDIT_FRAME::OnUpdateRemapSymbols(), and SCH_EDIT_FRAME::OpenProjectFiles().

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

1111 {
1112  EDA_ITEMS items;
1113  SCH_ITEM* item;
1114 
1115  for( size_t i = 0; i < m_screens.size(); i++ )
1116  m_screens[i]->GetHierarchicalItems( items );
1117 
1118  if( items.size() < 2 )
1119  return 0;
1120 
1121  sort( items.begin(), items.end(), SortByTimeStamp );
1122 
1123  int count = 0;
1124 
1125  for( size_t ii = 0; ii < items.size() - 1; ii++ )
1126  {
1127  item = (SCH_ITEM*)items[ii];
1128 
1129  SCH_ITEM* nextItem = (SCH_ITEM*)items[ii + 1];
1130 
1131  if( item->GetTimeStamp() == nextItem->GetTimeStamp() )
1132  {
1133  count++;
1134 
1135  // for a component, update its Time stamp and its paths
1136  // (m_PathsAndReferences field)
1137  if( item->Type() == SCH_COMPONENT_T )
1138  ( (SCH_COMPONENT*) item )->SetTimeStamp( GetNewTimeStamp() );
1139 
1140  // for a sheet, update only its time stamp (annotation of its
1141  // components will be lost)
1142  // @todo: see how to change sheet paths for its cmp list (can
1143  // be possible in most cases)
1144  else
1145  item->SetTimeStamp( GetNewTimeStamp() );
1146  }
1147  }
1148 
1149  return count;
1150 }
timestamp_t GetNewTimeStamp()
Definition: common.cpp:217
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:588
timestamp_t GetTimeStamp() const
Definition: base_struct.h:210
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:496
size_t i
Definition: json11.cpp:597
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
static bool SortByTimeStamp(const EDA_ITEM *item1, const EDA_ITEM *item2)
Sort a list of schematic items by time stamp and type.
Definition: sch_screen.cpp:969
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:209

References GetNewTimeStamp(), EDA_ITEM::GetTimeStamp(), i, m_screens, SCH_COMPONENT_T, EDA_ITEM::SetTimeStamp(), SortByTimeStamp(), and EDA_ITEM::Type().

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

◆ TestDanglingEnds()

void SCH_SCREENS::TestDanglingEnds ( )

Definition at line 1215 of file sch_screen.cpp.

1216 {
1217  std::vector<SCH_SCREEN*> screens;
1218  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1219  screens.push_back( screen );
1220 
1221  size_t parallelThreadCount = std::min<size_t>( std::thread::hardware_concurrency(),
1222  screens.size() );
1223 
1224  std::atomic<size_t> nextScreen( 0 );
1225  std::vector<std::future<size_t>> returns( parallelThreadCount );
1226 
1227  auto update_lambda = [&screens, &nextScreen]() -> size_t
1228  {
1229  for( auto i = nextScreen++; i < screens.size(); i = nextScreen++ )
1230  screens[i]->TestDanglingEnds();
1231 
1232  return 1;
1233  };
1234 
1235  if( parallelThreadCount == 1 )
1236  update_lambda();
1237  else
1238  {
1239  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
1240  returns[ii] = std::async( std::launch::async, update_lambda );
1241 
1242  // Finalize the threads
1243  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
1244  returns[ii].wait();
1245  }
1246 
1247 }
SCH_SCREEN * GetNext()
void TestDanglingEnds()
size_t i
Definition: json11.cpp:597
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:996

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

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

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

1209 {
1210  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1211  screen->UpdateSymbolLinks( aForce );
1212 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:996

References GetFirst(), and GetNext().

Referenced by SCH_EDIT_FRAME::AppendSchematic(), SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile(), SCH_EDIT_FRAME::CreateNetlist(), SCH_EDIT_FRAME::importFile(), InvokeSchEditSymbolLibTable(), SCH_EDIT_FRAME::KiwayMailIn(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::prepareForNetlist(), DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable(), 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 497 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: