KiCad PCB EDA Suite
SCH_SCREENS Class Reference

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

#include <class_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 SchematicCleanUp ()
 Merge and break wire segments in the entire schematic hierarchy. 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...
 

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 525 of file class_sch_screen.h.

Constructor & Destructor Documentation

SCH_SCREENS::SCH_SCREENS ( SCH_SHEET aSheet = NULL)

Definition at line 1281 of file sch_screen.cpp.

References buildScreenList(), g_RootSheet, and m_index.

1282 {
1283  m_index = 0;
1284  buildScreenList( ( !aSheet ) ? g_RootSheet : aSheet );
1285 }
unsigned int m_index
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
void buildScreenList(SCH_SHEET *aSheet)
SCH_SCREENS::~SCH_SCREENS ( )

Definition at line 1288 of file sch_screen.cpp.

1289 {
1290 }

Member Function Documentation

void SCH_SCREENS::addScreenToList ( SCH_SCREEN aScreen)
private

Definition at line 1322 of file sch_screen.cpp.

References m_screens.

Referenced by buildScreenList().

1323 {
1324  if( aScreen == NULL )
1325  return;
1326 
1327  for( unsigned int i = 0; i < m_screens.size(); i++ )
1328  {
1329  if( m_screens[i] == aScreen )
1330  return;
1331  }
1332 
1333  m_screens.push_back( aScreen );
1334 }
std::vector< SCH_SCREEN * > m_screens
void SCH_SCREENS::buildScreenList ( SCH_SHEET aSheet)
private

Definition at line 1337 of file sch_screen.cpp.

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

Referenced by SCH_SCREENS().

1338 {
1339  if( aSheet && aSheet->Type() == SCH_SHEET_T )
1340  {
1341  SCH_SCREEN* screen = aSheet->GetScreen();
1342 
1343  addScreenToList( screen );
1344 
1345  EDA_ITEM* strct = screen->GetDrawItems();
1346 
1347  while( strct )
1348  {
1349  if( strct->Type() == SCH_SHEET_T )
1350  {
1351  buildScreenList( ( SCH_SHEET* )strct );
1352  }
1353 
1354  strct = strct->Next();
1355  }
1356  }
1357 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
EDA_ITEM * Next() const
Definition: base_struct.h:220
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:279
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
void buildScreenList(SCH_SHEET *aSheet)
SCH_ITEM * GetDrawItems() const
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:165
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 1553 of file sch_screen.cpp.

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().

1554 {
1555  SCH_COMPONENT* symbol;
1556  SCH_ITEM* item;
1557  SCH_ITEM* nextItem;
1558  SCH_SCREEN* screen;
1559  int cnt = 0;
1560 
1561  for( screen = GetFirst(); screen; screen = GetNext() )
1562  {
1563  for( item = screen->GetDrawItems(); item; item = nextItem )
1564  {
1565  nextItem = item->Next();
1566 
1567  if( item->Type() != SCH_COMPONENT_T )
1568  continue;
1569 
1570  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1571 
1572  if( symbol->GetLibId().GetLibNickname() != aFrom )
1573  continue;
1574 
1575  LIB_ID id = symbol->GetLibId();
1576  id.SetLibNickname( aTo );
1577  symbol->SetLibId( id );
1578  cnt++;
1579  }
1580  }
1581 
1582  return cnt;
1583 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
SCH_SCREEN * GetNext()
Class LIB_ID.
Definition: lib_id.h:56
SCH_ITEM * Next() const
void SetLibId(const LIB_ID &aName, PART_LIBS *aLibs=NULL)
int SetLibNickname(const UTF8 &aNickname)
Function SetLibNickname.
Definition: lib_id.cpp:219
SCH_ITEM * GetDrawItems() const
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
const LIB_ID & GetLibId() const
SCH_SCREEN * GetFirst()
const UTF8 & GetLibNickname() const
Function GetLibNickname.
Definition: lib_id.h:108
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void SCH_SCREENS::ClearAnnotation ( )

Clear the annotation for all components in the hierarchy.

Definition at line 1360 of file sch_screen.cpp.

References m_screens.

Referenced by SCH_EDIT_FRAME::DeleteAnnotation().

1361 {
1362  for( size_t i = 0; i < m_screens.size(); i++ )
1363  m_screens[i]->ClearAnnotation( NULL );
1364 }
std::vector< SCH_SCREEN * > m_screens
void ClearAnnotation()
Clear the annotation for all components in the hierarchy.
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 1422 of file sch_screen.cpp.

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().

1423 {
1424  SCH_ITEM* item;
1425  SCH_ITEM* nextItem;
1426  SCH_MARKER* marker;
1427  SCH_SCREEN* screen;
1428 
1429  for( screen = GetFirst(); screen; screen = GetNext() )
1430  {
1431  for( item = screen->GetDrawItems(); item; item = nextItem )
1432  {
1433  nextItem = item->Next();
1434 
1435  if( item->Type() != SCH_MARKER_T )
1436  continue;
1437 
1438  marker = (SCH_MARKER*) item;
1439 
1440  if( marker->GetMarkerType() != aMarkerType )
1441  continue;
1442 
1443  screen->DeleteItem( marker );
1444  }
1445  }
1446 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
enum TYPEMARKER GetMarkerType() const
void DeleteItem(SCH_ITEM *aItem)
Removes aItem from the linked list and deletes the object.
Definition: sch_screen.cpp:176
SCH_ITEM * GetDrawItems() const
SCH_SCREEN * GetFirst()
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
int SCH_SCREENS::GetCount ( ) const
inline

Definition at line 534 of file class_sch_screen.h.

534 { return m_screens.size(); }
std::vector< SCH_SCREEN * > m_screens
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 1523 of file sch_screen.cpp.

References 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::AppendSchematic().

1524 {
1525  SCH_COMPONENT* symbol;
1526  SCH_ITEM* item;
1527  SCH_ITEM* nextItem;
1528  SCH_SCREEN* screen;
1529  wxString nickname;
1530 
1531  for( screen = GetFirst(); screen; screen = GetNext() )
1532  {
1533  for( item = screen->GetDrawItems(); item; item = nextItem )
1534  {
1535  nextItem = item->Next();
1536 
1537  if( item->Type() != SCH_COMPONENT_T )
1538  continue;
1539 
1540  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1541 
1542  nickname = symbol->GetLibId().GetLibNickname();
1543 
1544  if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1545  aLibNicknames.Add( nickname );;
1546  }
1547  }
1548 
1549  return aLibNicknames.GetCount();
1550 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
SCH_ITEM * GetDrawItems() const
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
const LIB_ID & GetLibId() const
SCH_SCREEN * GetFirst()
const UTF8 & GetLibNickname() const
Function GetLibNickname.
Definition: lib_id.h:108
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
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 1449 of file sch_screen.cpp.

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().

1451 {
1452  int count = 0;
1453 
1454  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1455  {
1456  for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
1457  {
1458  if( item->Type() != SCH_MARKER_T )
1459  continue;
1460 
1461  SCH_MARKER* marker = (SCH_MARKER*) item;
1462 
1463  if( ( aMarkerType != MARKER_BASE::MARKER_UNSPEC ) &&
1464  ( marker->GetMarkerType() != aMarkerType ) )
1465  continue;
1466 
1467  if( aSeverity == MARKER_BASE::MARKER_SEVERITY_UNSPEC ||
1468  aSeverity == marker->GetErrorLevel() )
1469  count++;
1470  }
1471  }
1472 
1473  return count;
1474 }
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
enum TYPEMARKER GetMarkerType() const
MARKER_SEVERITY GetErrorLevel() const
SCH_SCREEN * GetFirst()
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
SCH_SCREEN * SCH_SCREENS::GetScreen ( unsigned int  aIndex) const

Definition at line 1313 of file sch_screen.cpp.

References m_screens.

Referenced by GetNext().

1314 {
1315  if( aIndex < m_screens.size() )
1316  return m_screens[ aIndex ];
1317 
1318  return NULL;
1319 }
std::vector< SCH_SCREEN * > m_screens
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 1491 of file sch_screen.cpp.

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().

1492 {
1493  SCH_COMPONENT* symbol;
1494  SCH_ITEM* item;
1495  SCH_ITEM* nextItem;
1496  SCH_SCREEN* screen;
1497  unsigned cnt = 0;
1498 
1499  for( screen = GetFirst(); screen; screen = GetNext() )
1500  {
1501  for( item = screen->GetDrawItems(); item; item = nextItem )
1502  {
1503  nextItem = item->Next();
1504 
1505  if( item->Type() != SCH_COMPONENT_T )
1506  continue;
1507 
1508  cnt += 1;
1509  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1510 
1511  if( !symbol->GetLibId().GetLibNickname().empty() )
1512  return false;
1513  }
1514  }
1515 
1516  if( cnt == 0 )
1517  return false;
1518 
1519  return true;
1520 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
bool empty() const
Definition: utf8.h:108
SCH_ITEM * GetDrawItems() const
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
const LIB_ID & GetLibId() const
SCH_SCREEN * GetFirst()
const UTF8 & GetLibNickname() const
Function GetLibNickname.
Definition: lib_id.h:108
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
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 1379 of file sch_screen.cpp.

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

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

1380 {
1381  EDA_ITEMS items;
1382  SCH_ITEM* item;
1383 
1384  for( size_t i = 0; i < m_screens.size(); i++ )
1385  m_screens[i]->GetHierarchicalItems( items );
1386 
1387  if( items.size() < 2 )
1388  return 0;
1389 
1390  sort( items.begin(), items.end(), SortByTimeStamp );
1391 
1392  int count = 0;
1393 
1394  for( size_t ii = 0; ii < items.size() - 1; ii++ )
1395  {
1396  item = (SCH_ITEM*)items[ii];
1397 
1398  SCH_ITEM* nextItem = (SCH_ITEM*)items[ii + 1];
1399 
1400  if( item->GetTimeStamp() == nextItem->GetTimeStamp() )
1401  {
1402  count++;
1403 
1404  // for a component, update its Time stamp and its paths
1405  // (m_PathsAndReferences field)
1406  if( item->Type() == SCH_COMPONENT_T )
1407  ( (SCH_COMPONENT*) item )->SetTimeStamp( GetNewTimeStamp() );
1408 
1409  // for a sheet, update only its time stamp (annotation of its
1410  // components will be lost)
1411  // @todo: see how to change sheet paths for its cmp list (can
1412  // be possible in most cases)
1413  else
1414  item->SetTimeStamp( GetNewTimeStamp() );
1415  }
1416  }
1417 
1418  return count;
1419 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
time_t GetNewTimeStamp()
Definition: common.cpp:166
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:217
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:544
time_t GetTimeStamp() const
Definition: base_struct.h:218
std::vector< SCH_SCREEN * > m_screens
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
static bool SortByTimeStamp(const EDA_ITEM *item1, const EDA_ITEM *item2)
Sort a list of schematic items by time stamp and type.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void SCH_SCREENS::SchematicCleanUp ( )

Merge and break wire segments in the entire schematic hierarchy.

Definition at line 1367 of file sch_screen.cpp.

References m_screens.

Referenced by SCH_EDIT_FRAME::CreateNetlist(), and SCH_EDIT_FRAME::prepareForNetlist().

1368 {
1369  for( size_t i = 0; i < m_screens.size(); i++ )
1370  {
1371  // if wire list has changed, delete the undo/redo list to avoid
1372  // pointer problems with deleted data.
1373  if( m_screens[i]->SchematicCleanUp() )
1374  m_screens[i]->ClearUndoRedoList();
1375  }
1376 }
void SchematicCleanUp()
Merge and break wire segments in the entire schematic hierarchy.
std::vector< SCH_SCREEN * > m_screens
void SCH_SCREENS::TestDanglingEnds ( )

Definition at line 1484 of file sch_screen.cpp.

References GetFirst(), and GetNext().

Referenced by LIB_EDIT_FRAME::refreshSchematic().

1485 {
1486  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1487  screen->TestDanglingEnds();
1488 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
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.

Definition at line 1477 of file sch_screen.cpp.

References GetFirst(), and GetNext().

Referenced by SCH_EDIT_FRAME::AppendSchematic(), SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile(), SCH_EDIT_FRAME::CreateNetlist(), SCH_EDIT_FRAME::ImportFile(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::prepareForNetlist(), LIB_EDIT_FRAME::refreshSchematic(), DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable(), DIALOG_EDIT_COMPONENTS_LIBID::revertChanges(), DIALOG_EDIT_COMPONENTS_LIBID::TransferDataFromWindow(), LEGACY_RESCUER::WriteRescueLibrary(), and SYMBOL_LIB_TABLE_RESCUER::WriteRescueLibrary().

1478 {
1479  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1480  screen->UpdateSymbolLinks( aForce );
1481 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()

Member Data Documentation

unsigned int SCH_SCREENS::m_index
private

Definition at line 529 of file class_sch_screen.h.

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

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

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