KiCad PCB EDA Suite
drc_item.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) 2007 Dick Hollenbeck, dick@softplc.com
5  * Copyright (C) 2015-2020 KiCad Developers, see change_log.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 
26 #include "wx/html/m_templ.h"
27 #include "wx/html/styleparams.h"
28 #include <drc/drc_item.h>
29 #include <board.h>
30 
31 
32 // These, being statically-defined, require specialized I18N handling. We continue to
33 // use the _() macro so that string harvesting by the I18N framework doesn't have to be
34 // specialized, but we don't translate on initialization and instead do it in the getters.
35 
36 #undef _
37 #define _(s) s
38 
39 // NOTE: Avoid changing the settings key for a DRC item after it has been created
40 
41 
42 DRC_ITEM DRC_ITEM::heading_electrical( 0, _( "Electrical" ), "" );
43 DRC_ITEM DRC_ITEM::heading_DFM( 0, _( "Design For Manufacturing" ), "" );
44 DRC_ITEM DRC_ITEM::heading_schematic_parity( 0, _( "Schematic Parity" ), "" );
45 DRC_ITEM DRC_ITEM::heading_signal_integrity( 0, _( "Signal Integrity" ), "" );
46 DRC_ITEM DRC_ITEM::heading_misc( 0, _( "Miscellaneous" ), "" );
47 
49  _( "Missing connection between items" ),
50  wxT( "unconnected_items" ) );
51 
53  _( "Items shorting two nets" ),
54  wxT( "shorting_items" ) );
55 
57  _( "Items not allowed" ),
58  wxT( "items_not_allowed" ) );
59 
61  _( "Clearance violation" ),
62  wxT( "clearance" ) );
63 
65  _( "Tracks crossing" ),
66  wxT( "tracks_crossing" ) );
67 
69  _( "Board edge clearance violation" ),
70  wxT( "copper_edge_clearance" ) );
71 
73  _( "Copper areas intersect" ),
74  wxT( "zones_intersect" ) );
75 
77  _( "Copper zone net has no pads" ),
78  wxT( "zone_has_empty_net" ) );
79 
81  _( "Via is not connected or connected on only one layer" ),
82  wxT( "via_dangling" ) );
83 
85  _( "Track has unconnected end" ),
86  wxT( "track_dangling" ) );
87 
89  _( "Hole clearance violation" ),
90  wxT( "hole_clearance" ) );
91 
93  _( "Drilled holes too close together" ),
94  wxT( "hole_near_hole" ) );
95 
97  _( "Track width" ),
98  wxT( "track_width" ) );
99 
101  _( "Annular width" ),
102  wxT( "annular_width" ) );
103 
105  _( "Drill out of range" ),
106  wxT( "drill_out_of_range" ) );
107 
109  _( "Via diameter" ),
110  wxT( "via_diameter" ) );
111 
113  _( "Padstack is not valid" ),
114  wxT( "padstack" ) );
115 
117  _( "Micro via drill out of range" ),
118  wxT( "microvia_drill_out_of_range" ) );
119 
121  _( "Courtyards overlap" ),
122  wxT( "courtyards_overlap" ) );
123 
125  _( "Footprint has no courtyard defined" ),
126  wxT( "missing_courtyard" ) );
127 
129  _( "Footprint has malformed courtyard" ),
130  wxT( "malformed_courtyard" ) );
131 
133  _( "PTH inside courtyard" ),
134  wxT( "pth_inside_courtyard" ) );
135 
137  _( "NPTH inside courtyard" ),
138  wxT( "npth_inside_courtyard" ) );
139 
141  _( "Item on a disabled layer" ),
142  wxT( "item_on_disabled_layer" ) );
143 
145  _( "Board has malformed outline" ),
146  wxT( "invalid_outline" ) );
147 
149  _( "Duplicate footprints" ),
150  wxT( "duplicate_footprints" ) );
151 
153  _( "Missing footprint" ),
154  wxT( "missing_footprint" ) );
155 
157  _( "Extra footprint" ),
158  wxT( "extra_footprint" ) );
159 
161  _( "Pad net doesn't match schematic" ),
162  wxT( "net_conflict" ) );
163 
165  _( "Unresolved text variable" ),
166  wxT( "unresolved_variable" ) );
167 
169  _( "Silkscreen clipped by solder mask" ),
170  wxT( "silk_over_copper" ) );
171 
173  _( "Silkscreen overlap" ),
174  wxT( "silk_overlap" ) );
175 
177  _( "Trace length out of range" ),
178  wxT( "length_out_of_range" ) );
179 
181  _( "Skew between traces out of range" ),
182  wxT( "skew_out_of_range" ) );
183 
185  _( "Too many vias on a connection" ),
186  wxT( "too_many_vias" ) );
187 
189  _( "Differential pair gap out of range" ),
190  wxT( "diff_pair_gap_out_of_range" ) );
191 
193  _( "Differential uncoupled length too long" ),
194  wxT( "diff_pair_uncoupled_length_too_long" ) );
195 
196 std::vector<std::reference_wrapper<RC_ITEM>> DRC_ITEM::allItemTypes( {
203 
216 
223 
230 
242  } );
243 
244 
245 std::shared_ptr<DRC_ITEM> DRC_ITEM::Create( int aErrorCode )
246 {
247  switch( aErrorCode )
248  {
249  case DRCE_UNCONNECTED_ITEMS: return std::make_shared<DRC_ITEM>( unconnectedItems );
250  case DRCE_SHORTING_ITEMS: return std::make_shared<DRC_ITEM>( shortingItems );
251  case DRCE_ALLOWED_ITEMS: return std::make_shared<DRC_ITEM>( itemsNotAllowed );
252  case DRCE_CLEARANCE: return std::make_shared<DRC_ITEM>( clearance );
253  case DRCE_TRACKS_CROSSING: return std::make_shared<DRC_ITEM>( tracksCrossing );
254  case DRCE_COPPER_EDGE_CLEARANCE: return std::make_shared<DRC_ITEM>( copperEdgeClearance );
255  case DRCE_ZONES_INTERSECT: return std::make_shared<DRC_ITEM>( zonesIntersect );
256  case DRCE_ZONE_HAS_EMPTY_NET: return std::make_shared<DRC_ITEM>( zoneHasEmptyNet );
257  case DRCE_DANGLING_VIA: return std::make_shared<DRC_ITEM>( viaDangling );
258  case DRCE_DANGLING_TRACK: return std::make_shared<DRC_ITEM>( trackDangling );
259  case DRCE_DRILLED_HOLES_TOO_CLOSE: return std::make_shared<DRC_ITEM>( holeNearHole );
260  case DRCE_HOLE_CLEARANCE: return std::make_shared<DRC_ITEM>( holeClearance );
261  case DRCE_TRACK_WIDTH: return std::make_shared<DRC_ITEM>( trackWidth );
262  case DRCE_ANNULAR_WIDTH: return std::make_shared<DRC_ITEM>( annularWidth );
263  case DRCE_DRILL_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( drillTooSmall );
264  case DRCE_VIA_DIAMETER: return std::make_shared<DRC_ITEM>( viaDiameter );
265  case DRCE_PADSTACK: return std::make_shared<DRC_ITEM>( padstack );
266  case DRCE_MICROVIA_DRILL_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( microviaDrillTooSmall );
267  case DRCE_OVERLAPPING_FOOTPRINTS: return std::make_shared<DRC_ITEM>( courtyardsOverlap );
268  case DRCE_MISSING_COURTYARD: return std::make_shared<DRC_ITEM>( missingCourtyard );
269  case DRCE_MALFORMED_COURTYARD: return std::make_shared<DRC_ITEM>( malformedCourtyard );
270  case DRCE_PTH_IN_COURTYARD: return std::make_shared<DRC_ITEM>( pthInsideCourtyard );
271  case DRCE_NPTH_IN_COURTYARD: return std::make_shared<DRC_ITEM>( npthInsideCourtyard );
272  case DRCE_DISABLED_LAYER_ITEM: return std::make_shared<DRC_ITEM>( itemOnDisabledLayer );
273  case DRCE_INVALID_OUTLINE: return std::make_shared<DRC_ITEM>( invalidOutline );
274  case DRCE_MISSING_FOOTPRINT: return std::make_shared<DRC_ITEM>( missingFootprint );
275  case DRCE_DUPLICATE_FOOTPRINT: return std::make_shared<DRC_ITEM>( duplicateFootprints );
276  case DRCE_NET_CONFLICT: return std::make_shared<DRC_ITEM>( netConflict );
277  case DRCE_EXTRA_FOOTPRINT: return std::make_shared<DRC_ITEM>( extraFootprint );
278  case DRCE_UNRESOLVED_VARIABLE: return std::make_shared<DRC_ITEM>( unresolvedVariable );
279  case DRCE_OVERLAPPING_SILK: return std::make_shared<DRC_ITEM>( silkOverlaps );
280  case DRCE_SILK_MASK_CLEARANCE: return std::make_shared<DRC_ITEM>( silkMaskClearance );
281  case DRCE_LENGTH_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( lengthOutOfRange );
282  case DRCE_SKEW_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( skewOutOfRange );
283  case DRCE_TOO_MANY_VIAS: return std::make_shared<DRC_ITEM>( tooManyVias );
284  case DRCE_DIFF_PAIR_GAP_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( diffPairGapOutOfRange );
285  case DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG: return std::make_shared<DRC_ITEM>( diffPairUncoupledLengthTooLong );
286  default:
287  wxFAIL_MSG( "Unknown DRC error code" );
288  return nullptr;
289  }
290 
291  return nullptr;
292 }
293 
294 
295 std::shared_ptr<DRC_ITEM> DRC_ITEM::Create( const wxString& aErrorKey )
296 {
297  for( const RC_ITEM& item : allItemTypes )
298  {
299  if( aErrorKey == item.GetSettingsKey() )
300  return std::make_shared<DRC_ITEM>( static_cast<const DRC_ITEM&>( item ) );
301  }
302 
303  // This can happen if a project has old-format exclusions. Just drop these items.
304  return nullptr;
305 }
306 
307 
static DRC_ITEM extraFootprint
Definition: drc_item.h:155
static DRC_ITEM heading_signal_integrity
Definition: drc_item.h:125
static DRC_ITEM copperEdgeClearance
Definition: drc_item.h:133
static DRC_ITEM itemOnDisabledLayer
Definition: drc_item.h:151
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:245
static DRC_ITEM heading_electrical
Definition: drc_item.h:122
static DRC_ITEM missingCourtyard
Definition: drc_item.h:147
A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema.
Definition: rc_item.h:72
static DRC_ITEM invalidOutline
Definition: drc_item.h:152
static DRC_ITEM holeNearHole
Definition: drc_item.h:138
static DRC_ITEM silkMaskClearance
Definition: drc_item.h:158
static DRC_ITEM clearance
Definition: drc_item.h:131
static DRC_ITEM heading_schematic_parity
Definition: drc_item.h:124
static DRC_ITEM unconnectedItems
Definition: drc_item.h:128
static DRC_ITEM missingFootprint
Definition: drc_item.h:154
static DRC_ITEM itemsNotAllowed
Definition: drc_item.h:130
static DRC_ITEM heading_misc
Definition: drc_item.h:126
static DRC_ITEM microviaDrillTooSmall
Definition: drc_item.h:145
#define _(s)
Definition: drc_item.cpp:37
static DRC_ITEM diffPairUncoupledLengthTooLong
Definition: drc_item.h:164
static DRC_ITEM heading_DFM
Definition: drc_item.h:123
static DRC_ITEM tracksCrossing
Definition: drc_item.h:132
static DRC_ITEM npthInsideCourtyard
Definition: drc_item.h:150
static DRC_ITEM malformedCourtyard
Definition: drc_item.h:148
static DRC_ITEM courtyardsOverlap
Definition: drc_item.h:146
static DRC_ITEM shortingItems
Definition: drc_item.h:129
static DRC_ITEM diffPairGapOutOfRange
Definition: drc_item.h:163
static DRC_ITEM drillTooSmall
Definition: drc_item.h:142
static DRC_ITEM duplicateFootprints
Definition: drc_item.h:153
static DRC_ITEM zoneHasEmptyNet
Definition: drc_item.h:135
static DRC_ITEM zonesIntersect
Definition: drc_item.h:134
static DRC_ITEM viaDangling
Definition: drc_item.h:136
static DRC_ITEM trackWidth
Definition: drc_item.h:140
static DRC_ITEM annularWidth
Definition: drc_item.h:141
static DRC_ITEM silkOverlaps
Definition: drc_item.h:159
static DRC_ITEM holeClearance
Definition: drc_item.h:139
static DRC_ITEM trackDangling
Definition: drc_item.h:137
static DRC_ITEM lengthOutOfRange
Definition: drc_item.h:160
static DRC_ITEM tooManyVias
Definition: drc_item.h:162
static DRC_ITEM unresolvedVariable
Definition: drc_item.h:157
static DRC_ITEM viaDiameter
Definition: drc_item.h:143
static DRC_ITEM skewOutOfRange
Definition: drc_item.h:161
static DRC_ITEM netConflict
Definition: drc_item.h:156
static std::vector< std::reference_wrapper< RC_ITEM > > allItemTypes
A list of all DRC_ITEM types which are valid error codes.
Definition: drc_item.h:120
static DRC_ITEM pthInsideCourtyard
Definition: drc_item.h:149
static DRC_ITEM padstack
Definition: drc_item.h:144