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

Constructor & Destructor Documentation

◆ SCH_SCREENS() [1/2]

SCH_SCREENS::SCH_SCREENS ( SCH_SHEET aSheet)

Definition at line 1097 of file sch_screen.cpp.

1098 {
1099  m_index = 0;
1100  buildScreenList( aSheet );
1101 }
unsigned int m_index
Definition: sch_screen.h:539
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 543 of file sch_screen.h.

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

◆ ~SCH_SCREENS()

SCH_SCREENS::~SCH_SCREENS ( )

Definition at line 1104 of file sch_screen.cpp.

1105 {
1106 }

Member Function Documentation

◆ addScreenToList()

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

Definition at line 1147 of file sch_screen.cpp.

1148 {
1149  if( aScreen == NULL )
1150  return;
1151 
1152  for( const SCH_SCREEN* screen : m_screens )
1153  {
1154  if( screen == aScreen )
1155  return;
1156  }
1157 
1158  m_screens.push_back( aScreen );
1159  m_sheets.push_back( aSheet );
1160 }
std::vector< SCH_SHEET * > m_sheets
Definition: sch_screen.h:538
#define NULL
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:537

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

1433 {
1434  SCH_SCREEN* first = GetFirst();
1435 
1436  if( !first )
1437  return;
1438 
1439  SCHEMATIC* sch = first->Schematic();
1440 
1441  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::BuildClientSheetPathList" );
1442 
1443  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1444  curr_screen->GetClientSheetPaths().clear();
1445 
1446  for( SCH_SHEET_PATH& sheetpath : sch->GetSheets() )
1447  {
1448  SCH_SCREEN* used_screen = sheetpath.LastScreen();
1449 
1450  // SEarch for the used_screen in list and add this unique sheet path:
1451  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1452  {
1453  if( used_screen == curr_screen )
1454  {
1455  curr_screen->GetClientSheetPaths().push_back( sheetpath );
1456  break;
1457  }
1458  }
1459  }
1460 }
SCH_SCREEN * GetNext()
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:58
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:111
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:87
std::vector< SCH_SHEET_PATH > & GetClientSheetPaths()
Definition: sch_screen.h:212
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 1163 of file sch_screen.cpp.

1164 {
1165  if( aSheet && aSheet->Type() == SCH_SHEET_T )
1166  {
1167  SCH_SCREEN* screen = aSheet->GetScreen();
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:219
void addScreenToList(SCH_SCREEN *aScreen, SCH_SHEET *aSheet)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:285
void buildScreenList(SCH_SHEET *aSheet)
EE_RTREE & Items()
Definition: sch_screen.h:162
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:196
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162

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

1406 {
1407  wxString lhsLower;
1408  wxString rhsLower;
1409  wxFileName lhs;
1410  wxFileName rhs = aSchematicFileName;
1411 
1412  wxCHECK( rhs.IsAbsolute(), false );
1413 
1414  for( const SCH_SCREEN* screen : m_screens )
1415  {
1416  lhs = screen->GetFileName();
1417 
1418  if( lhs.GetPath() != rhs.GetPath() )
1419  continue;
1420 
1421  lhsLower = lhs.GetFullName().Lower();
1422  rhsLower = rhs.GetFullName().Lower();
1423 
1424  if( lhsLower == rhsLower && lhs.GetFullName() != rhs.GetFullName() )
1425  return true;
1426  }
1427 
1428  return false;
1429 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:537

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

1369 {
1370  SCH_SCREEN* screen;
1371  int cnt = 0;
1372 
1373  for( screen = GetFirst(); screen; screen = GetNext() )
1374  {
1375  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
1376  {
1377  auto symbol = static_cast<SCH_COMPONENT*>( item );
1378 
1379  if( symbol->GetLibId().GetLibNickname() != aFrom )
1380  continue;
1381 
1382  LIB_ID id = symbol->GetLibId();
1383  id.SetLibNickname( aTo );
1384  symbol->SetLibId( id );
1385  cnt++;
1386  }
1387  }
1388 
1389  return cnt;
1390 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:219
SCH_SCREEN * GetNext()
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:193
EE_RTREE & Items()
Definition: sch_screen.h:162
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 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 A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:58
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
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:111
SCH_SHEET & Root() const
Definition: schematic.h:116
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:87
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:534

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

1301 {
1302  DeleteMarkers( aMarkerType, ERCE_UNSPECIFIED, aIncludeExclusions );
1303 }
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 1257 of file sch_screen.cpp.

1258 {
1259  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1260  {
1261  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1262  {
1263  if( item == aMarker )
1264  {
1265  screen->DeleteItem( item );
1266  return;
1267  }
1268  }
1269  }
1270 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:196

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

1275 {
1276  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1277  {
1278  std::vector<SCH_ITEM*> markers;
1279 
1280  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1281  {
1282  SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
1283  std::shared_ptr<RC_ITEM>rcItem = marker->GetRCItem();
1284 
1285  if( marker->GetMarkerType() == aMarkerType
1286  && ( aErrorCode == ERCE_UNSPECIFIED || rcItem->GetErrorCode() == aErrorCode )
1287  && ( !marker->IsExcluded() || aIncludeExclusions ) )
1288  {
1289  markers.push_back( item );
1290  }
1291  }
1292 
1293  for( SCH_ITEM* marker : markers )
1294  screen->DeleteItem( marker );
1295  }
1296 }
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:196
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 545 of file sch_screen.h.

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

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

1351 {
1352  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1353  {
1354  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
1355  {
1356  SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
1357  const UTF8& nickname = symbol->GetLibId().GetLibNickname();
1358 
1359  if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1360  aLibNicknames.Add( nickname );
1361  }
1362  }
1363 
1364  return aLibNicknames.GetCount();
1365 }
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:70
SCH_SCREEN * GetNext()
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:92
Schematic symbol object.
Definition: sch_symbol.h:79
SCH_SCREEN * GetFirst()
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:189
bool empty() const
Definition: utf8.h:103

References UTF8::empty(), GetFirst(), SCH_COMPONENT::GetLibId(), LIB_ID::GetLibNickname(), GetNext(), and SCH_COMPONENT_T.

◆ GetNext()

◆ GetScreen()

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

Definition at line 1129 of file sch_screen.cpp.

1130 {
1131  if( aIndex < m_screens.size() )
1132  return m_screens[ aIndex ];
1133 
1134  return NULL;
1135 }
#define NULL
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:537

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

1139 {
1140  if( aIndex < m_sheets.size() )
1141  return m_sheets[ aIndex ];
1142 
1143  return NULL;
1144 }
std::vector< SCH_SHEET * > m_sheets
Definition: sch_screen.h:538
#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 1329 of file sch_screen.cpp.

1330 {
1331  SCH_SCREEN* screen;
1332  unsigned cnt = 0;
1333 
1334  for( screen = GetFirst(); screen; screen = GetNext() )
1335  {
1336  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
1337  {
1338  cnt++;
1339  SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
1340 
1341  if( !symbol->GetLibId().GetLibNickname().empty() )
1342  return false;
1343  }
1344  }
1345 
1346  return cnt != 0;
1347 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:219
SCH_SCREEN * GetNext()
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:92
EE_RTREE & Items()
Definition: sch_screen.h:162
Schematic symbol object.
Definition: sch_symbol.h:79
SCH_SCREEN * GetFirst()
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:189
bool empty() const
Definition: utf8.h:103

References UTF8::empty(), GetFirst(), SCH_COMPONENT::GetLibId(), LIB_ID::GetLibNickname(), 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 1393 of file sch_screen.cpp.

1394 {
1395  for( const SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1396  {
1397  if( screen->GetFileName() == aSchematicFileName )
1398  return true;
1399  }
1400 
1401  return false;
1402 }
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 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:524
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:537
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149

References m_screens, and EDA_ITEM::m_Uuid.

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

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

1307 {
1308  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1309  screen->UpdateSymbolLinks( aReporter );
1310 
1311  SCH_SCREEN* first = GetFirst();
1312 
1313  if( !first )
1314  return;
1315 
1316  SCHEMATIC* sch = first->Schematic();
1317 
1318  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::UpdateSymbolLinks" );
1319 
1320  SCH_SHEET_LIST sheets = sch->GetSheets();
1321 
1322  // All of the library symbols have been replaced with copies so the connection graph
1323  // pointers are stale.
1324  if( sch->ConnectionGraph() )
1325  sch->ConnectionGraph()->Recalculate( sheets, true );
1326 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_SCREEN * GetNext()
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:58
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:151
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:111
SCHEMATIC * Schematic() const
Definition: sch_screen.cpp:87
SCH_SCREEN * GetFirst()

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

Referenced by 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 539 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 538 of file sch_screen.h.

Referenced by addScreenToList(), and GetSheet().


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