KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The KiCad Developers, see AUTHORS.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, see <https://www.gnu.org/licenses/>.
19 */
20
21
22#include "wx/html/m_templ.h"
23#include "wx/html/styleparams.h"
24#include "core/kicad_algo.h"
25#include <algorithm>
26#include <drc/drc_item.h>
27#include <drc/drc_rule.h>
28#include <board.h>
29#include <pad.h>
30#include <pcb_marker.h>
31#include <i18n_utility.h>
32
33
34// These, being statically-defined, require specialized I18N handling.
35// We don't translate on initialization and instead do it in the getters.
36
37// NOTE: Avoid changing the settings key for a DRC item after it has been created
38
39
40DRC_ITEM DRC_ITEM::heading_electrical( 0, _HKI( "Electrical" ), "" );
41DRC_ITEM DRC_ITEM::heading_DFM( 0, _HKI( "Design for Manufacturing" ), "" );
42DRC_ITEM DRC_ITEM::heading_schematic_parity( 0, _HKI( "Schematic Parity" ), "" );
43DRC_ITEM DRC_ITEM::heading_signal_integrity( 0, _HKI( "Signal Integrity" ), "" );
44DRC_ITEM DRC_ITEM::heading_readability( 0, _HKI( "Readability" ), "" );
45DRC_ITEM DRC_ITEM::heading_misc( 0, _HKI( "Miscellaneous" ), "" );
48
50 _HKI( "Missing connection between items" ),
51 wxT( "unconnected_items" ) );
52
54 _HKI( "Items shorting two nets" ),
55 wxT( "shorting_items" ) );
56
58 _HKI( "Items not allowed" ),
59 wxT( "items_not_allowed" ) );
60
61DRC_ITEM DRC_ITEM::textOnEdgeCuts( DRCE_TEXT_ON_EDGECUTS, _HKI( "Text or graphic on Edge.Cuts layer" ),
62 wxT( "text_on_edge_cuts" ) );
63
65 _HKI( "Clearance violation" ),
66 wxT( "clearance" ) );
67
69 _HKI( "Creepage violation" ),
70 wxT( "creepage" ) );
71
73 _HKI( "Tracks crossing" ),
74 wxT( "tracks_crossing" ) );
75
77 _HKI( "Board edge clearance violation" ),
78 wxT( "copper_edge_clearance" ) );
79
81 _HKI( "Isolated copper fill" ),
82 wxT( "isolated_copper" ) );
83
85 _HKI( "Thermal relief connection to zone incomplete" ),
86 wxT( "starved_thermal" ) );
87
89 _HKI( "Via is not connected or connected on only one layer" ),
90 wxT( "via_dangling" ) );
91
93 _HKI( "Track has unconnected end" ),
94 wxT( "track_dangling" ) );
95
97 _HKI( "Hole clearance violation" ),
98 wxT( "hole_clearance" ) );
99
101 _HKI( "Drilled hole too close to other hole" ),
102 wxT( "hole_to_hole" ) );
103
105 _HKI( "Drilled holes co-located" ),
106 wxT( "holes_co_located" ) );
107
109 _HKI( "Copper connection too narrow" ),
110 wxT( "connection_width" ) );
111
113 _HKI( "Track width" ),
114 wxT( "track_width" ) );
115
117 _HKI( "Track angle" ),
118 wxT( "track_angle" ) );
119
121 _HKI( "Track segment length" ),
122 wxT( "track_segment_length" ) );
123
125 _HKI( "Annular width" ),
126 wxT( "annular_width" ) );
127
129 _HKI( "Hole size out of range" ),
130 wxT( "drill_out_of_range" ) );
131
133 _HKI( "Via diameter" ),
134 wxT( "via_diameter" ) );
135
137 _HKI( "Padstack is questionable" ),
138 wxT( "padstack" ) );
139
141 _HKI( "Padstack is not valid" ),
142 wxT( "padstack_invalid" ) );
143
145 _HKI( "Micro via hole size out of range" ),
146 wxT( "microvia_drill_out_of_range" ) );
147
149 _HKI( "Microvia stack has malformed span" ),
150 wxT( "malformed_microvia_stack_span" ) );
151
152DRC_ITEM DRC_ITEM::microviaStackNotFilled( DRCE_MICROVIA_STACK_NOT_FILLED, _HKI( "Microvia under microvia not filled" ),
153 wxT( "microvia_stack_not_filled" ) );
154
156 wxT( "microvia_stack_depth" ) );
157
158DRC_ITEM DRC_ITEM::microviaAspectRatio( DRCE_MICROVIA_ASPECT_RATIO, _HKI( "Microvia too deep for its diameter" ),
159 wxT( "microvia_aspect_ratio" ) );
160
161DRC_ITEM DRC_ITEM::microviaCrossesCore( DRCE_MICROVIA_CROSSES_CORE, _HKI( "Microvia crosses core material" ),
162 wxT( "microvia_crosses_core" ) );
163
165 _HKI( "Courtyards overlap" ),
166 wxT( "courtyards_overlap" ) );
167
169 _HKI( "Footprint has no courtyard defined" ),
170 wxT( "missing_courtyard" ) );
171
173 _HKI( "Footprint has malformed courtyard" ),
174 wxT( "malformed_courtyard" ) );
175
177 _HKI( "PTH inside courtyard" ),
178 wxT( "pth_inside_courtyard" ) );
179
181 _HKI( "NPTH inside courtyard" ),
182 wxT( "npth_inside_courtyard" ) );
183
185 _HKI( "Item on a disabled copper layer" ),
186 wxT( "item_on_disabled_layer" ) );
187
189 _HKI( "Board has malformed outline" ),
190 wxT( "invalid_outline" ) );
191
193 _HKI( "Duplicate footprints" ),
194 wxT( "duplicate_footprints" ) );
195
197 _HKI( "Missing footprint" ),
198 wxT( "missing_footprint" ) );
199
201 _HKI( "Extra footprint" ),
202 wxT( "extra_footprint" ) );
203
205 _HKI( "Pad net doesn't match schematic" ),
206 wxT( "net_conflict" ) );
207
209 _HKI( "Footprint attributes don't match symbol" ),
210 wxT( "footprint_symbol_mismatch" ) );
211
213 _HKI( "Footprint doesn't match symbol's footprint filters" ),
214 wxT( "footprint_filters_mismatch" ) );
215
217 _HKI( "Footprint field does not match symbol field" ),
218 wxT( "footprint_symbol_field_mismatch" ) );
219
221 _HKI( "Via-stitching zones overlap for same net" ),
222 wxT( "via_stitch_overlap" ) );
223
225 _HKI( "Footprint not found in libraries" ),
226 wxT( "lib_footprint_issues" ) );
227
229 _HKI( "Footprint doesn't match copy in library" ),
230 wxT( "lib_footprint_mismatch" ) );
231
233 _HKI( "Unresolved text variable" ),
234 wxT( "unresolved_variable" ) );
235
237 _HKI( "Assertion failure" ),
238 wxT( "assertion_failure" ) );
239
241 _HKI( "Warning" ),
242 wxT( "generic_warning" ) );
243
245 _HKI( "Error" ),
246 wxT( "generic_error" ) );
247
249 _HKI( "Copper sliver" ),
250 wxT( "copper_sliver" ) );
251
253 _HKI( "Solder mask aperture bridges items with different nets" ),
254 wxT( "solder_mask_bridge" ) );
255
257 _HKI( "Silkscreen clipped by solder mask" ),
258 wxT( "silk_over_copper" ) );
259
261 _HKI( "Silkscreen clipped by board edge" ),
262 wxT( "silk_edge_clearance" ) );
263
265 _HKI( "Silkscreen clearance" ),
266 wxT( "silk_overlap" ) );
267
269 _HKI( "Text height out of range" ),
270 wxT( "text_height" ) );
271
273 _HKI( "Text thickness out of range" ),
274 wxT( "text_thickness" ) );
275
277 _HKI( "Track length out of range" ),
278 wxT( "length_out_of_range" ) );
279
281 _HKI( "Net chain stub length out of range" ),
282 wxT( "net_chain_stub_length" ) );
283
285 _HKI( "Net chain routed without continuous copper on the required reference layer" ),
286 wxT( "net_chain_return_path" ) );
287
289 _HKI( "Net chain nets do not have consistent tuning profile assignment" ),
290 wxT( "net_chain_tuning_profiles" ) );
291
293 _HKI( "Skew between tracks out of range" ),
294 wxT( "skew_out_of_range" ) );
295
296// Note: this used to only check against a max value, hence the settings key too_many_vias
298 _HKI( "Too many or too few vias on a connection" ),
299 wxT( "too_many_vias" ) );
300
302 _HKI( "Differential pair gap out of range" ),
303 wxT( "diff_pair_gap_out_of_range" ) );
304
306 _HKI( "Differential uncoupled length too long" ),
307 wxT( "diff_pair_uncoupled_length_too_long" ) );
308
310 _HKI( "Footprint is not valid" ),
311 wxT( "footprint" ) );
312
314 _HKI( "Footprint component type doesn't match footprint pads" ),
315 wxT( "footprint_type_mismatch" ) );
316
318 _HKI( "Through hole pad has no hole" ),
319 wxT( "through_hole_pad_without_hole" ) );
320
322 _HKI( "Footprint with pads is scaled (physical part size unchanged)" ),
323 wxT( "footprint_scaled_with_pads" ) );
324
326 _HKI( "Mirrored text on front layer" ),
327 wxT( "mirrored_text_on_front_layer" ) );
328
330 _HKI( "Non-Mirrored text on back layer" ),
331 wxT( "nonmirrored_text_on_back_layer" ) );
332
334 _HKI( "Missing tuning profile" ),
335 wxT( "missing_tuning_profile" ) );
336
338 _HKI( "Tuning profile track geometries" ),
339 wxT( "tuning_profile_track_geometries" ) );
340
342 _HKI( "Track connected to post-machined or backdrilled layer" ),
343 wxT( "track_on_post_machined_layer" ) );
344
346 _HKI( "Track endpoint not centered on via" ),
347 wxT( "track_not_centered_on_via" ) );
348
349std::vector<std::reference_wrapper<RC_ITEM>> DRC_ITEM::allItemTypes( {
358
387
397
407
416
434
435 // DRC_ITEM types with no user-editable severities
436 // NOTE: this MUST be the last grouping in the list!
441} );
442
443
444std::shared_ptr<DRC_ITEM> DRC_ITEM::Create( int aErrorCode )
445{
446 switch( aErrorCode )
447 {
448 case DRCE_UNCONNECTED_ITEMS: return std::make_shared<DRC_ITEM>( unconnectedItems );
449 case DRCE_SHORTING_ITEMS: return std::make_shared<DRC_ITEM>( shortingItems );
450 case DRCE_ALLOWED_ITEMS: return std::make_shared<DRC_ITEM>( itemsNotAllowed );
451 case DRCE_TEXT_ON_EDGECUTS: return std::make_shared<DRC_ITEM>( textOnEdgeCuts );
452 case DRCE_CLEARANCE: return std::make_shared<DRC_ITEM>( clearance );
453 case DRCE_CREEPAGE: return std::make_shared<DRC_ITEM>( creepage );
454 case DRCE_TRACKS_CROSSING: return std::make_shared<DRC_ITEM>( tracksCrossing );
455 case DRCE_EDGE_CLEARANCE: return std::make_shared<DRC_ITEM>( edgeClearance );
456 case DRCE_ISOLATED_COPPER: return std::make_shared<DRC_ITEM>( isolatedCopper );
457 case DRCE_STARVED_THERMAL: return std::make_shared<DRC_ITEM>( starvedThermal );
458 case DRCE_DANGLING_VIA: return std::make_shared<DRC_ITEM>( viaDangling );
459 case DRCE_DANGLING_TRACK: return std::make_shared<DRC_ITEM>( trackDangling );
460 case DRCE_DRILLED_HOLES_TOO_CLOSE: return std::make_shared<DRC_ITEM>( holeNearHole );
461 case DRCE_DRILLED_HOLES_COLOCATED: return std::make_shared<DRC_ITEM>( holesCoLocated );
462 case DRCE_HOLE_CLEARANCE: return std::make_shared<DRC_ITEM>( holeClearance );
463 case DRCE_CONNECTION_WIDTH: return std::make_shared<DRC_ITEM>( connectionWidth );
464 case DRCE_TRACK_WIDTH: return std::make_shared<DRC_ITEM>( trackWidth );
465 case DRCE_TRACK_ANGLE: return std::make_shared<DRC_ITEM>( trackAngle );
466 case DRCE_TRACK_SEGMENT_LENGTH: return std::make_shared<DRC_ITEM>( trackSegmentLength );
467 case DRCE_ANNULAR_WIDTH: return std::make_shared<DRC_ITEM>( annularWidth );
468 case DRCE_DRILL_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( drillTooSmall );
469 case DRCE_VIA_DIAMETER: return std::make_shared<DRC_ITEM>( viaDiameter );
470 case DRCE_PADSTACK: return std::make_shared<DRC_ITEM>( padstack );
471 case DRCE_PADSTACK_INVALID: return std::make_shared<DRC_ITEM>( padstackInvalid );
472 case DRCE_MICROVIA_DRILL_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( microviaDrillTooSmall );
473 case DRCE_MALFORMED_MICROVIA_STACK_SPAN: return std::make_shared<DRC_ITEM>( malformedMicroviaStackSpan );
474 case DRCE_MICROVIA_STACK_NOT_FILLED: return std::make_shared<DRC_ITEM>( microviaStackNotFilled );
475 case DRCE_MICROVIA_STACK_DEPTH: return std::make_shared<DRC_ITEM>( microviaStackDepth );
476 case DRCE_MICROVIA_ASPECT_RATIO: return std::make_shared<DRC_ITEM>( microviaAspectRatio );
477 case DRCE_MICROVIA_CROSSES_CORE: return std::make_shared<DRC_ITEM>( microviaCrossesCore );
478 case DRCE_OVERLAPPING_FOOTPRINTS: return std::make_shared<DRC_ITEM>( courtyardsOverlap );
479 case DRCE_MISSING_COURTYARD: return std::make_shared<DRC_ITEM>( missingCourtyard );
480 case DRCE_MALFORMED_COURTYARD: return std::make_shared<DRC_ITEM>( malformedCourtyard );
481 case DRCE_PTH_IN_COURTYARD: return std::make_shared<DRC_ITEM>( pthInsideCourtyard );
482 case DRCE_NPTH_IN_COURTYARD: return std::make_shared<DRC_ITEM>( npthInsideCourtyard );
483 case DRCE_DISABLED_LAYER_ITEM: return std::make_shared<DRC_ITEM>( itemOnDisabledLayer );
484 case DRCE_INVALID_OUTLINE: return std::make_shared<DRC_ITEM>( invalidOutline );
485 case DRCE_MISSING_FOOTPRINT: return std::make_shared<DRC_ITEM>( missingFootprint );
486 case DRCE_DUPLICATE_FOOTPRINT: return std::make_shared<DRC_ITEM>( duplicateFootprints );
487 case DRCE_NET_CONFLICT: return std::make_shared<DRC_ITEM>( netConflict );
488 case DRCE_EXTRA_FOOTPRINT: return std::make_shared<DRC_ITEM>( extraFootprint );
489 case DRCE_SCHEMATIC_PARITY: return std::make_shared<DRC_ITEM>( schematicParity );
490 case DRCE_SCHEMATIC_FIELDS_PARITY: return std::make_shared<DRC_ITEM>( schematicFieldsParity );
491 case DRCE_FOOTPRINT_FILTERS: return std::make_shared<DRC_ITEM>( footprintFilters );
492 case DRCE_LIB_FOOTPRINT_ISSUES: return std::make_shared<DRC_ITEM>( libFootprintIssues );
493 case DRCE_LIB_FOOTPRINT_MISMATCH: return std::make_shared<DRC_ITEM>( libFootprintMismatch );
494 case DRCE_UNRESOLVED_VARIABLE: return std::make_shared<DRC_ITEM>( unresolvedVariable );
495 case DRCE_ASSERTION_FAILURE: return std::make_shared<DRC_ITEM>( assertionFailure );
496 case DRCE_GENERIC_WARNING: return std::make_shared<DRC_ITEM>( genericWarning );
497 case DRCE_GENERIC_ERROR: return std::make_shared<DRC_ITEM>( genericError );
498 case DRCE_COPPER_SLIVER: return std::make_shared<DRC_ITEM>( copperSliver );
499 case DRCE_SILK_CLEARANCE: return std::make_shared<DRC_ITEM>( silkClearance );
500 case DRCE_SILK_MASK_CLEARANCE: return std::make_shared<DRC_ITEM>( silkMaskClearance );
501 case DRCE_SILK_EDGE_CLEARANCE: return std::make_shared<DRC_ITEM>( silkEdgeClearance );
502 case DRCE_SOLDERMASK_BRIDGE: return std::make_shared<DRC_ITEM>( solderMaskBridge );
503 case DRCE_TEXT_HEIGHT: return std::make_shared<DRC_ITEM>( textHeightOutOfRange );
504 case DRCE_TEXT_THICKNESS: return std::make_shared<DRC_ITEM>( textThicknessOutOfRange );
505 case DRCE_LENGTH_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( lengthOutOfRange );
506 case DRCE_NET_CHAIN_STUB_TOO_LONG: return std::make_shared<DRC_ITEM>( netChainStubTooLong );
507 case DRCE_NET_CHAIN_RETURN_PATH_BREAK: return std::make_shared<DRC_ITEM>( netChainReturnPathBreak );
508 case DRCE_NET_CHAIN_TUNING_PROFILES: return std::make_shared<DRC_ITEM>( netChainTuningProfiles );
509 case DRCE_SKEW_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( skewOutOfRange );
510 case DRCE_VIA_COUNT_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( viaCountOutOfRange );
511 case DRCE_DP_GAP_OUT_OF_RANGE: return std::make_shared<DRC_ITEM>( diffPairGapOutOfRange );
512 case DRCE_DP_UNCOUPLED_LENGTH_TOO_LONG: return std::make_shared<DRC_ITEM>( diffPairUncoupledLengthTooLong );
513 case DRCE_FOOTPRINT: return std::make_shared<DRC_ITEM>( footprint );
514 case DRCE_FOOTPRINT_TYPE_MISMATCH: return std::make_shared<DRC_ITEM>( footprintTypeMismatch );
515 case DRCE_PAD_TH_WITH_NO_HOLE: return std::make_shared<DRC_ITEM>( footprintTHPadhasNoHole );
516 case DRCE_FOOTPRINT_SCALED_WITH_PADS: return std::make_shared<DRC_ITEM>( footprintScaledWithPads );
517 case DRCE_MIRRORED_TEXT_ON_FRONT_LAYER: return std::make_shared<DRC_ITEM>( mirroredTextOnFrontLayer );
518 case DRCE_UNMIRRORED_TEXT_ON_BACK_LAYER: return std::make_shared<DRC_ITEM>( unMirroredTextOnBackLayer );
519 case DRCE_MISSING_TUNING_PROFILE: return std::make_shared<DRC_ITEM>( missingTuningProfile );
520 case DRCE_TRACK_ON_POST_MACHINED_LAYER: return std::make_shared<DRC_ITEM>( trackOnPostMachinedLayer );
521 case DRCE_TRACK_NOT_CENTERED_ON_VIA: return std::make_shared<DRC_ITEM>( trackNotCenteredOnVia );
522 case DRCE_VIA_STITCH_OVERLAP: return std::make_shared<DRC_ITEM>( viaStitchOverlap );
523
524 default:
525 return nullptr;
526 }
527}
528
529
530std::shared_ptr<DRC_ITEM> DRC_ITEM::Create( const wxString& aErrorKey )
531{
532 for( const std::reference_wrapper<RC_ITEM>& item : allItemTypes )
533 {
534 if( aErrorKey == item.get().GetSettingsKey() )
535 return std::make_shared<DRC_ITEM>( static_cast<const DRC_ITEM&>( item.get() ) );
536 }
537
538 // This can happen if a project has old-format exclusions. Just drop these items.
539 return nullptr;
540}
541
542
544{
546 {
547 // we have lots of segments, but it's enough to show the first P and the first N
548 return niluuid;
549 }
550
551 return m_ids.size() > 2 ? m_ids[2] : niluuid;
552}
553
554
556{
558 {
559 // we have lots of segments, but it's enough to show the first P and the first N
560 return niluuid;
561 }
562
563 return m_ids.size() > 3 ? m_ids[3] : niluuid;
564}
565
566
567wxString DRC_ITEM::GetViolatingRuleDesc( bool aTranslate ) const
568{
569 if( m_violatingRule )
570 return wxString::Format( aTranslate ? _( "Rule: %s" ) : wxString( wxT( "Rule: %s" ) ), m_violatingRule->m_Name );
571 else
572 return aTranslate ? _( "Local override" ) : wxString( wxT( "Local override" ) );
573}
574
575
576void DRC_ITEM::GetViolationLayers( BOARD* aBoard, const std::shared_ptr<RC_ITEM>& aItem, PCB_MARKER* aMarker,
577 PCB_LAYER_ID& aPrincipalLayer, LSET& aViolationLayers )
578{
579 auto getActiveLayers = []( BOARD_ITEM* it ) -> LSET
580 {
581 if( it->Type() == PCB_PAD_T )
582 {
583 PAD* pad = static_cast<PAD*>( it );
584 LSET layers;
585
586 for( int layer : it->GetLayerSet() )
587 {
588 if( pad->FlashLayer( layer ) )
589 layers.set( layer );
590 }
591
592 return layers;
593 }
594 else
595 {
596 return it->GetLayerSet();
597 }
598 };
599
600 aPrincipalLayer = UNDEFINED_LAYER;
601 aViolationLayers = LSET();
602
603 BOARD_ITEM* a = aBoard->ResolveItem( aItem->GetMainItemID(), true );
604 BOARD_ITEM* b = aBoard->ResolveItem( aItem->GetAuxItemID(), true );
605 BOARD_ITEM* c = aBoard->ResolveItem( aItem->GetAuxItem2ID(), true );
606 BOARD_ITEM* d = aBoard->ResolveItem( aItem->GetAuxItem3ID(), true );
607
608 if( aItem->GetErrorCode() == DRCE_MALFORMED_COURTYARD )
609 {
610 if( a && ( a->GetFlags() & MALFORMED_B_COURTYARD ) > 0 && ( a->GetFlags() & MALFORMED_F_COURTYARD ) == 0 )
611 {
612 aPrincipalLayer = B_CrtYd;
613 }
614 else
615 {
616 aPrincipalLayer = F_CrtYd;
617 }
618 }
619 else if( aItem->GetErrorCode() == DRCE_INVALID_OUTLINE || aItem->GetErrorCode() == DRCE_EDGE_CLEARANCE )
620 {
621 aPrincipalLayer = Edge_Cuts;
622 }
623 else
624 {
625 // The marker's layer is set by the test provider
626 if( aMarker )
627 {
628 PCB_LAYER_ID markerLayer = aMarker->GetLayer();
629
630 if( markerLayer > UNDEFINED_LAYER )
631 aPrincipalLayer = markerLayer;
632 }
633
634 // Fall back to intersecting the layer sets of the contributing items
635 if( aPrincipalLayer <= UNDEFINED_LAYER )
636 {
637 if( a || b || c || d )
638 aViolationLayers = LSET::AllLayersMask();
639
640 for( BOARD_ITEM* it : { a, b, c, d } )
641 {
642 if( !it )
643 continue;
644
645 LSET layersList = getActiveLayers( it );
646 aViolationLayers &= layersList;
647
648 if( aPrincipalLayer <= UNDEFINED_LAYER && layersList.count() )
649 aPrincipalLayer = layersList.Seq().front();
650 }
651 }
652 }
653
654 if( aViolationLayers.count() )
655 aPrincipalLayer = aViolationLayers.Seq().front();
656 else if( aPrincipalLayer >= 0 )
657 aViolationLayers.set( aPrincipalLayer );
658}
659
660
662{
663 m_severities = aSeverities;
664
665 m_filteredMarkers.clear();
666
667 for( PCB_MARKER* marker : m_board->Markers() )
668 {
669 if( alg::contains( m_markerTypes, marker->GetMarkerType() )
670 && ( marker->GetSeverity() & m_severities ) > 0 )
671 {
672 m_filteredMarkers.push_back( marker );
673 }
674 }
675
676 // Sort markers so that errors appear before warnings
677 std::stable_sort( m_filteredMarkers.begin(), m_filteredMarkers.end(),
678 []( const PCB_MARKER* a, const PCB_MARKER* b )
679 {
680 return a->GetSeverity() > b->GetSeverity();
681 } );
682}
683
684
686{
687 return m_severities;
688}
689
690
691int DRC_ITEMS_PROVIDER::GetCount( int aSeverity ) const
692{
693 if( aSeverity < 0 )
694 return (int) m_filteredMarkers.size();
695
696 int count = 0;
697
698 for( PCB_MARKER* marker : m_board->Markers() )
699 {
700 if( alg::contains( m_markerTypes, marker->GetMarkerType() )
701 && ( marker->GetSeverity() & aSeverity ) > 0 )
702 {
703 count++;
704 }
705 }
706
707 return count;
708}
709
710
711std::shared_ptr<RC_ITEM> DRC_ITEMS_PROVIDER::GetItem( int aIndex ) const
712{
713 PCB_MARKER* marker = m_filteredMarkers[ aIndex ];
714
715 return marker ? marker->GetRCItem() : nullptr;
716}
717
718
719void DRC_ITEMS_PROVIDER::DeleteItem( int aIndex, bool aDeep )
720{
721 PCB_MARKER* marker = m_filteredMarkers[ aIndex ];
722 m_filteredMarkers.erase( m_filteredMarkers.begin() + aIndex );
723
724 if( aDeep )
725 m_board->Delete( marker );
726}
727
BASE_SET & set(size_t pos)
Definition base_set.h:126
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
Definition board.cpp:2116
void SetSeverities(int aSeverities) override
Definition drc_item.cpp:661
std::vector< MARKER_BASE::MARKER_T > m_markerTypes
Definition drc_item.h:324
void DeleteItem(int aIndex, bool aDeep) override
Remove (and optionally deletes) the indexed item from the list.
Definition drc_item.cpp:719
int GetSeverities() const override
Definition drc_item.cpp:685
int GetCount(int aSeverity=-1) const override
Definition drc_item.cpp:691
std::vector< PCB_MARKER * > m_filteredMarkers
Definition drc_item.h:327
std::shared_ptr< RC_ITEM > GetItem(int aIndex) const override
Retrieve a RC_ITEM by index.
Definition drc_item.cpp:711
static DRC_ITEM viaStitchOverlap
Definition drc_item.h:285
static DRC_ITEM lengthOutOfRange
Definition drc_item.h:266
KIID GetAuxItem3ID() const override
Definition drc_item.cpp:555
static DRC_ITEM viaDiameter
Definition drc_item.h:231
static DRC_ITEM silkEdgeClearance
Definition drc_item.h:261
static DRC_ITEM trackWidth
Definition drc_item.h:226
static DRC_ITEM heading_DFM
Definition drc_item.h:201
static DRC_ITEM annularWidth
Definition drc_item.h:229
static DRC_ITEM pthInsideCourtyard
Definition drc_item.h:243
static DRC_ITEM microviaStackDepth
Definition drc_item.h:237
static DRC_ITEM trackSegmentLength
Definition drc_item.h:228
static DRC_ITEM schematicParity
Definition drc_item.h:251
static DRC_ITEM netConflict
Definition drc_item.h:250
static void GetViolationLayers(BOARD *aBoard, const std::shared_ptr< RC_ITEM > &aItem, PCB_MARKER *aMarker, PCB_LAYER_ID &aPrincipalLayer, LSET &aViolationLayers)
Work out which layer to focus on and which layers a violation involves.
Definition drc_item.cpp:576
static DRC_ITEM copperSliver
Definition drc_item.h:259
static DRC_ITEM trackNotCenteredOnVia
Definition drc_item.h:283
static DRC_ITEM holeNearHole
Definition drc_item.h:222
static DRC_ITEM heading_signal_integrity
Definition drc_item.h:203
static DRC_ITEM courtyardsOverlap
Definition drc_item.h:240
static DRC_ITEM textThicknessOutOfRange
Definition drc_item.h:265
static DRC_ITEM trackOnPostMachinedLayer
Definition drc_item.h:282
static DRC_ITEM connectionWidth
Definition drc_item.h:225
static DRC_ITEM footprint
Definition drc_item.h:274
static DRC_ITEM unresolvedVariable
Definition drc_item.h:255
static DRC_ITEM assertionFailure
Definition drc_item.h:256
static DRC_ITEM npthInsideCourtyard
Definition drc_item.h:244
static DRC_ITEM footprintFilters
Definition drc_item.h:252
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition drc_item.cpp:444
static DRC_ITEM textOnEdgeCuts
Definition drc_item.h:212
static DRC_ITEM creepage
Definition drc_item.h:214
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:198
static DRC_ITEM tuningProfileImplicitRules
Definition drc_item.h:281
static DRC_ITEM starvedThermal
Definition drc_item.h:219
static DRC_ITEM footprintScaledWithPads
Definition drc_item.h:277
static DRC_ITEM heading_deprecated
Definition drc_item.h:207
static DRC_ITEM shortingItems
Definition drc_item.h:210
static DRC_ITEM tracksCrossing
Definition drc_item.h:215
static DRC_ITEM missingCourtyard
Definition drc_item.h:241
static DRC_ITEM skewOutOfRange
Definition drc_item.h:270
static DRC_ITEM trackDangling
Definition drc_item.h:221
static DRC_ITEM netChainStubTooLong
Definition drc_item.h:267
static DRC_ITEM viaDangling
Definition drc_item.h:220
static DRC_ITEM genericError
Definition drc_item.h:258
static DRC_ITEM netChainReturnPathBreak
Definition drc_item.h:268
static DRC_ITEM drillTooSmall
Definition drc_item.h:230
static DRC_ITEM holesCoLocated
Definition drc_item.h:223
static DRC_ITEM missingFootprint
Definition drc_item.h:248
static DRC_ITEM textHeightOutOfRange
Definition drc_item.h:264
static DRC_ITEM diffPairGapOutOfRange
Definition drc_item.h:272
static DRC_ITEM heading_electrical
Definition drc_item.h:200
static DRC_ITEM padstack
Definition drc_item.h:232
static DRC_ITEM itemOnDisabledLayer
Definition drc_item.h:245
static DRC_ITEM mirroredTextOnFrontLayer
Definition drc_item.h:278
static DRC_ITEM heading_readability
Definition drc_item.h:204
static DRC_ITEM microviaStackNotFilled
Definition drc_item.h:236
static DRC_ITEM itemsNotAllowed
Definition drc_item.h:211
DRC_ITEM(int aErrorCode=0, const wxString &aTitle="", const wxString &aSettingsKey="")
Definition drc_item.h:189
static DRC_ITEM extraFootprint
Definition drc_item.h:249
static DRC_ITEM diffPairUncoupledLengthTooLong
Definition drc_item.h:273
static DRC_ITEM netChainTuningProfiles
Definition drc_item.h:269
KIID GetAuxItem2ID() const override
Definition drc_item.cpp:543
static DRC_ITEM unconnectedItems
Definition drc_item.h:209
static DRC_ITEM clearance
Definition drc_item.h:213
DRC_RULE * m_violatingRule
Definition drc_item.h:288
static DRC_ITEM missingTuningProfile
Definition drc_item.h:280
static DRC_ITEM libFootprintMismatch
Definition drc_item.h:254
static DRC_ITEM microviaCrossesCore
Definition drc_item.h:239
static DRC_ITEM malformedMicroviaStackSpan
Definition drc_item.h:235
static DRC_ITEM viaCountOutOfRange
Definition drc_item.h:271
static DRC_ITEM edgeClearance
Definition drc_item.h:216
static DRC_ITEM silkMaskClearance
Definition drc_item.h:260
static DRC_ITEM unMirroredTextOnBackLayer
Definition drc_item.h:279
static DRC_ITEM genericWarning
Definition drc_item.h:257
static DRC_ITEM schematicFieldsParity
Definition drc_item.h:284
static DRC_ITEM invalidOutline
Definition drc_item.h:246
static DRC_ITEM isolatedCopper
Definition drc_item.h:218
static DRC_ITEM malformedCourtyard
Definition drc_item.h:242
static DRC_ITEM heading_internal
Definition drc_item.h:206
static DRC_ITEM holeClearance
Definition drc_item.h:224
static DRC_ITEM libFootprintIssues
Definition drc_item.h:253
static DRC_ITEM padstackInvalid
Definition drc_item.h:233
static DRC_ITEM trackAngle
Definition drc_item.h:227
static DRC_ITEM heading_schematic_parity
Definition drc_item.h:202
static DRC_ITEM microviaDrillTooSmall
Definition drc_item.h:234
static DRC_ITEM microviaAspectRatio
Definition drc_item.h:238
wxString GetViolatingRuleDesc(bool aTranslate) const override
Definition drc_item.cpp:567
static DRC_ITEM solderMaskBridge
Definition drc_item.h:262
static DRC_ITEM heading_misc
Definition drc_item.h:205
static DRC_ITEM footprintTypeMismatch
Definition drc_item.h:275
static DRC_ITEM footprintTHPadhasNoHole
Definition drc_item.h:276
static DRC_ITEM silkClearance
Definition drc_item.h:263
static DRC_ITEM duplicateFootprints
Definition drc_item.h:247
EDA_ITEM_FLAGS GetFlags() const
Definition eda_item.h:167
Definition kiid.h:46
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition lset.cpp:309
static const LSET & AllLayersMask()
Definition lset.cpp:637
std::shared_ptr< RC_ITEM > GetRCItem() const
Definition pad.h:61
int m_errorCode
The error code's numeric value.
Definition rc_item.h:204
KIIDS m_ids
Definition rc_item.h:210
@ DRCE_DISABLED_LAYER_ITEM
Definition drc_item.h:74
@ DRCE_FOOTPRINT_SCALED_WITH_PADS
Definition drc_item.h:89
@ DRCE_DP_UNCOUPLED_LENGTH_TOO_LONG
Definition drc_item.h:114
@ DRCE_SKEW_OUT_OF_RANGE
Definition drc_item.h:111
@ DRCE_CREEPAGE
Definition drc_item.h:42
@ DRCE_TUNING_PROFILE_IMPLICIT_RULES
Definition drc_item.h:120
@ DRCE_HOLE_CLEARANCE
Definition drc_item.h:52
@ DRCE_MICROVIA_STACK_DEPTH
Definition drc_item.h:65
@ DRCE_SILK_EDGE_CLEARANCE
Definition drc_item.h:102
@ DRCE_FOOTPRINT_FILTERS
Definition drc_item.h:82
@ DRCE_SILK_MASK_CLEARANCE
Definition drc_item.h:100
@ DRCE_VIA_DIAMETER
Definition drc_item.h:59
@ DRCE_UNCONNECTED_ITEMS
Definition drc_item.h:37
@ DRCE_DP_GAP_OUT_OF_RANGE
Definition drc_item.h:113
@ DRCE_TRACK_WIDTH
Definition drc_item.h:53
@ DRCE_PADSTACK
Definition drc_item.h:60
@ DRCE_MIRRORED_TEXT_ON_FRONT_LAYER
Definition drc_item.h:116
@ DRCE_LIB_FOOTPRINT_ISSUES
Definition drc_item.h:85
@ DRCE_VIA_STITCH_OVERLAP
Definition drc_item.h:128
@ DRCE_MICROVIA_CROSSES_CORE
Definition drc_item.h:67
@ DRCE_OVERLAPPING_FOOTPRINTS
Definition drc_item.h:68
@ DRCE_INVALID_OUTLINE
Definition drc_item.h:75
@ DRCE_TRACK_ON_POST_MACHINED_LAYER
Definition drc_item.h:122
@ DRCE_TEXT_ON_EDGECUTS
Definition drc_item.h:40
@ DRCE_NET_CHAIN_STUB_TOO_LONG
Definition drc_item.h:108
@ DRCE_MALFORMED_MICROVIA_STACK_SPAN
Definition drc_item.h:63
@ DRCE_MICROVIA_ASPECT_RATIO
Definition drc_item.h:66
@ DRCE_DRILL_OUT_OF_RANGE
Definition drc_item.h:58
@ DRCE_EDGE_CLEARANCE
Definition drc_item.h:44
@ DRCE_NET_CHAIN_RETURN_PATH_BREAK
Definition drc_item.h:109
@ DRCE_STARVED_THERMAL
Definition drc_item.h:47
@ DRCE_TRACK_SEGMENT_LENGTH
Definition drc_item.h:55
@ DRCE_SCHEMATIC_FIELDS_PARITY
Definition drc_item.h:126
@ DRCE_MISSING_COURTYARD
Definition drc_item.h:69
@ DRCE_MICROVIA_STACK_NOT_FILLED
Definition drc_item.h:64
@ DRCE_TRACK_ANGLE
Definition drc_item.h:54
@ DRCE_TRACK_NOT_CENTERED_ON_VIA
Definition drc_item.h:124
@ DRCE_CLEARANCE
Definition drc_item.h:41
@ DRCE_ISOLATED_COPPER
Definition drc_item.h:46
@ DRCE_GENERIC_ERROR
Definition drc_item.h:94
@ DRCE_NET_CHAIN_TUNING_PROFILES
Definition drc_item.h:110
@ DRCE_MISSING_TUNING_PROFILE
Definition drc_item.h:119
@ DRCE_DRILLED_HOLES_TOO_CLOSE
Definition drc_item.h:50
@ DRCE_ALLOWED_ITEMS
Definition drc_item.h:39
@ DRCE_COPPER_SLIVER
Definition drc_item.h:96
@ DRCE_PTH_IN_COURTYARD
Definition drc_item.h:72
@ DRCE_MICROVIA_DRILL_OUT_OF_RANGE
Definition drc_item.h:62
@ DRCE_SHORTING_ITEMS
Definition drc_item.h:38
@ DRCE_MALFORMED_COURTYARD
Definition drc_item.h:70
@ DRCE_DANGLING_VIA
Definition drc_item.h:48
@ DRCE_PADSTACK_INVALID
Definition drc_item.h:61
@ DRCE_UNRESOLVED_VARIABLE
Definition drc_item.h:91
@ DRCE_FOOTPRINT_TYPE_MISMATCH
Definition drc_item.h:84
@ DRCE_DUPLICATE_FOOTPRINT
Definition drc_item.h:78
@ DRCE_DANGLING_TRACK
Definition drc_item.h:49
@ DRCE_TEXT_HEIGHT
Definition drc_item.h:104
@ DRCE_ASSERTION_FAILURE
Definition drc_item.h:92
@ DRCE_SOLDERMASK_BRIDGE
Definition drc_item.h:97
@ DRCE_DRILLED_HOLES_COLOCATED
Definition drc_item.h:51
@ DRCE_EXTRA_FOOTPRINT
Definition drc_item.h:79
@ DRCE_SILK_CLEARANCE
Definition drc_item.h:103
@ DRCE_LENGTH_OUT_OF_RANGE
Definition drc_item.h:107
@ DRCE_LIB_FOOTPRINT_MISMATCH
Definition drc_item.h:86
@ DRCE_NET_CONFLICT
Definition drc_item.h:80
@ DRCE_MISSING_FOOTPRINT
Definition drc_item.h:77
@ DRCE_PAD_TH_WITH_NO_HOLE
Definition drc_item.h:87
@ DRCE_FOOTPRINT
Definition drc_item.h:88
@ DRCE_UNMIRRORED_TEXT_ON_BACK_LAYER
Definition drc_item.h:117
@ DRCE_GENERIC_WARNING
Definition drc_item.h:93
@ DRCE_TEXT_THICKNESS
Definition drc_item.h:105
@ DRCE_NPTH_IN_COURTYARD
Definition drc_item.h:73
@ DRCE_CONNECTION_WIDTH
Definition drc_item.h:57
@ DRCE_SCHEMATIC_PARITY
Definition drc_item.h:81
@ DRCE_TRACKS_CROSSING
Definition drc_item.h:43
@ DRCE_VIA_COUNT_OUT_OF_RANGE
Definition drc_item.h:112
@ DRCE_ANNULAR_WIDTH
Definition drc_item.h:56
#define _(s)
#define MALFORMED_F_COURTYARD
#define MALFORMED_B_COURTYARD
Some functions to handle hotkeys in KiCad.
KIID niluuid(0)
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_CrtYd
Definition layer_ids.h:112
@ Edge_Cuts
Definition layer_ids.h:108
@ B_CrtYd
Definition layer_ids.h:111
@ UNDEFINED_LAYER
Definition layer_ids.h:57
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition kicad_algo.h:96
#define _HKI(x)
Definition page_info.cpp:40
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:79