KiCad PCB EDA Suite
drc_results_provider.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2018-2021 KiCad Developers, see change_log.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #include <board_design_settings.h>
25 #include "drc_results_provider.h"
26 
28 {
29  m_severities = aSeverities;
30 
32 
33  m_filteredMarkers.clear();
34 
35  for( PCB_MARKER* marker : m_board->Markers() )
36  {
37  SEVERITY markerSeverity;
38 
39  if( marker->IsExcluded() )
40  markerSeverity = RPT_SEVERITY_EXCLUSION;
41  else
42  markerSeverity = bds.GetSeverity( marker->GetRCItem()->GetErrorCode() );
43 
44  if( markerSeverity & m_severities )
45  m_filteredMarkers.push_back( marker );
46  }
47 }
48 
49 
50 int BOARD_DRC_ITEMS_PROVIDER::GetCount( int aSeverity ) const
51 {
52  if( aSeverity < 0 )
53  return m_filteredMarkers.size();
54 
56 
57  int count = 0;
58 
59  for( PCB_MARKER* marker : m_board->Markers() )
60  {
61  SEVERITY markerSeverity;
62 
63  if( marker->IsExcluded() )
64  markerSeverity = RPT_SEVERITY_EXCLUSION;
65  else
66  markerSeverity = bds.GetSeverity( marker->GetRCItem()->GetErrorCode() );
67 
68  if( markerSeverity == aSeverity )
69  count++;
70  }
71 
72  return count;
73 }
74 
75 
77 {
78  m_severities = aSeverities;
79 
81 
82  m_filteredVector.clear();
83 
84  if( m_sourceVector )
85  {
86  for( const std::shared_ptr<DRC_ITEM>& item : *m_sourceVector )
87  {
88  if( bds.GetSeverity( item->GetErrorCode() ) & aSeverities )
89  m_filteredVector.push_back( item );
90  }
91  }
92 }
93 
94 
95 int VECTOR_DRC_ITEMS_PROVIDER::GetCount( int aSeverity ) const
96 {
97  if( aSeverity < 0 )
98  return m_filteredVector.size();
99 
100  int count = 0;
102 
103  if( m_sourceVector )
104  {
105  for( const std::shared_ptr<DRC_ITEM>& item : *m_sourceVector )
106  {
107  if( bds.GetSeverity( item->GetErrorCode() ) == aSeverity )
108  count++;
109  }
110  }
111 
112  return count;
113 }
void SetSeverities(int aSeverities) override
int GetCount(int aSeverity=-1) const override
MARKERS & Markers()
Definition: board.h:242
std::vector< PCB_MARKER * > m_filteredMarkers
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
SEVERITY GetSeverity(int aDRCErrorCode)
std::vector< std::shared_ptr< DRC_ITEM > > m_filteredVector
std::vector< std::shared_ptr< DRC_ITEM > > * m_sourceVector
SEVERITY
void SetSeverities(int aSeverities) override
int GetCount(int aSeverity=-1) const override
BOARD * GetBoard() const
Container for design settings for a BOARD object.