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

380{
381 SCH_MARKER* marker = m_filteredMarkers[ aIndex ];
382 m_filteredMarkers.erase( m_filteredMarkers.begin() + aIndex );
383
384 if( aDeep )
385 {
386 SCH_SCREENS screens( m_schematic->Root() );
387 screens.DeleteMarker( marker );
388 }
389}
SCH_SHEET & Root() const
Definition: schematic.h:91
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:662
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 338 of file erc_settings.cpp.

339{
340 if( aSeverity < 0 )
341 return m_filteredMarkers.size();
342
343 int count = 0;
344
345 const ERC_SETTINGS& settings = m_schematic->ErcSettings();
346
348 [&]( SCH_MARKER* aMarker )
349 {
350 SEVERITY markerSeverity;
351
352 if( aMarker->IsExcluded() )
353 markerSeverity = RPT_SEVERITY_EXCLUSION;
354 else
355 markerSeverity = settings.GetSeverity( aMarker->GetRCItem()->GetErrorCode() );
356
357 if( ( markerSeverity & aSeverity ) > 0 )
358 count++;
359 } );
360
361 return count;
362}
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:212
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 365 of file erc_settings.cpp.

366{
367 SCH_MARKER* marker = m_filteredMarkers[ aIndex ];
368
369 return marker ? std::static_pointer_cast<ERC_ITEM>( marker->GetRCItem() ) : nullptr;
370}

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

374{
375 return GetERCItem( aIndex );
376}
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 314 of file erc_settings.cpp.

315{
316 m_severities = aSeverities;
317
318 m_filteredMarkers.clear();
319
320 ERC_SETTINGS& settings = m_schematic->ErcSettings();
321
323 [&]( SCH_MARKER* aMarker )
324 {
325 SEVERITY markerSeverity;
326
327 if( aMarker->IsExcluded() )
328 markerSeverity = RPT_SEVERITY_EXCLUSION;
329 else
330 markerSeverity = settings.GetSeverity( aMarker->GetRCItem()->GetErrorCode() );
331
332 if( markerSeverity & m_severities )
333 m_filteredMarkers.push_back( aMarker );
334 } );
335}

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 std::shared_ptr<const ERC_ITEM> ercItem =
295 std::static_pointer_cast<const ERC_ITEM>( marker->GetRCItem() );
296
297 // Only show sheet-specific markers on the owning sheet
298 if( ercItem->IsSheetSpecific() )
299 {
300 if( ercItem->GetSpecificSheetPath() != sheetList[i] )
301 continue;
302 }
303
304 // Don't show non-specific markers more than once
305 if( !firstTime && !ercItem->IsSheetSpecific() )
306 continue;
307
308 aVisitor( marker );
309 }
310 }
311}
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(), 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: