KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_rule.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-2023 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#ifndef DRC_RULE_H
25#define DRC_RULE_H
26
27#include <bitset>
28#include <kiid.h>
29#include <core/typeinfo.h>
30#include <optional>
31#include <core/minoptmax.h>
32#include <layer_ids.h>
33#include <lset.h>
34#include <netclass.h>
35#include <zones.h>
37#include <wx/intl.h>
39
40class BOARD_ITEM;
41class PCBEXPR_UCODE;
42class DRC_CONSTRAINT;
44
45
47{
76};
77
78
80{
91};
92
93
95{
96public:
97 DRC_RULE();
98 DRC_RULE( const wxString& aName );
99
100 virtual ~DRC_RULE();
101
102 virtual bool AppliesTo( const BOARD_ITEM* a, const BOARD_ITEM* b = nullptr ) const
103 {
104 return true;
105 };
106
107 void AddConstraint( DRC_CONSTRAINT& aConstraint );
108 std::optional<DRC_CONSTRAINT> FindConstraint( DRC_CONSTRAINT_T aType );
109
110public:
114 wxString m_Name;
118 std::vector<DRC_CONSTRAINT> m_Constraints;
120};
121
122
124{
125 public:
127 const wxString& aName = wxEmptyString ) :
128 m_Type( aType ),
129 m_Value(),
130 m_DisallowFlags( 0 ),
132 m_Test( nullptr ),
133 m_name( aName ),
134 m_parentRule( nullptr )
135 {
136 }
137
138 enum class OPTIONS : std::size_t
139 {
141 };
142
143 bool IsNull() const
144 {
145 return m_Type == NULL_CONSTRAINT;
146 }
147
148 const MINOPTMAX<int>& GetValue() const { return m_Value; }
150
151 void SetParentRule( DRC_RULE *aParentRule ) { m_parentRule = aParentRule; }
153
154 void SetName( const wxString& aName ) { m_name = aName; }
155
156 wxString GetName() const
157 {
158 if( m_parentRule )
159 {
161 return m_parentRule->m_Name;
162 else
163 return wxString::Format( _( "rule '%s'" ), m_parentRule->m_Name );
164 }
165
166 return m_name;
167 }
168
170 {
171 if( m_parentRule )
172 return m_parentRule->m_Severity;
173 else
175 }
176
177 void SetOption( OPTIONS option ) { m_options.set( static_cast<std::size_t>( option ), true ); }
178
179 bool GetOption( OPTIONS option ) const
180 {
181 return m_options.test( static_cast<std::size_t>( option ) );
182 }
183
184public:
190
191private:
192 wxString m_name; // For just-in-time constraints
193 DRC_RULE* m_parentRule; // For constraints found in rules
194 std::bitset<1> m_options; // Constraint-specific option bits
195 // (indexed from DRC_CONSTRAINT::OPTIONS)
196};
197
198
199const DRC_CONSTRAINT* GetConstraint( const BOARD_ITEM* aItem, const BOARD_ITEM* bItem,
200 int aConstraint, PCB_LAYER_ID aLayer,
201 wxString* aRuleName = nullptr );
202
203
204#endif // DRC_RULE_H
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
DRC_RULE_CONDITION * m_Test
Definition: drc_rule.h:189
wxString GetName() const
Definition: drc_rule.h:156
int m_DisallowFlags
Definition: drc_rule.h:187
SEVERITY GetSeverity() const
Definition: drc_rule.h:169
void SetOption(OPTIONS option)
Definition: drc_rule.h:177
DRC_RULE * m_parentRule
Definition: drc_rule.h:193
void SetParentRule(DRC_RULE *aParentRule)
Definition: drc_rule.h:151
MINOPTMAX< int > & Value()
Definition: drc_rule.h:149
const MINOPTMAX< int > & GetValue() const
Definition: drc_rule.h:148
ZONE_CONNECTION m_ZoneConnection
Definition: drc_rule.h:188
void SetName(const wxString &aName)
Definition: drc_rule.h:154
MINOPTMAX< int > m_Value
Definition: drc_rule.h:186
DRC_CONSTRAINT_T m_Type
Definition: drc_rule.h:185
std::bitset< 1 > m_options
Definition: drc_rule.h:194
wxString m_name
Definition: drc_rule.h:192
bool GetOption(OPTIONS option) const
Definition: drc_rule.h:179
DRC_RULE * GetParentRule() const
Definition: drc_rule.h:152
DRC_CONSTRAINT(DRC_CONSTRAINT_T aType=NULL_CONSTRAINT, const wxString &aName=wxEmptyString)
Definition: drc_rule.h:126
bool IsNull() const
Definition: drc_rule.h:143
SEVERITY m_Severity
Definition: drc_rule.h:119
bool m_Unary
Definition: drc_rule.h:111
DRC_RULE_CONDITION * m_Condition
Definition: drc_rule.h:117
LSET m_LayerCondition
Definition: drc_rule.h:116
virtual bool AppliesTo(const BOARD_ITEM *a, const BOARD_ITEM *b=nullptr) const
Definition: drc_rule.h:102
KIID m_ImplicitItemId
Definition: drc_rule.h:113
DRC_RULE()
Definition: drc_rule.cpp:31
std::vector< DRC_CONSTRAINT > m_Constraints
Definition: drc_rule.h:118
bool m_Implicit
Definition: drc_rule.h:112
wxString m_Name
Definition: drc_rule.h:114
void AddConstraint(DRC_CONSTRAINT &aConstraint)
Definition: drc_rule.cpp:60
wxString m_LayerSource
Definition: drc_rule.h:115
virtual ~DRC_RULE()
Definition: drc_rule.cpp:54
std::optional< DRC_CONSTRAINT > FindConstraint(DRC_CONSTRAINT_T aType)
Definition: drc_rule.cpp:67
Definition: kiid.h:49
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:36
const DRC_CONSTRAINT * GetConstraint(const BOARD_ITEM *aItem, const BOARD_ITEM *bItem, int aConstraint, PCB_LAYER_ID aLayer, wxString *aRuleName=nullptr)
DRC_DISALLOW_T
Definition: drc_rule.h:80
@ DRC_DISALLOW_PADS
Definition: drc_rule.h:85
@ DRC_DISALLOW_VIAS
Definition: drc_rule.h:81
@ DRC_DISALLOW_TEXTS
Definition: drc_rule.h:87
@ DRC_DISALLOW_ZONES
Definition: drc_rule.h:86
@ DRC_DISALLOW_HOLES
Definition: drc_rule.h:89
@ DRC_DISALLOW_GRAPHICS
Definition: drc_rule.h:88
@ DRC_DISALLOW_FOOTPRINTS
Definition: drc_rule.h:90
@ DRC_DISALLOW_TRACKS
Definition: drc_rule.h:84
@ DRC_DISALLOW_MICRO_VIAS
Definition: drc_rule.h:82
@ DRC_DISALLOW_BB_VIAS
Definition: drc_rule.h:83
DRC_CONSTRAINT_T
Definition: drc_rule.h:47
@ ANNULAR_WIDTH_CONSTRAINT
Definition: drc_rule.h:59
@ COURTYARD_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:54
@ VIA_DIAMETER_CONSTRAINT
Definition: drc_rule.h:65
@ ZONE_CONNECTION_CONSTRAINT
Definition: drc_rule.h:60
@ DIFF_PAIR_GAP_CONSTRAINT
Definition: drc_rule.h:68
@ DISALLOW_CONSTRAINT
Definition: drc_rule.h:64
@ TRACK_WIDTH_CONSTRAINT
Definition: drc_rule.h:58
@ SILK_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:55
@ EDGE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:52
@ MIN_RESOLVED_SPOKES_CONSTRAINT
Definition: drc_rule.h:63
@ TEXT_THICKNESS_CONSTRAINT
Definition: drc_rule.h:57
@ LENGTH_CONSTRAINT
Definition: drc_rule.h:66
@ VIA_COUNT_CONSTRAINT
Definition: drc_rule.h:71
@ PHYSICAL_HOLE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:73
@ CLEARANCE_CONSTRAINT
Definition: drc_rule.h:49
@ NULL_CONSTRAINT
Definition: drc_rule.h:48
@ THERMAL_SPOKE_WIDTH_CONSTRAINT
Definition: drc_rule.h:62
@ CONNECTION_WIDTH_CONSTRAINT
Definition: drc_rule.h:75
@ THERMAL_RELIEF_GAP_CONSTRAINT
Definition: drc_rule.h:61
@ MAX_UNCOUPLED_CONSTRAINT
Definition: drc_rule.h:69
@ ASSERTION_CONSTRAINT
Definition: drc_rule.h:74
@ SKEW_CONSTRAINT
Definition: drc_rule.h:67
@ HOLE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:50
@ HOLE_SIZE_CONSTRAINT
Definition: drc_rule.h:53
@ TEXT_HEIGHT_CONSTRAINT
Definition: drc_rule.h:56
@ DIFF_PAIR_INTRA_SKEW_CONSTRAINT
Definition: drc_rule.h:70
@ PHYSICAL_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:72
@ HOLE_TO_HOLE_CONSTRAINT
Definition: drc_rule.h:51
#define _(s)
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
SEVERITY
@ RPT_SEVERITY_UNDEFINED
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:47