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

References g_RootSheet.

1250 {
1251  m_index = 0;
1252  buildScreenList( ( !aSheet ) ? g_RootSheet : aSheet );
1253 }
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 1256 of file sch_screen.cpp.

1257 {
1258 }

Member Function Documentation

void SCH_SCREENS::addScreenToList ( SCH_SCREEN aScreen)
private

Definition at line 1290 of file sch_screen.cpp.

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

Definition at line 1305 of file sch_screen.cpp.

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

1306 {
1307  if( aSheet && aSheet->Type() == SCH_SHEET_T )
1308  {
1309  SCH_SCREEN* screen = aSheet->GetScreen();
1310 
1311  addScreenToList( screen );
1312 
1313  EDA_ITEM* strct = screen->GetDrawItems();
1314 
1315  while( strct )
1316  {
1317  if( strct->Type() == SCH_SHEET_T )
1318  {
1319  buildScreenList( ( SCH_SHEET* )strct );
1320  }
1321 
1322  strct = strct->Next();
1323  }
1324  }
1325 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
EDA_ITEM * Next() const
Definition: base_struct.h:235
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:180
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 1510 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().

1511 {
1512  SCH_COMPONENT* symbol;
1513  SCH_ITEM* item;
1514  SCH_ITEM* nextItem;
1515  SCH_SCREEN* screen;
1516  int cnt = 0;
1517 
1518  for( screen = GetFirst(); screen; screen = GetNext() )
1519  {
1520  for( item = screen->GetDrawItems(); item; item = nextItem )
1521  {
1522  nextItem = item->Next();
1523 
1524  if( item->Type() != SCH_COMPONENT_T )
1525  continue;
1526 
1527  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1528  wxASSERT( symbol );
1529 
1530  if( symbol->GetLibId().GetLibNickname() != aFrom )
1531  continue;
1532 
1533  LIB_ID id = symbol->GetLibId();
1534  id.SetLibNickname( aTo );
1535  symbol->SetLibId( id );
1536  cnt++;
1537  }
1538  }
1539 
1540  return cnt;
1541 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
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:98
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 1328 of file sch_screen.cpp.

References SCH_SCREEN::ClearAnnotation().

Referenced by SCH_EDIT_FRAME::DeleteAnnotation().

1329 {
1330  for( size_t i = 0; i < m_screens.size(); i++ )
1331  m_screens[i]->ClearAnnotation( NULL );
1332 }
std::vector< SCH_SCREEN * > m_screens
Definition: sch_screen.h:506
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 1377 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().

1378 {
1379  SCH_ITEM* item;
1380  SCH_ITEM* nextItem;
1381  SCH_MARKER* marker;
1382  SCH_SCREEN* screen;
1383 
1384  for( screen = GetFirst(); screen; screen = GetNext() )
1385  {
1386  for( item = screen->GetDrawItems(); item; item = nextItem )
1387  {
1388  nextItem = item->Next();
1389 
1390  if( item->Type() != SCH_MARKER_T )
1391  continue;
1392 
1393  marker = (SCH_MARKER*) item;
1394 
1395  if( marker->GetMarkerType() != aMarkerType )
1396  continue;
1397 
1398  screen->DeleteItem( marker );
1399  }
1400  }
1401 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
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 1479 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().

1480 {
1481  SCH_COMPONENT* symbol;
1482  SCH_ITEM* item;
1483  SCH_ITEM* nextItem;
1484  SCH_SCREEN* screen;
1485  wxString nickname;
1486 
1487  for( screen = GetFirst(); screen; screen = GetNext() )
1488  {
1489  for( item = screen->GetDrawItems(); item; item = nextItem )
1490  {
1491  nextItem = item->Next();
1492 
1493  if( item->Type() != SCH_COMPONENT_T )
1494  continue;
1495 
1496  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1497  wxASSERT( symbol );
1498 
1499  nickname = symbol->GetLibId().GetLibNickname();
1500 
1501  if( !nickname.empty() && ( aLibNicknames.Index( nickname ) == wxNOT_FOUND ) )
1502  aLibNicknames.Add( nickname );;
1503  }
1504  }
1505 
1506  return aLibNicknames.GetCount();
1507 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
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:98
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 1404 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().

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

1282 {
1283  if( aIndex < m_screens.size() )
1284  return m_screens[ aIndex ];
1285 
1286  return NULL;
1287 }
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 1446 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().

1447 {
1448  SCH_COMPONENT* symbol;
1449  SCH_ITEM* item;
1450  SCH_ITEM* nextItem;
1451  SCH_SCREEN* screen;
1452  unsigned cnt = 0;
1453 
1454  for( screen = GetFirst(); screen; screen = GetNext() )
1455  {
1456  for( item = screen->GetDrawItems(); item; item = nextItem )
1457  {
1458  nextItem = item->Next();
1459 
1460  if( item->Type() != SCH_COMPONENT_T )
1461  continue;
1462 
1463  cnt += 1;
1464  symbol = dynamic_cast< SCH_COMPONENT* >( item );
1465  wxASSERT( symbol );
1466 
1467  if( !symbol->GetLibId().GetLibNickname().empty() )
1468  return false;
1469  }
1470  }
1471 
1472  if( cnt == 0 )
1473  return false;
1474 
1475  return true;
1476 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
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:98
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 1334 of file sch_screen.cpp.

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

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

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

Definition at line 1439 of file sch_screen.cpp.

Referenced by LIB_EDIT_FRAME::refreshSchematic().

1440 {
1441  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1442  screen->TestDanglingEnds();
1443 }
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 1432 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().

1433 {
1434  for( SCH_SCREEN* screen = GetFirst(); screen; screen = GetNext() )
1435  screen->UpdateSymbolLinks( aForce );
1436 }
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: