KiCad PCB EDA Suite
DRC_TEST_PROVIDER_COPPER_CLEARANCE Class Reference
Inheritance diagram for DRC_TEST_PROVIDER_COPPER_CLEARANCE:
DRC_TEST_PROVIDER_CLEARANCE_BASE DRC_TEST_PROVIDER UNITS_PROVIDER

Public Member Functions

 DRC_TEST_PROVIDER_COPPER_CLEARANCE ()
 
virtual ~DRC_TEST_PROVIDER_COPPER_CLEARANCE ()
 
virtual bool Run () override
 Run this provider against the given PCB with configured options (if any). More...
 
virtual const wxString GetName () const override
 
virtual const wxString GetDescription () const override
 
void SetDRCEngine (DRC_ENGINE *engine)
 
bool RunTests (EDA_UNITS aUnits)
 
EDA_UNITS GetUserUnits () const
 
void SetUserUnits (EDA_UNITS aUnits)
 
const EDA_IU_SCALEGetIuScale () const
 
wxString StringFromValue (double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Converts aValue in internal units into a united string. More...
 
wxString StringFromValue (const EDA_ANGLE &aValue, bool aAddUnitLabel=false)
 
wxString MessageTextFromValue (double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 A lower-precision version of StringFromValue(). More...
 
wxString MessageTextFromValue (const EDA_ANGLE &aValue, bool aAddUnitLabel=true)
 
int ValueFromString (const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
 Converts aTextValue in aUnits to internal units used by the frame. More...
 
EDA_ANGLE AngleValueFromString (const wxString &aTextValue)
 

Static Public Member Functions

static void Init ()
 

Protected Member Functions

int forEachGeometryItem (const std::vector< KICAD_T > &aTypes, LSET aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
 
virtual void reportAux (wxString fmt,...)
 
virtual void reportViolation (std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
 
virtual bool reportProgress (int aCount, int aSize, int aDelta)
 
virtual bool reportPhase (const wxString &aStageName)
 
virtual void reportRuleStatistics ()
 
virtual void accountCheck (const DRC_RULE *ruleToTest)
 
virtual void accountCheck (const DRC_CONSTRAINT &constraintToTest)
 
bool isInvisibleText (const BOARD_ITEM *aItem) const
 
wxString formatMsg (const wxString &aFormatString, const wxString &aSource, int aConstraint, int aActual)
 
EDA_UNITS userUnits () const
 

Protected Attributes

BOARDm_board
 
bool m_boardOutlineValid
 
DRC_ENGINEm_drcEngine
 
std::unordered_map< const DRC_RULE *, int > m_stats
 
bool m_isRuleDriven = true
 

Static Protected Attributes

static std::vector< KICAD_Ts_allBasicItems
 
static std::vector< KICAD_Ts_allBasicItemsButZones
 

Private Member Functions

bool testTrackAgainstItem (PCB_TRACK *track, SHAPE *trackShape, PCB_LAYER_ID layer, BOARD_ITEM *other)
 
void testTrackClearances ()
 
bool testPadAgainstItem (PAD *pad, SHAPE *padShape, PCB_LAYER_ID layer, BOARD_ITEM *other)
 
void testPadClearances ()
 
void testZonesToZones ()
 
void testItemAgainstZone (BOARD_ITEM *aItem, ZONE *aZone, PCB_LAYER_ID aLayer)
 

Private Attributes

int m_drcEpsilon
 
const EDA_IU_SCALEm_iuScale
 
EDA_UNITS m_userUnits
 

Detailed Description

Definition at line 56 of file drc_test_provider_copper_clearance.cpp.

Constructor & Destructor Documentation

◆ DRC_TEST_PROVIDER_COPPER_CLEARANCE()

DRC_TEST_PROVIDER_COPPER_CLEARANCE::DRC_TEST_PROVIDER_COPPER_CLEARANCE ( )
inline

◆ ~DRC_TEST_PROVIDER_COPPER_CLEARANCE()

virtual DRC_TEST_PROVIDER_COPPER_CLEARANCE::~DRC_TEST_PROVIDER_COPPER_CLEARANCE ( )
inlinevirtual

Definition at line 65 of file drc_test_provider_copper_clearance.cpp.

66 {
67 }

Member Function Documentation

◆ accountCheck() [1/2]

void DRC_TEST_PROVIDER::accountCheck ( const DRC_CONSTRAINT constraintToTest)
protectedvirtualinherited

Definition at line 127 of file drc_test_provider.cpp.

128{
129 accountCheck( constraintToTest.GetParentRule() );
130}
DRC_RULE * GetParentRule() const
Definition: drc_rule.h:143
virtual void accountCheck(const DRC_RULE *ruleToTest)

References DRC_TEST_PROVIDER::accountCheck(), and DRC_CONSTRAINT::GetParentRule().

◆ accountCheck() [2/2]

void DRC_TEST_PROVIDER::accountCheck ( const DRC_RULE ruleToTest)
protectedvirtualinherited

Definition at line 116 of file drc_test_provider.cpp.

117{
118 auto it = m_stats.find( ruleToTest );
119
120 if( it == m_stats.end() )
121 m_stats[ ruleToTest ] = 1;
122 else
123 m_stats[ ruleToTest ] += 1;
124}
std::unordered_map< const DRC_RULE *, int > m_stats

References DRC_TEST_PROVIDER::m_stats.

Referenced by DRC_TEST_PROVIDER::accountCheck(), and DRC_TEST_PROVIDER::reportViolation().

◆ AngleValueFromString()

EDA_ANGLE UNITS_PROVIDER::AngleValueFromString ( const wxString &  aTextValue)
inlineinherited

Definition at line 104 of file units_provider.h.

105 {
107 aTextValue );
108
109 return EDA_ANGLE( angle, DEGREES_T );
110 }
const EDA_IU_SCALE & GetIuScale() const
@ DEGREES_T
Definition: eda_angle.h:31
double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function DoubleValueFromString converts aTextValue to a double.
Definition: eda_units.cpp:449
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

References PNS::angle(), DEGREES, DEGREES_T, EDA_UNIT_UTILS::UI::DoubleValueFromString(), and UNITS_PROVIDER::GetIuScale().

Referenced by FP_TEXT_GRID_TABLE::SetValue().

◆ forEachGeometryItem()

int DRC_TEST_PROVIDER::forEachGeometryItem ( const std::vector< KICAD_T > &  aTypes,
LSET  aLayers,
const std::function< bool(BOARD_ITEM *)> &  aFunc 
)
protectedinherited

Definition at line 152 of file drc_test_provider.cpp.

154{
155 BOARD *brd = m_drcEngine->GetBoard();
156 std::bitset<MAX_STRUCT_TYPE_ID> typeMask;
157 int n = 0;
158
159 if( aTypes.size() == 0 )
160 {
161 for( int i = 0; i < MAX_STRUCT_TYPE_ID; i++ )
162 typeMask[ i ] = true;
163 }
164 else
165 {
166 for( KICAD_T aType : aTypes )
167 typeMask[ aType ] = true;
168 }
169
170 for( PCB_TRACK* item : brd->Tracks() )
171 {
172 if( (item->GetLayerSet() & aLayers).any() )
173 {
174 if( typeMask[ PCB_TRACE_T ] && item->Type() == PCB_TRACE_T )
175 {
176 aFunc( item );
177 n++;
178 }
179 else if( typeMask[ PCB_VIA_T ] && item->Type() == PCB_VIA_T )
180 {
181 aFunc( item );
182 n++;
183 }
184 else if( typeMask[ PCB_ARC_T ] && item->Type() == PCB_ARC_T )
185 {
186 aFunc( item );
187 n++;
188 }
189 }
190 }
191
192 for( BOARD_ITEM* item : brd->Drawings() )
193 {
194 if( (item->GetLayerSet() & aLayers).any() )
195 {
196 if( typeMask[ PCB_DIMENSION_T ] && BaseType( item->Type() ) == PCB_DIMENSION_T )
197 {
198 if( !aFunc( item ) )
199 return n;
200
201 n++;
202 }
203 else if( typeMask[ PCB_SHAPE_T ] && item->Type() == PCB_SHAPE_T )
204 {
205 if( !aFunc( item ) )
206 return n;
207
208 n++;
209 }
210 else if( typeMask[ PCB_TEXT_T ] && item->Type() == PCB_TEXT_T )
211 {
212 if( !aFunc( item ) )
213 return n;
214
215 n++;
216 }
217 else if( typeMask[ PCB_TEXTBOX_T ] && item->Type() == PCB_TEXTBOX_T )
218 {
219 if( !aFunc( item ) )
220 return n;
221
222 n++;
223 }
224 else if( typeMask[ PCB_TARGET_T ] && item->Type() == PCB_TARGET_T )
225 {
226 if( !aFunc( item ) )
227 return n;
228
229 n++;
230 }
231 }
232 }
233
234 if( typeMask[ PCB_ZONE_T ] )
235 {
236 for( ZONE* item : brd->Zones() )
237 {
238 if( ( item->GetLayerSet() & aLayers ).any() )
239 {
240 if( !aFunc( item ) )
241 return n;
242
243 n++;
244 }
245 }
246 }
247
248 for( FOOTPRINT* footprint : brd->Footprints() )
249 {
250 if( typeMask[ PCB_FP_TEXT_T ] )
251 {
252 if( ( footprint->Reference().GetLayerSet() & aLayers ).any() )
253 {
254 if( !aFunc( &footprint->Reference() ) )
255 return n;
256
257 n++;
258 }
259
260 if( ( footprint->Value().GetLayerSet() & aLayers ).any() )
261 {
262 if( !aFunc( &footprint->Value() ) )
263 return n;
264
265 n++;
266 }
267 }
268
269 if( typeMask[ PCB_PAD_T ] )
270 {
271 for( PAD* pad : footprint->Pads() )
272 {
273 // Careful: if a pad has a hole then it pierces all layers
274 if( pad->HasHole() || ( pad->GetLayerSet() & aLayers ).any() )
275 {
276 if( !aFunc( pad ) )
277 return n;
278
279 n++;
280 }
281 }
282 }
283
284 for( BOARD_ITEM* dwg : footprint->GraphicalItems() )
285 {
286 if( (dwg->GetLayerSet() & aLayers).any() )
287 {
288 if( typeMask[ PCB_DIMENSION_T ] && BaseType( dwg->Type() ) == PCB_DIMENSION_T )
289 {
290 if( !aFunc( dwg ) )
291 return n;
292
293 n++;
294 }
295 else if( typeMask[ PCB_FP_TEXT_T ] && dwg->Type() == PCB_FP_TEXT_T )
296 {
297 if( !aFunc( dwg ) )
298 return n;
299
300 n++;
301 }
302 else if( typeMask[ PCB_FP_TEXTBOX_T ] && dwg->Type() == PCB_FP_TEXTBOX_T )
303 {
304 if( !aFunc( dwg ) )
305 return n;
306
307 n++;
308 }
309 else if( typeMask[ PCB_FP_SHAPE_T ] && dwg->Type() == PCB_FP_SHAPE_T )
310 {
311 if( !aFunc( dwg ) )
312 return n;
313
314 n++;
315 }
316 }
317 }
318
319 if( typeMask[ PCB_FP_ZONE_T ] )
320 {
321 for( ZONE* zone : footprint->Zones() )
322 {
323 if( (zone->GetLayerSet() & aLayers).any() )
324 {
325 if( !aFunc( zone ) )
326 return n;
327
328 n++;
329 }
330 }
331 }
332
333 if( typeMask[ PCB_FOOTPRINT_T ] )
334 {
335 if( !aFunc( footprint ) )
336 return n;
337
338 n++;
339 }
340 }
341
342 return n;
343}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
ZONES & Zones()
Definition: board.h:313
FOOTPRINTS & Footprints()
Definition: board.h:307
TRACKS & Tracks()
Definition: board.h:304
DRAWINGS & Drawings()
Definition: board.h:310
BOARD * GetBoard() const
Definition: drc_engine.h:89
DRC_ENGINE * m_drcEngine
Definition: pad.h:59
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
Definition: typeinfo.h:254
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ MAX_STRUCT_TYPE_ID
Definition: typeinfo.h:242
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:111
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
Definition: typeinfo.h:100
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
Definition: typeinfo.h:105
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101

References BaseType(), BOARD::Drawings(), BOARD::Footprints(), DRC_ENGINE::GetBoard(), DRC_TEST_PROVIDER::m_drcEngine, MAX_STRUCT_TYPE_ID, pad, PCB_ARC_T, PCB_DIMENSION_T, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_FP_ZONE_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, BOARD::Tracks(), and BOARD::Zones().

Referenced by DRC_TEST_PROVIDER_SOLDER_MASK::buildRTrees(), DRC_CACHE_GENERATOR::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), DRC_TEST_PROVIDER_SLIVER_CHECKER::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal(), DRC_TEST_PROVIDER_MISC::testAssertions(), DRC_TEST_PROVIDER_MISC::testDisabledLayers(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskBridges(), DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance(), and DRC_TEST_PROVIDER_MISC::testTextVars().

◆ formatMsg()

wxString DRC_TEST_PROVIDER::formatMsg ( const wxString &  aFormatString,
const wxString &  aSource,
int  aConstraint,
int  aActual 
)
protectedinherited

Definition at line 365 of file drc_test_provider.cpp.

367{
368 wxString constraint_str = MessageTextFromValue( aConstraint );
369 wxString actual_str = MessageTextFromValue( aActual );
370
371 if( constraint_str == actual_str )
372 {
373 // Use more precise formatting if the message-text strings were equal.
374 constraint_str = StringFromValue( aConstraint );
375 actual_str = StringFromValue( aActual );
376 }
377
378 return wxString::Format( aFormatString, aSource, constraint_str, actual_str );
379}
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Converts aValue in internal units into a united string.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
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

References Format(), UNITS_PROVIDER::MessageTextFromValue(), and UNITS_PROVIDER::StringFromValue().

Referenced by DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengths(), DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole(), DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), DRC_TEST_PROVIDER_TRACK_WIDTH::Run(), DRC_TEST_PROVIDER_VIA_DIAMETER::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem(), testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), testPadAgainstItem(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testShapeLineChain(), testTrackAgainstItem(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer(), and testZonesToZones().

◆ GetDescription()

virtual const wxString DRC_TEST_PROVIDER_COPPER_CLEARANCE::GetDescription ( ) const
inlineoverridevirtual

Reimplemented from DRC_TEST_PROVIDER.

Definition at line 76 of file drc_test_provider_copper_clearance.cpp.

77 {
78 return wxT( "Tests copper item clearance" );
79 }

◆ GetIuScale()

◆ GetName()

virtual const wxString DRC_TEST_PROVIDER_COPPER_CLEARANCE::GetName ( void  ) const
inlineoverridevirtual

Reimplemented from DRC_TEST_PROVIDER.

Definition at line 71 of file drc_test_provider_copper_clearance.cpp.

72 {
73 return wxT( "clearance" );
74 };

◆ GetUserUnits()

EDA_UNITS UNITS_PROVIDER::GetUserUnits ( ) const
inlineinherited

Definition at line 37 of file units_provider.h.

37{ return m_userUnits; }
EDA_UNITS m_userUnits

References UNITS_PROVIDER::m_userUnits.

Referenced by DIALOG_CONSTRAINTS_REPORTER::AddPage(), DIALOG_SHIM::DIALOG_SHIM(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), PL_EDITOR_FRAME::DisplayGridMsg(), EDA_DRAW_FRAME::DisplayUnitsMsg(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawShape(), DRAWING_TOOL::DrawSpecificationStackup(), EVT_GRID_CMD_CELL_CHANGED(), FP_TEXT_GRID_TABLE::FP_TEXT_GRID_TABLE(), PCB_EDIT_FRAME::GenFootprintsReport(), GERBER_DRAW_ITEM::GetMsgPanelInfo(), EDA_DRAW_FRAME::GetUnitPair(), WX_GRID::GetUnitValue(), GetUserUnits(), UNIT_BINDER::init(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), UNITS_PROVIDER::MessageTextFromValue(), PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness(), WX_GRID::onCellEditorHidden(), PANEL_SETUP_BOARD_STACKUP::onExportToClipboard(), PANEL_SETUP_NETCLASSES::onUnitsChanged(), UNIT_BINDER::onUnitsChanged(), DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged(), DIALOG_NET_INSPECTOR::onUnitsChanged(), PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL(), PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES(), PIN_TABLE_DATA_MODEL::PIN_TABLE_DATA_MODEL(), PCB_CONTROL::placeBoardItems(), POSITION_RELATIVE_TOOL::PositionRelative(), DRC_TOOL::RunTests(), SCH_EDIT_FRAME::SaveSettings(), EDA_DRAW_FRAME::SaveSettings(), WX_GRID::SetUnitsProvider(), PIN_TABLE_DATA_MODEL::SetValue(), FP_TEXT_GRID_TABLE::SetValue(), GERBVIEW_INSPECTION_TOOL::ShowDCodes(), UNITS_PROVIDER::StringFromValue(), COMMON_TOOLS::ToggleUnits(), EDA_DRAW_FRAME::ToggleUserUnits(), PCB_BASE_EDIT_FRAME::unitsChangeRefresh(), EDITOR_CONDITIONS::unitsFunc(), PROPERTIES_PANEL::update(), GERBVIEW_FRAME::updateDCodeSelectBox(), DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog(), PNS_TUNE_STATUS_POPUP::UpdateStatus(), PL_EDITOR_FRAME::UpdateStatusBar(), PCB_EDIT_FRAME::UpdateViaSizeSelectBox(), DRC_TOOL::userUnits(), and UNITS_PROVIDER::ValueFromString().

◆ Init()

void DRC_TEST_PROVIDER::Init ( )
staticinherited

Definition at line 53 of file drc_test_provider.cpp.

54{
55 if( s_allBasicItems.size() == 0 )
56 {
57 for( int i = 0; i < MAX_STRUCT_TYPE_ID; i++ )
58 {
59 if( i != PCB_FOOTPRINT_T && i != PCB_GROUP_T )
60 {
61 s_allBasicItems.push_back( (KICAD_T) i );
62
63 if( i != PCB_ZONE_T && i != PCB_FP_ZONE_T )
64 s_allBasicItemsButZones.push_back( (KICAD_T) i );
65 }
66 }
67 }
68}
static std::vector< KICAD_T > s_allBasicItemsButZones
static std::vector< KICAD_T > s_allBasicItems
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115

References MAX_STRUCT_TYPE_ID, PCB_FOOTPRINT_T, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_ZONE_T, DRC_TEST_PROVIDER::s_allBasicItems, and DRC_TEST_PROVIDER::s_allBasicItemsButZones.

Referenced by DRC_ENGINE::RunTests().

◆ isInvisibleText()

bool DRC_TEST_PROVIDER::isInvisibleText ( const BOARD_ITEM aItem) const
protectedinherited

Definition at line 346 of file drc_test_provider.cpp.

347{
348
349 if( const FP_TEXT* text = dyn_cast<const FP_TEXT*>( aItem ) )
350 {
351 if( !text->IsVisible() )
352 return true;
353 }
354
355 if( const PCB_TEXT* text = dyn_cast<const PCB_TEXT*>( aItem ) )
356 {
357 if( !text->IsVisible() )
358 return true;
359 }
360
361 return false;
362}

References text.

Referenced by DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), and DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance().

◆ MessageTextFromValue() [1/2]

wxString UNITS_PROVIDER::MessageTextFromValue ( const EDA_ANGLE aValue,
bool  aAddUnitLabel = true 
)
inlineinherited

Definition at line 82 of file units_provider.h.

83 {
85 aValue.AsDegrees(), aAddUnitLabel,
87 }
constexpr EDA_IU_SCALE unityScale
Definition: base_units.h:112
double AsDegrees() const
Definition: eda_angle.h:149
wxString MessageTextFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A helper to convert the double length aValue to a string in inches, millimeters, or unscaled units.
Definition: eda_units.cpp:319

References EDA_ANGLE::AsDegrees(), DEGREES, DISTANCE, EDA_UNIT_UTILS::UI::MessageTextFromValue(), and unityScale.

◆ MessageTextFromValue() [2/2]

wxString UNITS_PROVIDER::MessageTextFromValue ( double  aValue,
bool  aAddUnitLabel = true,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)
inlineinherited

A lower-precision version of StringFromValue().

Should ONLY be used for status text and messages. Not suitable for dialogs, files, etc. where the loss of precision matters.

Definition at line 75 of file units_provider.h.

77 {
79 aAddUnitLabel, aType );
80 }
EDA_UNITS GetUserUnits() const

References UNITS_PROVIDER::GetIuScale(), UNITS_PROVIDER::GetUserUnits(), and EDA_UNIT_UTILS::UI::MessageTextFromValue().

Referenced by CheckLibSymbol(), DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkews(), DIALOG_BOARD_REANNOTATE::CoordTowxString(), EDA_DRAW_FRAME::DisplayGridMsg(), GERBVIEW_FRAME::DisplayGridMsg(), PCB_BASE_FRAME::DisplayGridMsg(), GERBER_FILE_IMAGE::DisplayImageInfo(), DRAWING_TOOL::DrawBoardCharacteristics(), DRC_ENGINE::EvalRules(), DIALOG_NET_INSPECTOR::formatLength(), DRC_TEST_PROVIDER::formatMsg(), LIB_FIELD::GetMsgPanelInfo(), LIB_PIN::GetMsgPanelInfo(), LIB_TEXT::GetMsgPanelInfo(), LIB_TEXTBOX::GetMsgPanelInfo(), SCH_BITMAP::GetMsgPanelInfo(), SCH_FIELD::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_PIN::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_TEXTBOX::GetMsgPanelInfo(), DS_DRAW_ITEM_BASE::GetMsgPanelInfo(), FP_TEXT::GetMsgPanelInfo(), FP_TEXTBOX::GetMsgPanelInfo(), NETINFO_ITEM::GetMsgPanelInfo(), PAD::GetMsgPanelInfo(), PCB_BITMAP::GetMsgPanelInfo(), PCB_DIMENSION_BASE::GetMsgPanelInfo(), PCB_DIM_ALIGNED::GetMsgPanelInfo(), PCB_DIM_LEADER::GetMsgPanelInfo(), PCB_TARGET::GetMsgPanelInfo(), PCB_TEXT::GetMsgPanelInfo(), PCB_TEXTBOX::GetMsgPanelInfo(), PCB_TRACK::GetMsgPanelInfo(), PCB_VIA::GetMsgPanelInfo(), ZONE::GetMsgPanelInfo(), STROKE_PARAMS::GetMsgPanelInfo(), FOOTPRINT_SEARCH_HANDLER::GetResultCell(), ZONE_SEARCH_HANDLER::GetResultCell(), TEXT_SEARCH_HANDLER::GetResultCell(), LIB_SHAPE::GetSelectMenuText(), SCH_LINE::GetSelectMenuText(), SCH_SHAPE::GetSelectMenuText(), DS_DRAW_ITEM_LINE::GetSelectMenuText(), DS_DRAW_ITEM_RECT::GetSelectMenuText(), PCB_TRACK::GetSelectMenuText(), DIALOG_BOARD_REANNOTATE::MakeSampleText(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal(), DIALOG_BOARD_STATISTICS::saveReportClicked(), EDA_SHAPE::ShapeGetMsgPanelInfo(), showCoord(), TRACK_WIDTH_MENU::update(), DIFF_PAIR_MENU::update(), VIA_SIZE_MENU::update(), BOARD_NETLIST_UPDATER::updateCopperZoneNets(), DIALOG_BOARD_STATISTICS::updateDrillGrid(), PCB_CONTROL::UpdateMessagePanel(), PL_EDITOR_FRAME::UpdateMsgPanelInfo(), SCH_BASE_FRAME::UpdateStatusBar(), GERBVIEW_FRAME::UpdateStatusBar(), PCB_BASE_FRAME::UpdateStatusBar(), and DIALOG_BOARD_STATISTICS::updateWidets().

◆ reportAux()

◆ reportPhase()

bool DRC_TEST_PROVIDER::reportPhase ( const wxString &  aStageName)
protectedvirtualinherited

◆ reportProgress()

bool DRC_TEST_PROVIDER::reportProgress ( int  aCount,
int  aSize,
int  aDelta 
)
protectedvirtualinherited

◆ reportRuleStatistics()

void DRC_TEST_PROVIDER::reportRuleStatistics ( )
protectedvirtualinherited

◆ reportViolation()

void DRC_TEST_PROVIDER::reportViolation ( std::shared_ptr< DRC_ITEM > &  item,
const VECTOR2I aMarkerPos,
int  aMarkerLayer 
)
protectedvirtualinherited

Definition at line 75 of file drc_test_provider.cpp.

77{
78 if( item->GetViolatingRule() )
79 accountCheck( item->GetViolatingRule() );
80
81 item->SetViolatingTest( this );
82 m_drcEngine->ReportViolation( item, aMarkerPos, aMarkerLayer );
83}
void ReportViolation(const std::shared_ptr< DRC_ITEM > &aItem, const VECTOR2I &aPos, int aMarkerLayer)

References DRC_TEST_PROVIDER::accountCheck(), DRC_TEST_PROVIDER::m_drcEngine, and DRC_ENGINE::ReportViolation().

Referenced by DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengths(), DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole(), DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkews(), DRC_TEST_PROVIDER_MATCHED_LENGTH::checkViaCounts(), DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTIVITY::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_FOOTPRINT_CHECKS::Run(), DRC_TEST_PROVIDER_LIBRARY_PARITY::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), DRC_TEST_PROVIDER_SLIVER_CHECKER::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), DRC_TEST_PROVIDER_TRACK_WIDTH::Run(), DRC_TEST_PROVIDER_VIA_DIAMETER::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), DRC_TEST_PROVIDER_MISC::testAssertions(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_MISC::testDisabledLayers(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testFootprintCourtyardDefinitions(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem(), DRC_TEST_PROVIDER_SOLDER_MASK::testItemAgainstItems(), testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskItemAgainstZones(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist(), DRC_TEST_PROVIDER_MISC::testOutline(), testPadAgainstItem(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testShapeLineChain(), DRC_TEST_PROVIDER_MISC::testTextVars(), testTrackAgainstItem(), DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer(), and testZonesToZones().

◆ Run()

bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run ( )
overridevirtual

Run this provider against the given PCB with configured options (if any).

Implements DRC_TEST_PROVIDER.

Definition at line 100 of file drc_test_provider_copper_clearance.cpp.

101{
103
104 if( m_board->m_DRCMaxClearance <= 0 )
105 {
106 reportAux( wxT( "No Clearance constraints found. Tests not run." ) );
107 return true; // continue with other tests
108 }
109
111
113 {
114 if( !reportPhase( _( "Checking track & via clearances..." ) ) )
115 return false; // DRC cancelled
116
118 }
120 {
121 if( !reportPhase( _( "Checking hole clearances..." ) ) )
122 return false; // DRC cancelled
123
125 }
126
128 {
129 if( !reportPhase( _( "Checking pad clearances..." ) ) )
130 return false; // DRC cancelled
131
133 }
136 {
137 if( !reportPhase( _( "Checking pads..." ) ) )
138 return false; // DRC cancelled
139
141 }
142
144 {
145 if( !reportPhase( _( "Checking copper zone clearances..." ) ) )
146 return false; // DRC cancelled
147
149 }
151 {
152 if( !reportPhase( _( "Checking zones..." ) ) )
153 return false; // DRC cancelled
154
156 }
157
159
160 return !m_drcEngine->IsCancelled();
161}
int m_DRCMaxClearance
Definition: board.h:1150
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:628
bool IsErrorLimitExceeded(int error_code)
bool IsCancelled() const
virtual bool reportPhase(const wxString &aStageName)
virtual void reportRuleStatistics()
@ DRCE_HOLE_CLEARANCE
Definition: drc_item.h:53
@ DRCE_ZONES_INTERSECT
Definition: drc_item.h:46
@ DRCE_CLEARANCE
Definition: drc_item.h:43
@ DRCE_SHORTING_ITEMS
Definition: drc_item.h:40
#define _(s)

References _, DRCE_CLEARANCE, DRCE_HOLE_CLEARANCE, DRCE_SHORTING_ITEMS, DRCE_ZONES_INTERSECT, DRC_ENGINE::GetBoard(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetDRCEpsilon(), DRC_ENGINE::IsCancelled(), DRC_ENGINE::IsErrorLimitExceeded(), DRC_TEST_PROVIDER_CLEARANCE_BASE::m_board, DRC_TEST_PROVIDER::m_drcEngine, m_drcEpsilon, BOARD::m_DRCMaxClearance, DRC_TEST_PROVIDER::reportAux(), DRC_TEST_PROVIDER::reportPhase(), DRC_TEST_PROVIDER::reportRuleStatistics(), testPadClearances(), testTrackClearances(), and testZonesToZones().

◆ RunTests()

bool DRC_TEST_PROVIDER::RunTests ( EDA_UNITS  aUnits)
inlineinherited

Definition at line 88 of file drc_test_provider.h.

89 {
90 SetUserUnits( aUnits );
91 return Run();
92 }
virtual bool Run()=0
Run this provider against the given PCB with configured options (if any).
void SetUserUnits(EDA_UNITS aUnits)

References DRC_TEST_PROVIDER::Run(), and UNITS_PROVIDER::SetUserUnits().

◆ SetDRCEngine()

void DRC_TEST_PROVIDER::SetDRCEngine ( DRC_ENGINE engine)
inlineinherited

◆ SetUserUnits()

◆ StringFromValue() [1/2]

wxString UNITS_PROVIDER::StringFromValue ( const EDA_ANGLE aValue,
bool  aAddUnitLabel = false 
)
inlineinherited

Definition at line 62 of file units_provider.h.

63 {
65 aValue.AsDegrees(), aAddUnitLabel,
67 }
wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Returns the string from aValue according to aUnits (inch, mm ...) for display.
Definition: eda_units.cpp:229

References EDA_ANGLE::AsDegrees(), DEGREES, DISTANCE, EDA_UNIT_UTILS::UI::StringFromValue(), and unityScale.

◆ StringFromValue() [2/2]

wxString UNITS_PROVIDER::StringFromValue ( double  aValue,
bool  aAddUnitLabel = false,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)
inlineinherited

Converts aValue in internal units into a united string.

For readability, trailing 0s are removed if the mantissa has 3 or more digits. This function should be used to display values in dialogs because a value entered in mm (for instance 2.0 mm) could need up to 8 digits mantissa if displayed in inch to avoid truncation or rounding made just by the printf function.

Parameters
aValue= value in internal units
aAddUnitLabel= true to add symbol unit to the string value
Returns
A wxString object containing value and optionally the symbol unit (like 2.000 mm)

Definition at line 55 of file units_provider.h.

57 {
59 aAddUnitLabel, aType );
60 }

References UNITS_PROVIDER::GetIuScale(), UNITS_PROVIDER::GetUserUnits(), and EDA_UNIT_UTILS::UI::StringFromValue().

Referenced by DIALOG_PLOT::applyPlotSettings(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildNetclassesGrid(), PANEL_SETUP_BOARD_STACKUP::computeBoardThickness(), MICROWAVE_TOOL::createFootprint(), MICROWAVE_TOOL::createMicrowaveInductor(), PANEL_SETUP_BOARD_STACKUP::createRowData(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), DRAWING_TOOL::DrawSpecificationStackup(), DRC_TEST_PROVIDER::formatMsg(), PIN_TABLE_DATA_MODEL::GetValue(), FP_TEXT_GRID_TABLE::GetValue(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectDRCError(), PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness(), WX_GRID::onCellEditorHidden(), DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged(), reportMax(), reportMin(), reportOpt(), PANEL_SETUP_BOARD_STACKUP::setDefaultLayerWidths(), WX_GRID::SetUnitValue(), PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), PANEL_SETUP_CONSTRAINTS::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES::Validate(), and DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::Validate().

◆ testItemAgainstZone()

void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone ( BOARD_ITEM aItem,
ZONE aZone,
PCB_LAYER_ID  aLayer 
)
private

Definition at line 298 of file drc_test_provider_copper_clearance.cpp.

300{
301 if( !aZone->GetLayerSet().test( aLayer ) )
302 return;
303
304 if( aZone->GetNetCode() && aItem->IsConnected() )
305 {
306 if( aZone->GetNetCode() == static_cast<BOARD_CONNECTED_ITEM*>( aItem )->GetNetCode() )
307 return;
308 }
309
310 BOX2I itemBBox = aItem->GetBoundingBox();
311 BOX2I worstCaseBBox = itemBBox;
312
313 worstCaseBBox.Inflate( m_board->m_DRCMaxClearance );
314
315 if( !worstCaseBBox.Intersects( aZone->GetBoundingBox() ) )
316 return;
317
318 bool testClearance = !m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE );
320
321 if( !testClearance && !testHoles )
322 return;
323
324 DRC_RTREE* zoneTree = m_board->m_CopperZoneRTreeCache[ aZone ].get();
325
326 if( !zoneTree )
327 return;
328
329 DRC_CONSTRAINT constraint;
330 int clearance = -1;
331 int actual;
332 VECTOR2I pos;
333
334 if( aItem->Type() == PCB_PAD_T )
335 {
336 PAD* pad = static_cast<PAD*>( aItem );
337 bool flashedPad = pad->FlashLayer( aLayer );
338 bool platedHole = pad->HasHole() && pad->GetAttribute() == PAD_ATTRIB::PTH;
339
340 if( !flashedPad && !platedHole )
341 testClearance = false;
342 }
343
344 if( testClearance )
345 {
346 constraint = m_drcEngine->EvalRules( CLEARANCE_CONSTRAINT, aItem, aZone, aLayer );
347 clearance = constraint.GetValue().Min();
348 }
349
350 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && clearance > 0 )
351 {
352 std::shared_ptr<SHAPE> itemShape = aItem->GetEffectiveShape( aLayer, FLASHING::DEFAULT );
353
354 if( zoneTree->QueryColliding( itemBBox, itemShape.get(), aLayer,
355 std::max( 0, clearance - m_drcEpsilon ), &actual, &pos ) )
356 {
357 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
358 wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
359 constraint.GetName(),
360 clearance,
361 actual );
362
363 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
364 drce->SetItems( aItem, aZone );
365 drce->SetViolatingRule( constraint.GetParentRule() );
366
367 reportViolation( drce, pos, aLayer );
368 }
369 }
370
371 if( testHoles && aItem->HasHole() )
372 {
373 std::shared_ptr<SHAPE_SEGMENT> holeShape;
374
375 if( aItem->Type() == PCB_VIA_T )
376 {
377 if( aItem->GetLayerSet().Contains( aLayer ) )
378 holeShape = aItem->GetEffectiveHoleShape();
379 }
380 else
381 {
382 holeShape = aItem->GetEffectiveHoleShape();
383 }
384
385 if( holeShape )
386 {
387 constraint = m_drcEngine->EvalRules( HOLE_CLEARANCE_CONSTRAINT, aItem, aZone, aLayer );
388 clearance = constraint.GetValue().Min();
389
390 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && clearance > 0 )
391 {
392 if( zoneTree->QueryColliding( itemBBox, holeShape.get(), aLayer,
393 std::max( 0, clearance - m_drcEpsilon ),
394 &actual, &pos ) )
395 {
396 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
397 wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
398 constraint.GetName(),
399 clearance,
400 actual );
401
402 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
403 drce->SetItems( aItem, aZone );
404 drce->SetViolatingRule( constraint.GetParentRule() );
405
406 reportViolation( drce, pos, aLayer );
407 }
408 }
409 }
410 }
411}
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition: board_item.h:115
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: board_item.cpp:222
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:185
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
Definition: board_item.cpp:232
virtual bool HasHole() const
Definition: board_item.h:128
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
Definition: board.h:1143
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:269
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
wxString GetName() const
Definition: drc_rule.h:147
SEVERITY GetSeverity() const
Definition: drc_rule.h:160
const MINOPTMAX< int > & GetValue() const
Definition: drc_rule.h:139
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
Definition: drc_engine.cpp:671
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:325
Implement an R-tree for fast spatial and layer indexing of connectable items.
Definition: drc_rtree.h:48
int QueryColliding(BOARD_ITEM *aRefItem, PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer, std::function< bool(BOARD_ITEM *)> aFilter=nullptr, std::function< bool(BOARD_ITEM *)> aVisitor=nullptr, int aClearance=0) const
This is a fast test which essentially does bounding-box overlap given a worst-case clearance.
Definition: drc_rtree.h:211
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
wxString formatMsg(const wxString &aFormatString, const wxString &aSource, int aConstraint, int aActual)
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
Definition: layer_ids.h:600
T Min() const
Definition: minoptmax.h:33
const BOX2I GetBoundingBox() const override
Definition: zone.cpp:320
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.h:121
@ CLEARANCE_CONSTRAINT
Definition: drc_rule.h:46
@ HOLE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:47
@ PTH
Plated through hole pad.
@ RPT_SEVERITY_IGNORE

References _, CLEARANCE_CONSTRAINT, LSET::Contains(), DRC_ITEM::Create(), DEFAULT, DRCE_CLEARANCE, DRCE_HOLE_CLEARANCE, DRC_ENGINE::EvalRules(), DRC_TEST_PROVIDER::formatMsg(), EDA_ITEM::GetBoundingBox(), ZONE::GetBoundingBox(), BOARD_ITEM::GetEffectiveHoleShape(), BOARD_ITEM::GetEffectiveShape(), BOARD_ITEM::GetLayerSet(), ZONE::GetLayerSet(), DRC_CONSTRAINT::GetName(), BOARD_CONNECTED_ITEM::GetNetCode(), DRC_CONSTRAINT::GetParentRule(), DRC_CONSTRAINT::GetSeverity(), DRC_CONSTRAINT::GetValue(), BOARD_ITEM::HasHole(), HOLE_CLEARANCE_CONSTRAINT, BOX2< Vec >::Inflate(), BOX2< Vec >::Intersects(), BOARD_ITEM::IsConnected(), DRC_ENGINE::IsErrorLimitExceeded(), DRC_TEST_PROVIDER_CLEARANCE_BASE::m_board, BOARD::m_CopperZoneRTreeCache, DRC_TEST_PROVIDER::m_drcEngine, m_drcEpsilon, BOARD::m_DRCMaxClearance, MINOPTMAX< T >::Min(), pad, PCB_PAD_T, PCB_VIA_T, PTH, DRC_RTREE::QueryColliding(), DRC_TEST_PROVIDER::reportViolation(), RPT_SEVERITY_IGNORE, and EDA_ITEM::Type().

Referenced by testPadClearances(), and testTrackClearances().

◆ testPadAgainstItem()

bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem ( PAD pad,
SHAPE padShape,
PCB_LAYER_ID  layer,
BOARD_ITEM other 
)
private

Definition at line 500 of file drc_test_provider_copper_clearance.cpp.

503{
504 bool testClearance = !m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE );
507
508 // Disable some tests for net-tie objects in a footprint
509 if( other->GetParent() == pad->GetParent() )
510 {
511 FOOTPRINT* fp = static_cast<FOOTPRINT*>( pad->GetParent() );
512 std::map<wxString, int> padToNetTieGroupMap = fp->MapPadNumbersToNetTieGroups();
513 int padGroupIdx = padToNetTieGroupMap[ pad->GetNumber() ];
514
515 if( other->Type() == PCB_PAD_T )
516 {
517 PAD* otherPad = static_cast<PAD*>( other );
518
519 if( padGroupIdx >= 0 && padGroupIdx == padToNetTieGroupMap[ otherPad->GetNumber() ] )
520 testClearance = false;
521
522 if( pad->SameLogicalPadAs( otherPad ) )
523 testHoles = false;
524 }
525
526 if( other->Type() == PCB_FP_SHAPE_T && padGroupIdx >= 0 )
527 testClearance = false;
528 }
529
530 PAD* otherPad = nullptr;
531 PCB_VIA* otherVia = nullptr;
532
533 if( other->Type() == PCB_PAD_T )
534 otherPad = static_cast<PAD*>( other );
535
536 if( other->Type() == PCB_VIA_T )
537 otherVia = static_cast<PCB_VIA*>( other );
538
539 if( !IsCopperLayer( aLayer ) )
540 testClearance = false;
541
542 // A NPTH has no cylinder, but it may still have pads on some layers
543 if( pad->GetAttribute() == PAD_ATTRIB::NPTH && !pad->FlashLayer( aLayer ) )
544 testClearance = false;
545
546 if( otherPad && otherPad->GetAttribute() == PAD_ATTRIB::NPTH && !otherPad->FlashLayer( aLayer ) )
547 testClearance = false;
548
549 // Track clearances are tested in testTrackClearances()
550 if( dynamic_cast<PCB_TRACK*>( other) )
551 testClearance = false;
552
553 int padNet = pad->GetNetCode();
554 int otherPadNet = otherPad ? otherPad->GetNetCode() : 0;
555 int otherViaNet = otherVia ? otherVia->GetNetCode() : 0;
556
557 // Pads and vias of the same (defined) net get a waiver on clearance and hole tests
558 if( ( otherPadNet && otherPadNet == padNet ) || ( otherViaNet && otherViaNet == padNet ) )
559 {
560 testClearance = false;
561 testHoles = false;
562 }
563
564 if( !( pad->GetDrillSize().x > 0 )
565 && !( otherPad && otherPad->GetDrillSize().x > 0 )
566 && !( otherVia && otherVia->GetDrill() > 0 ) )
567 {
568 testHoles = false;
569 }
570
571 if( !testClearance && !testShorting && !testHoles )
572 return false;
573
574 std::shared_ptr<SHAPE> otherShape = other->GetEffectiveShape( aLayer );
575 DRC_CONSTRAINT constraint;
576 int clearance;
577 int actual;
578 VECTOR2I pos;
579
580 if( otherPad && pad->SameLogicalPadAs( otherPad ) )
581 {
582 // If pads are equivalent (ie: from the same footprint with the same pad number)...
583 // ... and have nets...
584 // then they must be the same net
585 if( pad->GetNetCode() && otherPad->GetNetCode()
586 && pad->GetNetCode() != otherPad->GetNetCode()
587 && testShorting )
588 {
589 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_SHORTING_ITEMS );
590 wxString msg;
591
592 msg.Printf( _( "(nets %s and %s)" ),
593 pad->GetNetname(),
594 otherPad->GetNetname() );
595
596 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
597 drce->SetItems( pad, otherPad );
598
599 reportViolation( drce, otherPad->GetPosition(), aLayer );
600 }
601
602 return !m_drcEngine->IsCancelled();
603 }
604
605 if( testClearance )
606 {
607 constraint = m_drcEngine->EvalRules( CLEARANCE_CONSTRAINT, pad, other, aLayer );
608 clearance = constraint.GetValue().Min();
609
610 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && clearance > 0 )
611 {
612 if( padShape->Collide( otherShape.get(), std::max( 0, clearance - m_drcEpsilon ),
613 &actual, &pos ) )
614 {
615 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
616 wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
617 constraint.GetName(),
618 clearance,
619 actual );
620
621 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
622 drce->SetItems( pad, other );
623 drce->SetViolatingRule( constraint.GetParentRule() );
624
625 reportViolation( drce, pos, aLayer );
626 testHoles = false; // No need for multiple violations
627 }
628 }
629 }
630
631 if( testHoles )
632 {
633 constraint = m_drcEngine->EvalRules( HOLE_CLEARANCE_CONSTRAINT, pad, other, aLayer );
634 clearance = constraint.GetValue().Min();
635
636 if( constraint.GetSeverity() == RPT_SEVERITY_IGNORE )
637 testHoles = false;
638 }
639
640 if( testHoles && otherPad && pad->FlashLayer( aLayer ) && otherPad->HasHole() )
641 {
642 if( clearance > 0 && padShape->Collide( otherPad->GetEffectiveHoleShape().get(),
643 std::max( 0, clearance - m_drcEpsilon ),
644 &actual, &pos ) )
645 {
646 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
647 wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
648 constraint.GetName(),
649 clearance,
650 actual );
651
652 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
653 drce->SetItems( pad, other );
654 drce->SetViolatingRule( constraint.GetParentRule() );
655
656 reportViolation( drce, pos, aLayer );
657 testHoles = false; // No need for multiple violations
658 }
659 }
660
661 if( testHoles && otherPad && otherPad->FlashLayer( aLayer ) && pad->HasHole() )
662 {
663 if( clearance > 0 && otherShape->Collide( pad->GetEffectiveHoleShape().get(),
664 std::max( 0, clearance - m_drcEpsilon ),
665 &actual, &pos ) )
666 {
667 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
668 wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
669 constraint.GetName(),
670 clearance,
671 actual );
672
673 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
674 drce->SetItems( pad, other );
675 drce->SetViolatingRule( constraint.GetParentRule() );
676
677 reportViolation( drce, pos, aLayer );
678 testHoles = false; // No need for multiple violations
679 }
680 }
681
682 if( testHoles && otherVia && otherVia->IsOnLayer( aLayer ) )
683 {
684 if( clearance > 0 && padShape->Collide( otherVia->GetEffectiveHoleShape().get(),
685 std::max( 0, clearance - m_drcEpsilon ),
686 &actual, &pos ) )
687 {
688 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
689 wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
690 constraint.GetName(),
691 clearance,
692 actual );
693
694 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
695 drce->SetItems( pad, otherVia );
696 drce->SetViolatingRule( constraint.GetParentRule() );
697
698 reportViolation( drce, pos, aLayer );
699 }
700 }
701
702 return !m_drcEngine->IsCancelled();
703}
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:163
std::map< wxString, int > MapPadNumbersToNetTieGroups() const
Definition: footprint.cpp:2256
const VECTOR2I & GetDrillSize() const
Definition: pad.h:262
PAD_ATTRIB GetAttribute() const
Definition: pad.h:395
const wxString & GetNumber() const
Definition: pad.h:135
VECTOR2I GetPosition() const override
Definition: pad.h:197
bool FlashLayer(int aLayer) const
Check to see whether the pad should be flashed on the specific layer.
Definition: pad.cpp:248
bool HasHole() const override
Definition: pad.h:106
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:392
int GetDrill() const
Function GetDrill returns the local drill setting for this PCB_VIA.
Definition: pcb_track.h:508
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Definition: pcb_track.cpp:428
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pcb_track.cpp:456
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
Definition: shape.h:178
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:825
@ NPTH
like PAD_PTH, but not plated

References _, CLEARANCE_CONSTRAINT, SHAPE::Collide(), DRC_ITEM::Create(), DRCE_CLEARANCE, DRCE_HOLE_CLEARANCE, DRCE_SHORTING_ITEMS, DRC_ENGINE::EvalRules(), PAD::FlashLayer(), DRC_TEST_PROVIDER::formatMsg(), PAD::GetAttribute(), PCB_VIA::GetDrill(), PAD::GetDrillSize(), PAD::GetEffectiveHoleShape(), PCB_VIA::GetEffectiveHoleShape(), BOARD_ITEM::GetEffectiveShape(), DRC_CONSTRAINT::GetName(), BOARD_CONNECTED_ITEM::GetNetCode(), BOARD_CONNECTED_ITEM::GetNetname(), PAD::GetNumber(), BOARD_ITEM::GetParent(), DRC_CONSTRAINT::GetParentRule(), PAD::GetPosition(), DRC_CONSTRAINT::GetSeverity(), DRC_CONSTRAINT::GetValue(), PAD::HasHole(), HOLE_CLEARANCE_CONSTRAINT, DRC_ENGINE::IsCancelled(), IsCopperLayer(), DRC_ENGINE::IsErrorLimitExceeded(), PCB_VIA::IsOnLayer(), DRC_TEST_PROVIDER::m_drcEngine, m_drcEpsilon, FOOTPRINT::MapPadNumbersToNetTieGroups(), MINOPTMAX< T >::Min(), NPTH, pad, PCB_FP_SHAPE_T, PCB_PAD_T, PCB_VIA_T, DRC_TEST_PROVIDER::reportViolation(), RPT_SEVERITY_IGNORE, EDA_ITEM::Type(), and VECTOR2< T >::x.

Referenced by testPadClearances().

◆ testPadClearances()

void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadClearances ( )
private

Definition at line 706 of file drc_test_provider_copper_clearance.cpp.

707{
708 const int progressDelta = 100;
709 size_t count = 0;
710 int ii = 0;
711
712 for( FOOTPRINT* footprint : m_board->Footprints() )
713 count += footprint->Pads().size();
714
715 reportAux( wxT( "Testing %d pads..." ), count );
716
717 std::unordered_map<PTR_PTR_CACHE_KEY, int> checkedPairs;
718
719 for( FOOTPRINT* footprint : m_board->Footprints() )
720 {
721 for( PAD* pad : footprint->Pads() )
722 {
723 for( PCB_LAYER_ID layer : pad->GetLayerSet().Seq() )
724 {
725 std::shared_ptr<SHAPE> padShape = pad->GetEffectiveShape( layer );
726
727 m_board->m_CopperItemRTreeCache->QueryColliding( pad, layer, layer,
728 // Filter:
729 [&]( BOARD_ITEM* other ) -> bool
730 {
731 BOARD_ITEM* a = pad;
732 BOARD_ITEM* b = other;
733
734 // store canonical order so we don't collide in both directions
735 // (a:b and b:a)
736 if( static_cast<void*>( a ) > static_cast<void*>( b ) )
737 std::swap( a, b );
738
739 if( checkedPairs.find( { a, b } ) != checkedPairs.end() )
740 {
741 return false;
742 }
743 else
744 {
745 checkedPairs[ { a, b } ] = 1;
746 return true;
747 }
748 },
749 // Visitor
750 [&]( BOARD_ITEM* other ) -> bool
751 {
752 return testPadAgainstItem( pad, padShape.get(), layer, other );
753 },
755
756 for( ZONE* zone : m_board->m_DRCCopperZones )
757 {
758 testItemAgainstZone( pad, zone, layer );
759
760 if( m_drcEngine->IsCancelled() )
761 return;
762 }
763 }
764
765 if( !reportProgress( ii++, count, progressDelta ) )
766 return;
767 }
768
769 if( m_drcEngine->IsCancelled() )
770 return;
771 }
772}
std::vector< ZONE * > m_DRCCopperZones
Definition: board.h:1149
std::unique_ptr< DRC_RTREE > m_CopperItemRTreeCache
Definition: board.h:1144
void testItemAgainstZone(BOARD_ITEM *aItem, ZONE *aZone, PCB_LAYER_ID aLayer)
bool testPadAgainstItem(PAD *pad, SHAPE *padShape, PCB_LAYER_ID layer, BOARD_ITEM *other)
virtual bool reportProgress(int aCount, int aSize, int aDelta)
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59

References BOARD::Footprints(), DRC_ENGINE::IsCancelled(), DRC_TEST_PROVIDER_CLEARANCE_BASE::m_board, BOARD::m_CopperItemRTreeCache, BOARD::m_DRCCopperZones, DRC_TEST_PROVIDER::m_drcEngine, BOARD::m_DRCMaxClearance, pad, DRC_TEST_PROVIDER::reportAux(), DRC_TEST_PROVIDER::reportProgress(), testItemAgainstZone(), and testPadAgainstItem().

Referenced by Run().

◆ testTrackAgainstItem()

bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem ( PCB_TRACK track,
SHAPE trackShape,
PCB_LAYER_ID  layer,
BOARD_ITEM other 
)
private

Definition at line 164 of file drc_test_provider_copper_clearance.cpp.

167{
168 bool testClearance = !m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE );
170 DRC_CONSTRAINT constraint;
171 int clearance = -1;
172 int actual;
173 VECTOR2I pos;
174
175 std::shared_ptr<SHAPE> otherShape = other->GetEffectiveShape( layer );
176
177 if( other->Type() == PCB_PAD_T )
178 {
179 PAD* pad = static_cast<PAD*>( other );
180
181 if( pad->GetAttribute() == PAD_ATTRIB::NPTH && !pad->FlashLayer( layer ) )
182 testClearance = false;
183 }
184
185 if( testClearance )
186 {
187 constraint = m_drcEngine->EvalRules( CLEARANCE_CONSTRAINT, track, other, layer );
188 clearance = constraint.GetValue().Min();
189 }
190
191 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && clearance > 0 )
192 {
193 // Special processing for track:track intersections
194 if( track->Type() == PCB_TRACE_T && other->Type() == PCB_TRACE_T )
195 {
196 SEG trackSeg( track->GetStart(), track->GetEnd() );
197 SEG otherSeg( track->GetStart(), track->GetEnd() );
198
199 if( OPT_VECTOR2I intersection = trackSeg.Intersect( otherSeg ) )
200 {
201 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TRACKS_CROSSING );
202 drcItem->SetItems( track, other );
203 drcItem->SetViolatingRule( constraint.GetParentRule() );
204
205 reportViolation( drcItem, *intersection, layer );
206
208 }
209 }
210
211 if( trackShape->Collide( otherShape.get(), clearance - m_drcEpsilon, &actual, &pos ) )
212 {
213 if( m_drcEngine->IsNetTieExclusion( track->GetNetCode(), layer, pos, other ) )
214 {
215 // Collision occurred as track was entering a pad marked as a net-tie. We
216 // allow these.
217 }
218 else
219 {
220 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
221 wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
222 constraint.GetName(),
223 clearance,
224 actual );
225
226 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
227 drce->SetItems( track, other );
228 drce->SetViolatingRule( constraint.GetParentRule() );
229
230 reportViolation( drce, pos, layer );
231
233 return false;
234 }
235 }
236 }
237
238 if( testHoles && ( track->HasHole() || other->HasHole() ) )
239 {
240 std::array<BOARD_ITEM*, 2> a{ track, other };
241 std::array<BOARD_ITEM*, 2> b{ other, track };
242 std::array<SHAPE*, 2> a_shape{ trackShape, otherShape.get() };
243
244 bool has_error = false;
245
246 for( size_t ii = 0; ii < 2 && !has_error; ++ii )
247 {
248 std::shared_ptr<SHAPE_SEGMENT> holeShape;
249
250 // We only test a track item here against an item with a hole.
251 // If either case is not valid, simply move on
252 if( !( dynamic_cast<PCB_TRACK*>( a[ii] ) ) || !b[ii]->HasHole() )
253 {
254 continue;
255 }
256 if( b[ii]->Type() == PCB_VIA_T )
257 {
258 if( b[ii]->GetLayerSet().Contains( layer ) )
259 holeShape = b[ii]->GetEffectiveHoleShape();
260 }
261 else
262 {
263 holeShape = b[ii]->GetEffectiveHoleShape();
264 }
265
266 constraint = m_drcEngine->EvalRules( HOLE_CLEARANCE_CONSTRAINT, b[ii], a[ii], layer );
267 clearance = constraint.GetValue().Min();
268
269 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && clearance > 0 )
270 {
271 if( a_shape[ii]->Collide( holeShape.get(), std::max( 0, clearance - m_drcEpsilon ),
272 &actual, &pos ) )
273 {
274 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
275 wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
276 constraint.GetName(),
277 clearance,
278 actual );
279
280 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
281 drce->SetItems( a[ii], b[ii] );
282 drce->SetViolatingRule( constraint.GetParentRule() );
283
284 reportViolation( drce, pos, layer );
285 has_error = true;
286
288 return false;
289 }
290 }
291 }
292 }
293
294 return !m_drcEngine->IsCancelled();
295}
bool GetReportAllTrackErrors() const
Definition: drc_engine.h:162
static bool IsNetTieExclusion(int aTrackNetCode, PCB_LAYER_ID aTrackLayer, const VECTOR2I &aCollisionPos, BOARD_ITEM *aCollidingItem)
Check if the given collision between a track and another item occurs during the track's entry into a ...
const VECTOR2I & GetStart() const
Definition: pcb_track.h:112
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:109
Definition: seg.h:42
@ DRCE_TRACKS_CROSSING
Definition: drc_item.h:44
std::optional< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:39
static bool Collide(const SHAPE_CIRCLE &aA, const SHAPE_CIRCLE &aB, int aClearance, int *aActual, VECTOR2I *aLocation, VECTOR2I *aMTV)

References _, CLEARANCE_CONSTRAINT, Collide(), SHAPE::Collide(), DRC_ITEM::Create(), DRCE_CLEARANCE, DRCE_HOLE_CLEARANCE, DRCE_TRACKS_CROSSING, DRC_ENGINE::EvalRules(), DRC_TEST_PROVIDER::formatMsg(), BOARD_ITEM::GetEffectiveShape(), PCB_TRACK::GetEnd(), DRC_CONSTRAINT::GetName(), BOARD_CONNECTED_ITEM::GetNetCode(), DRC_CONSTRAINT::GetParentRule(), DRC_ENGINE::GetReportAllTrackErrors(), DRC_CONSTRAINT::GetSeverity(), PCB_TRACK::GetStart(), DRC_CONSTRAINT::GetValue(), BOARD_ITEM::HasHole(), HOLE_CLEARANCE_CONSTRAINT, SEG::Intersect(), DRC_ENGINE::IsCancelled(), DRC_ENGINE::IsErrorLimitExceeded(), DRC_ENGINE::IsNetTieExclusion(), DRC_TEST_PROVIDER::m_drcEngine, m_drcEpsilon, MINOPTMAX< T >::Min(), NPTH, pad, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, DRC_TEST_PROVIDER::reportViolation(), RPT_SEVERITY_IGNORE, and EDA_ITEM::Type().

Referenced by testTrackClearances().

◆ testTrackClearances()

void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackClearances ( )
private

Definition at line 414 of file drc_test_provider_copper_clearance.cpp.

415{
416 // This is the number of tests between 2 calls to the progress bar
417 const int progressDelta = 100;
418 int ii = 0;
419
420 reportAux( wxT( "Testing %d tracks & vias..." ), m_board->Tracks().size() );
421
422 std::map<BOARD_ITEM*, int> freePadsUsageMap;
423 std::unordered_map<PTR_PTR_CACHE_KEY, LSET> checkedPairs;
424
425 for( PCB_TRACK* track : m_board->Tracks() )
426 {
427 if( !reportProgress( ii++, m_board->Tracks().size(), progressDelta ) )
428 break;
429
430 for( PCB_LAYER_ID layer : LSET( track->GetLayerSet() & LSET::AllCuMask() ).Seq() )
431 {
432 std::shared_ptr<SHAPE> trackShape = track->GetEffectiveShape( layer );
433
434 m_board->m_CopperItemRTreeCache->QueryColliding( track, layer, layer,
435 // Filter:
436 [&]( BOARD_ITEM* other ) -> bool
437 {
438 auto otherCItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( other );
439
440 if( otherCItem && otherCItem->GetNetCode() == track->GetNetCode() )
441 return false;
442
443 BOARD_ITEM* a = track;
444 BOARD_ITEM* b = other;
445
446 // store canonical order so we don't collide in both directions
447 // (a:b and b:a)
448 if( static_cast<void*>( a ) > static_cast<void*>( b ) )
449 std::swap( a, b );
450
451 auto it = checkedPairs.find( { a, b } );
452
453 if( it != checkedPairs.end() && it->second.test( layer ) )
454 {
455 return false;
456 }
457 else
458 {
459 checkedPairs[ { a, b } ].set( layer );
460 return true;
461 }
462 },
463 // Visitor:
464 [&]( BOARD_ITEM* other ) -> bool
465 {
466 if( other->Type() == PCB_PAD_T && static_cast<PAD*>( other )->IsFreePad() )
467 {
468 if( other->GetEffectiveShape( layer )->Collide( trackShape.get() ) )
469 {
470 auto it = freePadsUsageMap.find( other );
471
472 if( it == freePadsUsageMap.end() )
473 {
474 freePadsUsageMap[ other ] = track->GetNetCode();
475 return false;
476 }
477 else if( it->second == track->GetNetCode() )
478 {
479 return false;
480 }
481 }
482 }
483
484 return testTrackAgainstItem( track, trackShape.get(), layer, other );
485 },
487
488 for( ZONE* zone : m_board->m_DRCCopperZones )
489 {
490 testItemAgainstZone( track, zone, layer );
491
492 if( m_drcEngine->IsCancelled() )
493 break;
494 }
495 }
496 }
497}
bool testTrackAgainstItem(PCB_TRACK *track, SHAPE *trackShape, PCB_LAYER_ID layer, BOARD_ITEM *other)
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773

References LSET::AllCuMask(), BOARD_ITEM::GetEffectiveShape(), DRC_ENGINE::IsCancelled(), DRC_TEST_PROVIDER_CLEARANCE_BASE::m_board, BOARD::m_CopperItemRTreeCache, BOARD::m_DRCCopperZones, DRC_TEST_PROVIDER::m_drcEngine, BOARD::m_DRCMaxClearance, PCB_PAD_T, DRC_TEST_PROVIDER::reportAux(), DRC_TEST_PROVIDER::reportProgress(), LSET::Seq(), testItemAgainstZone(), testTrackAgainstItem(), BOARD::Tracks(), and EDA_ITEM::Type().

Referenced by Run().

◆ testZonesToZones()

void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones ( )
private

Definition at line 775 of file drc_test_provider_copper_clearance.cpp.

776{
777 const int progressDelta = 50;
778
779 bool testClearance = !m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE );
780 bool testIntersects = !m_drcEngine->IsErrorLimitExceeded( DRCE_ZONES_INTERSECT );
781
782 SHAPE_POLY_SET buffer;
783 SHAPE_POLY_SET* boardOutline = nullptr;
784 DRC_CONSTRAINT constraint;
785 int zone2zoneClearance;
786
787 if( m_board->GetBoardPolygonOutlines( buffer ) )
788 boardOutline = &buffer;
789
790 for( int layer_id = F_Cu; layer_id <= B_Cu; ++layer_id )
791 {
792 PCB_LAYER_ID layer = static_cast<PCB_LAYER_ID>( layer_id );
793 std::vector<SHAPE_POLY_SET> smoothed_polys;
794 smoothed_polys.resize( m_board->m_DRCCopperZones.size() );
795
796 // Skip over layers not used on the current board
797 if( !m_board->IsLayerEnabled( layer ) )
798 continue;
799
800 for( size_t ii = 0; ii < m_board->m_DRCCopperZones.size(); ii++ )
801 {
802 if( m_board->m_DRCCopperZones[ii]->IsOnLayer( layer ) )
803 {
804 m_board->m_DRCCopperZones[ii]->BuildSmoothedPoly( smoothed_polys[ii], layer,
805 boardOutline );
806 }
807 }
808
809 // iterate through all areas
810 for( size_t ia = 0; ia < m_board->m_DRCCopperZones.size(); ia++ )
811 {
812 if( !reportProgress( layer_id * m_board->m_DRCCopperZones.size() + ia,
813 B_Cu * m_board->m_DRCCopperZones.size(), progressDelta ) )
814 {
815 return; // DRC cancelled
816 }
817
818 ZONE* zoneA = m_board->m_DRCCopperZones[ia];
819
820 if( !zoneA->IsOnLayer( layer ) )
821 continue;
822
823 for( size_t ia2 = ia + 1; ia2 < m_board->m_DRCCopperZones.size(); ia2++ )
824 {
825 ZONE* zoneB = m_board->m_DRCCopperZones[ia2];
826
827 // test for same layer
828 if( !zoneB->IsOnLayer( layer ) )
829 continue;
830
831 // Test for same net
832 if( zoneA->GetNetCode() == zoneB->GetNetCode() && zoneA->GetNetCode() >= 0 )
833 continue;
834
835 // test for different priorities
836 if( zoneA->GetAssignedPriority() != zoneB->GetAssignedPriority() )
837 continue;
838
839 // rule areas may overlap at will
840 if( zoneA->GetIsRuleArea() || zoneB->GetIsRuleArea() )
841 continue;
842
843 // Examine a candidate zone: compare zoneB to zoneA
844
845 // Get clearance used in zone to zone test.
846 constraint = m_drcEngine->EvalRules( CLEARANCE_CONSTRAINT, zoneA, zoneB, layer );
847 zone2zoneClearance = constraint.GetValue().Min();
848
849 if( constraint.GetSeverity() == RPT_SEVERITY_IGNORE )
850 continue;
851
852 if( testIntersects )
853 {
854 // test for some corners of zoneA inside zoneB
855 for( auto it = smoothed_polys[ia].IterateWithHoles(); it; it++ )
856 {
857 VECTOR2I currentVertex = *it;
858 wxPoint pt( currentVertex.x, currentVertex.y );
859
860 if( smoothed_polys[ia2].Contains( currentVertex ) )
861 {
862 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_ZONES_INTERSECT );
863 drce->SetItems( zoneA, zoneB );
864 drce->SetViolatingRule( constraint.GetParentRule() );
865
866 reportViolation( drce, pt, layer );
867 }
868 }
869
870 // test for some corners of zoneB inside zoneA
871 for( auto it = smoothed_polys[ia2].IterateWithHoles(); it; it++ )
872 {
873 VECTOR2I currentVertex = *it;
874 wxPoint pt( currentVertex.x, currentVertex.y );
875
876 if( smoothed_polys[ia].Contains( currentVertex ) )
877 {
878 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_ZONES_INTERSECT );
879 drce->SetItems( zoneB, zoneA );
880 drce->SetViolatingRule( constraint.GetParentRule() );
881
882 reportViolation( drce, pt, layer );
883 }
884 }
885 }
886
887 // Iterate through all the segments of refSmoothedPoly
888 std::map<VECTOR2I, int> conflictPoints;
889
890 for( auto refIt = smoothed_polys[ia].IterateSegmentsWithHoles(); refIt; refIt++ )
891 {
892 // Build ref segment
893 SEG refSegment = *refIt;
894
895 // Iterate through all the segments in smoothed_polys[ia2]
896 for( auto it = smoothed_polys[ia2].IterateSegmentsWithHoles(); it; it++ )
897 {
898 // Build test segment
899 SEG testSegment = *it;
900 VECTOR2I pt;
901
902 int ax1, ay1, ax2, ay2;
903 ax1 = refSegment.A.x;
904 ay1 = refSegment.A.y;
905 ax2 = refSegment.B.x;
906 ay2 = refSegment.B.y;
907
908 int bx1, by1, bx2, by2;
909 bx1 = testSegment.A.x;
910 by1 = testSegment.A.y;
911 bx2 = testSegment.B.x;
912 by2 = testSegment.B.y;
913
914 int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2, 0,
915 ax1, ay1, ax2, ay2, 0,
916 zone2zoneClearance, &pt.x, &pt.y );
917
918 if( d < zone2zoneClearance )
919 {
920 if( conflictPoints.count( pt ) )
921 conflictPoints[ pt ] = std::min( conflictPoints[ pt ], d );
922 else
923 conflictPoints[ pt ] = d;
924 }
925 }
926 }
927
928 for( const std::pair<const VECTOR2I, int>& conflict : conflictPoints )
929 {
930 int actual = conflict.second;
931 std::shared_ptr<DRC_ITEM> drce;
932
933 if( actual <= 0 && testIntersects )
934 {
936 }
937 else if( testClearance )
938 {
940 wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
941 constraint.GetName(),
942 zone2zoneClearance,
943 std::max( actual, 0 ) );
944
945 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
946 }
947
948 if( drce )
949 {
950 drce->SetItems( zoneA, zoneB );
951 drce->SetViolatingRule( constraint.GetParentRule() );
952
953 reportViolation( drce, conflict.first, layer );
954 }
955 }
956
957 if( m_drcEngine->IsCancelled() )
958 return;
959 }
960 }
961 }
962}
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.cpp:537
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
Definition: board.cpp:1893
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50
Represent a set of closed polygons.
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:696
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Test to see if this object is on the given layer.
Definition: zone.cpp:314
unsigned GetAssignedPriority() const
Definition: zone.h:112
@ B_Cu
Definition: layer_ids.h:95
@ F_Cu
Definition: layer_ids.h:64

References _, SEG::A, SEG::B, B_Cu, CLEARANCE_CONSTRAINT, DRC_ITEM::Create(), DRCE_CLEARANCE, DRCE_ZONES_INTERSECT, DRC_ENGINE::EvalRules(), F_Cu, DRC_TEST_PROVIDER::formatMsg(), ZONE::GetAssignedPriority(), BOARD::GetBoardPolygonOutlines(), ZONE::GetIsRuleArea(), DRC_CONSTRAINT::GetName(), BOARD_CONNECTED_ITEM::GetNetCode(), DRC_CONSTRAINT::GetParentRule(), DRC_CONSTRAINT::GetSeverity(), DRC_CONSTRAINT::GetValue(), DRC_ENGINE::IsCancelled(), DRC_ENGINE::IsErrorLimitExceeded(), BOARD::IsLayerEnabled(), ZONE::IsOnLayer(), DRC_TEST_PROVIDER_CLEARANCE_BASE::m_board, BOARD::m_DRCCopperZones, DRC_TEST_PROVIDER::m_drcEngine, MINOPTMAX< T >::Min(), DRC_TEST_PROVIDER::reportProgress(), DRC_TEST_PROVIDER::reportViolation(), RPT_SEVERITY_IGNORE, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Run().

◆ userUnits()

EDA_UNITS DRC_TEST_PROVIDER::userUnits ( ) const
protectedinherited

◆ ValueFromString()

int UNITS_PROVIDER::ValueFromString ( const wxString &  aTextValue,
EDA_DATA_TYPE  aType = EDA_DATA_TYPE::DISTANCE 
)
inlineinherited

Member Data Documentation

◆ m_board

◆ m_boardOutlineValid

bool DRC_TEST_PROVIDER_CLEARANCE_BASE::m_boardOutlineValid
protectedinherited

Definition at line 51 of file drc_test_provider_clearance_base.h.

◆ m_drcEngine

DRC_ENGINE* DRC_TEST_PROVIDER::m_drcEngine
protectedinherited

Definition at line 128 of file drc_test_provider.h.

Referenced by DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole(), DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole(), DRC_TEST_PROVIDER::forEachGeometryItem(), DRC_TEST_PROVIDER_CONNECTION_WIDTH::layerDesc(), DRC_TEST_PROVIDER_SLIVER_CHECKER::layerDesc(), DRC_TEST_PROVIDER::reportAux(), DRC_TEST_PROVIDER::reportPhase(), DRC_TEST_PROVIDER::reportProgress(), DRC_TEST_PROVIDER::reportRuleStatistics(), DRC_TEST_PROVIDER::reportViolation(), DRC_CACHE_GENERATOR::Run(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::Run(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTIVITY::Run(), Run(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), DRC_TEST_PROVIDER_FOOTPRINT_CHECKS::Run(), DRC_TEST_PROVIDER_HOLE_SIZE::Run(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run(), DRC_TEST_PROVIDER_LIBRARY_PARITY::Run(), DRC_TEST_PROVIDER_MISC::Run(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::Run(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), DRC_TEST_PROVIDER_SLIVER_CHECKER::Run(), DRC_TEST_PROVIDER_SOLDER_MASK::Run(), DRC_TEST_PROVIDER_TEXT_DIMS::Run(), DRC_TEST_PROVIDER_TRACK_WIDTH::Run(), DRC_TEST_PROVIDER_VIA_DIAMETER::Run(), DRC_TEST_PROVIDER_ZONE_CONNECTIONS::Run(), DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal(), DRC_TEST_PROVIDER::SetDRCEngine(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), DRC_TEST_PROVIDER_MISC::testAssertions(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_MISC::testDisabledLayers(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testFootprintCourtyardDefinitions(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem(), DRC_TEST_PROVIDER_SOLDER_MASK::testItemAgainstItems(), testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskBridges(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskItemAgainstZones(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist(), testPadAgainstItem(), testPadClearances(), DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance(), DRC_TEST_PROVIDER_MISC::testTextVars(), testTrackAgainstItem(), testTrackClearances(), DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer(), and testZonesToZones().

◆ m_drcEpsilon

int DRC_TEST_PROVIDER_COPPER_CLEARANCE::m_drcEpsilon
private

◆ m_isRuleDriven

◆ m_iuScale

const EDA_IU_SCALE& UNITS_PROVIDER::m_iuScale
privateinherited

Definition at line 113 of file units_provider.h.

Referenced by UNITS_PROVIDER::GetIuScale().

◆ m_stats

std::unordered_map<const DRC_RULE*, int> DRC_TEST_PROVIDER::m_stats
protectedinherited

◆ m_userUnits

EDA_UNITS UNITS_PROVIDER::m_userUnits
privateinherited

Definition at line 114 of file units_provider.h.

Referenced by UNITS_PROVIDER::GetUserUnits(), and UNITS_PROVIDER::SetUserUnits().

◆ s_allBasicItems

◆ s_allBasicItemsButZones

std::vector< KICAD_T > DRC_TEST_PROVIDER::s_allBasicItemsButZones
staticprotectedinherited

The documentation for this class was generated from the following file: