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...
 

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

198 :
199 m_schematic( aSchematic ),
200 m_severities( 0 )
201 { }

Member Function Documentation

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

373{
374 SCH_MARKER* marker = m_filteredMarkers[ aIndex ];
375 m_filteredMarkers.erase( m_filteredMarkers.begin() + aIndex );
376
377 if( aDeep )
378 {
379 SCH_SCREENS screens( m_schematic->Root() );
380 screens.DeleteMarker( marker );
381 }
382}
SCH_SHEET & Root() const
Definition: schematic.h:91
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:619
std::vector< SCH_MARKER * > m_filteredMarkers
Definition: erc_settings.h:195

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

332{
333 if( aSeverity < 0 )
334 return m_filteredMarkers.size();
335
336 int count = 0;
337
338 const ERC_SETTINGS& settings = m_schematic->ErcSettings();
339
341 [&]( SCH_MARKER* aMarker )
342 {
343 SEVERITY markerSeverity;
344
345 if( aMarker->IsExcluded() )
346 markerSeverity = RPT_SEVERITY_EXCLUSION;
347 else
348 markerSeverity = settings.GetSeverity( aMarker->GetRCItem()->GetErrorCode() );
349
350 if( ( markerSeverity & aSeverity ) > 0 )
351 count++;
352 } );
353
354 return count;
355}
Container for ERC settings.
Definition: erc_settings.h:114
SEVERITY GetSeverity(int aErrorCode) const
bool IsExcluded() const
Definition: marker_base.h:97
std::shared_ptr< RC_ITEM > GetRCItem() const
Definition: marker_base.h:105
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:179
void visitMarkers(std::function< void(SCH_MARKER *)> aVisitor) const
SEVERITY
@ RPT_SEVERITY_EXCLUSION

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

Referenced by BOOST_FIXTURE_TEST_CASE().

◆ GetERCItem()

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

Definition at line 358 of file erc_settings.cpp.

359{
360 SCH_MARKER* marker = m_filteredMarkers[ aIndex ];
361
362 return marker ? std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() ) : nullptr;
363}

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

367{
368 return GetERCItem( aIndex );
369}
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 307 of file erc_settings.cpp.

308{
309 m_severities = aSeverities;
310
311 m_filteredMarkers.clear();
312
313 ERC_SETTINGS& settings = m_schematic->ErcSettings();
314
316 [&]( SCH_MARKER* aMarker )
317 {
318 SEVERITY markerSeverity;
319
320 if( aMarker->IsExcluded() )
321 markerSeverity = RPT_SEVERITY_EXCLUSION;
322 else
323 markerSeverity = settings.GetSeverity( aMarker->GetRCItem()->GetErrorCode() );
324
325 if( markerSeverity & m_severities )
326 m_filteredMarkers.push_back( aMarker );
327 } );
328}

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

Referenced by BOOST_FIXTURE_TEST_CASE().

◆ visitMarkers()

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

Definition at line 274 of file erc_settings.cpp.

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

References MARKER_BASE::GetMarkerType(), MARKER_BASE::GetRCItem(), SCHEMATIC::GetSheets(), ERC_ITEM::IsSheetSpecific(), 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 195 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 193 of file erc_settings.h.

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

◆ m_severities

int SHEETLIST_ERC_ITEMS_PROVIDER::m_severities
private

Definition at line 194 of file erc_settings.h.

Referenced by SetSeverities().


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