KiCad PCB EDA Suite
SCH_SCREENS Class Reference

Class SCH_SCREENS is a container class that holds multiple SCH_SCREENs in a hierarchy. More...

#include <class_sch_screen.h>

Public Member Functions

 SCH_SCREENS ()
 
 ~SCH_SCREENS ()
 
int GetCount () const
 
SCH_SCREENGetFirst ()
 
SCH_SCREENGetNext ()
 
SCH_SCREENGetScreen (unsigned int aIndex) const
 
void ClearAnnotation ()
 Function ClearAnnotation clears the annotation for all components in the hierarchy. More...
 
void SchematicCleanUp ()
 Function SchematicCleanUp merges and breaks wire segments in the entire schematic hierarchy. More...
 
int ReplaceDuplicateTimeStamps ()
 Function ReplaceDuplicateTimeStamps test all sheet and component objects in the schematic for duplicate time stamps an replaces them as necessary. More...
 
void DeleteAllMarkers (enum MARKER_BASE::TYPEMARKER aMarkerType)
 Function DeleteAllMarkers deletes 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)
 Function GetMarkerCount returns the number of ERC markers of aMarkerType from all of the screens in the list. More...
 
void UpdateSymbolLinks ()
 initializes or reinitializes the weak reference to the LIB_PART for each SCH_COMPONENT found in the full schematic It must be called from: More...
 
void TestDanglingEnds ()
 
bool HasNoFullyDefinedLibIds ()
 Function HasNoFullyDefinedLibIds. More...
 

Private Member Functions

void AddScreenToList (SCH_SCREEN *aScreen)
 
void BuildScreenList (EDA_ITEM *aItem)
 

Private Attributes

std::vector< SCH_SCREEN * > m_screens
 
unsigned int m_index
 

Detailed Description

Class SCH_SCREENS is a container class that holds multiple SCH_SCREENs in a hierarchy.

Individual SCH_SCREENs are unique, and correspond to .sch files.

Definition at line 534 of file class_sch_screen.h.

Constructor & Destructor Documentation

SCH_SCREENS::SCH_SCREENS ( )

Definition at line 1321 of file sch_screen.cpp.

References BuildScreenList(), g_RootSheet, and m_index.

1322 {
1323  m_index = 0;
1325 }
unsigned int m_index
void BuildScreenList(EDA_ITEM *aItem)
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:54
SCH_SCREENS::~SCH_SCREENS ( )

Definition at line 1328 of file sch_screen.cpp.

1329 {
1330 }

Member Function Documentation

void SCH_SCREENS::AddScreenToList ( SCH_SCREEN aScreen)
private

Definition at line 1362 of file sch_screen.cpp.

References m_screens.

Referenced by BuildScreenList().

1363 {
1364  if( aScreen == NULL )
1365  return;
1366 
1367  for( unsigned int i = 0; i < m_screens.size(); i++ )
1368  {
1369  if( m_screens[i] == aScreen )
1370  return;
1371  }
1372 
1373  m_screens.push_back( aScreen );
1374 }
std::vector< SCH_SCREEN * > m_screens
void SCH_SCREENS::BuildScreenList ( EDA_ITEM aItem)
private

Definition at line 1377 of file sch_screen.cpp.

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

Referenced by SCH_SCREENS().

1378 {
1379  if( aItem && aItem->Type() == SCH_SHEET_T )
1380  {
1381  SCH_SHEET* ds = (SCH_SHEET*) aItem;
1382  aItem = ds->GetScreen();
1383  }
1384 
1385  if( aItem && aItem->Type() == SCH_SCREEN_T )
1386  {
1387  SCH_SCREEN* screen = (SCH_SCREEN*) aItem;
1388 
1389  AddScreenToList( screen );
1390  EDA_ITEM* strct = screen->GetDrawItems();
1391 
1392  while( strct )
1393  {
1394  if( strct->Type() == SCH_SHEET_T )
1395  {
1396  BuildScreenList( strct );
1397  }
1398 
1399  strct = strct->Next();
1400  }
1401  }
1402 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
EDA_ITEM * Next() const
Definition: base_struct.h:206
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:286
void BuildScreenList(EDA_ITEM *aItem)
void AddScreenToList(SCH_SCREEN *aScreen)
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
SCH_ITEM * GetDrawItems() const
Function GetDrawItems().
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
void SCH_SCREENS::ClearAnnotation ( )

Function ClearAnnotation clears the annotation for all components in the hierarchy.

Definition at line 1405 of file sch_screen.cpp.

References m_screens.

Referenced by SCH_EDIT_FRAME::DeleteAnnotation().

1406 {
1407  for( size_t i = 0; i < m_screens.size(); i++ )
1408  m_screens[i]->ClearAnnotation( NULL );
1409 }
std::vector< SCH_SCREEN * > m_screens
void ClearAnnotation()
Function ClearAnnotation clears the annotation for all components in the hierarchy.
void SCH_SCREENS::DeleteAllMarkers ( enum MARKER_BASE::TYPEMARKER  aMarkerType)

Function DeleteAllMarkers deletes all electronic rules check markers of aMarkerType from all the screens in the list.

Parameters
aMarkerTypeType of markers to be deleted.

Definition at line 1467 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().

1468 {
1469  SCH_ITEM* item;
1470  SCH_ITEM* nextItem;
1471  SCH_MARKER* marker;
1472  SCH_SCREEN* screen;
1473 
1474  for( screen = GetFirst(); screen; screen = GetNext() )
1475  {
1476  for( item = screen->GetDrawItems(); item; item = nextItem )
1477  {
1478  nextItem = item->Next();
1479 
1480  if( item->Type() != SCH_MARKER_T )
1481  continue;
1482 
1483  marker = (SCH_MARKER*) item;
1484 
1485  if( marker->GetMarkerType() != aMarkerType )
1486  continue;
1487 
1488  screen->DeleteItem( marker );
1489  }
1490  }
1491 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
enum TYPEMARKER GetMarkerType() const
void DeleteItem(SCH_ITEM *aItem)
Function DeleteItem removes aItem from the linked list and deletes the object.
Definition: sch_screen.cpp:164
SCH_ITEM * GetDrawItems() const
Function GetDrawItems().
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 543 of file class_sch_screen.h.

543 { return m_screens.size(); }
std::vector< SCH_SCREEN * > m_screens
int SCH_SCREENS::GetMarkerCount ( enum MARKER_BASE::TYPEMARKER  aMarkerType,
enum MARKER_BASE::MARKER_SEVERITY  aSeverity 
)

Function GetMarkerCount returns 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 1494 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().

1496 {
1497  int count = 0;
1498 
1499  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1500  {
1501  for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
1502  {
1503  if( item->Type() != SCH_MARKER_T )
1504  continue;
1505 
1506  SCH_MARKER* marker = (SCH_MARKER*) item;
1507 
1508  if( ( aMarkerType != MARKER_BASE::MARKER_UNSPEC ) &&
1509  ( marker->GetMarkerType() != aMarkerType ) )
1510  continue;
1511 
1512  if( aSeverity == MARKER_BASE::MARKER_SEVERITY_UNSPEC ||
1513  aSeverity == marker->GetErrorLevel() )
1514  count++;
1515  }
1516  }
1517 
1518  return count;
1519 }
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 1353 of file sch_screen.cpp.

References m_screens.

Referenced by GetNext().

1354 {
1355  if( aIndex < m_screens.size() )
1356  return m_screens[ aIndex ];
1357 
1358  return NULL;
1359 }
std::vector< SCH_SCREEN * > m_screens
bool SCH_SCREENS::HasNoFullyDefinedLibIds ( )

Function HasNoFullyDefinedLibIds.

tests 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 if all of the LIB_ID object library nick names are empty, otherwise false.

Definition at line 1536 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().

1537 {
1538  SCH_COMPONENT* symbol;
1539  SCH_ITEM* item;
1540  SCH_ITEM* nextItem;
1541  SCH_SCREEN* screen;
1542 
1543  for( screen = GetFirst(); screen; screen = GetNext() )
1544  {
1545  for( item = screen->GetDrawItems(); item; item = nextItem )
1546  {
1547  nextItem = item->Next();
1548 
1549  if( item->Type() != SCH_COMPONENT_T )
1550  continue;
1551 
1552  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1553 
1554  if( !symbol->GetLibId().GetLibNickname().empty() )
1555  return false;
1556  }
1557  }
1558 
1559  return true;
1560 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
SCH_ITEM * GetDrawItems() const
Function GetDrawItems().
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 ( )

Function ReplaceDuplicateTimeStamps test all sheet and component objects in the schematic for duplicate time stamps an 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 1424 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().

1425 {
1426  EDA_ITEMS items;
1427  SCH_ITEM* item;
1428 
1429  for( size_t i = 0; i < m_screens.size(); i++ )
1430  m_screens[i]->GetHierarchicalItems( items );
1431 
1432  if( items.size() < 2 )
1433  return 0;
1434 
1435  sort( items.begin(), items.end(), SortByTimeStamp );
1436 
1437  int count = 0;
1438 
1439  for( size_t ii = 0; ii < items.size() - 1; ii++ )
1440  {
1441  item = (SCH_ITEM*)items[ii];
1442 
1443  SCH_ITEM* nextItem = (SCH_ITEM*)items[ii + 1];
1444 
1445  if( item->GetTimeStamp() == nextItem->GetTimeStamp() )
1446  {
1447  count++;
1448 
1449  // for a component, update its Time stamp and its paths
1450  // (m_PathsAndReferences field)
1451  if( item->Type() == SCH_COMPONENT_T )
1452  ( (SCH_COMPONENT*) item )->SetTimeStamp( GetNewTimeStamp() );
1453 
1454  // for a sheet, update only its time stamp (annotation of its
1455  // components will be lost)
1456  // @todo: see how to change sheet paths for its cmp list (can
1457  // be possible in most cases)
1458  else
1459  item->SetTimeStamp( GetNewTimeStamp() );
1460  }
1461  }
1462 
1463  return count;
1464 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
time_t GetNewTimeStamp()
Definition: common.cpp:166
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:203
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:530
time_t GetTimeStamp() const
Definition: base_struct.h:204
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)
Function SortByTimeStamp sorts 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 ( )

Function SchematicCleanUp merges and breaks wire segments in the entire schematic hierarchy.

Definition at line 1412 of file sch_screen.cpp.

References m_screens.

Referenced by SCH_EDIT_FRAME::prepareForNetlist().

1413 {
1414  for( size_t i = 0; i < m_screens.size(); i++ )
1415  {
1416  // if wire list has changed, delete the undo/redo list to avoid
1417  // pointer problems with deleted data.
1418  if( m_screens[i]->SchematicCleanUp() )
1419  m_screens[i]->ClearUndoRedoList();
1420  }
1421 }
void SchematicCleanUp()
Function SchematicCleanUp merges and breaks wire segments in the entire schematic hierarchy...
std::vector< SCH_SCREEN * > m_screens
void SCH_SCREENS::TestDanglingEnds ( )

Definition at line 1529 of file sch_screen.cpp.

References GetFirst(), and GetNext().

Referenced by LIB_EDIT_FRAME::refreshSchematic().

1530 {
1531  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1532  screen->TestDanglingEnds();
1533 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
void SCH_SCREENS::UpdateSymbolLinks ( )

initializes or reinitializes the weak reference to the LIB_PART for each SCH_COMPONENT found in the full schematic It must be called from:

  • Draw function
  • when loading a schematic file
  • before creating a netlist (in case a library is modified)

Definition at line 1522 of file sch_screen.cpp.

References GetFirst(), and GetNext().

Referenced by SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile(), insert_library(), LIB_EDIT_FRAME::InstallConfigFrame(), SCH_EDIT_FRAME::InstallConfigFrame(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::prepareForNetlist(), and LIB_EDIT_FRAME::refreshSchematic().

1523 {
1524  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1525  screen->CheckComponentsToPartsLinks();
1526 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()

Member Data Documentation

unsigned int SCH_SCREENS::m_index
private

Definition at line 538 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: