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) 2018-2020 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, 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 #ifndef DRC_ITEM_H 26 #define DRC_ITEM_H 27 28 #include <rc_item.h> 29 30 class PCB_BASE_FRAME; 31 class DRC_RULE; 32 class DRC_TEST_PROVIDER; 33 34 enum PCB_DRC_CODE { 35 DRCE_FIRST = 1, 36 DRCE_UNCONNECTED_ITEMS = DRCE_FIRST, // items are unconnected 37 DRCE_SHORTING_ITEMS, // items short two nets but are not a net-tie 38 DRCE_ALLOWED_ITEMS, // a disallowed item has been used 39 DRCE_TEXT_ON_EDGECUTS, // text or dimension on Edge.Cuts layer 40 DRCE_CLEARANCE, // items are too close together 41 DRCE_TRACKS_CROSSING, // tracks are crossing 42 DRCE_EDGE_CLEARANCE, // a copper item is too close to the board edge 43 DRCE_ZONES_INTERSECT, // copper area outlines intersect 44 DRCE_ZONE_HAS_EMPTY_NET, // copper area has a net but no pads in nets, which is suspicious 45 DRCE_DANGLING_VIA, // via which isn't connected to anything 46 DRCE_DANGLING_TRACK, // track with at least one end not connected to anything 47 DRCE_DRILLED_HOLES_TOO_CLOSE, // overlapping drilled holes break drill bits 48 DRCE_DRILLED_HOLES_COLOCATED, // two holes at the same location 49 DRCE_HOLE_CLEARANCE, // 50 DRCE_TRACK_WIDTH, // Track width is too small or too large 51 DRCE_ANNULAR_WIDTH, // Via size and drill leave annular ring too small 52 DRCE_DRILL_OUT_OF_RANGE, // Too small via or pad drill 53 DRCE_VIA_DIAMETER, // Via diameter checks (min/max) 54 DRCE_PADSTACK, // something is wrong with a pad or via stackup 55 DRCE_MICROVIA_DRILL_OUT_OF_RANGE, // Too small micro via drill 56 DRCE_OVERLAPPING_FOOTPRINTS, // footprint courtyards overlap 57 DRCE_MISSING_COURTYARD, // footprint has no courtyard defined 58 DRCE_MALFORMED_COURTYARD, // footprint has a courtyard but malformed 59 // (not convertible to a closed polygon with holes) 60 DRCE_PTH_IN_COURTYARD, 61 DRCE_NPTH_IN_COURTYARD, 62 DRCE_DISABLED_LAYER_ITEM, // item on a disabled layer 63 DRCE_INVALID_OUTLINE, // invalid board outline 64 65 DRCE_MISSING_FOOTPRINT, // footprint not found for netlist item 66 DRCE_DUPLICATE_FOOTPRINT, // more than one footprints found for netlist item 67 DRCE_EXTRA_FOOTPRINT, // netlist item not found for footprint 68 DRCE_NET_CONFLICT, // pad net doesn't match netlist 69 70 DRCE_FOOTPRINT_TYPE_MISMATCH, // footprint attribute does not match actual pads 71 DRCE_PAD_TH_WITH_NO_HOLE, // footprint has Plated Through-Hole with no hole 72 73 DRCE_UNRESOLVED_VARIABLE, 74 DRCE_SILK_MASK_CLEARANCE, // silkscreen clipped by mask (potentially leaving it 75 // over pads, exposed copper, etc.) 76 DRCE_OVERLAPPING_SILK, // silk to silk clearance error 77 DRCE_LENGTH_OUT_OF_RANGE, 78 DRCE_SKEW_OUT_OF_RANGE, 79 DRCE_TOO_MANY_VIAS, 80 81 DRCE_DIFF_PAIR_GAP_OUT_OF_RANGE, 82 DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG, 83 84 DRCE_LAST = DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG 85 }; 86 87 88 class DRC_ITEM : public RC_ITEM 89 { 90 public: 91 /** 92 * Constructs a DRC_ITEM for the given error code 93 * @see DRCE_T 94 */ 95 static std::shared_ptr<DRC_ITEM> Create( int aErrorCode ); 96 97 /** 98 * Constructs a DRC item from a given error settings key 99 * @param aErrorKey is a settings key for an error code (the untranslated string that is used 100 * to represent a given error code in settings files and for storing ignored DRC items) 101 * @return the created item 102 */ 103 static std::shared_ptr<DRC_ITEM> Create( const wxString& aErrorKey ); 104 GetItemsWithSeverities()105 static std::vector<std::reference_wrapper<RC_ITEM>> GetItemsWithSeverities() 106 { 107 return allItemTypes; 108 } 109 SetViolatingRule(DRC_RULE * aRule)110 void SetViolatingRule ( DRC_RULE *aRule ) { m_violatingRule = aRule; } GetViolatingRule()111 DRC_RULE* GetViolatingRule() const { return m_violatingRule; } 112 113 wxString GetViolatingRuleDesc() const override; 114 SetViolatingTest(DRC_TEST_PROVIDER * aProvider)115 void SetViolatingTest( DRC_TEST_PROVIDER *aProvider ) { m_violatingTest = aProvider; } GetViolatingTest()116 DRC_TEST_PROVIDER* GetViolatingTest() const { return m_violatingTest; } 117 118 private: 119 DRC_ITEM( int aErrorCode = 0, const wxString& aTitle = "", const wxString& aSettingsKey = "" ) 120 { 121 m_errorCode = aErrorCode; 122 m_errorTitle = aTitle; 123 m_settingsKey = aSettingsKey; 124 m_parent = nullptr; 125 } 126 127 /// A list of all DRC_ITEM types which are valid error codes 128 static std::vector<std::reference_wrapper<RC_ITEM>> allItemTypes; 129 130 static DRC_ITEM heading_electrical; 131 static DRC_ITEM heading_DFM; 132 static DRC_ITEM heading_schematic_parity; 133 static DRC_ITEM heading_signal_integrity; 134 static DRC_ITEM heading_misc; 135 136 static DRC_ITEM unconnectedItems; 137 static DRC_ITEM shortingItems; 138 static DRC_ITEM itemsNotAllowed; 139 static DRC_ITEM textOnEdgeCuts; 140 static DRC_ITEM clearance; 141 static DRC_ITEM tracksCrossing; 142 static DRC_ITEM edgeClearance; 143 static DRC_ITEM zonesIntersect; 144 static DRC_ITEM zoneHasEmptyNet; 145 static DRC_ITEM viaDangling; 146 static DRC_ITEM trackDangling; 147 static DRC_ITEM holeNearHole; 148 static DRC_ITEM holesCoLocated; 149 static DRC_ITEM holeClearance; 150 static DRC_ITEM trackWidth; 151 static DRC_ITEM annularWidth; 152 static DRC_ITEM drillTooSmall; 153 static DRC_ITEM viaDiameter; 154 static DRC_ITEM padstack; 155 static DRC_ITEM microviaDrillTooSmall; 156 static DRC_ITEM courtyardsOverlap; 157 static DRC_ITEM missingCourtyard; 158 static DRC_ITEM malformedCourtyard; 159 static DRC_ITEM pthInsideCourtyard; 160 static DRC_ITEM npthInsideCourtyard; 161 static DRC_ITEM itemOnDisabledLayer; 162 static DRC_ITEM invalidOutline; 163 static DRC_ITEM duplicateFootprints; 164 static DRC_ITEM missingFootprint; 165 static DRC_ITEM extraFootprint; 166 static DRC_ITEM netConflict; 167 static DRC_ITEM unresolvedVariable; 168 static DRC_ITEM silkMaskClearance; 169 static DRC_ITEM silkOverlaps; 170 static DRC_ITEM lengthOutOfRange; 171 static DRC_ITEM skewOutOfRange; 172 static DRC_ITEM tooManyVias; 173 static DRC_ITEM diffPairGapOutOfRange; 174 static DRC_ITEM diffPairUncoupledLengthTooLong; 175 static DRC_ITEM footprintTypeMismatch; 176 static DRC_ITEM footprintTHPadhasNoHole; 177 178 private: 179 DRC_RULE* m_violatingRule = nullptr; 180 DRC_TEST_PROVIDER* m_violatingTest = nullptr; 181 }; 182 183 #endif // DRC_ITEM_H 184