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

Public Member Functions

 DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE ()
 
virtual ~DRC_TEST_PROVIDER_PHYSICAL_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)
 
long long 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...
 

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
 
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 testItemAgainstItem (BOARD_ITEM *aItem, SHAPE *aItemShape, PCB_LAYER_ID aLayer, BOARD_ITEM *other)
 
void testItemAgainstZones (BOARD_ITEM *aItem, PCB_LAYER_ID aLayer)
 
void testShapeLineChain (const SHAPE_LINE_CHAIN &aOutline, int aLineWidth, PCB_LAYER_ID aLayer, BOARD_ITEM *aParentItem, DRC_CONSTRAINT &aConstraint)
 
void testZoneLayer (ZONE *aZone, PCB_LAYER_ID aLayer, DRC_CONSTRAINT &aConstraint)
 

Private Attributes

DRC_RTREE m_itemTree
 
const EDA_IU_SCALEm_iuScale
 
EDA_UNITS m_userUnits
 

Detailed Description

Definition at line 49 of file drc_test_provider_physical_clearance.cpp.

Constructor & Destructor Documentation

◆ DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE()

DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE ( )
inline

◆ ~DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE()

virtual DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::~DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE ( )
inlinevirtual

Definition at line 57 of file drc_test_provider_physical_clearance.cpp.

58 {
59 }

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().

◆ 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:50
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:58
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:253
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:241
@ 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(), 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().

◆ GetDescription()

virtual const wxString DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::GetDescription ( ) const
inlineoverridevirtual

Reimplemented from DRC_TEST_PROVIDER.

Definition at line 68 of file drc_test_provider_physical_clearance.cpp.

69 {
70 return wxT( "Tests item clearances irrespective of nets" );
71 }

◆ GetIuScale()

const EDA_IU_SCALE & UNITS_PROVIDER::GetIuScale ( ) const
inlineinherited

◆ GetName()

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

Reimplemented from DRC_TEST_PROVIDER.

Definition at line 63 of file drc_test_provider_physical_clearance.cpp.

64 {
65 return wxT( "physical_clearance" );
66 };

◆ 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(), PCB_EDIT_FRAME::GenFootprintsReport(), PANEL_SETUP_TEXT_AND_GRAPHICS::getGridValue(), GERBER_DRAW_ITEM::GetMsgPanelInfo(), EDA_DRAW_FRAME::GetUnitPair(), GetUserUnits(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), UNITS_PROVIDER::MessageTextFromValue(), PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness(), PANEL_SETUP_BOARD_STACKUP::onExportToClipboard(), PANEL_SETUP_TRACKS_AND_VIAS::OnSortDiffPairsClick(), PANEL_SETUP_TRACKS_AND_VIAS::OnSortTrackWidthsClick(), PANEL_SETUP_TRACKS_AND_VIAS::OnSortViaSizesClick(), PANEL_SETUP_BOARD_STACKUP::onThicknessChange(), UNIT_BINDER::onUnitsChanged(), DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged(), DIALOG_NET_INSPECTOR::onUnitsChanged(), PANEL_FP_EDITOR_DEFAULTS::PANEL_FP_EDITOR_DEFAULTS(), PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL(), PCB_CONTROL::placeBoardItems(), POSITION_RELATIVE_TOOL::PositionRelative(), DRC_TOOL::RunTests(), SCH_EDIT_FRAME::SaveSettings(), EDA_DRAW_FRAME::SaveSettings(), PIN_TABLE_DATA_MODEL::SetValue(), FP_TEXT_GRID_TABLE::SetValue(), GERBVIEW_INSPECTION_TOOL::ShowDCodes(), UNITS_PROVIDER::StringFromValue(), COMMON_TOOLS::ToggleUnits(), EDA_DRAW_FRAME::ToggleUserUnits(), PANEL_SETUP_BOARD_STACKUP::transferDataFromUIToStackup(), PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow(), UNIT_BINDER::UNIT_BINDER(), 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:323

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 }
const EDA_IU_SCALE & GetIuScale() const
EDA_UNITS GetUserUnits() const

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

Referenced by DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengths(), CheckLibSymbol(), DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole(), DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkews(), DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole(), 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(), 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(), 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_MATCHED_LENGTH::runInternal(), DIALOG_BOARD_STATISTICS::saveReportClicked(), EDA_SHAPE::ShapeGetMsgPanelInfo(), showCoord(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole(), testItemAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), testItemAgainstZones(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), testShapeLineChain(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem(), testZoneLayer(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones(), 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

Definition at line 133 of file drc_test_provider.cpp.

134{
135 if( !m_isRuleDriven )
136 return;
137
138 m_drcEngine->ReportAux( wxT( "Rule hit statistics: " ) );
139
140 for( const std::pair<const DRC_RULE* const, int>& stat : m_stats )
141 {
142 if( stat.first )
143 {
144 m_drcEngine->ReportAux( wxString::Format( wxT( " - rule '%s': %d hits " ),
145 stat.first->m_Name,
146 stat.second ) );
147 }
148 }
149}
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(), DRC_TEST_PROVIDER::m_drcEngine, DRC_TEST_PROVIDER::m_isRuleDriven, DRC_TEST_PROVIDER::m_stats, and DRC_ENGINE::ReportAux().

Referenced by DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTIVITY::Run(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_HOLE_SIZE::Run(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::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(), and DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal().

◆ 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(), testItemAgainstItem(), DRC_TEST_PROVIDER_SOLDER_MASK::testItemAgainstItems(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), testItemAgainstZones(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskItemAgainstZones(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist(), DRC_TEST_PROVIDER_MISC::testOutline(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), testShapeLineChain(), DRC_TEST_PROVIDER_MISC::testTextVars(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem(), DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer(), testZoneLayer(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones().

◆ Run()

bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::Run ( )
overridevirtual

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

Implements DRC_TEST_PROVIDER.

Definition at line 89 of file drc_test_provider_physical_clearance.cpp.

90{
93
94 int errorMax = m_board->GetDesignSettings().m_MaxError;
95
97 {
98 reportAux( wxT( "No physical clearance constraints found. Tests not run." ) );
99 return true; // continue with other tests
100 }
101
102 reportAux( wxT( "Largest physical clearance : %d nm" ), m_board->m_DRCMaxPhysicalClearance );
103
104 size_t progressDelta = 250;
105 size_t count = 0;
106 size_t ii = 0;
107
108 if( !reportPhase( _( "Gathering physical items..." ) ) )
109 return false; // DRC cancelled
110
111 static const std::vector<KICAD_T> itemTypes = {
114 PCB_PAD_T,
118 };
119
120 static const LSET courtyards( 2, F_CrtYd, B_CrtYd );
121
122 //
123 // Generate a count for use in progress reporting.
124 //
125
127 [&]( BOARD_ITEM* item ) -> bool
128 {
129 ++count;
130 return true;
131 } );
132
133 //
134 // Generate a BOARD_ITEM RTree.
135 //
136
138 [&]( BOARD_ITEM* item ) -> bool
139 {
140 if( !reportProgress( ii++, count, progressDelta ) )
141 return false;
142
143 LSET layers = item->GetLayerSet();
144
145 // Special-case holes and edge-cuts which pierce all physical layers
146 if( item->HasHole() )
147 {
148 layers |= LSET::PhysicalLayersMask() | courtyards;
149 }
150 else if( item->Type() == PCB_FOOTPRINT_T )
151 {
152 layers = courtyards;
153 }
154 else if( item->IsOnLayer( Edge_Cuts ) )
155 {
156 layers |= LSET::PhysicalLayersMask() | courtyards;
157 }
158
159 for( PCB_LAYER_ID layer : layers.Seq() )
161
162 return true;
163 } );
164
165 std::unordered_map<PTR_PTR_CACHE_KEY, LSET> checkedPairs;
166 progressDelta = 100;
167 ii = 0;
168
169 //
170 // Run clearance checks -between- items.
171 //
172
175 {
176 if( !reportPhase( _( "Checking physical clearances..." ) ) )
177 return false; // DRC cancelled
178
180 [&]( BOARD_ITEM* item ) -> bool
181 {
182 if( !reportProgress( ii++, count, progressDelta ) )
183 return false;
184
185 LSET layers = item->GetLayerSet();
186
187 if( item->Type() == PCB_FOOTPRINT_T )
188 layers = courtyards;
189
190 for( PCB_LAYER_ID layer : layers.Seq() )
191 {
192 std::shared_ptr<SHAPE> itemShape = item->GetEffectiveShape( layer );
193
194 m_itemTree.QueryColliding( item, layer, layer,
195 // Filter:
196 [&]( BOARD_ITEM* other ) -> bool
197 {
198 BOARD_ITEM* a = item;
199 BOARD_ITEM* b = other;
200
201 // store canonical order so we don't collide in both
202 // directions (a:b and b:a)
203 if( static_cast<void*>( a ) > static_cast<void*>( b ) )
204 std::swap( a, b );
205
206 auto it = checkedPairs.find( { a, b } );
207
208 if( it != checkedPairs.end() && it->second.test( layer ) )
209 {
210 return false;
211 }
212 else
213 {
214 checkedPairs[ { a, b } ].set( layer );
215 return true;
216 }
217 },
218 // Visitor:
219 [&]( BOARD_ITEM* other ) -> bool
220 {
221 return testItemAgainstItem( item, itemShape.get(), layer,
222 other );
223 },
225
226 testItemAgainstZones( item, layer );
227 }
228
229 return true;
230 } );
231 }
232
233 progressDelta = 100;
234 count = 0;
235 ii = 0;
236
237 //
238 // Generate a count for progress reporting.
239 //
240
243 [&]( BOARD_ITEM* item ) -> bool
244 {
245 ZONE* zone = dynamic_cast<ZONE*>( item );
246
247 if( zone && zone->GetIsRuleArea() )
248 return true; // Continue with other items
249
250 count += ( item->GetLayerSet() & LSET::AllCuMask() ).count();
251
252 return true;
253 } );
254
255 //
256 // Run clearance checks -within- polygonal items.
257 //
258
261 [&]( BOARD_ITEM* item ) -> bool
262 {
263 PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( item );
264 ZONE* zone = dynamic_cast<ZONE*>( item );
265
266 if( zone && zone->GetIsRuleArea() )
267 return true; // Continue with other items
268
269 for( PCB_LAYER_ID layer : item->GetLayerSet().Seq() )
270 {
271 if( IsCopperLayer( layer ) )
272 {
273 if( !reportProgress( ii++, count, progressDelta ) )
274 return false;
275
277 item, nullptr, layer );
278
279 if( shape )
280 {
281 switch( shape->GetShape() )
282 {
283 case SHAPE_T::POLY:
285 shape->GetWidth(), layer, item, c );
286 break;
287
288 case SHAPE_T::BEZIER:
289 {
290 SHAPE_LINE_CHAIN asPoly;
291
293
294 for( const VECTOR2I& pt : shape->GetBezierPoints() )
295 asPoly.Append( pt );
296
297 testShapeLineChain( asPoly, shape->GetWidth(), layer, item, c );
298 break;
299 }
300
301 case SHAPE_T::ARC:
302 {
303 SHAPE_LINE_CHAIN asPoly;
304
305 VECTOR2I center = shape->GetCenter();
306 EDA_ANGLE angle = -shape->GetArcAngle();
307 double r = shape->GetRadius();
308 int steps = GetArcToSegmentCount( r, errorMax, angle );
309
310 asPoly.Append( shape->GetStart() );
311
312 for( int step = 1; step <= steps; ++step )
313 {
314 EDA_ANGLE rotation = ( angle * step ) / steps;
315 VECTOR2I pt = shape->GetStart();
316
317 RotatePoint( pt, center, rotation );
318 asPoly.Append( pt );
319 }
320
321 testShapeLineChain( asPoly, shape->GetWidth(), layer, item, c );
322 break;
323 }
324
325 case SHAPE_T::RECT:
326 {
327 SHAPE_LINE_CHAIN asPoly;
328 std::vector<VECTOR2I> pts = shape->GetRectCorners();
329 asPoly.Append( pts[0] );
330 asPoly.Append( pts[1] );
331 asPoly.Append( pts[2] );
332 asPoly.Append( pts[3] );
333 asPoly.SetClosed( true );
334
335 testShapeLineChain( asPoly, shape->GetWidth(), layer, item, c );
336 break;
337 }
338
339 default:
341 }
342 }
343
344 if( zone )
345 testZoneLayer( static_cast<ZONE*>( item ), layer, c );
346 }
347
348 if( m_drcEngine->IsCancelled() )
349 return false;
350 }
351
352 return !m_drcEngine->IsCancelled();
353 } );
354
356
357 return !m_drcEngine->IsCancelled();
358}
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:232
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:172
virtual bool HasHole() const
Definition: board_item.h:118
int m_DRCMaxPhysicalClearance
Definition: board.h:1160
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:618
bool IsErrorLimitExceeded(int error_code)
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
bool IsCancelled() const
void Insert(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer, int aWorstClearance=0)
Insert an item into the tree on a particular layer with an optional worst clearance.
Definition: drc_rtree.h:104
void clear()
Remove all items from the RTree.
Definition: drc_rtree.h:166
void testZoneLayer(ZONE *aZone, PCB_LAYER_ID aLayer, DRC_CONSTRAINT &aConstraint)
void testItemAgainstZones(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer)
void testShapeLineChain(const SHAPE_LINE_CHAIN &aOutline, int aLineWidth, PCB_LAYER_ID aLayer, BOARD_ITEM *aParentItem, DRC_CONSTRAINT &aConstraint)
virtual bool reportPhase(const wxString &aStageName)
int forEachGeometryItem(const std::vector< KICAD_T > &aTypes, LSET aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
virtual bool reportProgress(int aCount, int aSize, int aDelta)
virtual void reportRuleStatistics()
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
EDA_ANGLE GetArcAngle() const
Definition: eda_shape.cpp:538
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
Definition: eda_shape.cpp:370
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:243
int GetRadius() const
Definition: eda_shape.cpp:476
SHAPE_T GetShape() const
Definition: eda_shape.h:111
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:116
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:983
int GetWidth() const
Definition: eda_shape.h:107
const std::vector< VECTOR2I > & GetBezierPoints() const
Definition: eda_shape.h:226
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:75
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
static LSET AllLayersMask()
Definition: lset.cpp:808
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
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:65
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
SHAPE_LINE_CHAIN & Outline(int aIndex)
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:691
@ DRCE_HOLE_CLEARANCE
Definition: drc_item.h:53
@ DRCE_CLEARANCE
Definition: drc_item.h:43
@ PHYSICAL_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:69
#define _(s)
E_SERIE r
Definition: eserie.cpp:41
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:823
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ F_CrtYd
Definition: layer_ids.h:117
@ Edge_Cuts
Definition: layer_ids.h:113
@ B_CrtYd
Definition: layer_ids.h:116
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183

References _, LSET::AllLayersMask(), B_CrtYd, DRC_RTREE::clear(), DRCE_CLEARANCE, DRCE_HOLE_CLEARANCE, Edge_Cuts, F_CrtYd, DRC_TEST_PROVIDER::forEachGeometryItem(), DRC_ENGINE::GetBoard(), BOARD::GetDesignSettings(), BOARD_ITEM::GetLayerSet(), BOARD_ITEM::HasHole(), DRC_RTREE::Insert(), DRC_ENGINE::IsErrorLimitExceeded(), BOARD_ITEM::IsOnLayer(), DRC_TEST_PROVIDER_CLEARANCE_BASE::m_board, DRC_TEST_PROVIDER::m_drcEngine, BOARD::m_DRCMaxPhysicalClearance, m_itemTree, BOARD_DESIGN_SETTINGS::m_MaxError, PCB_ARC_T, PCB_DIMENSION_T, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_TRACE_T, PCB_VIA_T, DRC_TEST_PROVIDER::reportAux(), DRC_TEST_PROVIDER::reportPhase(), DRC_TEST_PROVIDER::reportProgress(), LSET::Seq(), testItemAgainstZones(), and EDA_ITEM::Type().

◆ RunTests()

bool DRC_TEST_PROVIDER::RunTests ( EDA_UNITS  aUnits)
inlineinherited

Definition at line 86 of file drc_test_provider.h.

87 {
88 SetUserUnits( aUnits );
89 return Run();
90 }
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

Definition at line 80 of file drc_test_provider.h.

81 {
82 m_drcEngine = engine;
83 m_stats.clear();
84 }

References DRC_TEST_PROVIDER::m_drcEngine, and DRC_TEST_PROVIDER::m_stats.

Referenced by EDIT_TOOL::doMoveSelection(), and DRC_ENGINE::RunTests().

◆ 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:233

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 PANEL_SETUP_TRACKS_AND_VIAS::AppendDiffPairs(), PANEL_SETUP_TRACKS_AND_VIAS::AppendTrackWidth(), PANEL_SETUP_TRACKS_AND_VIAS::AppendViaSize(), 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(), PIN_TABLE_DATA_MODEL::GetValue(), FP_TEXT_GRID_TABLE::GetValue(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectDRCError(), PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness(), DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged(), reportMax(), reportMin(), reportOpt(), PANEL_SETUP_BOARD_STACKUP::setDefaultLayerWidths(), PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard(), DIALOG_GRID_SETTINGS::TransferDataFromWindow(), PANEL_SETUP_NETCLASSES::TransferDataToWindow(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::TransferDataToWindow(), and PANEL_SETUP_CONSTRAINTS::TransferDataToWindow().

◆ testItemAgainstItem()

bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem ( BOARD_ITEM aItem,
SHAPE aItemShape,
PCB_LAYER_ID  aLayer,
BOARD_ITEM other 
)
private

Definition at line 581 of file drc_test_provider_physical_clearance.cpp.

585{
586 bool testClearance = !m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE );
588 DRC_CONSTRAINT constraint;
589 int clearance = 0;
590 int actual;
591 VECTOR2I pos;
592
593 std::shared_ptr<SHAPE> otherShape = other->GetEffectiveShape( aLayer );
594
595 if( testClearance )
596 {
597 constraint = m_drcEngine->EvalRules( PHYSICAL_CLEARANCE_CONSTRAINT, aItem, other, aLayer );
598 clearance = constraint.GetValue().Min();
599 }
600
601 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && clearance > 0 )
602 {
603 if( aItemShape->Collide( otherShape.get(), clearance, &actual, &pos ) )
604 {
605 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
606 wxString msg;
607
608 msg.Printf( _( "(%s clearance %s; actual %s)" ),
609 constraint.GetName(),
610 MessageTextFromValue( clearance ),
611 MessageTextFromValue( actual ) );
612
613 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
614 drce->SetItems( aItem, other );
615 drce->SetViolatingRule( constraint.GetParentRule() );
616
617 reportViolation( drce, pos, aLayer );
618 }
619 }
620
621 if( testHoles )
622 {
623 std::shared_ptr<SHAPE_SEGMENT> itemHoleShape;
624 std::shared_ptr<SHAPE_SEGMENT> otherHoleShape;
625 clearance = 0;
626
627 if( aItem->Type() == PCB_VIA_T )
628 {
629 if( aItem->GetLayerSet().Contains( aLayer ) )
630 itemHoleShape = aItem->GetEffectiveHoleShape();
631 }
632 else if( aItem->HasHole() )
633 {
634 itemHoleShape = aItem->GetEffectiveHoleShape();
635 }
636
637 if( other->Type() == PCB_VIA_T )
638 {
639 if( other->GetLayerSet().Contains( aLayer ) )
640 otherHoleShape = other->GetEffectiveHoleShape();
641 }
642 else if( other->HasHole() )
643 {
644 otherHoleShape = other->GetEffectiveHoleShape();
645 }
646
647 if( itemHoleShape || otherHoleShape )
648 {
649 constraint = m_drcEngine->EvalRules( PHYSICAL_HOLE_CLEARANCE_CONSTRAINT, other, aItem,
650 aLayer );
651 clearance = constraint.GetValue().Min();
652 }
653
654 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && clearance > 0 )
655 {
656 if( itemHoleShape && itemHoleShape->Collide( otherShape.get(), clearance, &actual, &pos ) )
657 {
658 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
659 wxString msg;
660
661 msg.Printf( _( "(%s clearance %s; actual %s)" ),
662 constraint.GetName(),
663 MessageTextFromValue( clearance ),
664 MessageTextFromValue( actual ) );
665
666 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
667 drce->SetItems( aItem, other );
668 drce->SetViolatingRule( constraint.GetParentRule() );
669
670 reportViolation( drce, pos, aLayer );
671 }
672
673 if( otherHoleShape && otherHoleShape->Collide( aItemShape, clearance, &actual, &pos ) )
674 {
675 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
676 wxString msg;
677
678 msg.Printf( _( "(%s clearance %s; actual %s)" ),
679 constraint.GetName(),
680 MessageTextFromValue( clearance ),
681 MessageTextFromValue( actual ) );
682
683 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
684 drce->SetItems( aItem, other );
685 drce->SetViolatingRule( constraint.GetParentRule() );
686
687 reportViolation( drce, pos, aLayer );
688 }
689 }
690 }
691
692 return !m_drcEngine->IsCancelled();
693}
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:197
virtual std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const
Definition: board_item.cpp:207
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
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:325
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, int aMarkerLayer)
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
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
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
@ PHYSICAL_HOLE_CLEARANCE_CONSTRAINT
Definition: drc_rule.h:70
@ RPT_SEVERITY_IGNORE

References _, SHAPE::Collide(), LSET::Contains(), DRC_ITEM::Create(), DRCE_CLEARANCE, DRCE_HOLE_CLEARANCE, DRC_ENGINE::EvalRules(), BOARD_ITEM::GetEffectiveHoleShape(), BOARD_ITEM::GetEffectiveShape(), BOARD_ITEM::GetLayerSet(), DRC_CONSTRAINT::GetName(), DRC_CONSTRAINT::GetParentRule(), DRC_CONSTRAINT::GetSeverity(), DRC_CONSTRAINT::GetValue(), BOARD_ITEM::HasHole(), DRC_ENGINE::IsCancelled(), DRC_ENGINE::IsErrorLimitExceeded(), DRC_TEST_PROVIDER::m_drcEngine, UNITS_PROVIDER::MessageTextFromValue(), MINOPTMAX< T >::Min(), PCB_VIA_T, PHYSICAL_CLEARANCE_CONSTRAINT, PHYSICAL_HOLE_CLEARANCE_CONSTRAINT, DRC_TEST_PROVIDER::reportViolation(), RPT_SEVERITY_IGNORE, and EDA_ITEM::Type().

◆ testItemAgainstZones()

void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones ( BOARD_ITEM aItem,
PCB_LAYER_ID  aLayer 
)
private

Definition at line 696 of file drc_test_provider_physical_clearance.cpp.

698{
699 for( ZONE* zone : m_board->m_DRCZones )
700 {
701 if( !zone->GetLayerSet().test( aLayer ) )
702 continue;
703
704 BOX2I itemBBox = aItem->GetBoundingBox();
705 BOX2I worstCaseBBox = itemBBox;
706
707 worstCaseBBox.Inflate( m_board->m_DRCMaxClearance );
708
709 if( !worstCaseBBox.Intersects( zone->GetBoundingBox() ) )
710 continue;
711
712 bool testClearance = !m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE );
714
715 if( !testClearance && !testHoles )
716 return;
717
718 DRC_RTREE* zoneTree = m_board->m_CopperZoneRTreeCache[ zone ].get();
719 DRC_CONSTRAINT constraint;
720 bool colliding;
721 int clearance = -1;
722 int actual;
723 VECTOR2I pos;
724
725 if( testClearance )
726 {
727 constraint = m_drcEngine->EvalRules( PHYSICAL_CLEARANCE_CONSTRAINT, aItem, zone,
728 aLayer );
729 clearance = constraint.GetValue().Min();
730 }
731
732 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && clearance > 0 )
733 {
734 std::shared_ptr<SHAPE> itemShape = aItem->GetEffectiveShape( aLayer );
735
736 if( aItem->Type() == PCB_PAD_T )
737 {
738 PAD* pad = static_cast<PAD*>( aItem );
739
740 if( !pad->FlashLayer( aLayer ) )
741 {
742 if( pad->GetDrillSize().x == 0 && pad->GetDrillSize().y == 0 )
743 continue;
744
745 std::shared_ptr<SHAPE_SEGMENT> hole = pad->GetEffectiveHoleShape();
746 int size = hole->GetWidth();
747
748 // Note: drill size represents finish size, which means the actual hole
749 // size is the plating thickness larger.
750 if( pad->GetAttribute() == PAD_ATTRIB::PTH )
752
753 itemShape = std::make_shared<SHAPE_SEGMENT>( hole->GetSeg(), size );
754 }
755 }
756
757 if( zoneTree )
758 {
759 colliding = zoneTree->QueryColliding( itemBBox, itemShape.get(), aLayer, clearance,
760 &actual, &pos );
761 }
762 else
763 {
764 colliding = zone->Outline()->Collide( itemShape.get(), clearance, &actual, &pos );
765 }
766
767 if( colliding )
768 {
769 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
770 wxString msg;
771
772 msg.Printf( _( "(%s clearance %s; actual %s)" ),
773 constraint.GetName(),
774 MessageTextFromValue( clearance ),
775 MessageTextFromValue( actual ) );
776
777 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
778 drce->SetItems( aItem, zone );
779 drce->SetViolatingRule( constraint.GetParentRule() );
780
781 reportViolation( drce, pos, aLayer );
782 }
783 }
784
785 if( testHoles )
786 {
787 std::shared_ptr<SHAPE_SEGMENT> holeShape;
788
789 if( aItem->Type() == PCB_VIA_T )
790 {
791 if( aItem->GetLayerSet().Contains( aLayer ) )
792 holeShape = aItem->GetEffectiveHoleShape();
793 }
794 else if( aItem->HasHole() )
795 {
796 holeShape = aItem->GetEffectiveHoleShape();
797 }
798
799 if( holeShape )
800 {
802 zone, aLayer );
803 clearance = constraint.GetValue().Min();
804
805 if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE
806 && clearance > 0
807 && zoneTree->QueryColliding( itemBBox, holeShape.get(), aLayer, clearance,
808 &actual, &pos ) )
809 {
810 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
811 wxString msg;
812
813 msg.Printf( _( "(%s clearance %s; actual %s)" ),
814 constraint.GetName(),
815 MessageTextFromValue( clearance ),
816 MessageTextFromValue( actual ) );
817
818 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
819 drce->SetItems( aItem, zone );
820 drce->SetViolatingRule( constraint.GetParentRule() );
821
822 reportViolation( drce, pos, aLayer );
823 }
824 }
825 }
826
827 if( m_drcEngine->IsCancelled() )
828 return;
829 }
830}
int GetHolePlatingThickness() const
Pad & via drills are finish size.
int m_DRCMaxClearance
Definition: board.h:1159
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
Definition: board.h:1152
std::vector< ZONE * > m_DRCZones
Definition: board.h:1157
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
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 const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
const BOX2I GetBoundingBox() const override
Definition: zone.cpp:309
SHAPE_POLY_SET * Outline()
Definition: zone.h:305
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.h:115
@ PTH
Plated through hole pad.

References _, SHAPE_POLY_SET::Collide(), LSET::Contains(), DRC_ITEM::Create(), DRCE_CLEARANCE, DRCE_HOLE_CLEARANCE, DRC_ENGINE::EvalRules(), EDA_ITEM::GetBoundingBox(), ZONE::GetBoundingBox(), BOARD::GetDesignSettings(), BOARD_ITEM::GetEffectiveHoleShape(), BOARD_ITEM::GetEffectiveShape(), BOARD_DESIGN_SETTINGS::GetHolePlatingThickness(), BOARD_ITEM::GetLayerSet(), ZONE::GetLayerSet(), DRC_CONSTRAINT::GetName(), DRC_CONSTRAINT::GetParentRule(), DRC_CONSTRAINT::GetSeverity(), DRC_CONSTRAINT::GetValue(), BOARD_ITEM::HasHole(), BOX2< Vec >::Inflate(), BOX2< Vec >::Intersects(), DRC_ENGINE::IsCancelled(), DRC_ENGINE::IsErrorLimitExceeded(), DRC_TEST_PROVIDER_CLEARANCE_BASE::m_board, BOARD::m_CopperZoneRTreeCache, DRC_TEST_PROVIDER::m_drcEngine, BOARD::m_DRCMaxClearance, BOARD::m_DRCZones, UNITS_PROVIDER::MessageTextFromValue(), MINOPTMAX< T >::Min(), ZONE::Outline(), pad, PCB_PAD_T, PCB_VIA_T, PHYSICAL_CLEARANCE_CONSTRAINT, PHYSICAL_HOLE_CLEARANCE_CONSTRAINT, PTH, DRC_RTREE::QueryColliding(), DRC_TEST_PROVIDER::reportViolation(), RPT_SEVERITY_IGNORE, and EDA_ITEM::Type().

Referenced by Run().

◆ testShapeLineChain()

void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testShapeLineChain ( const SHAPE_LINE_CHAIN aOutline,
int  aLineWidth,
PCB_LAYER_ID  aLayer,
BOARD_ITEM aParentItem,
DRC_CONSTRAINT aConstraint 
)
private

Definition at line 361 of file drc_test_provider_physical_clearance.cpp.

365{
366 // We don't want to collide with neighboring segments forming a curve until the concavity
367 // approaches 180 degrees.
368 double angleTolerance = DEG2RAD( 180.0 - ADVANCED_CFG::GetCfg().m_SliverAngleTolerance );
369 int epsilon = m_board->GetDesignSettings().GetDRCEpsilon();
370 int count = aOutline.SegmentCount();
371 int clearance = aConstraint.GetValue().Min();
372
373 if( aConstraint.GetSeverity() == RPT_SEVERITY_IGNORE || clearance - epsilon <= 0 )
374 return;
375
376 // Trigonometry is not cheap; cache seg angles
377 std::vector<double> angles;
378 angles.reserve( count );
379
380 auto angleDiff =
381 []( double a, double b ) -> double
382 {
383 if( a > b )
384 std::swap( a, b );
385
386 double diff = b - a;
387
388 if( diff > M_PI )
389 return 2 * M_PI - diff;
390 else
391 return diff;
392 };
393
394 for( int ii = 0; ii < count; ++ii )
395 {
396 const SEG& seg = aOutline.CSegment( ii );
397
398 // NB: don't store angles of really short segments (which could point anywhere)
399
400 if( seg.SquaredLength() > SEG::Square( epsilon * 2 ) )
401 {
402 angles.push_back( EDA_ANGLE( seg.B - seg.A ).AsRadians() );
403 }
404 else if( ii > 0 )
405 {
406 angles.push_back( angles.back() );
407 }
408 else
409 {
410 for( int jj = 1; jj < count; ++jj )
411 {
412 const SEG& following = aOutline.CSegment( jj );
413
414 if( following.SquaredLength() > SEG::Square( epsilon * 2 ) || jj == count - 1 )
415 {
416 angles.push_back( EDA_ANGLE( following.B - following.A ).AsRadians() );
417 break;
418 }
419 }
420 }
421 }
422
423 // Find collisions before reporting so that we can condense them into fewer reports.
424 std::vector< std::pair<VECTOR2I, int> > collisions;
425
426 for( int ii = 0; ii < count; ++ii )
427 {
428 const SEG seg = aOutline.CSegment( ii );
429 double segAngle = angles[ ii ];
430
431 // Exclude segments on either side of us until we reach the angle tolerance
432 int firstCandidate = ii + 1;
433 int lastCandidate = count - 1;
434
435 while( firstCandidate < count )
436 {
437 if( angleDiff( segAngle, angles[ firstCandidate ] ) < angleTolerance )
438 firstCandidate++;
439 else
440 break;
441 }
442
443 if( aOutline.IsClosed() )
444 {
445 if( ii > 0 )
446 lastCandidate = ii - 1;
447
448 while( lastCandidate != std::min( firstCandidate, count - 1 ) )
449 {
450 if( angleDiff( segAngle, angles[ lastCandidate ] ) < angleTolerance )
451 lastCandidate = ( lastCandidate == 0 ) ? count - 1 : lastCandidate - 1;
452 else
453 break;
454 }
455 }
456
457 // Now run the collision between seg and each candidate seg in the candidate range.
458 if( lastCandidate < ii )
459 lastCandidate = count - 1;
460
461 for( int jj = firstCandidate; jj <= lastCandidate; ++jj )
462 {
463 const SEG candidate = aOutline.CSegment( jj );
464 int actual;
465
466 if( seg.Collide( candidate, clearance + aLineWidth - epsilon, &actual ) )
467 {
468 VECTOR2I firstPoint = seg.NearestPoint( candidate );
469 VECTOR2I secondPoint = candidate.NearestPoint( seg );
470 VECTOR2I pos = ( firstPoint + secondPoint ) / 2;
471
472 if( !collisions.empty() &&
473 ( pos - collisions.back().first ).EuclideanNorm() < clearance * 2 )
474 {
475 if( actual < collisions.back().second )
476 {
477 collisions.back().first = pos;
478 collisions.back().second = actual;
479 }
480
481 continue;
482 }
483
484 collisions.push_back( { pos, actual } );
485 }
486 }
487 }
488
489 for( std::pair<VECTOR2I, int> collision : collisions )
490 {
491 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
492 wxString msg;
493 VECTOR2I pt = collision.first;
494
495 if( aParentItem->GetParentFootprint() )
496 pt += aParentItem->GetParentFootprint()->GetPosition();
497
498 msg.Printf( _( "Internal clearance violation (%s clearance %s; actual %s)" ),
499 aConstraint.GetName(),
500 MessageTextFromValue( clearance ),
501 MessageTextFromValue( collision.second ) );
502
503 drce->SetErrorMessage( msg );
504 drce->SetItems( aParentItem );
505 drce->SetViolatingRule( aConstraint.GetParentRule() );
506
507 reportViolation( drce, pt, aLayer );
508 }
509}
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
BOARD_ITEM_CONTAINER * GetParentFootprint() const
Definition: board_item.cpp:217
double AsRadians() const
Definition: eda_angle.h:153
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:249
Definition: seg.h:42
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
Definition: seg.cpp:261
static SEG::ecoord Square(int a)
Definition: seg.h:123
bool Collide(const SEG &aSeg, int aClearance, int *aActual=nullptr) const
Definition: seg.cpp:223
ecoord SquaredLength() const
Definition: seg.h:356
bool IsClosed() const override
int SegmentCount() const
Return the number of segments in this line chain.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
double DEG2RAD(double deg)
Definition: trigo.h:195
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129

References _, SEG::A, EDA_ANGLE::AsRadians(), SEG::B, SEG::Collide(), DRC_ITEM::Create(), SHAPE_LINE_CHAIN::CSegment(), DEG2RAD(), DRCE_CLEARANCE, EuclideanNorm(), ADVANCED_CFG::GetCfg(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetDRCEpsilon(), DRC_CONSTRAINT::GetName(), BOARD_ITEM::GetParentFootprint(), DRC_CONSTRAINT::GetParentRule(), EDA_ITEM::GetPosition(), DRC_CONSTRAINT::GetSeverity(), DRC_CONSTRAINT::GetValue(), SHAPE_LINE_CHAIN::IsClosed(), DRC_TEST_PROVIDER_CLEARANCE_BASE::m_board, UNITS_PROVIDER::MessageTextFromValue(), MINOPTMAX< T >::Min(), SEG::NearestPoint(), DRC_TEST_PROVIDER::reportViolation(), RPT_SEVERITY_IGNORE, SHAPE_LINE_CHAIN::SegmentCount(), SEG::Square(), and SEG::SquaredLength().

Referenced by testZoneLayer().

◆ testZoneLayer()

void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer ( ZONE aZone,
PCB_LAYER_ID  aLayer,
DRC_CONSTRAINT aConstraint 
)
private

Definition at line 512 of file drc_test_provider_physical_clearance.cpp.

514{
515 int epsilon = m_board->GetDesignSettings().GetDRCEpsilon();
516 int clearance = aConstraint.GetValue().Min();
517
518 if( aConstraint.GetSeverity() == RPT_SEVERITY_IGNORE || clearance - epsilon <= 0 )
519 return;
520
521 SHAPE_POLY_SET fill = aZone->GetFilledPolysList( aLayer )->CloneDropTriangulation();
522
523 // Turn fractured fill into outlines and holes
525
526 for( int outlineIdx = 0; outlineIdx < fill.OutlineCount(); ++outlineIdx )
527 {
528 SHAPE_LINE_CHAIN* firstOutline = &fill.Outline( outlineIdx );
529
530 //
531 // Step one: outline to outline clearance violations
532 //
533
534 for( int ii = outlineIdx + 1; ii < fill.OutlineCount(); ++ii )
535 {
536 SHAPE_LINE_CHAIN* secondOutline = &fill.Outline( ii );
537
538 for( int jj = 0; jj < secondOutline->SegmentCount(); ++jj )
539 {
540 SEG secondSeg = secondOutline->Segment( jj );
541 int actual;
542 VECTOR2I pos;
543
544 if( firstOutline->Collide( secondSeg, clearance - epsilon, &actual, &pos ) )
545 {
546 std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
547 wxString msg;
548
549 msg.Printf( _( "(%s clearance %s; actual %s)" ),
550 aConstraint.GetName(),
551 MessageTextFromValue( clearance ),
552 MessageTextFromValue( actual ) );
553
554 drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
555 drce->SetItems( aZone );
556 drce->SetViolatingRule( aConstraint.GetParentRule() );
557
558 reportViolation( drce, pos, aLayer );
559 }
560 }
561
562 if( m_drcEngine->IsCancelled() )
563 return;
564 }
565
566 //
567 // Step two: interior hole clearance violations
568 //
569
570 for( int holeIdx = 0; holeIdx < fill.HoleCount( outlineIdx ); ++holeIdx )
571 {
572 testShapeLineChain( fill.Hole( outlineIdx, holeIdx ), 0, aLayer, aZone, aConstraint );
573
574 if( m_drcEngine->IsCancelled() )
575 return;
576 }
577 }
578}
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if point aP lies closer to us than aClearance.
SEG Segment(int aIndex)
Return a copy of the aIndex-th segment in the line chain.
Represent a set of closed polygons.
int HoleCount(int aOutline) const
Return the reference to aIndex-th outline in the set.
void Simplify(POLYGON_MODE aFastMode)
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the aIndex-th subpolygon in the set.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:596

References _, SHAPE_LINE_CHAIN::Collide(), DRC_ITEM::Create(), DRCE_CLEARANCE, BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetDRCEpsilon(), ZONE::GetFilledPolysList(), DRC_CONSTRAINT::GetName(), DRC_CONSTRAINT::GetParentRule(), DRC_CONSTRAINT::GetSeverity(), DRC_CONSTRAINT::GetValue(), SHAPE_POLY_SET::Hole(), SHAPE_POLY_SET::HoleCount(), DRC_ENGINE::IsCancelled(), DRC_TEST_PROVIDER_CLEARANCE_BASE::m_board, DRC_TEST_PROVIDER::m_drcEngine, UNITS_PROVIDER::MessageTextFromValue(), MINOPTMAX< T >::Min(), SHAPE_POLY_SET::Outline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_POLY_SET::PM_FAST, DRC_TEST_PROVIDER::reportViolation(), RPT_SEVERITY_IGNORE, SHAPE_LINE_CHAIN::Segment(), SHAPE_LINE_CHAIN::SegmentCount(), SHAPE_POLY_SET::Simplify(), and testShapeLineChain().

◆ userUnits()

EDA_UNITS DRC_TEST_PROVIDER::userUnits ( ) const
protectedinherited

◆ ValueFromString()

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

Converts aTextValue in aUnits to internal units used by the frame.

Warning
This utilizes the current locale and will break if decimal formats differ
Parameters
aTextValueA reference to a wxString object containing the string to convert.
Returns
internal units value

Definition at line 96 of file units_provider.h.

98 {
100 aType );
101 }
long long int ValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: eda_units.cpp:530

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

Referenced by PIN_TABLE_DATA_MODEL::compare(), PANEL_SETUP_BOARD_STACKUP::computeBoardThickness(), MICROWAVE_TOOL::createFootprint(), MICROWAVE_TOOL::createMicrowaveInductor(), PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness(), PANEL_SETUP_BOARD_STACKUP::onCopperLayersSelCount(), PANEL_SETUP_BOARD_STACKUP::setDefaultLayerWidths(), PANEL_SETUP_NETCLASSES::TransferDataFromWindow(), and DIALOG_GRID_SETTINGS::TransferDataToWindow().

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 123 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_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTIVITY::Run(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::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(), 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_COURTYARD_CLEARANCE_ON_MOVE::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(), testItemAgainstItem(), DRC_TEST_PROVIDER_SOLDER_MASK::testItemAgainstItems(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), testItemAgainstZones(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskBridges(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskItemAgainstZones(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadClearances(), DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance(), DRC_TEST_PROVIDER_MISC::testTextVars(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackClearances(), DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer(), testZoneLayer(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones().

◆ m_isRuleDriven

◆ m_itemTree

DRC_RTREE DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::m_itemTree
private

Definition at line 85 of file drc_test_provider_physical_clearance.cpp.

Referenced by Run().

◆ m_iuScale

const EDA_IU_SCALE& UNITS_PROVIDER::m_iuScale
privateinherited

Definition at line 104 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 105 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: