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 ()
 
void TestDanglingEnds ()
 

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

References BuildScreenList(), g_RootSheet, and m_index.

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

Definition at line 1324 of file sch_screen.cpp.

1325 {
1326 }

Member Function Documentation

void SCH_SCREENS::AddScreenToList ( SCH_SCREEN aScreen)
private

Definition at line 1358 of file sch_screen.cpp.

References m_screens.

Referenced by BuildScreenList().

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

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

1374 {
1375  if( aItem && aItem->Type() == SCH_SHEET_T )
1376  {
1377  SCH_SHEET* ds = (SCH_SHEET*) aItem;
1378  aItem = ds->GetScreen();
1379  }
1380 
1381  if( aItem && aItem->Type() == SCH_SCREEN_T )
1382  {
1383  SCH_SCREEN* screen = (SCH_SCREEN*) aItem;
1384 
1385  AddScreenToList( screen );
1386  EDA_ITEM* strct = screen->GetDrawItems();
1387 
1388  while( strct )
1389  {
1390  if( strct->Type() == SCH_SHEET_T )
1391  {
1392  BuildScreenList( strct );
1393  }
1394 
1395  strct = strct->Next();
1396  }
1397  }
1398 }
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 1401 of file sch_screen.cpp.

References m_screens.

Referenced by SCH_EDIT_FRAME::DeleteAnnotation().

1402 {
1403  for( size_t i = 0; i < m_screens.size(); i++ )
1404  m_screens[i]->ClearAnnotation( NULL );
1405 }
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 1463 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().

1464 {
1465  SCH_ITEM* item;
1466  SCH_ITEM* nextItem;
1467  SCH_MARKER* marker;
1468  SCH_SCREEN* screen;
1469 
1470  for( screen = GetFirst(); screen; screen = GetNext() )
1471  {
1472  for( item = screen->GetDrawItems(); item; item = nextItem )
1473  {
1474  nextItem = item->Next();
1475 
1476  if( item->Type() != SCH_MARKER_T )
1477  continue;
1478 
1479  marker = (SCH_MARKER*) item;
1480 
1481  if( marker->GetMarkerType() != aMarkerType )
1482  continue;
1483 
1484  screen->DeleteItem( marker );
1485  }
1486  }
1487 }
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 1490 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().

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

References m_screens.

Referenced by GetNext().

1350 {
1351  if( aIndex < m_screens.size() )
1352  return m_screens[ aIndex ];
1353 
1354  return NULL;
1355 }
std::vector< SCH_SCREEN * > m_screens
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 1420 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().

1421 {
1422  EDA_ITEMS items;
1423  SCH_ITEM* item;
1424 
1425  for( size_t i = 0; i < m_screens.size(); i++ )
1426  m_screens[i]->GetHierarchicalItems( items );
1427 
1428  if( items.size() < 2 )
1429  return 0;
1430 
1431  sort( items.begin(), items.end(), SortByTimeStamp );
1432 
1433  int count = 0;
1434 
1435  for( size_t ii = 0; ii < items.size() - 1; ii++ )
1436  {
1437  item = (SCH_ITEM*)items[ii];
1438 
1439  SCH_ITEM* nextItem = (SCH_ITEM*)items[ii + 1];
1440 
1441  if( item->GetTimeStamp() == nextItem->GetTimeStamp() )
1442  {
1443  count++;
1444 
1445  // for a component, update its Time stamp and its paths
1446  // (m_PathsAndReferences field)
1447  if( item->Type() == SCH_COMPONENT_T )
1448  ( (SCH_COMPONENT*) item )->SetTimeStamp( GetNewTimeStamp() );
1449 
1450  // for a sheet, update only its time stamp (annotation of its
1451  // components will be lost)
1452  // @todo: see how to change sheet paths for its cmp list (can
1453  // be possible in most cases)
1454  else
1455  item->SetTimeStamp( GetNewTimeStamp() );
1456  }
1457  }
1458 
1459  return count;
1460 }
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:532
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:68
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 1408 of file sch_screen.cpp.

References m_screens.

Referenced by SCH_EDIT_FRAME::prepareForNetlist().

1409 {
1410  for( size_t i = 0; i < m_screens.size(); i++ )
1411  {
1412  // if wire list has changed, delete the undo/redo list to avoid
1413  // pointer problems with deleted data.
1414  if( m_screens[i]->SchematicCleanUp() )
1415  m_screens[i]->ClearUndoRedoList();
1416  }
1417 }
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 1525 of file sch_screen.cpp.

References GetFirst(), and GetNext().

Referenced by LIB_EDIT_FRAME::refreshSchematic().

1526 {
1527  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1528  screen->TestDanglingEnds();
1529 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
void SCH_SCREENS::UpdateSymbolLinks ( )

Definition at line 1518 of file sch_screen.cpp.

References GetFirst(), and GetNext().

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

1519 {
1520  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1521  screen->CheckComponentsToPartsLinks();
1522 }
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: