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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef ERC_ITEM_H
21#define ERC_ITEM_H
22
23#include <optional>
24#include <rc_item.h>
25#include "sch_sheet_path.h"
26
34{
35public:
36 ERC_TREE_MODEL( EDA_DRAW_FRAME* aParentFrame, wxDataViewCtrl* aView ) :
37 RC_TREE_MODEL( aParentFrame, aView )
38 {
39 }
40
42
48 void GetValue( wxVariant& aVariant, wxDataViewItem const& aItem,
49 unsigned int aCol ) const override;
50};
51
52class ERC_ITEM : public RC_ITEM
53{
54public:
59 static std::shared_ptr<ERC_ITEM> Create( int aErrorCode );
60
61 static std::shared_ptr<ERC_ITEM> Create( const wxString& aErrorKey )
62 {
63 for( const RC_ITEM& item : allItemTypes )
64 {
65 if( aErrorKey == item.GetSettingsKey() )
66 return std::make_shared<ERC_ITEM>( static_cast<const ERC_ITEM&>( item ) );
67 }
68
69 return nullptr;
70 }
71
72 static std::vector<std::reference_wrapper<RC_ITEM>> GetItemsWithSeverities()
73 {
74 static std::vector<std::reference_wrapper<RC_ITEM>> itemsWithSeverities;
75
76 if( itemsWithSeverities.empty() )
77 {
78 for( RC_ITEM& item : allItemTypes )
79 {
80 if( &item == &heading_internal )
81 break;
82
83 itemsWithSeverities.push_back( item );
84 }
85 }
86
87 return itemsWithSeverities;
88 }
89
96 bool IsSheetSpecific() const { return m_sheetSpecificPath.has_value(); }
97
102 void SetSheetSpecificPath( const SCH_SHEET_PATH& aSpecificSheet )
103 {
104 m_sheetSpecificPath = aSpecificSheet;
105 }
106
113 {
114 wxASSERT( m_sheetSpecificPath.has_value() );
115 return m_sheetSpecificPath.value();
116 }
117
124 void SetItemsSheetPaths( const SCH_SHEET_PATH& mainItemSheet )
125 {
126 m_mainItemSheet = mainItemSheet;
127 }
128
136 void SetItemsSheetPaths( const SCH_SHEET_PATH& mainItemSheet,
137 const SCH_SHEET_PATH& auxItemSheet )
138 {
139 m_mainItemSheet = mainItemSheet;
140 m_auxItemSheet = auxItemSheet;
141 }
142
148 {
149 wxASSERT( MainItemHasSheetPath() );
150 return m_mainItemSheet.value();
151 }
152
158 {
159 wxASSERT( AuxItemHasSheetPath() );
160 return m_auxItemSheet.value();
161 }
162
168 bool MainItemHasSheetPath() { return m_mainItemSheet.has_value(); }
169
175 bool AuxItemHasSheetPath() { return m_auxItemSheet.has_value(); }
176
177protected:
183 wxString getItemDescription( EDA_ITEM* aItem, int aIndex,
184 UNITS_PROVIDER* aUnitsProvider ) const override;
185
186private:
187 ERC_ITEM( int aErrorCode = 0, const wxString& aTitle = "", const wxString& aSettingsKey = "" )
188 {
189 m_errorCode = aErrorCode;
190 m_errorTitle = aTitle;
191 m_settingsKey = aSettingsKey;
192 }
193
194 std::optional<SCH_SHEET_PATH> m_mainItemSheet;
195 std::optional<SCH_SHEET_PATH> m_auxItemSheet;
196
198 static std::vector<std::reference_wrapper<RC_ITEM>> allItemTypes;
199
204
256
258 std::optional<SCH_SHEET_PATH> m_sheetSpecificPath;
259};
260
261
262#endif // ERC_ITEM_H
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
static ERC_ITEM differentUnitValue
Definition erc_item.h:252
std::optional< SCH_SHEET_PATH > m_mainItemSheet
Definition erc_item.h:194
static ERC_ITEM busToBusConflict
Definition erc_item.h:233
static ERC_ITEM labelMultipleWires
Definition erc_item.h:218
static ERC_ITEM pinTableWarning
Definition erc_item.h:211
static std::shared_ptr< ERC_ITEM > Create(const wxString &aErrorKey)
Definition erc_item.h:61
static ERC_ITEM footprintLinkIssues
Definition erc_item.h:244
const SCH_SHEET_PATH & GetSpecificSheetPath() const
Gets the SCH_SHEET_PATH this ERC item is bound to.
Definition erc_item.h:112
static ERC_ITEM unresolvedVariable
Definition erc_item.h:238
static ERC_ITEM duplicateSheetName
Definition erc_item.h:205
static ERC_ITEM noConnectDangling
Definition erc_item.h:219
static ERC_ITEM busDefinitionConflict
Definition erc_item.h:230
static ERC_ITEM fourWayJunction
Definition erc_item.h:217
static ERC_ITEM genericError
Definition erc_item.h:214
static ERC_ITEM libSymbolIssues
Definition erc_item.h:242
SCH_SHEET_PATH & GetMainItemSheetPath()
Gets the SCH_SHEET_PATH of the main item causing this ERC violation.
Definition erc_item.h:147
static ERC_ITEM pinNotDriven
Definition erc_item.h:208
wxString getItemDescription(EDA_ITEM *aItem, int aIndex, UNITS_PROVIDER *aUnitsProvider) const override
Resolve the affected-item description in the per-instance SCH_SHEET_PATH context stored on this marke...
Definition erc_item.cpp:486
static ERC_ITEM undefinedNetclass
Definition erc_item.h:239
static ERC_ITEM extraUnits
Definition erc_item.h:247
bool AuxItemHasSheetPath()
Determines whether the auxiliary item causing this ERC violation has a specific SCH_SHEET_PATH bindin...
Definition erc_item.h:175
static ERC_ITEM heading_conflicts
Definition erc_item.h:201
void SetSheetSpecificPath(const SCH_SHEET_PATH &aSpecificSheet)
Sets the SCH_SHEET_PATH this ERC item is bound to.
Definition erc_item.h:102
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
Definition erc_item.cpp:315
static ERC_ITEM noConnectConnected
Definition erc_item.h:216
static ERC_ITEM heading_misc
Definition erc_item.h:202
static ERC_ITEM endpointOffGrid
Definition erc_item.h:206
static ERC_ITEM isolatedPinLabel
Definition erc_item.h:221
static ERC_ITEM busToNetConflict
Definition erc_item.h:234
static ERC_ITEM differentUnitFootprint
Definition erc_item.h:228
bool MainItemHasSheetPath()
Determines whether the main item causing this ERC violation has a specific SCH_SHEET_PATH binding.
Definition erc_item.h:168
static ERC_ITEM sameLocalGlobalLabel
Definition erc_item.h:223
static ERC_ITEM hierLabelMismatch
Definition erc_item.h:215
static ERC_ITEM heading_connections
Definition erc_item.h:200
static ERC_ITEM missingUnits
Definition erc_item.h:248
static ERC_ITEM similarLabels
Definition erc_item.h:225
static ERC_ITEM unconnectedWireEndpoint
Definition erc_item.h:255
static ERC_ITEM heading_internal
Definition erc_item.h:203
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:198
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:124
static std::vector< std::reference_wrapper< RC_ITEM > > GetItemsWithSeverities()
Definition erc_item.h:72
static ERC_ITEM labelDangling
Definition erc_item.h:220
static ERC_ITEM differentUnitNet
Definition erc_item.h:229
static ERC_ITEM pinTableError
Definition erc_item.h:212
static ERC_ITEM similarLabelAndPower
Definition erc_item.h:227
static ERC_ITEM groundPinNotGround
Definition erc_item.h:235
static ERC_ITEM genericWarning
Definition erc_item.h:213
static ERC_ITEM footprintFilters
Definition erc_item.h:245
static ERC_ITEM fieldNameWhitespace
Definition erc_item.h:237
static ERC_ITEM netNotBusMember
Definition erc_item.h:232
static ERC_ITEM wireDangling
Definition erc_item.h:241
ERC_ITEM(int aErrorCode=0, const wxString &aTitle="", const wxString &aSettingsKey="")
Definition erc_item.h:187
static ERC_ITEM powerpinNotDriven
Definition erc_item.h:209
static ERC_ITEM missingPowerInputPin
Definition erc_item.h:251
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:258
static ERC_ITEM missingBidiPin
Definition erc_item.h:250
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:96
static ERC_ITEM unannotated
Definition erc_item.h:246
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:136
static ERC_ITEM missingInputPin
Definition erc_item.h:249
static ERC_ITEM singleGlobalLabel
Definition erc_item.h:222
static ERC_ITEM sameLocalGlobalPower
Definition erc_item.h:224
static ERC_ITEM busEntryNeeded
Definition erc_item.h:254
static ERC_ITEM simulationModelIssues
Definition erc_item.h:240
std::optional< SCH_SHEET_PATH > m_auxItemSheet
Definition erc_item.h:195
SCH_SHEET_PATH & GetAuxItemSheetPath()
Gets the SCH_SHEET_PATH of the auxiliary item causing this ERC violation.
Definition erc_item.h:157
static ERC_ITEM multipleNetNames
Definition erc_item.h:231
static ERC_ITEM similarPower
Definition erc_item.h:226
static ERC_ITEM pinNotConnected
Definition erc_item.h:207
static ERC_ITEM stackedPinName
Definition erc_item.h:236
static ERC_ITEM libSymbolMismatch
Definition erc_item.h:243
static ERC_ITEM duplicateReference
Definition erc_item.h:253
static ERC_ITEM duplicatePinError
Definition erc_item.h:210
ERC_TREE_MODEL(EDA_DRAW_FRAME *aParentFrame, wxDataViewCtrl *aView)
Definition erc_item.h:36
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:384
wxString m_settingsKey
The key used to describe this type of error in settings.
Definition rc_item.h:206
int m_errorCode
The error code's numeric value.
Definition rc_item.h:203
wxString m_errorTitle
The string describing the type of error.
Definition rc_item.h:205
RC_ITEM()
Definition rc_item.h:84
RC_TREE_MODEL(EDA_DRAW_FRAME *aParentFrame, wxDataViewCtrl *aView)
Definition rc_item.cpp:253
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.