KiCad PCB EDA Suite
Loading...
Searching...
No Matches
erc_item.h
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) 2020 KiCad Developers, see AUTHORS.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#ifndef ERC_ITEM_H
25#define ERC_ITEM_H
26
27#include <optional>
28#include <rc_item.h>
29#include "sch_sheet_path.h"
30
38{
39public:
40 ERC_TREE_MODEL( EDA_DRAW_FRAME* aParentFrame, wxDataViewCtrl* aView ) :
41 RC_TREE_MODEL( aParentFrame, aView )
42 {
43 }
44
46
52 void GetValue( wxVariant& aVariant, wxDataViewItem const& aItem,
53 unsigned int aCol ) const override;
54};
55
56class ERC_ITEM : public RC_ITEM
57{
58public:
63 static std::shared_ptr<ERC_ITEM> Create( int aErrorCode );
64
65 static std::shared_ptr<ERC_ITEM> Create( const wxString& aErrorKey )
66 {
67 for( const RC_ITEM& item : allItemTypes )
68 {
69 if( aErrorKey == item.GetSettingsKey() )
70 return std::make_shared<ERC_ITEM>( static_cast<const ERC_ITEM&>( item ) );
71 }
72
73 return nullptr;
74 }
75
76 static std::vector<std::reference_wrapper<RC_ITEM>> GetItemsWithSeverities()
77 {
78 static std::vector<std::reference_wrapper<RC_ITEM>> itemsWithSeverities;
79
80 if( itemsWithSeverities.empty() )
81 {
82 for( RC_ITEM& item : allItemTypes )
83 {
84 if( &item == &heading_internal )
85 break;
86
87 itemsWithSeverities.push_back( item );
88 }
89 }
90
91 return itemsWithSeverities;
92 }
93
100 bool IsSheetSpecific() const { return m_sheetSpecificPath.has_value(); }
101
106 void SetSheetSpecificPath( const SCH_SHEET_PATH& aSpecificSheet )
107 {
108 m_sheetSpecificPath = aSpecificSheet;
109 }
110
117 {
118 wxASSERT( m_sheetSpecificPath.has_value() );
119 return m_sheetSpecificPath.value();
120 }
121
128 void SetItemsSheetPaths( const SCH_SHEET_PATH& mainItemSheet )
129 {
130 m_mainItemSheet = mainItemSheet;
131 }
132
140 void SetItemsSheetPaths( const SCH_SHEET_PATH& mainItemSheet,
141 const SCH_SHEET_PATH& auxItemSheet )
142 {
143 m_mainItemSheet = mainItemSheet;
144 m_auxItemSheet = auxItemSheet;
145 }
146
152 {
153 wxASSERT( MainItemHasSheetPath() );
154 return m_mainItemSheet.value();
155 }
156
162 {
163 wxASSERT( AuxItemHasSheetPath() );
164 return m_auxItemSheet.value();
165 }
166
172 bool MainItemHasSheetPath() { return m_mainItemSheet.has_value(); }
173
179 bool AuxItemHasSheetPath() { return m_auxItemSheet.has_value(); }
180
181private:
182 ERC_ITEM( int aErrorCode = 0, const wxString& aTitle = "", const wxString& aSettingsKey = "" )
183 {
184 m_errorCode = aErrorCode;
185 m_errorTitle = aTitle;
186 m_settingsKey = aSettingsKey;
187 }
188
189 std::optional<SCH_SHEET_PATH> m_mainItemSheet;
190 std::optional<SCH_SHEET_PATH> m_auxItemSheet;
191
193 static std::vector<std::reference_wrapper<RC_ITEM>> allItemTypes;
194
199
247
249 std::optional<SCH_SHEET_PATH> m_sheetSpecificPath;
250};
251
252
253#endif // ERC_ITEM_H
The base class for create windows for drawing purpose.
static ERC_ITEM differentUnitValue
Definition: erc_item.h:243
std::optional< SCH_SHEET_PATH > m_mainItemSheet
Definition: erc_item.h:189
static ERC_ITEM busToBusConflict
Definition: erc_item.h:227
static ERC_ITEM labelMultipleWires
Definition: erc_item.h:213
static ERC_ITEM pinTableWarning
Definition: erc_item.h:206
static std::shared_ptr< ERC_ITEM > Create(const wxString &aErrorKey)
Definition: erc_item.h:65
static ERC_ITEM footprintLinkIssues
Definition: erc_item.h:235
const SCH_SHEET_PATH & GetSpecificSheetPath() const
Gets the SCH_SHEET_PATH this ERC item is bound to.
Definition: erc_item.h:116
static ERC_ITEM unresolvedVariable
Definition: erc_item.h:229
static ERC_ITEM duplicateSheetName
Definition: erc_item.h:200
static ERC_ITEM noConnectDangling
Definition: erc_item.h:214
static ERC_ITEM busDefinitionConflict
Definition: erc_item.h:224
static ERC_ITEM fourWayJunction
Definition: erc_item.h:212
static ERC_ITEM genericError
Definition: erc_item.h:209
static ERC_ITEM libSymbolIssues
Definition: erc_item.h:233
SCH_SHEET_PATH & GetMainItemSheetPath()
Gets the SCH_SHEET_PATH of the main item causing this ERC violation.
Definition: erc_item.h:151
static ERC_ITEM pinNotDriven
Definition: erc_item.h:203
static ERC_ITEM undefinedNetclass
Definition: erc_item.h:230
static ERC_ITEM extraUnits
Definition: erc_item.h:238
bool AuxItemHasSheetPath()
Determines whether the auxiliary item causing this ERC violation has a specific SCH_SHEET_PATH bindin...
Definition: erc_item.h:179
static ERC_ITEM heading_conflicts
Definition: erc_item.h:196
void SetSheetSpecificPath(const SCH_SHEET_PATH &aSpecificSheet)
Sets the SCH_SHEET_PATH this ERC item is bound to.
Definition: erc_item.h:106
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
Definition: erc_item.cpp:299
static ERC_ITEM noConnectConnected
Definition: erc_item.h:211
static ERC_ITEM heading_misc
Definition: erc_item.h:197
static ERC_ITEM endpointOffGrid
Definition: erc_item.h:201
static ERC_ITEM busToNetConflict
Definition: erc_item.h:228
static ERC_ITEM differentUnitFootprint
Definition: erc_item.h:222
bool MainItemHasSheetPath()
Determines whether the main item causing this ERC violation has a specific SCH_SHEET_PATH binding.
Definition: erc_item.h:172
static ERC_ITEM sameLocalGlobalLabel
Definition: erc_item.h:218
static ERC_ITEM hierLabelMismatch
Definition: erc_item.h:210
static ERC_ITEM heading_connections
Definition: erc_item.h:195
static ERC_ITEM missingUnits
Definition: erc_item.h:239
static ERC_ITEM similarLabels
Definition: erc_item.h:219
static ERC_ITEM unconnectedWireEndpoint
Definition: erc_item.h:246
static ERC_ITEM heading_internal
Definition: erc_item.h:198
static std::vector< std::reference_wrapper< RC_ITEM > > allItemTypes
A list of all ERC_ITEM types which are valid error codes.
Definition: erc_item.h:193
void SetItemsSheetPaths(const SCH_SHEET_PATH &mainItemSheet)
Sets the SCH_SHEET_PATH of the main item causing this ERC violation to (e.g.
Definition: erc_item.h:128
static std::vector< std::reference_wrapper< RC_ITEM > > GetItemsWithSeverities()
Definition: erc_item.h:76
static ERC_ITEM globalLabelDangling
Definition: erc_item.h:216
static ERC_ITEM labelDangling
Definition: erc_item.h:215
static ERC_ITEM differentUnitNet
Definition: erc_item.h:223
static ERC_ITEM pinTableError
Definition: erc_item.h:207
static ERC_ITEM similarLabelAndPower
Definition: erc_item.h:221
static ERC_ITEM genericWarning
Definition: erc_item.h:208
static ERC_ITEM footprintFilters
Definition: erc_item.h:236
static ERC_ITEM netNotBusMember
Definition: erc_item.h:226
static ERC_ITEM wireDangling
Definition: erc_item.h:232
ERC_ITEM(int aErrorCode=0, const wxString &aTitle="", const wxString &aSettingsKey="")
Definition: erc_item.h:182
static ERC_ITEM powerpinNotDriven
Definition: erc_item.h:204
static ERC_ITEM missingPowerInputPin
Definition: erc_item.h:242
std::optional< SCH_SHEET_PATH > m_sheetSpecificPath
True if this item is specific to a sheet instance (as opposed to applying to all instances)
Definition: erc_item.h:249
static ERC_ITEM missingBidiPin
Definition: erc_item.h:241
bool IsSheetSpecific() const
Determines whether the ERC item is bound to a specific sheet, or is common across multiple sheets (e....
Definition: erc_item.h:100
static ERC_ITEM unannotated
Definition: erc_item.h:237
void SetItemsSheetPaths(const SCH_SHEET_PATH &mainItemSheet, const SCH_SHEET_PATH &auxItemSheet)
Set the SCH_SHEET PATHs of the main and auxiliary items causing this ERC violation to (e....
Definition: erc_item.h:140
static ERC_ITEM missingInputPin
Definition: erc_item.h:240
static ERC_ITEM singleGlobalLabel
Definition: erc_item.h:217
static ERC_ITEM busEntryNeeded
Definition: erc_item.h:245
static ERC_ITEM simulationModelIssues
Definition: erc_item.h:231
std::optional< SCH_SHEET_PATH > m_auxItemSheet
Definition: erc_item.h:190
SCH_SHEET_PATH & GetAuxItemSheetPath()
Gets the SCH_SHEET_PATH of the auxiliary item causing this ERC violation.
Definition: erc_item.h:161
static ERC_ITEM multipleNetNames
Definition: erc_item.h:225
static ERC_ITEM similarPower
Definition: erc_item.h:220
static ERC_ITEM pinNotConnected
Definition: erc_item.h:202
static ERC_ITEM libSymbolMismatch
Definition: erc_item.h:234
static ERC_ITEM duplicateReference
Definition: erc_item.h:244
static ERC_ITEM duplicatePinError
Definition: erc_item.h:205
A specialisation of the RC_TREE_MODEL class to enable ERC errors / warnings to be resolved in a speci...
Definition: erc_item.h:38
ERC_TREE_MODEL(EDA_DRAW_FRAME *aParentFrame, wxDataViewCtrl *aView)
Definition: erc_item.h:40
void GetValue(wxVariant &aVariant, wxDataViewItem const &aItem, unsigned int aCol) const override
Override of RC_TREE_MODEL::GetValue which returns item descriptions in a specific SCH_SHEET_PATH cont...
Definition: erc_item.cpp:364
A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema.
Definition: rc_item.h:79
wxString m_settingsKey
The key used to describe this type of error in settings.
Definition: rc_item.h:187
int m_errorCode
The error code's numeric value.
Definition: rc_item.h:184
wxString m_errorTitle
The string describing the type of error.
Definition: rc_item.h:186
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.