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) const override
 
std::shared_ptr< RC_ITEMGetItem (int aIndex) const override
 Retrieve a RC_ITEM by index. More...
 
std::shared_ptr< ERC_ITEMGetERCItem (int aIndex) const
 
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 Member Functions

void visitMarkers (std::function< void(SCH_MARKER *)> aVisitor) const
 

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 182 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 190 of file erc_settings.h.

190  :
191  m_schematic( aSchematic ),
192  m_severities( 0 )
193  { }

Member Function Documentation

◆ DeleteAllItems()

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

Implements RC_ITEMS_PROVIDER.

Definition at line 380 of file erc_settings.cpp.

381 {
382  // Filtered list was already handled through DeleteItem() by the tree control
383 
384  if( aDeep )
385  {
386  SCH_SCREENS screens( m_schematic->Root() );
387  screens.DeleteAllMarkers( MARKER_BASE::MARKER_ERC, aIncludeExclusions );
388  }
389 }
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:92
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:549

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 367 of file erc_settings.cpp.

368 {
369  SCH_MARKER* marker = m_filteredMarkers[ aIndex ];
370  m_filteredMarkers.erase( m_filteredMarkers.begin() + aIndex );
371 
372  if( aDeep )
373  {
374  SCH_SCREENS screens( m_schematic->Root() );
375  screens.DeleteMarker( marker );
376  }
377 }
std::vector< SCH_MARKER * > m_filteredMarkers
Definition: erc_settings.h:187
void DeleteMarker(SCH_MARKER *aMarker)
Delete a specific marker.
SCH_SHEET & Root() const
Definition: schematic.h:92
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:549

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

◆ GetCount()

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

Implements RC_ITEMS_PROVIDER.

Definition at line 326 of file erc_settings.cpp.

327 {
328  if( aSeverity < 0 )
329  return m_filteredMarkers.size();
330 
331  int count = 0;
332 
333  const ERC_SETTINGS& settings = m_schematic->ErcSettings();
334 
335  visitMarkers(
336  [&]( SCH_MARKER* aMarker )
337  {
338  SEVERITY markerSeverity;
339 
340  if( aMarker->IsExcluded() )
341  markerSeverity = RPT_SEVERITY_EXCLUSION;
342  else
343  markerSeverity = settings.GetSeverity( aMarker->GetRCItem()->GetErrorCode() );
344 
345  if( markerSeverity == aSeverity )
346  count++;
347  } );
348 
349  return count;
350 }
SEVERITY
Definition: ui_common.h:83
void visitMarkers(std::function< void(SCH_MARKER *)> aVisitor) const
std::vector< SCH_MARKER * > m_filteredMarkers
Definition: erc_settings.h:187
bool IsExcluded() const
Definition: marker_base.h:94
Container for ERC settings.
Definition: erc_settings.h:105
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:134
std::shared_ptr< RC_ITEM > GetRCItem() const
Definition: marker_base.h:100
SEVERITY GetSeverity(int aErrorCode) const

References SCHEMATIC::ErcSettings(), MARKER_BASE::GetRCItem(), ERC_SETTINGS::GetSeverity(), MARKER_BASE::IsExcluded(), m_filteredMarkers, m_schematic, RPT_SEVERITY_EXCLUSION, and visitMarkers().

◆ GetERCItem()

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

Definition at line 353 of file erc_settings.cpp.

354 {
355  SCH_MARKER* marker = m_filteredMarkers[ aIndex ];
356 
357  return marker ? std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() ) : nullptr;
358 }
std::vector< SCH_MARKER * > m_filteredMarkers
Definition: erc_settings.h:187
std::shared_ptr< RC_ITEM > GetRCItem() const
Definition: marker_base.h:100

References MARKER_BASE::GetRCItem(), and m_filteredMarkers.

Referenced by GetItem().

◆ GetItem()

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

Retrieve a RC_ITEM by index.

Implements RC_ITEMS_PROVIDER.

Definition at line 361 of file erc_settings.cpp.

362 {
363  return GetERCItem( aIndex );
364 }
std::shared_ptr< ERC_ITEM > GetERCItem(int aIndex) const

References GetERCItem().

◆ SetSeverities()

void SHEETLIST_ERC_ITEMS_PROVIDER::SetSeverities ( int  aSeverities)
overridevirtual

Implements RC_ITEMS_PROVIDER.

Definition at line 302 of file erc_settings.cpp.

303 {
304  m_severities = aSeverities;
305 
306  m_filteredMarkers.clear();
307 
308  ERC_SETTINGS& settings = m_schematic->ErcSettings();
309 
310  visitMarkers(
311  [&]( SCH_MARKER* aMarker )
312  {
313  SEVERITY markerSeverity;
314 
315  if( aMarker->IsExcluded() )
316  markerSeverity = RPT_SEVERITY_EXCLUSION;
317  else
318  markerSeverity = settings.GetSeverity( aMarker->GetRCItem()->GetErrorCode() );
319 
320  if( markerSeverity & m_severities )
321  m_filteredMarkers.push_back( aMarker );
322  } );
323 }
SEVERITY
Definition: ui_common.h:83
void visitMarkers(std::function< void(SCH_MARKER *)> aVisitor) const
std::vector< SCH_MARKER * > m_filteredMarkers
Definition: erc_settings.h:187
bool IsExcluded() const
Definition: marker_base.h:94
Container for ERC settings.
Definition: erc_settings.h:105
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:134
std::shared_ptr< RC_ITEM > GetRCItem() const
Definition: marker_base.h:100
SEVERITY GetSeverity(int aErrorCode) const

References SCHEMATIC::ErcSettings(), MARKER_BASE::GetRCItem(), ERC_SETTINGS::GetSeverity(), MARKER_BASE::IsExcluded(), m_filteredMarkers, m_schematic, m_severities, RPT_SEVERITY_EXCLUSION, and visitMarkers().

◆ visitMarkers()

void SHEETLIST_ERC_ITEMS_PROVIDER::visitMarkers ( std::function< void(SCH_MARKER *)>  aVisitor) const
private

Definition at line 269 of file erc_settings.cpp.

270 {
271  SCH_SHEET_LIST sheetList = m_schematic->GetSheets();
272 
273  std::set<SCH_SCREEN*> seenScreens;
274 
275  for( unsigned i = 0; i < sheetList.size(); i++ )
276  {
277  bool firstTime = seenScreens.count( sheetList[i].LastScreen() ) == 0;
278 
279  if( firstTime )
280  seenScreens.insert( sheetList[i].LastScreen() );
281 
282  for( SCH_ITEM* item : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) )
283  {
284  SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
285 
286  if( marker->GetMarkerType() != MARKER_BASE::MARKER_ERC )
287  continue;
288 
289  // Don't show non-specific markers more than once
290  if( !firstTime &&
291  !static_cast<const ERC_ITEM*>( marker->GetRCItem().get() )->IsSheetSpecific() )
292  {
293  continue;
294  }
295 
296  aVisitor( marker );
297  }
298  }
299 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:92
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
std::shared_ptr< RC_ITEM > GetRCItem() const
Definition: marker_base.h:100

References MARKER_BASE::GetMarkerType(), MARKER_BASE::GetRCItem(), SCHEMATIC::GetSheets(), m_schematic, MARKER_BASE::MARKER_ERC, and SCH_MARKER_T.

Referenced by GetCount(), and SetSeverities().

Member Data Documentation

◆ m_filteredMarkers

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

Definition at line 187 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 185 of file erc_settings.h.

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

◆ m_severities

int SHEETLIST_ERC_ITEMS_PROVIDER::m_severities
private

Definition at line 186 of file erc_settings.h.

Referenced by SetSeverities().


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