KiCad PCB EDA Suite
DRC_TEST_PROVIDER_MISC Class Reference
Inheritance diagram for DRC_TEST_PROVIDER_MISC:
DRC_TEST_PROVIDER

Public Member Functions

 DRC_TEST_PROVIDER_MISC ()
 
virtual ~DRC_TEST_PROVIDER_MISC ()
 
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)
 

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, PCB_LAYER_ID 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

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

void testOutline ()
 
void testDisabledLayers ()
 
void testTextVars ()
 
void testAssertions ()
 

Private Attributes

BOARDm_board
 

Detailed Description

Definition at line 45 of file drc_test_provider_misc.cpp.

Constructor & Destructor Documentation

◆ DRC_TEST_PROVIDER_MISC()

DRC_TEST_PROVIDER_MISC::DRC_TEST_PROVIDER_MISC ( )
inline

Definition at line 48 of file drc_test_provider_misc.cpp.

48 :
49 m_board( nullptr )
50 {
51 m_isRuleDriven = false;
52 }

References DRC_TEST_PROVIDER::m_isRuleDriven.

◆ ~DRC_TEST_PROVIDER_MISC()

virtual DRC_TEST_PROVIDER_MISC::~DRC_TEST_PROVIDER_MISC ( )
inlinevirtual

Definition at line 54 of file drc_test_provider_misc.cpp.

55 {
56 }

Member Function Documentation

◆ accountCheck() [1/2]

void DRC_TEST_PROVIDER::accountCheck ( const DRC_CONSTRAINT constraintToTest)
protectedvirtualinherited

Definition at line 132 of file drc_test_provider.cpp.

133{
134 accountCheck( constraintToTest.GetParentRule() );
135}
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 121 of file drc_test_provider.cpp.

122{
123 auto it = m_stats.find( ruleToTest );
124
125 if( it == m_stats.end() )
126 m_stats[ ruleToTest ] = 1;
127 else
128 m_stats[ ruleToTest ] += 1;
129}
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 157 of file drc_test_provider.cpp.

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

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(), testAssertions(), testDisabledLayers(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskBridges(), DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance(), and testTextVars().

◆ GetDescription()

virtual const wxString DRC_TEST_PROVIDER_MISC::GetDescription ( ) const
inlineoverridevirtual

Reimplemented from DRC_TEST_PROVIDER.

Definition at line 65 of file drc_test_provider_misc.cpp.

66 {
67 return wxT( "Misc checks (board outline, missing textvars)" );
68 }

◆ GetName()

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

Reimplemented from DRC_TEST_PROVIDER.

Definition at line 60 of file drc_test_provider_misc.cpp.

61 {
62 return wxT( "miscellaneous" );
63 };

◆ Init()

void DRC_TEST_PROVIDER::Init ( )
staticinherited

Definition at line 52 of file drc_test_provider.cpp.

53{
54 if( s_allBasicItems.size() == 0 )
55 {
56 for( int i = 0; i < MAX_STRUCT_TYPE_ID; i++ )
57 {
58 if( i != PCB_FOOTPRINT_T && i != PCB_GROUP_T )
59 {
60 s_allBasicItems.push_back( (KICAD_T) i );
61
62 if( i != PCB_ZONE_T && i != PCB_FP_ZONE_T )
63 s_allBasicItemsButZones.push_back( (KICAD_T) i );
64 }
65 }
66 }
67}
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:117

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 351 of file drc_test_provider.cpp.

352{
353
354 if( const FP_TEXT* text = dyn_cast<const FP_TEXT*>( aItem ) )
355 {
356 if( !text->IsVisible() )
357 return true;
358 }
359
360 if( const PCB_TEXT* text = dyn_cast<const PCB_TEXT*>( aItem ) )
361 {
362 if( !text->IsVisible() )
363 return true;
364 }
365
366 return false;
367}

References text.

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

◆ 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 138 of file drc_test_provider.cpp.

139{
140 if( !m_isRuleDriven )
141 return;
142
143 m_drcEngine->ReportAux( wxT( "Rule hit statistics: " ) );
144
145 for( const std::pair<const DRC_RULE* const, int>& stat : m_stats )
146 {
147 if( stat.first )
148 {
149 m_drcEngine->ReportAux( wxString::Format( wxT( " - rule '%s': %d hits " ),
150 stat.first->m_Name,
151 stat.second ) );
152 }
153 }
154}
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,
PCB_LAYER_ID  aMarkerLayer 
)
protectedvirtualinherited

Definition at line 74 of file drc_test_provider.cpp.

76{
77 if( item->GetViolatingRule() )
78 accountCheck( item->GetViolatingRule() );
79
80 item->SetViolatingTest( this );
81 m_drcEngine->ReportViolation( item, aMarkerPos, aMarkerLayer );
82}
void ReportViolation(const std::shared_ptr< DRC_ITEM > &aItem, const VECTOR2I &aPos, PCB_LAYER_ID 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(), testAssertions(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), 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(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_SOLDER_MASK::testMaskItemAgainstZones(), DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist(), testOutline(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testShapeLineChain(), testTextVars(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem(), DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer(), and DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones().

◆ Run()

bool DRC_TEST_PROVIDER_MISC::Run ( )
overridevirtual

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

Implements DRC_TEST_PROVIDER.

Definition at line 335 of file drc_test_provider_misc.cpp.

336{
338
340 {
341 if( !reportPhase( _( "Checking board outline..." ) ) )
342 return false; // DRC cancelled
343
344 testOutline();
345 }
346
348 {
349 if( !reportPhase( _( "Checking disabled layers..." ) ) )
350 return false; // DRC cancelled
351
353 }
354
356 {
357 if( !reportPhase( _( "Checking text variables..." ) ) )
358 return false; // DRC cancelled
359
360 testTextVars();
361 }
362
364 {
365 if( !reportPhase( _( "Checking assertions..." ) ) )
366 return false; // DRC cancelled
367
369 }
370
371 return !m_drcEngine->IsCancelled();
372}
bool IsErrorLimitExceeded(int error_code)
bool IsCancelled() const
virtual bool reportPhase(const wxString &aStageName)
@ DRCE_DISABLED_LAYER_ITEM
Definition: drc_item.h:67
@ DRCE_INVALID_OUTLINE
Definition: drc_item.h:68
@ DRCE_UNRESOLVED_VARIABLE
Definition: drc_item.h:81
@ DRCE_ASSERTION_FAILURE
Definition: drc_item.h:82
#define _(s)

References _, DRCE_ASSERTION_FAILURE, DRCE_DISABLED_LAYER_ITEM, DRCE_INVALID_OUTLINE, DRCE_UNRESOLVED_VARIABLE, DRC_ENGINE::GetBoard(), DRC_ENGINE::IsCancelled(), DRC_ENGINE::IsErrorLimitExceeded(), m_board, DRC_TEST_PROVIDER::m_drcEngine, DRC_TEST_PROVIDER::reportPhase(), testAssertions(), testDisabledLayers(), testOutline(), and testTextVars().

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

◆ testAssertions()

void DRC_TEST_PROVIDER_MISC::testAssertions ( )
private

Definition at line 215 of file drc_test_provider_misc.cpp.

216{
217 const int progressDelta = 2000;
218 int ii = 0;
219 int items = 0;
220
221 auto countItems =
222 [&]( BOARD_ITEM* item ) -> bool
223 {
224 ++items;
225 return true;
226 };
227
228 auto checkAssertions =
229 [&]( BOARD_ITEM* item ) -> bool
230 {
232 return false;
233
234 if( !reportProgress( ii++, items, progressDelta ) )
235 return false;
236
238 [&]( const DRC_CONSTRAINT* c )
239 {
241 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " (" )
242 + c->GetName() + wxS( ")" ) );
243 drcItem->SetItems( item );
244
245 reportViolation( drcItem, item->GetPosition(), item->GetLayer() );
246 } );
247
248 return true;
249 };
250
251 forEachGeometryItem( {}, LSET::AllLayersMask(), countItems );
252 forEachGeometryItem( {}, LSET::AllLayersMask(), checkAssertions );
253}
wxString GetName() const
Definition: drc_rule.h:147
void ProcessAssertions(const BOARD_ITEM *a, std::function< void(const DRC_CONSTRAINT *)> aFailureHandler, REPORTER *aReporter=nullptr)
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:324
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 reportViolation(std::shared_ptr< DRC_ITEM > &item, const VECTOR2I &aMarkerPos, PCB_LAYER_ID aMarkerLayer)
static LSET AllLayersMask()
Definition: lset.cpp:808

References LSET::AllLayersMask(), DRC_ITEM::Create(), DRCE_ASSERTION_FAILURE, DRC_TEST_PROVIDER::forEachGeometryItem(), DRC_CONSTRAINT::GetName(), DRC_ENGINE::IsErrorLimitExceeded(), DRC_TEST_PROVIDER::m_drcEngine, DRC_ENGINE::ProcessAssertions(), DRC_TEST_PROVIDER::reportProgress(), and DRC_TEST_PROVIDER::reportViolation().

Referenced by Run().

◆ testDisabledLayers()

void DRC_TEST_PROVIDER_MISC::testDisabledLayers ( )
private

Definition at line 124 of file drc_test_provider_misc.cpp.

125{
126 const int progressDelta = 2000;
127 int ii = 0;
128 int items = 0;
129
130 auto countItems =
131 [&]( BOARD_ITEM* item ) -> bool
132 {
133 ++items;
134 return true;
135 };
136
137 LSET disabledLayers = m_board->GetEnabledLayers().flip();
138
139 // Perform the test only for copper layers
140 disabledLayers &= LSET::AllCuMask();
141
142 auto checkDisabledLayers =
143 [&]( BOARD_ITEM* item ) -> bool
144 {
146 return false;
147
148 if( !reportProgress( ii++, items, progressDelta ) )
149 return false;
150
151 PCB_LAYER_ID badLayer = UNDEFINED_LAYER;
152
153 if( item->Type() == PCB_PAD_T )
154 {
155 PAD* pad = static_cast<PAD*>( item );
156
157 if( pad->GetAttribute() == PAD_ATTRIB::SMD
158 || pad->GetAttribute() == PAD_ATTRIB::CONN )
159 {
160 if( disabledLayers.test( pad->GetPrincipalLayer() ) )
161 badLayer = item->GetLayer();
162 }
163 else
164 {
165 // Through hole pad pierces all physical layers.
166 }
167 }
168 else if( item->Type() == PCB_VIA_T )
169 {
170 PCB_VIA* via = static_cast<PCB_VIA*>( item );
171 PCB_LAYER_ID top;
172 PCB_LAYER_ID bottom;
173
174 via->LayerPair( &top, &bottom );
175
176 if( disabledLayers.test( top ) )
177 badLayer = top;
178 else if( disabledLayers.test( bottom ) )
179 badLayer = bottom;
180 }
181 else if( item->Type() == PCB_FP_ZONE_T )
182 {
183 // Footprint zones just get a top/bottom/inner setting, so they're on
184 // whatever inner layers there are.
185 }
186 else
187 {
188 LSET badLayers = disabledLayers & item->GetLayerSet();
189
190 if( badLayers.any() )
191 badLayer = badLayers.Seq().front();
192 }
193
194 if( badLayer != UNDEFINED_LAYER )
195 {
197 wxString msg;
198
199 msg.Printf( _( "(layer %s)" ), LayerName( badLayer ) );
200
201 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
202 drcItem->SetItems( item );
203
204 reportViolation( drcItem, item->GetPosition(), UNDEFINED_LAYER );
205 }
206
207 return true;
208 };
209
212}
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:502
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:529
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
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pad.cpp:203
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
Definition: layer_id.cpp:30
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ SMD
Smd pad, appears on the solder paste layer (default)
@ CONN
Like smd, does not appear on the solder paste layer (default)

References _, LSET::AllCuMask(), LSET::AllLayersMask(), CONN, DRC_ITEM::Create(), DRCE_DISABLED_LAYER_ITEM, DRC_TEST_PROVIDER::forEachGeometryItem(), BOARD::GetEnabledLayers(), PAD::GetLayer(), DRC_ENGINE::IsErrorLimitExceeded(), LayerName(), m_board, DRC_TEST_PROVIDER::m_drcEngine, pad, PCB_FP_ZONE_T, PCB_PAD_T, PCB_VIA_T, DRC_TEST_PROVIDER::reportProgress(), DRC_TEST_PROVIDER::reportViolation(), DRC_TEST_PROVIDER::s_allBasicItems, LSET::Seq(), SMD, UNDEFINED_LAYER, and via.

Referenced by Run().

◆ testOutline()

void DRC_TEST_PROVIDER_MISC::testOutline ( )
private

Definition at line 80 of file drc_test_provider_misc.cpp.

81{
82 SHAPE_POLY_SET dummyOutline;
83 bool errorHandled = false;
84
85 OUTLINE_ERROR_HANDLER errorHandler =
86 [&]( const wxString& msg, BOARD_ITEM* itemA, BOARD_ITEM* itemB, const VECTOR2I& pt )
87 {
88 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_INVALID_OUTLINE );
89
90 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
91 drcItem->SetItems( itemA, itemB );
92
93 reportViolation( drcItem, pt, Edge_Cuts );
94 errorHandled = true;
95 };
96
97 // Use a really tight chaining epsilon here so that we report errors that might affect
98 // other tools (such as STEP export).
99 constexpr int chainingEpsilon = Millimeter2iu( 0.02 ) / 100;
100
102 chainingEpsilon, &errorHandler ) )
103 {
104 if( errorHandled )
105 {
106 // if there is an invalid outline, then there must be an outline
107 }
108 else
109 {
110 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_INVALID_OUTLINE );
111 wxString msg;
112
113 msg.Printf( _( "(no edges found on Edge.Cuts layer)" ) );
114
115 drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
116 drcItem->SetItems( m_board );
117
119 }
120 }
121}
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:619
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: board.h:781
VECTOR2I Centre() const
Definition: eda_rect.h:69
Represent a set of closed polygons.
bool BuildBoardPolygonOutlines(BOARD *aBoard, SHAPE_POLY_SET &aOutlines, int aErrorMax, int aChainingEpsilon, OUTLINE_ERROR_HANDLER *aErrorHandler)
Extracts the board outlines and build a closed polygon from lines, arcs and circle items on edge cut ...
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const VECTOR2I &pt)> OUTLINE_ERROR_HANDLER
@ Edge_Cuts
Definition: layer_ids.h:113
static constexpr int Millimeter2iu(double mm)

References _, BuildBoardPolygonOutlines(), EDA_RECT::Centre(), DRC_ITEM::Create(), DRCE_INVALID_OUTLINE, Edge_Cuts, BOARD::GetBoundingBox(), BOARD::GetDesignSettings(), m_board, BOARD_DESIGN_SETTINGS::m_MaxError, Millimeter2iu(), and DRC_TEST_PROVIDER::reportViolation().

Referenced by Run().

◆ testTextVars()

void DRC_TEST_PROVIDER_MISC::testTextVars ( )
private

Definition at line 256 of file drc_test_provider_misc.cpp.

257{
258 const int progressDelta = 2000;
259 int ii = 0;
260 int items = 0;
261
262 static const std::vector<KICAD_T> itemTypes = {
265 };
266
268 [&]( BOARD_ITEM* item ) -> bool
269 {
270 ++items;
271 return true;
272 } );
273
275 [&]( BOARD_ITEM* item ) -> bool
276 {
278 return false;
279
280 if( !reportProgress( ii++, items, progressDelta ) )
281 return false;
282
283 BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item );
284 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( boardItem );
285
286 wxCHECK( boardItem, false );
287
288 if( text && text->GetShownText().Matches( wxT( "*${*}*" ) ) )
289 {
290 std::shared_ptr<DRC_ITEM>drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE );
291 drcItem->SetItems( item );
292
293 reportViolation( drcItem, boardItem->GetPosition(), boardItem->GetLayer() );
294 }
295
296 return true;
297 } );
298
300 DS_DRAW_ITEM_LIST drawItems;
301
303 return;
304
305 drawItems.SetMilsToIUfactor( IU_PER_MILS );
306 drawItems.SetPageNumber( wxT( "1" ) );
307 drawItems.SetSheetCount( 1 );
308 drawItems.SetFileName( wxT( "dummyFilename" ) );
309 drawItems.SetSheetName( wxT( "dummySheet" ) );
310 drawItems.SetSheetLayer( wxT( "dummyLayer" ) );
311 drawItems.SetProject( m_board->GetProject() );
312 drawItems.BuildDrawItemsList( drawingSheet->GetPageInfo(), drawingSheet->GetTitleBlock() );
313
314 for( DS_DRAW_ITEM_BASE* item = drawItems.GetFirst(); item; item = drawItems.GetNext() )
315 {
317 break;
318
319 if( m_drcEngine->IsCancelled() )
320 return;
321
322 DS_DRAW_ITEM_TEXT* text = dynamic_cast<DS_DRAW_ITEM_TEXT*>( item );
323
324 if( text && text->GetShownText().Matches( wxT( "*${*}*" ) ) )
325 {
326 std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE );
327 drcItem->SetItems( text );
328
329 reportViolation( drcItem, text->GetPosition(), UNDEFINED_LAYER );
330 }
331 }
332}
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:170
PROJECT * GetProject() const
Definition: board.h:415
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition: drc_engine.h:97
Base class to handle basic graphic items.
Definition: ds_draw_item.h:59
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
Definition: ds_draw_item.h:383
DS_DRAW_ITEM_BASE * GetFirst()
Definition: ds_draw_item.h:498
void BuildDrawItemsList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the drawing sheet.
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
Definition: ds_draw_item.h:421
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
Definition: ds_draw_item.h:429
void SetSheetLayer(const wxString &aSheetLayer)
Set the sheet layer to draw/plot.
Definition: ds_draw_item.h:445
void SetSheetCount(int aSheetCount)
Set the value of the count of sheets, for basic inscriptions.
Definition: ds_draw_item.h:482
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
Definition: ds_draw_item.h:469
DS_DRAW_ITEM_BASE * GetNext()
Definition: ds_draw_item.h:508
void SetMilsToIUfactor(double aMils2Iu)
Set the scalar to convert pages units (mils) to draw/plot units.
Definition: ds_draw_item.h:456
void SetProject(const PROJECT *aProject)
Definition: ds_draw_item.h:406
A graphic text.
Definition: ds_draw_item.h:302
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:262
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:73
#define IU_PER_MILS
Definition: plotter.cpp:129

References LSET::AllLayersMask(), DS_DRAW_ITEM_LIST::BuildDrawItemsList(), DRC_ITEM::Create(), DRCE_UNRESOLVED_VARIABLE, DRC_TEST_PROVIDER::forEachGeometryItem(), DRC_ENGINE::GetDrawingSheet(), DS_DRAW_ITEM_LIST::GetFirst(), BOARD_ITEM::GetLayer(), DS_DRAW_ITEM_LIST::GetNext(), EDA_ITEM::GetPosition(), BOARD::GetProject(), DRC_ENGINE::IsCancelled(), DRC_ENGINE::IsErrorLimitExceeded(), IU_PER_MILS, m_board, DRC_TEST_PROVIDER::m_drcEngine, PCB_DIMENSION_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_TEXT_T, PCB_TEXTBOX_T, DRC_TEST_PROVIDER::reportProgress(), DRC_TEST_PROVIDER::reportViolation(), DS_DRAW_ITEM_LIST::SetFileName(), DS_DRAW_ITEM_LIST::SetMilsToIUfactor(), DS_DRAW_ITEM_LIST::SetPageNumber(), DS_DRAW_ITEM_LIST::SetProject(), DS_DRAW_ITEM_LIST::SetSheetCount(), DS_DRAW_ITEM_LIST::SetSheetLayer(), DS_DRAW_ITEM_LIST::SetSheetName(), text, and UNDEFINED_LAYER.

Referenced by Run().

◆ userUnits()

Member Data Documentation

◆ m_board

BOARD* DRC_TEST_PROVIDER_MISC::m_board
private

Definition at line 76 of file drc_test_provider_misc.cpp.

Referenced by Run(), testDisabledLayers(), testOutline(), and testTextVars().

◆ m_drcEngine

DRC_ENGINE* DRC_TEST_PROVIDER::m_drcEngine
protectedinherited

Definition at line 117 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(), 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_COURTYARD_CLEARANCE_ON_MOVE::Run(), DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal(), DRC_TEST_PROVIDER::SetDRCEngine(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), testAssertions(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), 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(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::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(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadClearances(), DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance(), testTextVars(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackClearances(), DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer(), DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones(), and DRC_TEST_PROVIDER::userUnits().

◆ m_isRuleDriven

◆ m_stats

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

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