KiCad PCB EDA Suite
SCH_SCREENS Class Reference

Container class that holds multiple SCH_SCREEN objects in a hierarchy. More...

#include <sch_screen.h>

Public Member Functions

 SCH_SCREENS (SCH_SHEET *aSheet)
 
 SCH_SCREENS (SCH_SHEET &aSheet)
 
 ~SCH_SCREENS ()
 
size_t GetCount () const
 
SCH_SCREENGetFirst ()
 
SCH_SCREENGetNext ()
 
SCH_SCREENGetScreen (unsigned int aIndex) const
 
SCH_SHEETGetSheet (unsigned int aIndex) const
 
void ClearAnnotationOfNewSheetPaths (SCH_SHEET_LIST &aInitialSheetPathList)
 Clear the annotation for the symbols inside new sheetpaths when a complex hierarchy is modified and new sheetpaths added when a screen shares more than one sheet path, missing alternate references are added and alternate references of new sheet paths are cleared. More...
 
int ReplaceDuplicateTimeStamps ()
 Test all sheet and symbol objects in the schematic for duplicate time stamps and replaces them as necessary. More...
 
void DeleteAllMarkers (enum MARKER_BASE::TYPEMARKER aMarkerType, bool aIncludeExclusions)
 Delete all electronic rules check markers of aMarkerType from all the screens in the list. More...
 
void DeleteMarkers (enum MARKER_BASE::TYPEMARKER aMarkerTyp, int aErrorCode, bool aIncludeExclusions=true)
 Delete all markers of a particular type and error code. More...
 
void DeleteMarker (SCH_MARKER *aMarker)
 Delete a specific marker. More...
 
void UpdateSymbolLinks (REPORTER *aReporter=nullptr)
 Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in the full schematic. More...
 
void ClearEditFlags ()
 
bool HasNoFullyDefinedLibIds ()
 Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set. More...
 
size_t GetLibNicknames (wxArrayString &aLibNicknames)
 Fetch all of the symbol library nicknames into aLibNicknames. More...
 
int ChangeSymbolLibNickname (const wxString &aFrom, const wxString &aTo)
 Change all of the symbol library nicknames. More...
 
bool HasSchematic (const wxString &aSchematicFileName)
 Check if one of the schematics in the list of screens is aSchematicFileName. More...
 
void BuildClientSheetPathList ()
 built the list of sheet paths sharing a screen for each screen in use More...
 
bool CanCauseCaseSensitivityIssue (const wxString &aSchematicFileName) const
 Check aSchematicFileName for a potential file name case sensitivity issue. More...
 

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

Constructor & Destructor Documentation

◆ SCH_SCREENS() [1/2]

SCH_SCREENS::SCH_SCREENS ( SCH_SHEET aSheet)

Definition at line 1095 of file sch_screen.cpp.

1096 {
1097  m_index = 0;
1098  buildScreenList( aSheet );
1099 }
unsigned int m_index
Definition: sch_screen.h:688
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 561 of file sch_screen.h.

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

◆ ~SCH_SCREENS()

SCH_SCREENS::~SCH_SCREENS ( )

Definition at line 1102 of file sch_screen.cpp.

1103 {
1104 }

Member Function Documentation

◆ addScreenToList()

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

Definition at line 1145 of file sch_screen.cpp.

1146 {
1147  if( aScreen == nullptr )
1148  return;
1149 
1150  for( const SCH_SCREEN* screen : m_screens )
1151  {
1152  if( screen == aScreen )
1153  return;
1154  }
1155 
1156  m_screens.push_back( aScreen );
1157  m_sheets.push_back( aSheet );
1158 }
std::vector< SCH_SHEET * > m_sheets
Definition: sch_screen.h:687
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:686

References m_screens, and m_sheets.

Referenced by buildScreenList().

◆ BuildClientSheetPathList()

void SCH_SCREENS::BuildClientSheetPathList ( )

built the list of sheet paths sharing a screen for each screen in use

Definition at line 1442 of file sch_screen.cpp.

1443 {
1444  SCH_SCREEN* first = GetFirst();
1445 
1446  if( !first )
1447  return;
1448 
1449  SCHEMATIC* sch = first->Schematic();
1450 
1451  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::BuildClientSheetPathList" );
1452 
1453  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1454  curr_screen->GetClientSheetPaths().clear();
1455 
1456  for( SCH_SHEET_PATH& sheetpath : sch->GetSheets() )
1457  {
1458  SCH_SCREEN* used_screen = sheetpath.LastScreen();
1459 
1460  // SEarch for the used_screen in list and add this unique sheet path:
1461  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1462  {
1463  if( used_screen == curr_screen )
1464  {
1465  curr_screen->GetClientSheetPaths().push_back( sheetpath );
1466  break;
1467  }
1468  }
1469  }
1470 }
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:171
SCH_SCREEN * GetFirst()

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

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

◆ buildScreenList()

void SCH_SCREENS::buildScreenList ( SCH_SHEET aSheet)
private

Definition at line 1161 of file sch_screen.cpp.

1162 {
1163  if( aSheet && aSheet->Type() == SCH_SHEET_T )
1164  {
1165  SCH_SCREEN* screen = aSheet->GetScreen();
1166 
1167  wxCHECK_RET( screen, "No screen for aSheet" );
1168 
1169  addScreenToList( screen, aSheet );
1170 
1171  for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
1172  buildScreenList( static_cast<SCH_SHEET*>( item ) );
1173  }
1174 }
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()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193
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 1415 of file sch_screen.cpp.

1416 {
1417  wxString lhsLower;
1418  wxString rhsLower;
1419  wxFileName lhs;
1420  wxFileName rhs = aSchematicFileName;
1421 
1422  wxCHECK( rhs.IsAbsolute(), false );
1423 
1424  for( const SCH_SCREEN* screen : m_screens )
1425  {
1426  lhs = screen->GetFileName();
1427 
1428  if( lhs.GetPath() != rhs.GetPath() )
1429  continue;
1430 
1431  lhsLower = lhs.GetFullName().Lower();
1432  rhsLower = rhs.GetFullName().Lower();
1433 
1434  if( lhsLower == rhsLower && lhs.GetFullName() != rhs.GetFullName() )
1435  return true;
1436  }
1437 
1438  return false;
1439 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:686

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

1379 {
1380  SCH_SCREEN* screen;
1381  int cnt = 0;
1382 
1383  for( screen = GetFirst(); screen; screen = GetNext() )
1384  {
1385  for( auto item : screen->Items().OfType( SCH_SYMBOL_T ) )
1386  {
1387  auto symbol = static_cast<SCH_SYMBOL*>( item );
1388 
1389  if( symbol->GetLibId().GetLibNickname() != aFrom )
1390  continue;
1391 
1392  LIB_ID id = symbol->GetLibId();
1393  id.SetLibNickname( aTo );
1394  symbol->SetLibId( id );
1395  cnt++;
1396  }
1397  }
1398 
1399  return cnt;
1400 }
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:97
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
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 1177 of file sch_screen.cpp.

1178 {
1179  SCH_SCREEN* first = GetFirst();
1180 
1181  if( !first )
1182  return;
1183 
1184  SCHEMATIC* sch = first->Schematic();
1185 
1186  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::ClearAnnotationOfNewSheetPaths" );
1187 
1188  // Clear the annotation for symbols inside new sheetpaths not already in aInitialSheetList
1189  SCH_SCREENS screensList( sch->Root() ); // The list of screens, shared by sheet paths
1190  screensList.BuildClientSheetPathList(); // build the shared by sheet paths, by screen
1191 
1192  // Search for new sheet paths, not existing in aInitialSheetPathList
1193  // and existing in sheetpathList
1194  for( SCH_SHEET_PATH& sheetpath : sch->GetSheets() )
1195  {
1196  bool path_exists = false;
1197 
1198  for( const SCH_SHEET_PATH& existing_sheetpath: aInitialSheetPathList )
1199  {
1200  if( existing_sheetpath.Path() == sheetpath.Path() )
1201  {
1202  path_exists = true;
1203  break;
1204  }
1205  }
1206 
1207  if( !path_exists )
1208  {
1209  // A new sheet path is found: clear the annotation corresponding to this new path:
1210  SCH_SCREEN* curr_screen = sheetpath.LastScreen();
1211 
1212  // Clear annotation and create the AR for this path, if not exists,
1213  // when the screen is shared by sheet paths.
1214  // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1215  // reference default value and takes the latest displayed value
1216  curr_screen->EnsureAlternateReferencesExist();
1217  curr_screen->ClearAnnotation( &sheetpath );
1218  }
1219  }
1220 }
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:557

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

Referenced by SCH_EDIT_TOOL::Properties().

◆ ClearEditFlags()

void SCH_SCREENS::ClearEditFlags ( )

Definition at line 1257 of file sch_screen.cpp.

1258 {
1259  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1260  {
1261  for( SCH_ITEM* item : screen->Items() )
1262  item->ClearEditFlags();
1263  }
1264 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193

References GetFirst(), and GetNext().

Referenced by SCH_ALTIUM_PLUGIN::Load().

◆ DeleteAllMarkers()

void SCH_SCREENS::DeleteAllMarkers ( enum MARKER_BASE::TYPEMARKER  aMarkerType,
bool  aIncludeExclusions 
)

Delete all electronic rules check markers of aMarkerType from all the screens in the list.

Parameters
aMarkerTypeType of markers to be deleted.

Definition at line 1309 of file sch_screen.cpp.

1311 {
1312  DeleteMarkers( aMarkerType, ERCE_UNSPECIFIED, aIncludeExclusions );
1313 }
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 1267 of file sch_screen.cpp.

1268 {
1269  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1270  {
1271  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1272  {
1273  if( item == aMarker )
1274  {
1275  screen->DeleteItem( item );
1276  return;
1277  }
1278  }
1279  }
1280 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193

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

1285 {
1286  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1287  {
1288  std::vector<SCH_ITEM*> markers;
1289 
1290  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1291  {
1292  SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
1293  std::shared_ptr<RC_ITEM>rcItem = marker->GetRCItem();
1294 
1295  if( marker->GetMarkerType() == aMarkerType
1296  && ( aErrorCode == ERCE_UNSPECIFIED || rcItem->GetErrorCode() == aErrorCode )
1297  && ( !marker->IsExcluded() || aIncludeExclusions ) )
1298  {
1299  markers.push_back( item );
1300  }
1301  }
1302 
1303  for( SCH_ITEM* marker : markers )
1304  screen->DeleteItem( marker );
1305  }
1306 }
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:193
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 563 of file sch_screen.h.

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

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

1361 {
1362  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1363  {
1364  for( auto item : screen->Items().OfType( SCH_SYMBOL_T ) )
1365  {
1366  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1367  const UTF8& nickname = symbol->GetLibId().GetLibNickname();
1368 
1369  if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1370  aLibNicknames.Add( nickname );
1371  }
1372  }
1373 
1374  return aLibNicknames.GetCount();
1375 }
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:90
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 1127 of file sch_screen.cpp.

1128 {
1129  if( aIndex < m_screens.size() )
1130  return m_screens[ aIndex ];
1131 
1132  return nullptr;
1133 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:686

References m_screens.

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

1137 {
1138  if( aIndex < m_sheets.size() )
1139  return m_sheets[ aIndex ];
1140 
1141  return nullptr;
1142 }
std::vector< SCH_SHEET * > m_sheets
Definition: sch_screen.h:687

References m_sheets.

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

◆ HasNoFullyDefinedLibIds()

bool SCH_SCREENS::HasNoFullyDefinedLibIds ( )

Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.

If none of the LIB_ID object library nicknames are not set, this indicates that the project was created before the symbol library implementation.

Returns
true in there are any symbols and if all of the LIB_ID object library nicknames are empty, otherwise false.

Definition at line 1339 of file sch_screen.cpp.

1340 {
1341  bool has_symbols = false;
1342 
1343  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1344  {
1345  for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1346  {
1347  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1348  has_symbols = true;
1349 
1350  if( !symbol->GetLibId().GetLibNickname().empty() )
1351  return false;
1352  }
1353  }
1354 
1355  // return true (i.e. has no fully defined symbol) only if at least one symbol is found
1356  return has_symbols ? true : false;
1357 }
SCH_SCREEN * GetNext()
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:90
Schematic symbol object.
Definition: sch_symbol.h:78
SCH_SCREEN * GetFirst()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193
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.

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

1404 {
1405  for( const SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1406  {
1407  if( screen->GetFileName() == aSchematicFileName )
1408  return true;
1409  }
1410 
1411  return false;
1412 }
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 1223 of file sch_screen.cpp.

1224 {
1225  std::vector<SCH_ITEM*> items;
1226  int count = 0;
1227 
1228  auto timestamp_cmp = []( const EDA_ITEM* a, const EDA_ITEM* b ) -> bool
1229  {
1230  return a->m_Uuid < b->m_Uuid;
1231  };
1232 
1233  std::set<EDA_ITEM*, decltype( timestamp_cmp )> unique_stamps( timestamp_cmp );
1234 
1235  for( SCH_SCREEN* screen : m_screens )
1236  screen->GetHierarchicalItems( &items );
1237 
1238  if( items.size() < 2 )
1239  return 0;
1240 
1241  for( EDA_ITEM* item : items )
1242  {
1243  if( !unique_stamps.insert( item ).second )
1244  {
1245  // Reset to fully random UUID. This may lose reference, but better to be
1246  // deterministic about it rather than to have duplicate UUIDs with random
1247  // side-effects.
1248  const_cast<KIID&>( item->m_Uuid ) = KIID();
1249  count++;
1250  }
1251  }
1252 
1253  return count;
1254 }
Definition: kiid.h:44
const KIID m_Uuid
Definition: eda_item.h:475
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:686
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 1316 of file sch_screen.cpp.

1317 {
1318  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1319  screen->UpdateSymbolLinks( aReporter );
1320 
1321  SCH_SCREEN* first = GetFirst();
1322 
1323  if( !first )
1324  return;
1325 
1326  SCHEMATIC* sch = first->Schematic();
1327 
1328  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::UpdateSymbolLinks" );
1329 
1330  SCH_SHEET_LIST sheets = sch->GetSheets();
1331 
1332  // All of the library symbols have been replaced with copies so the connection graph
1333  // pointers are stale.
1334  if( sch->ConnectionGraph() )
1335  sch->ConnectionGraph()->Recalculate( sheets, true );
1336 }
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:131
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 688 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 687 of file sch_screen.h.

Referenced by addScreenToList(), and GetSheet().


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