KiCad PCB EDA Suite
SHEETLIST_ERC_ITEMS_PROVIDER Class Reference

An implementation of the RC_ITEM_LIST interface which uses the global SHEETLIST to fulfill the contract. More...

#include <erc_settings.h>

Inheritance diagram for SHEETLIST_ERC_ITEMS_PROVIDER:
RC_ITEMS_PROVIDER

Public Member Functions

 SHEETLIST_ERC_ITEMS_PROVIDER (SCHEMATIC *aSchematic)
 
void SetSeverities (int aSeverities) override
 
int GetCount (int aSeverity=-1) override
 
std::shared_ptr< RC_ITEMGetItem (int aIndex) override
 Retrieve a RC_ITEM by index. More...
 
std::shared_ptr< ERC_ITEMGetERCItem (int aIndex)
 
void DeleteItem (int aIndex, bool aDeep) override
 Remove (and optionally deletes) the indexed item from the list. More...
 
void DeleteAllItems (bool aIncludeExclusions, bool aDeep) override
 

Private Attributes

SCHEMATICm_schematic
 
int m_severities
 
std::vector< SCH_MARKER * > m_filteredMarkers
 

Detailed Description

An implementation of the RC_ITEM_LIST interface which uses the global SHEETLIST to fulfill the contract.

Definition at line 169 of file erc_settings.h.

Constructor & Destructor Documentation

◆ SHEETLIST_ERC_ITEMS_PROVIDER()

SHEETLIST_ERC_ITEMS_PROVIDER::SHEETLIST_ERC_ITEMS_PROVIDER ( SCHEMATIC aSchematic)
inline

Definition at line 177 of file erc_settings.h.

177  :
178  m_schematic( aSchematic ),
179  m_severities( 0 )
180  { }

Member Function Documentation

◆ DeleteAllItems()

void SHEETLIST_ERC_ITEMS_PROVIDER::DeleteAllItems ( bool  aIncludeExclusions,
bool  aDeep 
)
overridevirtual

Implements RC_ITEMS_PROVIDER.

Definition at line 334 of file erc_settings.cpp.

335 {
336  // Filtered list was already handled through DeleteItem() by the tree control
337 
338  if( aDeep )
339  {
340  SCH_SCREENS screens( m_schematic->Root() );
341  screens.DeleteAllMarkers( MARKER_BASE::MARKER_ERC, aIncludeExclusions );
342  }
343 }
void DeleteAllMarkers(enum MARKER_BASE::TYPEMARKER aMarkerType, bool aIncludeExclusions)
Delete all electronic rules check markers of aMarkerType from all the screens in the list.
SCH_SHEET & Root() const
Definition: schematic.h:96
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:521

References SCH_SCREENS::DeleteAllMarkers(), m_schematic, MARKER_BASE::MARKER_ERC, and SCHEMATIC::Root().

◆ DeleteItem()

void SHEETLIST_ERC_ITEMS_PROVIDER::DeleteItem ( int  aIndex,
bool  aDeep 
)
overridevirtual

Remove (and optionally deletes) the indexed item from the list.

Parameters
aDeepIf true, the source item should be deleted as well as its entry in the list.

Implements RC_ITEMS_PROVIDER.

Definition at line 321 of file erc_settings.cpp.

322 {
323  SCH_MARKER* marker = m_filteredMarkers[ aIndex ];
324  m_filteredMarkers.erase( m_filteredMarkers.begin() + aIndex );
325 
326  if( aDeep )
327  {
328  SCH_SCREENS screens( m_schematic->Root() );
329  screens.DeleteMarker( marker );
330  }
331 }
std::vector< SCH_MARKER * > m_filteredMarkers
Definition: erc_settings.h:174
void DeleteMarker(SCH_MARKER *aMarker)
Delete a specific marker.
SCH_SHEET & Root() const
Definition: schematic.h:96
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:521

References SCH_SCREENS::DeleteMarker(), m_filteredMarkers, m_schematic, and SCHEMATIC::Root().

◆ GetCount()

int SHEETLIST_ERC_ITEMS_PROVIDER::GetCount ( int  aSeverity = -1)
overridevirtual

Implements RC_ITEMS_PROVIDER.

Definition at line 273 of file erc_settings.cpp.

274 {
275  if( aSeverity < 0 )
276  return m_filteredMarkers.size();
277 
278  int count = 0;
279 
280  SCH_SHEET_LIST sheetList = m_schematic->GetSheets();
281  ERC_SETTINGS& settings = m_schematic->ErcSettings();
282 
283  for( unsigned i = 0; i < sheetList.size(); i++ )
284  {
285  for( SCH_ITEM* aItem : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) )
286  {
287  SCH_MARKER* marker = static_cast<SCH_MARKER*>( aItem );
288  int markerSeverity;
289 
290  if( marker->GetMarkerType() != MARKER_BASE::MARKER_ERC )
291  continue;
292 
293  if( marker->IsExcluded() )
294  markerSeverity = RPT_SEVERITY_EXCLUSION;
295  else
296  markerSeverity = settings.GetSeverity( marker->GetRCItem()->GetErrorCode() );
297 
298  if( markerSeverity == aSeverity )
299  count++;
300  }
301  }
302 
303  return count;
304 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:91
std::vector< SCH_MARKER * > m_filteredMarkers
Definition: erc_settings.h:174
int GetSeverity(int aErrorCode) const
bool IsExcluded() const
Definition: marker_base.h:109
Container for ERC settings.
Definition: erc_settings.h:94
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:107
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:131
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
std::shared_ptr< RC_ITEM > GetRCItem() const
Function GetReporter returns the DRC_ITEM held within this MARKER so that its interface may be used.
Definition: marker_base.h:120

References SCHEMATIC::ErcSettings(), MARKER_BASE::GetMarkerType(), MARKER_BASE::GetRCItem(), ERC_SETTINGS::GetSeverity(), SCHEMATIC::GetSheets(), MARKER_BASE::IsExcluded(), m_filteredMarkers, m_schematic, MARKER_BASE::MARKER_ERC, RPT_SEVERITY_EXCLUSION, and SCH_MARKER_T.

◆ GetERCItem()

std::shared_ptr< ERC_ITEM > SHEETLIST_ERC_ITEMS_PROVIDER::GetERCItem ( int  aIndex)

Definition at line 307 of file erc_settings.cpp.

308 {
309  SCH_MARKER* marker = m_filteredMarkers[ aIndex ];
310 
311  return marker ? std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() ) : nullptr;
312 }
std::vector< SCH_MARKER * > m_filteredMarkers
Definition: erc_settings.h:174
std::shared_ptr< RC_ITEM > GetRCItem() const
Function GetReporter returns the DRC_ITEM held within this MARKER so that its interface may be used.
Definition: marker_base.h:120

References MARKER_BASE::GetRCItem(), and m_filteredMarkers.

Referenced by GetItem().

◆ GetItem()

std::shared_ptr< RC_ITEM > SHEETLIST_ERC_ITEMS_PROVIDER::GetItem ( int  aIndex)
overridevirtual

Retrieve a RC_ITEM by index.

Implements RC_ITEMS_PROVIDER.

Definition at line 315 of file erc_settings.cpp.

316 {
317  return GetERCItem( aIndex );
318 }
std::shared_ptr< ERC_ITEM > GetERCItem(int aIndex)

References GetERCItem().

◆ SetSeverities()

void SHEETLIST_ERC_ITEMS_PROVIDER::SetSeverities ( int  aSeverities)
overridevirtual

Implements RC_ITEMS_PROVIDER.

Definition at line 242 of file erc_settings.cpp.

243 {
244  m_severities = aSeverities;
245 
246  m_filteredMarkers.clear();
247 
248  SCH_SHEET_LIST sheetList = m_schematic->GetSheets();
249  ERC_SETTINGS& settings = m_schematic->ErcSettings();
250 
251  for( unsigned i = 0; i < sheetList.size(); i++ )
252  {
253  for( SCH_ITEM* aItem : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) )
254  {
255  SCH_MARKER* marker = static_cast<SCH_MARKER*>( aItem );
256  int markerSeverity;
257 
258  if( marker->GetMarkerType() != MARKER_BASE::MARKER_ERC )
259  continue;
260 
261  if( marker->IsExcluded() )
262  markerSeverity = RPT_SEVERITY_EXCLUSION;
263  else
264  markerSeverity = settings.GetSeverity( marker->GetRCItem()->GetErrorCode() );
265 
266  if( markerSeverity & m_severities )
267  m_filteredMarkers.push_back( marker );
268  }
269  }
270 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:91
std::vector< SCH_MARKER * > m_filteredMarkers
Definition: erc_settings.h:174
int GetSeverity(int aErrorCode) const
bool IsExcluded() const
Definition: marker_base.h:109
Container for ERC settings.
Definition: erc_settings.h:94
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:107
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:131
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
std::shared_ptr< RC_ITEM > GetRCItem() const
Function GetReporter returns the DRC_ITEM held within this MARKER so that its interface may be used.
Definition: marker_base.h:120

References SCHEMATIC::ErcSettings(), MARKER_BASE::GetMarkerType(), MARKER_BASE::GetRCItem(), ERC_SETTINGS::GetSeverity(), SCHEMATIC::GetSheets(), MARKER_BASE::IsExcluded(), m_filteredMarkers, m_schematic, m_severities, MARKER_BASE::MARKER_ERC, RPT_SEVERITY_EXCLUSION, and SCH_MARKER_T.

Member Data Documentation

◆ m_filteredMarkers

std::vector<SCH_MARKER*> SHEETLIST_ERC_ITEMS_PROVIDER::m_filteredMarkers
private

Definition at line 174 of file erc_settings.h.

Referenced by DeleteItem(), GetCount(), GetERCItem(), and SetSeverities().

◆ m_schematic

SCHEMATIC* SHEETLIST_ERC_ITEMS_PROVIDER::m_schematic
private

Definition at line 172 of file erc_settings.h.

Referenced by DeleteAllItems(), DeleteItem(), GetCount(), and SetSeverities().

◆ m_severities

int SHEETLIST_ERC_ITEMS_PROVIDER::m_severities
private

Definition at line 173 of file erc_settings.h.

Referenced by SetSeverities().


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