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

Constructor & Destructor Documentation

SCH_SCREENS::SCH_SCREENS ( SCH_SHEET aSheet = NULL)

Definition at line 1247 of file sch_screen.cpp.

References g_RootSheet.

1248 {
1249  m_index = 0;
1250  buildScreenList( ( !aSheet ) ? g_RootSheet : aSheet );
1251 }
unsigned int m_index
Definition: sch_screen.h:507
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
void buildScreenList(SCH_SHEET *aSheet)
SCH_SCREENS::~SCH_SCREENS ( )

Definition at line 1254 of file sch_screen.cpp.

1255 {
1256 }

Member Function Documentation

void SCH_SCREENS::addScreenToList ( SCH_SCREEN aScreen)
private

Definition at line 1288 of file sch_screen.cpp.

References i.

1289 {
1290  if( aScreen == NULL )
1291  return;
1292 
1293  for( unsigned int i = 0; i < m_screens.size(); i++ )
1294  {
1295  if( m_screens[i] == aScreen )
1296  return;
1297  }
1298 
1299  m_screens.push_back( aScreen );
1300 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:506
size_t i
Definition: json11.cpp:597
void SCH_SCREENS::buildScreenList ( SCH_SHEET aSheet)
private

Definition at line 1303 of file sch_screen.cpp.

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

1304 {
1305  if( aSheet && aSheet->Type() == SCH_SHEET_T )
1306  {
1307  SCH_SCREEN* screen = aSheet->GetScreen();
1308 
1309  addScreenToList( screen );
1310 
1311  EDA_ITEM* strct = screen->GetDrawItems();
1312 
1313  while( strct )
1314  {
1315  if( strct->Type() == SCH_SHEET_T )
1316  {
1317  buildScreenList( ( SCH_SHEET* )strct );
1318  }
1319 
1320  strct = strct->Next();
1321  }
1322  }
1323 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
EDA_ITEM * Next() const
Definition: base_struct.h:217
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
Definition: sch_screen.h:138
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:162
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 1508 of file sch_screen.cpp.

References SCH_SCREEN::GetDrawItems(), SCH_COMPONENT::GetLibId(), LIB_ID::GetLibNickname(), SCH_ITEM::Next(), SCH_COMPONENT_T, SCH_COMPONENT::SetLibId(), LIB_ID::SetLibNickname(), and EDA_ITEM::Type().

1509 {
1510  SCH_COMPONENT* symbol;
1511  SCH_ITEM* item;
1512  SCH_ITEM* nextItem;
1513  SCH_SCREEN* screen;
1514  int cnt = 0;
1515 
1516  for( screen = GetFirst(); screen; screen = GetNext() )
1517  {
1518  for( item = screen->GetDrawItems(); item; item = nextItem )
1519  {
1520  nextItem = item->Next();
1521 
1522  if( item->Type() != SCH_COMPONENT_T )
1523  continue;
1524 
1525  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1526  wxASSERT( symbol );
1527 
1528  if( symbol->GetLibId().GetLibNickname() != aFrom )
1529  continue;
1530 
1531  LIB_ID id = symbol->GetLibId();
1532  id.SetLibNickname( aTo );
1533  symbol->SetLibId( id );
1534  cnt++;
1535  }
1536  }
1537 
1538  return cnt;
1539 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
SCH_SCREEN * GetNext()
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
SCH_ITEM * Next() const
void SetLibId(const LIB_ID &aName, PART_LIBS *aLibs=NULL)
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:219
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:138
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
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:101
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 1326 of file sch_screen.cpp.

References SCH_SCREEN::ClearAnnotation(), and i.

Referenced by SCH_EDIT_FRAME::AppendSchematic(), SCH_EDIT_FRAME::DeleteAnnotation(), and SCH_EDIT_FRAME::EditSheet().

1327 {
1328  for( size_t i = 0; i < m_screens.size(); i++ )
1329  m_screens[i]->ClearAnnotation( NULL );
1330 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:506
void ClearAnnotation()
Clear the annotation for all components in the hierarchy.
size_t i
Definition: json11.cpp:597
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 1375 of file sch_screen.cpp.

References SCH_SCREEN::DeleteItem(), SCH_SCREEN::GetDrawItems(), MARKER_BASE::GetMarkerType(), SCH_ITEM::Next(), SCH_MARKER_T, and EDA_ITEM::Type().

Referenced by DIALOG_ERC::OnEraseDrcMarkersClick(), and DIALOG_ERC::TestErc().

1376 {
1377  SCH_ITEM* item;
1378  SCH_ITEM* nextItem;
1379  SCH_MARKER* marker;
1380  SCH_SCREEN* screen;
1381 
1382  for( screen = GetFirst(); screen; screen = GetNext() )
1383  {
1384  for( item = screen->GetDrawItems(); item; item = nextItem )
1385  {
1386  nextItem = item->Next();
1387 
1388  if( item->Type() != SCH_MARKER_T )
1389  continue;
1390 
1391  marker = (SCH_MARKER*) item;
1392 
1393  if( marker->GetMarkerType() != aMarkerType )
1394  continue;
1395 
1396  screen->DeleteItem( marker );
1397  }
1398  }
1399 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:150
void DeleteItem(SCH_ITEM *aItem)
Removes aItem from the linked list and deletes the object.
Definition: sch_screen.cpp:175
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:138
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 512 of file sch_screen.h.

References SCH_SCREEN::ClearAnnotation(), SCH_SCREEN::TestDanglingEnds(), and SCH_SCREEN::UpdateSymbolLinks().

512 { return m_screens.size(); }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:506
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 1477 of file sch_screen.cpp.

References SCH_SCREEN::GetDrawItems(), SCH_COMPONENT::GetLibId(), LIB_ID::GetLibNickname(), SCH_ITEM::Next(), SCH_COMPONENT_T, and EDA_ITEM::Type().

Referenced by SCH_EDIT_FRAME::AppendSchematic().

1478 {
1479  SCH_COMPONENT* symbol;
1480  SCH_ITEM* item;
1481  SCH_ITEM* nextItem;
1482  SCH_SCREEN* screen;
1483  wxString nickname;
1484 
1485  for( screen = GetFirst(); screen; screen = GetNext() )
1486  {
1487  for( item = screen->GetDrawItems(); item; item = nextItem )
1488  {
1489  nextItem = item->Next();
1490 
1491  if( item->Type() != SCH_COMPONENT_T )
1492  continue;
1493 
1494  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1495  wxASSERT( symbol );
1496 
1497  nickname = symbol->GetLibId().GetLibNickname();
1498 
1499  if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1500  aLibNicknames.Add( nickname );;
1501  }
1502  }
1503 
1504  return aLibNicknames.GetCount();
1505 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:138
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
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:101
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 1402 of file sch_screen.cpp.

References MARKER_BASE::GetErrorLevel(), MARKER_BASE::GetMarkerType(), MARKER_BASE::MARKER_SEVERITY_UNSPEC, MARKER_BASE::MARKER_UNSPEC, SCH_ITEM::Next(), and SCH_MARKER_T.

Referenced by DIALOG_ERC::updateMarkerCounts().

1404 {
1405  int count = 0;
1406 
1407  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1408  {
1409  for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
1410  {
1411  if( item->Type() != SCH_MARKER_T )
1412  continue;
1413 
1414  SCH_MARKER* marker = (SCH_MARKER*) item;
1415 
1416  if( ( aMarkerType != MARKER_BASE::MARKER_UNSPEC ) &&
1417  ( marker->GetMarkerType() != aMarkerType ) )
1418  continue;
1419 
1420  if( aSeverity == MARKER_BASE::MARKER_SEVERITY_UNSPEC ||
1421  aSeverity == marker->GetErrorLevel() )
1422  count++;
1423  }
1424  }
1425 
1426  return count;
1427 }
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:150
MARKER_SEVERITY GetErrorLevel() const
Definition: marker_base.h:138
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 1279 of file sch_screen.cpp.

1280 {
1281  if( aIndex < m_screens.size() )
1282  return m_screens[ aIndex ];
1283 
1284  return NULL;
1285 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:506
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 1444 of file sch_screen.cpp.

References UTF8::empty(), SCH_SCREEN::GetDrawItems(), SCH_COMPONENT::GetLibId(), LIB_ID::GetLibNickname(), 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().

1445 {
1446  SCH_COMPONENT* symbol;
1447  SCH_ITEM* item;
1448  SCH_ITEM* nextItem;
1449  SCH_SCREEN* screen;
1450  unsigned cnt = 0;
1451 
1452  for( screen = GetFirst(); screen; screen = GetNext() )
1453  {
1454  for( item = screen->GetDrawItems(); item; item = nextItem )
1455  {
1456  nextItem = item->Next();
1457 
1458  if( item->Type() != SCH_COMPONENT_T )
1459  continue;
1460 
1461  cnt += 1;
1462  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1463  wxASSERT( symbol );
1464 
1465  if( !symbol->GetLibId().GetLibNickname().empty() )
1466  return false;
1467  }
1468  }
1469 
1470  if( cnt == 0 )
1471  return false;
1472 
1473  return true;
1474 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
SCH_SCREEN * GetNext()
SCH_ITEM * Next() const
bool empty() const
Definition: utf8.h:108
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:138
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
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:101
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 1332 of file sch_screen.cpp.

References SCH_SCREEN::GetHierarchicalItems(), GetNewTimeStamp(), EDA_ITEM::GetTimeStamp(), i, SCH_COMPONENT_T, EDA_ITEM::SetTimeStamp(), SortByTimeStamp(), and EDA_ITEM::Type().

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

1333 {
1334  EDA_ITEMS items;
1335  SCH_ITEM* item;
1336 
1337  for( size_t i = 0; i < m_screens.size(); i++ )
1338  m_screens[i]->GetHierarchicalItems( items );
1339 
1340  if( items.size() < 2 )
1341  return 0;
1342 
1343  sort( items.begin(), items.end(), SortByTimeStamp );
1344 
1345  int count = 0;
1346 
1347  for( size_t ii = 0; ii < items.size() - 1; ii++ )
1348  {
1349  item = (SCH_ITEM*)items[ii];
1350 
1351  SCH_ITEM* nextItem = (SCH_ITEM*)items[ii + 1];
1352 
1353  if( item->GetTimeStamp() == nextItem->GetTimeStamp() )
1354  {
1355  count++;
1356 
1357  // for a component, update its Time stamp and its paths
1358  // (m_PathsAndReferences field)
1359  if( item->Type() == SCH_COMPONENT_T )
1360  ( (SCH_COMPONENT*) item )->SetTimeStamp( GetNewTimeStamp() );
1361 
1362  // for a sheet, update only its time stamp (annotation of its
1363  // components will be lost)
1364  // @todo: see how to change sheet paths for its cmp list (can
1365  // be possible in most cases)
1366  else
1367  item->SetTimeStamp( GetNewTimeStamp() );
1368  }
1369  }
1370 
1371  return count;
1372 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
timestamp_t GetNewTimeStamp()
Definition: common.cpp:160
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:541
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:506
size_t i
Definition: json11.cpp:597
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...
timestamp_t GetTimeStamp() const
Definition: base_struct.h:215
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:214
void SCH_SCREENS::TestDanglingEnds ( )

Definition at line 1437 of file sch_screen.cpp.

Referenced by LIB_EDIT_FRAME::refreshSchematic().

1438 {
1439  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1440  screen->TestDanglingEnds();
1441 }
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 1430 of file sch_screen.cpp.

Referenced by SCH_EDIT_FRAME::AppendSchematic(), SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile(), SCH_EDIT_FRAME::CreateNetlist(), SCH_EDIT_FRAME::doUpdatePcb(), 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().

1431 {
1432  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1433  screen->UpdateSymbolLinks( aForce );
1434 }
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()

Member Data Documentation

unsigned int SCH_SCREENS::m_index
private

Definition at line 507 of file sch_screen.h.

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

Definition at line 506 of file sch_screen.h.


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