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, [email protected]
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 <drc/drc_rule.h>
30 #include <board.h>
31 
32 
33 // These, being statically-defined, require specialized I18N handling. We continue to
34 // use the _() macro so that string harvesting by the I18N framework doesn't have to be
35 // specialized, but we don't translate on initialization and instead do it in the getters.
36 
37 #undef _
38 #define _(s) s
39 
40 // NOTE: Avoid changing the settings key for a DRC item after it has been created
41 
42 
43 DRC_ITEM DRC_ITEM::heading_electrical( 0, _( "Electrical" ), "" );
44 DRC_ITEM DRC_ITEM::heading_DFM( 0, _( "Design For Manufacturing" ), "" );
45 DRC_ITEM DRC_ITEM::heading_schematic_parity( 0, _( "Schematic Parity" ), "" );
46 DRC_ITEM DRC_ITEM::heading_signal_integrity( 0, _( "Signal Integrity" ), "" );
47 DRC_ITEM DRC_ITEM::heading_misc( 0, _( "Miscellaneous" ), "" );
48 
50  _( "Missing connection between items" ),
51  wxT( "unconnected_items" ) );
52 
54  _( "Items shorting two nets" ),
55  wxT( "shorting_items" ) );
56 
58  _( "Items not allowed" ),
59  wxT( "items_not_allowed" ) );
60 
62  _( "Text (or dimension) on Edge.Cuts layer" ),
63  wxT( "text_on_edge_cuts" ) );
64 
66  _( "Clearance violation" ),
67  wxT( "clearance" ) );
68 
70  _( "Tracks crossing" ),
71  wxT( "tracks_crossing" ) );
72 
74  _( "Board edge clearance violation" ),
75  wxT( "copper_edge_clearance" ) );
76 
78  _( "Copper areas intersect" ),
79  wxT( "zones_intersect" ) );
80 
82  _( "Copper zone net has no pads" ),
83  wxT( "zone_has_empty_net" ) );
84 
86  _( "Via is not connected or connected on only one layer" ),
87  wxT( "via_dangling" ) );
88 
90  _( "Track has unconnected end" ),
91  wxT( "track_dangling" ) );
92 
94  _( "Hole clearance violation" ),
95  wxT( "hole_clearance" ) );
96 
98  _( "Drilled holes too close together" ),
99  wxT( "hole_near_hole" ) );
100 
102  _( "Drilled holes co-located" ),
103  wxT( "holes_co_located" ) );
104 
106  _( "Track width" ),
107  wxT( "track_width" ) );
108 
110  _( "Annular width" ),
111  wxT( "annular_width" ) );
112 
114  _( "Drill out of range" ),
115  wxT( "drill_out_of_range" ) );
116 
118  _( "Via diameter" ),
119  wxT( "via_diameter" ) );
120 
122  _( "Padstack is not valid" ),
123  wxT( "padstack" ) );
124 
126  _( "Micro via drill out of range" ),
127  wxT( "microvia_drill_out_of_range" ) );
128 
130  _( "Courtyards overlap" ),
131  wxT( "courtyards_overlap" ) );
132 
134  _( "Footprint has no courtyard defined" ),
135  wxT( "missing_courtyard" ) );
136 
138  _( "Footprint has malformed courtyard" ),
139  wxT( "malformed_courtyard" ) );
140 
142  _( "PTH inside courtyard" ),
143  wxT( "pth_inside_courtyard" ) );
144 
146  _( "NPTH inside courtyard" ),
147  wxT( "npth_inside_courtyard" ) );
148 
150  _( "Item on a disabled layer" ),
151  wxT( "item_on_disabled_layer" ) );
152 
154  _( "Board has malformed outline" ),
155  wxT( "invalid_outline" ) );
156 
158  _( "Duplicate footprints" ),
159  wxT( "duplicate_footprints" ) );
160 
162  _( "Missing footprint" ),
163  wxT( "missing_footprint" ) );
164 
166  _( "Extra footprint" ),
167  wxT( "extra_footprint" ) );
168 
170  _( "Pad net doesn't match schematic" ),
171  wxT( "net_conflict" ) );
172 
174  _( "Unresolved text variable" ),
175  wxT( "unresolved_variable" ) );
176 
178  _( "Silkscreen clipped by solder mask" ),
179  wxT( "silk_over_copper" ) );
180 
182  _( "Silkscreen overlap" ),
183  wxT( "silk_overlap" ) );
184 
186  _( "Trace length out of range" ),
187  wxT( "length_out_of_range" ) );
188 
190  _( "Skew between traces out of range" ),
191  wxT( "skew_out_of_range" ) );
192 
194  _( "Too many vias on a connection" ),
195  wxT( "too_many_vias" ) );
196 
198  _( "Differential pair gap out of range" ),
199  wxT( "diff_pair_gap_out_of_range" ) );
200 
202  _( "Differential uncoupled length too long" ),
203  wxT( "diff_pair_uncoupled_length_too_long" ) );
204 
206  _( "Footprint type doesn't match footprint pads" ),
207  wxT( "footprint_type_mismatch" ) );
208 
210  _( "Through hole pad has no hole" ),
211  wxT( "through_hole_pad_without_hole" ) );
212 
213 
214 std::vector<std::reference_wrapper<RC_ITEM>> DRC_ITEM::allItemTypes( {
221 
234 
241 
248 
260 
263  } );
264 
265 
266 std::shared_ptr<DRC_ITEM> DRC_ITEM::Create( int aErrorCode )
267 {
268  switch( aErrorCode )
269  {
270  case DRCE_UNCONNECTED_ITEMS: return std::make_shared<DRC_ITEM>( unconnectedItems );
271  case DRCE_SHORTING_ITEMS: return std::make_shared<DRC_ITEM>( shortingItems );
272  case DRCE_ALLOWED_ITEMS: return std::make_shared<DRC_ITEM>( itemsNotAllowed );
273  case DRCE_TEXT_ON_EDGECUTS: return std::make_shared<DRC_ITEM>( textOnEdgeCuts );
274  case DRCE_CLEARANCE: return std::make_shared<DRC_ITEM>( clearance );
275  case DRCE_TRACKS_CROSSING: return std::make_shared<DRC_ITEM>( tracksCrossing );
276  case DRCE_EDGE_CLEARANCE: return std::make_shared<DRC_ITEM>( edgeClearance );
277  case DRCE_ZONES_INTERSECT: return std::make_shared<DRC_ITEM>( zonesIntersect );
278  case DRCE_ZONE_HAS_EMPTY_NET: return std::make_shared<DRC_ITEM>( zoneHasEmptyNet );
279  case DRCE_DANGLING_VIA: return std::make_shared<DRC_ITEM>( viaDangling );
280  case DRCE_DANGLING_TRACK: return std::make_shared<DRC_ITEM>( trackDangling );
281  case DRCE_DRILLED_HOLES_TOO_CLOSE: return std::make_shared<DRC_ITEM>( holeNearHole );
282  case DRCE_DRILLED_HOLES_COLOCATED: return std::make_shared<DRC_ITEM>( holesCoLocated );
283  case DRCE_HOLE_CLEARANCE: return std::make_shared<DRC_ITEM>( holeClearance );
284  case DRCE_TRACK_WIDTH: return std::make_shared<DRC_ITEM>( trackWidth );
285  case DRCE_ANNULAR_WIDTH: return std::make_shared<DRC_ITEM>( annularWidth );
286  case DRCE_DRILL_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( drillTooSmall );
287  case DRCE_VIA_DIAMETER: return std::make_shared<DRC_ITEM>( viaDiameter );
288  case DRCE_PADSTACK: return std::make_shared<DRC_ITEM>( padstack );
289  case DRCE_MICROVIA_DRILL_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( microviaDrillTooSmall );
290  case DRCE_OVERLAPPING_FOOTPRINTS: return std::make_shared<DRC_ITEM>( courtyardsOverlap );
291  case DRCE_MISSING_COURTYARD: return std::make_shared<DRC_ITEM>( missingCourtyard );
292  case DRCE_MALFORMED_COURTYARD: return std::make_shared<DRC_ITEM>( malformedCourtyard );
293  case DRCE_PTH_IN_COURTYARD: return std::make_shared<DRC_ITEM>( pthInsideCourtyard );
294  case DRCE_NPTH_IN_COURTYARD: return std::make_shared<DRC_ITEM>( npthInsideCourtyard );
295  case DRCE_DISABLED_LAYER_ITEM: return std::make_shared<DRC_ITEM>( itemOnDisabledLayer );
296  case DRCE_INVALID_OUTLINE: return std::make_shared<DRC_ITEM>( invalidOutline );
297  case DRCE_MISSING_FOOTPRINT: return std::make_shared<DRC_ITEM>( missingFootprint );
298  case DRCE_DUPLICATE_FOOTPRINT: return std::make_shared<DRC_ITEM>( duplicateFootprints );
299  case DRCE_NET_CONFLICT: return std::make_shared<DRC_ITEM>( netConflict );
300  case DRCE_EXTRA_FOOTPRINT: return std::make_shared<DRC_ITEM>( extraFootprint );
301  case DRCE_UNRESOLVED_VARIABLE: return std::make_shared<DRC_ITEM>( unresolvedVariable );
302  case DRCE_OVERLAPPING_SILK: return std::make_shared<DRC_ITEM>( silkOverlaps );
303  case DRCE_SILK_MASK_CLEARANCE: return std::make_shared<DRC_ITEM>( silkMaskClearance );
304  case DRCE_LENGTH_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( lengthOutOfRange );
305  case DRCE_SKEW_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( skewOutOfRange );
306  case DRCE_TOO_MANY_VIAS: return std::make_shared<DRC_ITEM>( tooManyVias );
307  case DRCE_DIFF_PAIR_GAP_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( diffPairGapOutOfRange );
308  case DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG: return std::make_shared<DRC_ITEM>( diffPairUncoupledLengthTooLong );
309  case DRCE_FOOTPRINT_TYPE_MISMATCH: return std::make_shared<DRC_ITEM>( footprintTypeMismatch );
310  case DRCE_PAD_TH_WITH_NO_HOLE: return std::make_shared<DRC_ITEM>( footprintTHPadhasNoHole );
311  default:
312  wxFAIL_MSG( "Unknown DRC error code" );
313  return nullptr;
314  }
315 }
316 
317 
318 std::shared_ptr<DRC_ITEM> DRC_ITEM::Create( const wxString& aErrorKey )
319 {
320  for( const RC_ITEM& item : allItemTypes )
321  {
322  if( aErrorKey == item.GetSettingsKey() )
323  return std::make_shared<DRC_ITEM>( static_cast<const DRC_ITEM&>( item ) );
324  }
325 
326  // This can happen if a project has old-format exclusions. Just drop these items.
327  return nullptr;
328 }
329 
330 
332 {
333  if( m_violatingRule )
334  return wxString::Format( _( "Rule: %s" ), m_violatingRule->m_Name );
335  else
336  return _("Local override" );
337 }
338 
static DRC_ITEM extraFootprint
Definition: drc_item.h:165
static DRC_ITEM heading_signal_integrity
Definition: drc_item.h:133
static DRC_ITEM itemOnDisabledLayer
Definition: drc_item.h:161
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:266
static DRC_ITEM heading_electrical
Definition: drc_item.h:130
static DRC_ITEM missingCourtyard
Definition: drc_item.h:157
wxString m_Name
Definition: drc_rule.h:96
static DRC_ITEM holesCoLocated
Definition: drc_item.h:148
A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema.
Definition: rc_item.h:74
static DRC_ITEM invalidOutline
Definition: drc_item.h:162
static DRC_ITEM holeNearHole
Definition: drc_item.h:147
static DRC_ITEM silkMaskClearance
Definition: drc_item.h:168
static DRC_ITEM clearance
Definition: drc_item.h:140
static DRC_ITEM heading_schematic_parity
Definition: drc_item.h:132
static DRC_ITEM unconnectedItems
Definition: drc_item.h:136
static DRC_ITEM missingFootprint
Definition: drc_item.h:164
static DRC_ITEM footprintTHPadhasNoHole
Definition: drc_item.h:176
static DRC_ITEM itemsNotAllowed
Definition: drc_item.h:138
static DRC_ITEM heading_misc
Definition: drc_item.h:134
static DRC_ITEM microviaDrillTooSmall
Definition: drc_item.h:155
#define _(s)
Definition: drc_item.cpp:38
wxString GetViolatingRuleDesc() const override
Definition: drc_item.cpp:331
static DRC_ITEM diffPairUncoupledLengthTooLong
Definition: drc_item.h:174
static DRC_ITEM heading_DFM
Definition: drc_item.h:131
static DRC_ITEM tracksCrossing
Definition: drc_item.h:141
static DRC_ITEM npthInsideCourtyard
Definition: drc_item.h:160
static DRC_ITEM malformedCourtyard
Definition: drc_item.h:158
static DRC_ITEM footprintTypeMismatch
Definition: drc_item.h:175
static DRC_ITEM edgeClearance
Definition: drc_item.h:142
static DRC_ITEM courtyardsOverlap
Definition: drc_item.h:156
static DRC_ITEM shortingItems
Definition: drc_item.h:137
static DRC_ITEM diffPairGapOutOfRange
Definition: drc_item.h:173
static DRC_ITEM drillTooSmall
Definition: drc_item.h:152
DRC_RULE * m_violatingRule
Definition: drc_item.h:179
static DRC_ITEM duplicateFootprints
Definition: drc_item.h:163
static DRC_ITEM textOnEdgeCuts
Definition: drc_item.h:139
static DRC_ITEM zoneHasEmptyNet
Definition: drc_item.h:144
static DRC_ITEM zonesIntersect
Definition: drc_item.h:143
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static DRC_ITEM viaDangling
Definition: drc_item.h:145
static DRC_ITEM trackWidth
Definition: drc_item.h:150
static DRC_ITEM annularWidth
Definition: drc_item.h:151
static DRC_ITEM silkOverlaps
Definition: drc_item.h:169
static DRC_ITEM holeClearance
Definition: drc_item.h:149
static DRC_ITEM trackDangling
Definition: drc_item.h:146
static DRC_ITEM lengthOutOfRange
Definition: drc_item.h:170
static DRC_ITEM tooManyVias
Definition: drc_item.h:172
static DRC_ITEM unresolvedVariable
Definition: drc_item.h:167
static DRC_ITEM viaDiameter
Definition: drc_item.h:153
static DRC_ITEM skewOutOfRange
Definition: drc_item.h:171
static DRC_ITEM netConflict
Definition: drc_item.h:166
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:128
static DRC_ITEM pthInsideCourtyard
Definition: drc_item.h:159
static DRC_ITEM padstack
Definition: drc_item.h:154