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

Constructor & Destructor Documentation

◆ SCH_SCREENS() [1/2]

SCH_SCREENS::SCH_SCREENS ( SCH_SHEET aSheet)

Definition at line 1168 of file sch_screen.cpp.

1169 {
1170  m_index = 0;
1171  buildScreenList( aSheet );
1172 }
unsigned int m_index
Definition: sch_screen.h:724
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 597 of file sch_screen.h.

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

◆ ~SCH_SCREENS()

SCH_SCREENS::~SCH_SCREENS ( )

Definition at line 1175 of file sch_screen.cpp.

1176 {
1177 }

Member Function Documentation

◆ addScreenToList()

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

Definition at line 1218 of file sch_screen.cpp.

1219 {
1220  if( aScreen == nullptr )
1221  return;
1222 
1223  for( const SCH_SCREEN* screen : m_screens )
1224  {
1225  if( screen == aScreen )
1226  return;
1227  }
1228 
1229  m_screens.push_back( aScreen );
1230  m_sheets.push_back( aSheet );
1231 }
std::vector< SCH_SHEET * > m_sheets
Definition: sch_screen.h:723
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:722

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

1516 {
1517  SCH_SCREEN* first = GetFirst();
1518 
1519  if( !first )
1520  return;
1521 
1522  SCHEMATIC* sch = first->Schematic();
1523 
1524  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::BuildClientSheetPathList" );
1525 
1526  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1527  curr_screen->GetClientSheetPaths().clear();
1528 
1529  for( SCH_SHEET_PATH& sheetpath : sch->GetSheets() )
1530  {
1531  SCH_SCREEN* used_screen = sheetpath.LastScreen();
1532 
1533  // SEarch for the used_screen in list and add this unique sheet path:
1534  for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
1535  {
1536  if( used_screen == curr_screen )
1537  {
1538  curr_screen->GetClientSheetPaths().push_back( sheetpath );
1539  break;
1540  }
1541  }
1542  }
1543 }
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:92
std::vector< SCH_SHEET_PATH > & GetClientSheetPaths()
Return the number of times this screen is used.
Definition: sch_screen.h:179
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 1234 of file sch_screen.cpp.

1235 {
1236  if( aSheet && aSheet->Type() == SCH_SHEET_T )
1237  {
1238  SCH_SCREEN* screen = aSheet->GetScreen();
1239 
1240  wxCHECK_RET( screen, "No screen for aSheet" );
1241 
1242  addScreenToList( screen, aSheet );
1243 
1244  for( SCH_ITEM* item : screen->Items().OfType( SCH_SHEET_T ) )
1245  buildScreenList( static_cast<SCH_SHEET*>( item ) );
1246  }
1247 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:230
void addScreenToList(SCH_SCREEN *aScreen, SCH_SHEET *aSheet)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:105
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:182
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

1489 {
1490  wxString lhsLower;
1491  wxString rhsLower;
1492  wxFileName lhs;
1493  wxFileName rhs = aSchematicFileName;
1494 
1495  wxCHECK( rhs.IsAbsolute(), false );
1496 
1497  for( const SCH_SCREEN* screen : m_screens )
1498  {
1499  lhs = screen->GetFileName();
1500 
1501  if( lhs.GetPath() != rhs.GetPath() )
1502  continue;
1503 
1504  lhsLower = lhs.GetFullName().Lower();
1505  rhsLower = rhs.GetFullName().Lower();
1506 
1507  if( lhsLower == rhsLower && lhs.GetFullName() != rhs.GetFullName() )
1508  return true;
1509  }
1510 
1511  return false;
1512 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:722

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

1452 {
1453  SCH_SCREEN* screen;
1454  int cnt = 0;
1455 
1456  for( screen = GetFirst(); screen; screen = GetNext() )
1457  {
1458  for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1459  {
1460  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1461 
1462  if( symbol->GetLibId().GetLibNickname() != aFrom )
1463  continue;
1464 
1465  LIB_ID id = symbol->GetLibId();
1466  id.SetLibNickname( aTo );
1467  symbol->SetLibId( id );
1468  cnt++;
1469  }
1470  }
1471 
1472  return cnt;
1473 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:230
SCH_SCREEN * GetNext()
void SetLibId(const LIB_ID &aName)
Definition: sch_symbol.cpp:240
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:90
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:97
Schematic symbol object.
Definition: sch_symbol.h:78
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
SCH_SCREEN * GetFirst()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:147

References GetFirst(), SCH_SYMBOL::GetLibId(), LIB_ID::GetLibNickname(), GetNext(), SCH_SCREEN::Items(), EE_RTREE::OfType(), SCH_SYMBOL_T, SCH_SYMBOL::SetLibId(), 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 1250 of file sch_screen.cpp.

1251 {
1252  SCH_SCREEN* first = GetFirst();
1253 
1254  if( !first )
1255  return;
1256 
1257  SCHEMATIC* sch = first->Schematic();
1258 
1259  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::ClearAnnotationOfNewSheetPaths" );
1260 
1261  // Clear the annotation for symbols inside new sheetpaths not already in aInitialSheetList
1262  SCH_SCREENS screensList( sch->Root() ); // The list of screens, shared by sheet paths
1263  screensList.BuildClientSheetPathList(); // build the shared by sheet paths, by screen
1264 
1265  // Search for new sheet paths, not existing in aInitialSheetPathList
1266  // and existing in sheetpathList
1267  for( SCH_SHEET_PATH& sheetpath : sch->GetSheets() )
1268  {
1269  bool path_exists = false;
1270 
1271  for( const SCH_SHEET_PATH& existing_sheetpath: aInitialSheetPathList )
1272  {
1273  if( existing_sheetpath.Path() == sheetpath.Path() )
1274  {
1275  path_exists = true;
1276  break;
1277  }
1278  }
1279 
1280  if( !path_exists )
1281  {
1282  // A new sheet path is found: clear the annotation corresponding to this new path:
1283  SCH_SCREEN* curr_screen = sheetpath.LastScreen();
1284 
1285  // Clear annotation and create the AR for this path, if not exists,
1286  // when the screen is shared by sheet paths.
1287  // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1288  // reference default value and takes the latest displayed value
1289  curr_screen->EnsureAlternateReferencesExist();
1290  curr_screen->ClearAnnotation( &sheetpath );
1291  }
1292  }
1293 }
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:996
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:92
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the symbols in aSheetPath on the screen.
Definition: sch_screen.cpp:984
SCH_SCREEN * GetFirst()
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:593

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

1331 {
1332  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1333  {
1334  for( SCH_ITEM* item : screen->Items() )
1335  item->ClearEditFlags();
1336  }
1337 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182

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

1384 {
1385  DeleteMarkers( aMarkerType, ERCE_UNSPECIFIED, aIncludeExclusions );
1386 }
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 1340 of file sch_screen.cpp.

1341 {
1342  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1343  {
1344  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1345  {
1346  if( item == aMarker )
1347  {
1348  screen->DeleteItem( item );
1349  return;
1350  }
1351  }
1352  }
1353 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182

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

1358 {
1359  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1360  {
1361  std::vector<SCH_ITEM*> markers;
1362 
1363  for( SCH_ITEM* item : screen->Items().OfType( SCH_MARKER_T ) )
1364  {
1365  SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
1366  std::shared_ptr<RC_ITEM>rcItem = marker->GetRCItem();
1367 
1368  if( marker->GetMarkerType() == aMarkerType
1369  && ( aErrorCode == ERCE_UNSPECIFIED || rcItem->GetErrorCode() == aErrorCode )
1370  && ( !marker->IsExcluded() || aIncludeExclusions ) )
1371  {
1372  markers.push_back( item );
1373  }
1374  }
1375 
1376  for( SCH_ITEM* marker : markers )
1377  screen->DeleteItem( marker );
1378  }
1379 }
SCH_SCREEN * GetNext()
bool IsExcluded() const
Definition: marker_base.h:95
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:93
SCH_SCREEN * GetFirst()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
std::shared_ptr< RC_ITEM > GetRCItem() const
Definition: marker_base.h:101

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

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

References m_screens.

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

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

1434 {
1435  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1436  {
1437  for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1438  {
1439  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1440  const UTF8& nickname = symbol->GetLibId().GetLibNickname();
1441 
1442  if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1443  aLibNicknames.Add( nickname );
1444  }
1445  }
1446 
1447  return aLibNicknames.GetCount();
1448 }
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()
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
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 1200 of file sch_screen.cpp.

1201 {
1202  if( aIndex < m_screens.size() )
1203  return m_screens[ aIndex ];
1204 
1205  return nullptr;
1206 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:722

References m_screens.

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

◆ GetSheet()

SCH_SHEET * SCH_SCREENS::GetSheet ( unsigned int  aIndex) const

Definition at line 1209 of file sch_screen.cpp.

1210 {
1211  if( aIndex < m_sheets.size() )
1212  return m_sheets[ aIndex ];
1213 
1214  return nullptr;
1215 }
std::vector< SCH_SHEET * > m_sheets
Definition: sch_screen.h:723

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

1413 {
1414  bool has_symbols = false;
1415 
1416  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1417  {
1418  for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
1419  {
1420  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1421  has_symbols = true;
1422 
1423  if( !symbol->GetLibId().GetLibNickname().empty() )
1424  return false;
1425  }
1426  }
1427 
1428  // return true (i.e. has no fully defined symbol) only if at least one symbol is found
1429  return has_symbols ? true : false;
1430 }
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:182
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 1476 of file sch_screen.cpp.

1477 {
1478  for( const SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1479  {
1480  if( screen->GetFileName() == aSchematicFileName )
1481  return true;
1482  }
1483 
1484  return false;
1485 }
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 1296 of file sch_screen.cpp.

1297 {
1298  std::vector<SCH_ITEM*> items;
1299  int count = 0;
1300 
1301  auto timestamp_cmp = []( const EDA_ITEM* a, const EDA_ITEM* b ) -> bool
1302  {
1303  return a->m_Uuid < b->m_Uuid;
1304  };
1305 
1306  std::set<EDA_ITEM*, decltype( timestamp_cmp )> unique_stamps( timestamp_cmp );
1307 
1308  for( SCH_SCREEN* screen : m_screens )
1309  screen->GetHierarchicalItems( &items );
1310 
1311  if( items.size() < 2 )
1312  return 0;
1313 
1314  for( EDA_ITEM* item : items )
1315  {
1316  if( !unique_stamps.insert( item ).second )
1317  {
1318  // Reset to fully random UUID. This may lose reference, but better to be
1319  // deterministic about it rather than to have duplicate UUIDs with random
1320  // side-effects.
1321  const_cast<KIID&>( item->m_Uuid ) = KIID();
1322  count++;
1323  }
1324  }
1325 
1326  return count;
1327 }
Definition: kiid.h:44
const KIID m_Uuid
Definition: eda_item.h:474
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:722
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99

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

1390 {
1391  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1392  screen->UpdateSymbolLinks( aReporter );
1393 
1394  SCH_SCREEN* first = GetFirst();
1395 
1396  if( !first )
1397  return;
1398 
1399  SCHEMATIC* sch = first->Schematic();
1400 
1401  wxCHECK_RET( sch, "Null schematic in SCH_SCREENS::UpdateSymbolLinks" );
1402 
1403  SCH_SHEET_LIST sheets = sch->GetSheets();
1404 
1405  // All of the library symbols have been replaced with copies so the connection graph
1406  // pointers are stale.
1407  if( sch->ConnectionGraph() )
1408  sch->ConnectionGraph()->Recalculate( sheets, true );
1409 }
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:92
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 724 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 723 of file sch_screen.h.

Referenced by addScreenToList(), and GetSheet().


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