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
 
virtual std::set< DRC_CONSTRAINT_TGetConstraintTypes () const override
 
int GetNumPhases () const override
 
void SetDRCEngine (DRC_ENGINE *engine)
 
virtual bool IsRuleDriven () const
 
bool IsEnabled () const
 
void Enable (bool aEnable)
 

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 wxPoint &aMarkerPos)
 
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
 
bool m_enabled = true
 
wxString m_msg
 

Static Protected Attributes

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

Private Member Functions

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

Private Attributes

BOARDm_board
 

Detailed Description

Definition at line 46 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 49 of file drc_test_provider_misc.cpp.

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

References DRC_TEST_PROVIDER::m_isRuleDriven.

◆ ~DRC_TEST_PROVIDER_MISC()

virtual DRC_TEST_PROVIDER_MISC::~DRC_TEST_PROVIDER_MISC ( )
inlinevirtual

Definition at line 55 of file drc_test_provider_misc.cpp.

56  {
57  }

Member Function Documentation

◆ accountCheck() [1/2]

void DRC_TEST_PROVIDER::accountCheck ( const DRC_RULE ruleToTest)
protectedvirtualinherited

Definition at line 103 of file drc_test_provider.cpp.

104 {
105  auto it = m_stats.find( ruleToTest );
106 
107  if( it == m_stats.end() )
108  m_stats[ ruleToTest ] = 1;
109  else
110  m_stats[ ruleToTest ] += 1;
111 }
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().

◆ accountCheck() [2/2]

void DRC_TEST_PROVIDER::accountCheck ( const DRC_CONSTRAINT constraintToTest)
protectedvirtualinherited

Definition at line 114 of file drc_test_provider.cpp.

115 {
116  accountCheck( constraintToTest.GetParentRule() );
117 }
DRC_RULE * GetParentRule() const
Definition: drc_rule.h:126
virtual void accountCheck(const DRC_RULE *ruleToTest)

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

◆ Enable()

void DRC_TEST_PROVIDER::Enable ( bool  aEnable)
inlineinherited

Definition at line 106 of file drc_test_provider.h.

107  {
108  m_enabled = aEnable;
109  }

References DRC_TEST_PROVIDER::m_enabled.

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

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

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_ZONE_T, PCB_GROUP_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, DRC_TEST_PROVIDER::s_allBasicItems, DRC_TEST_PROVIDER::s_allBasicItemsButZones, BOARD::Tracks(), and BOARD::Zones().

Referenced by DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_SILK_TO_MASK::Run(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run(), DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal(), testDisabledLayers(), and testTextVars().

◆ GetConstraintTypes()

std::set< DRC_CONSTRAINT_T > DRC_TEST_PROVIDER_MISC::GetConstraintTypes ( ) const
overridevirtual

Implements DRC_TEST_PROVIDER.

Definition at line 293 of file drc_test_provider_misc.cpp.

294 {
295  return {};
296 }

◆ GetDescription()

virtual const wxString DRC_TEST_PROVIDER_MISC::GetDescription ( ) const
inlineoverridevirtual

Reimplemented from DRC_TEST_PROVIDER.

Definition at line 66 of file drc_test_provider_misc.cpp.

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

◆ GetName()

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

Reimplemented from DRC_TEST_PROVIDER.

Definition at line 61 of file drc_test_provider_misc.cpp.

62  {
63  return "miscellaneous";
64  };

◆ GetNumPhases()

int DRC_TEST_PROVIDER_MISC::GetNumPhases ( ) const
overridevirtual

Implements DRC_TEST_PROVIDER.

Definition at line 287 of file drc_test_provider_misc.cpp.

288 {
289  return 3;
290 }

◆ IsEnabled()

bool DRC_TEST_PROVIDER::IsEnabled ( ) const
inlineinherited

Definition at line 101 of file drc_test_provider.h.

102  {
103  return m_enabled;
104  }

References DRC_TEST_PROVIDER::m_enabled.

◆ isInvisibleText()

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

Definition at line 327 of file drc_test_provider.cpp.

328 {
329 
330  if( const FP_TEXT* text = dyn_cast<const FP_TEXT*>( aItem ) )
331  {
332  if( !text->IsVisible() )
333  return true;
334  }
335 
336  if( const PCB_TEXT* text = dyn_cast<const PCB_TEXT*>( aItem ) )
337  {
338  if( !text->IsVisible() )
339  return true;
340  }
341 
342  return false;
343 }

References text.

Referenced by DRC_TEST_PROVIDER_SILK_TO_MASK::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), and DRC_TEST_PROVIDER_SILK_CLEARANCE::Run().

◆ IsRuleDriven()

virtual bool DRC_TEST_PROVIDER::IsRuleDriven ( ) const
inlinevirtualinherited

Definition at line 96 of file drc_test_provider.h.

97  {
98  return m_isRuleDriven;
99  }

References DRC_TEST_PROVIDER::m_isRuleDriven.

◆ reportAux()

◆ reportPhase()

◆ reportProgress()

◆ reportRuleStatistics()

void DRC_TEST_PROVIDER::reportRuleStatistics ( )
protectedvirtualinherited

Definition at line 120 of file drc_test_provider.cpp.

121 {
122  if( !m_isRuleDriven )
123  return;
124 
125  m_drcEngine->ReportAux( "Rule hit statistics: " );
126 
127  for( const std::pair<const DRC_RULE* const, int>& stat : m_stats )
128  {
129  if( stat.first )
130  {
131  m_drcEngine->ReportAux( wxString::Format( " - rule '%s': %d hits ",
132  stat.first->m_Name,
133  stat.second ) );
134  }
135  }
136 }
std::unordered_map< const DRC_RULE *, int > m_stats
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
void ReportAux(const wxString &aStr)
DRC_ENGINE * m_drcEngine

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_VIA_DIAMETER::Run(), DRC_TEST_PROVIDER_TRACK_WIDTH::Run(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_HOLE_SIZE::Run(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTIVITY::Run(), DRC_TEST_PROVIDER_SILK_TO_MASK::Run(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run(), DRC_TEST_PROVIDER_LVS::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run(), and DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal().

◆ reportViolation()

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

Definition at line 56 of file drc_test_provider.cpp.

58 {
59  if( item->GetViolatingRule() )
60  accountCheck( item->GetViolatingRule() );
61 
62  item->SetViolatingTest( this );
63  m_drcEngine->ReportViolation( item, aMarkerPos );
64 }
virtual void accountCheck(const DRC_RULE *ruleToTest)
DRC_ENGINE * m_drcEngine
void ReportViolation(const std::shared_ptr< DRC_ITEM > &aItem, const wxPoint &aPos)

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::checkPad(), DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkews(), DRC_TEST_PROVIDER_HOLE_SIZE::checkVia(), DRC_TEST_PROVIDER_MATCHED_LENGTH::checkViaCounts(), DRC_TEST_PROVIDER_VIA_DIAMETER::Run(), DRC_TEST_PROVIDER_TRACK_WIDTH::Run(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTIVITY::Run(), DRC_TEST_PROVIDER_SILK_TO_MASK::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), testDisabledLayers(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testFootprintCourtyardDefinitions(), DRC_TEST_PROVIDER_LVS::testFootprints(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZones(), testOutline(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), testTextVars(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem(), 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 255 of file drc_test_provider_misc.cpp.

256 {
258 
260  {
261  if( !reportPhase( _( "Checking board outline..." ) ) )
262  return false; // DRC cancelled
263 
264  testOutline();
265  }
266 
268  {
269  if( !reportPhase( _( "Checking disabled layers..." ) ) )
270  return false; // DRC cancelled
271 
273  }
274 
276  {
277  if( !reportPhase( _( "Checking text variables..." ) ) )
278  return false; // DRC cancelled
279 
280  testTextVars();
281  }
282 
283  return true;
284 }
bool IsErrorLimitExceeded(int error_code)
BOARD * GetBoard() const
Definition: drc_engine.h:88
virtual bool reportPhase(const wxString &aStageName)
#define _(s)
DRC_ENGINE * m_drcEngine

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

◆ SetDRCEngine()

void DRC_TEST_PROVIDER::SetDRCEngine ( DRC_ENGINE engine)
inlineinherited

Definition at line 78 of file drc_test_provider.h.

79  {
80  m_drcEngine = engine;
81  m_stats.clear();
82  }
std::unordered_map< const DRC_RULE *, int > m_stats
DRC_ENGINE * m_drcEngine

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

◆ testDisabledLayers()

void DRC_TEST_PROVIDER_MISC::testDisabledLayers ( )
private

Definition at line 127 of file drc_test_provider_misc.cpp.

128 {
129  LSET disabledLayers = m_board->GetEnabledLayers().flip();
130 
131  // Perform the test only for copper layers
132  disabledLayers &= LSET::AllCuMask();
133 
134  auto checkDisabledLayers =
135  [&]( BOARD_ITEM* item ) -> bool
136  {
137  PCB_LAYER_ID badLayer = UNDEFINED_LAYER;
138 
139  if( item->Type() == PCB_PAD_T )
140  {
141  PAD* pad = static_cast<PAD*>( item );
142 
143  if( pad->GetAttribute() == PAD_ATTRIB::SMD
144  || pad->GetAttribute() == PAD_ATTRIB::CONN )
145  {
146  if( disabledLayers.test( item->GetLayer() ) )
147  badLayer = item->GetLayer();
148  }
149  else
150  {
151  // Through hole pad is on whatever layers there are.
152  }
153  }
154  else if( item->Type() == PCB_VIA_T )
155  {
156  PCB_VIA* via = static_cast<PCB_VIA*>( item );
157  PCB_LAYER_ID top;
158  PCB_LAYER_ID bottom;
159 
160  via->LayerPair( &top, &bottom );
161 
162  if( disabledLayers.test( top ) )
163  badLayer = top;
164  else if( disabledLayers.test( bottom ) )
165  badLayer = bottom;
166  }
167  else if( item->Type() == PCB_FP_ZONE_T )
168  {
169  // Footprint zones just get a top/bottom/inner setting, so they're on
170  // whatever inner layers there are.
171  }
172  else
173  {
174  LSET badLayers = disabledLayers & item->GetLayerSet();
175 
176  if( badLayers.any() )
177  badLayer = badLayers.Seq().front();
178  }
179 
180  if( badLayer != UNDEFINED_LAYER )
181  {
182  std::shared_ptr<DRC_ITEM>drcItem = DRC_ITEM::Create( DRCE_DISABLED_LAYER_ITEM );
183 
184  m_msg.Printf( _( "(layer %s)" ), LayerName( badLayer ) );
185 
186  drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
187  drcItem->SetItems( item );
188 
189  reportViolation( drcItem, item->GetPosition() );
190  }
191 
192  return true;
193  };
194 
195  forEachGeometryItem( s_allBasicItems, LSET::AllLayersMask(), checkDisabledLayers );
196 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:266
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const wxPoint &aMarkerPos)
Like smd, does not appear on the solder paste layer (default)
Smd pad, appears on the solder paste layer (default)
class PAD, a pad in a footprint
Definition: typeinfo.h:89
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:467
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
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:505
#define _(s)
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
Definition: layer_id.cpp:27
static LSET AllLayersMask()
Definition: lset.cpp:796
int forEachGeometryItem(const std::vector< KICAD_T > &aTypes, LSET aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
static std::vector< KICAD_T > s_allBasicItems
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
class ZONE, managed by a footprint
Definition: typeinfo.h:94
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
Definition: pad.h:57

References _, LSET::AllCuMask(), LSET::AllLayersMask(), CONN, DRC_ITEM::Create(), DRCE_DISABLED_LAYER_ITEM, DRC_TEST_PROVIDER::forEachGeometryItem(), BOARD::GetEnabledLayers(), LayerName(), m_board, DRC_TEST_PROVIDER::m_msg, pad, PCB_FP_ZONE_T, PCB_PAD_T, PCB_VIA_T, 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 84 of file drc_test_provider_misc.cpp.

85 {
86  SHAPE_POLY_SET dummyOutline;
87  bool errorHandled = false;
88 
89  OUTLINE_ERROR_HANDLER errorHandler =
90  [&]( const wxString& msg, BOARD_ITEM* itemA, BOARD_ITEM* itemB, const wxPoint& pt )
91  {
92  std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_INVALID_OUTLINE );
93 
94  drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
95  drcItem->SetItems( itemA, itemB );
96 
97  reportViolation( drcItem, pt );
98  errorHandled = true;
99  };
100 
101  // Use a really tight chaining epsilon here so that we report errors that might affect
102  // other tools (such as STEP export).
103  constexpr int chainingEpsilon = Millimeter2iu( 0.02 ) / 100;
104 
106  chainingEpsilon, &errorHandler ) )
107  {
108  if( errorHandled )
109  {
110  // if there is an invalid outline, then there must be an outline
111  }
112  else
113  {
114  std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_INVALID_OUTLINE );
115 
116  m_msg.Printf( _( "(no edges found on Edge.Cuts layer)" ) );
117 
118  drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
119  drcItem->SetItems( m_board );
120 
121  reportViolation( drcItem, m_board->GetBoundingBox().Centre() );
122  }
123  }
124 }
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: board.h:724
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:266
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const wxPoint &aMarkerPos)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
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 ...
Represent a set of closed polygons.
#define _(s)
wxPoint Centre() const
Definition: eda_rect.h:55
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const wxPoint &pt)> OUTLINE_ERROR_HANDLER
static constexpr int Millimeter2iu(double mm)

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

Referenced by Run().

◆ testTextVars()

void DRC_TEST_PROVIDER_MISC::testTextVars ( )
private

Definition at line 199 of file drc_test_provider_misc.cpp.

200 {
201  auto checkUnresolvedTextVar =
202  [&]( EDA_ITEM* item ) -> bool
203  {
205  return false;
206 
207  EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( item );
208 
209  if( text && text->GetShownText().Matches( wxT( "*${*}*" ) ) )
210  {
211  std::shared_ptr<DRC_ITEM>drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE );
212  drcItem->SetItems( item );
213 
214  reportViolation( drcItem, item->GetPosition() );
215  }
216  return true;
217  };
218 
220  checkUnresolvedTextVar );
221 
223  DS_DRAW_ITEM_LIST drawItems;
224 
226  return;
227 
228  drawItems.SetMilsToIUfactor( IU_PER_MILS );
229  drawItems.SetPageNumber( "1" );
230  drawItems.SetSheetCount( 1 );
231  drawItems.SetFileName( "dummyFilename" );
232  drawItems.SetSheetName( "dummySheet" );
233  drawItems.SetSheetLayer( "dummyLayer" );
234  drawItems.SetProject( m_board->GetProject() );
235  drawItems.BuildDrawItemsList( drawingSheet->GetPageInfo(), drawingSheet->GetTitleBlock() );
236 
237  for( DS_DRAW_ITEM_BASE* item = drawItems.GetFirst(); item; item = drawItems.GetNext() )
238  {
240  break;
241 
242  DS_DRAW_ITEM_TEXT* text = dynamic_cast<DS_DRAW_ITEM_TEXT*>( item );
243 
244  if( text && text->GetShownText().Matches( wxT( "*${*}*" ) ) )
245  {
246  std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE );
247  drcItem->SetItems( text );
248 
249  reportViolation( drcItem, text->GetPosition() );
250  }
251  }
252 }
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition: drc_engine.h:97
static std::shared_ptr< DRC_ITEM > Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:266
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
void SetMilsToIUfactor(double aMils2Iu)
Set the scalar to convert pages units (mils) to draw/plot units.
Definition: ds_draw_item.h:442
virtual void reportViolation(std::shared_ptr< DRC_ITEM > &item, const wxPoint &aMarkerPos)
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
Definition: ds_draw_item.h:415
bool IsErrorLimitExceeded(int error_code)
PROJECT * GetProject() const
Definition: board.h:361
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:140
Base class to handle basic graphic items.
Definition: ds_draw_item.h:58
A graphic text.
Definition: ds_draw_item.h:297
DS_DRAW_ITEM_BASE * GetNext()
Definition: ds_draw_item.h:494
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
Definition: ds_draw_item.h:455
static LSET AllLayersMask()
Definition: lset.cpp:796
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
Definition: ds_draw_item.h:423
int forEachGeometryItem(const std::vector< KICAD_T > &aTypes, LSET aLayers, const std::function< bool(BOARD_ITEM *)> &aFunc)
void BuildDrawItemsList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the drawing sheet.
void SetSheetLayer(const wxString &aSheetLayer)
Set the sheet layer to draw/plot.
Definition: ds_draw_item.h:431
DRC_ENGINE * m_drcEngine
void SetProject(const PROJECT *aProject)
Definition: ds_draw_item.h:400
#define IU_PER_MILS
Definition: plotter.cpp:136
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
void SetSheetCount(int aSheetCount)
Set the value of the count of sheets, for basic inscriptions.
Definition: ds_draw_item.h:468
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
Definition: ds_draw_item.h:376
DS_DRAW_ITEM_BASE * GetFirst()
Definition: ds_draw_item.h:484

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(), DS_DRAW_ITEM_LIST::GetNext(), BOARD::GetProject(), DRC_ENGINE::IsErrorLimitExceeded(), IU_PER_MILS, m_board, DRC_TEST_PROVIDER::m_drcEngine, PCB_FP_TEXT_T, PCB_TEXT_T, 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(), and text.

Referenced by Run().

◆ userUnits()

Member Data Documentation

◆ m_board

BOARD* DRC_TEST_PROVIDER_MISC::m_board
private

Definition at line 80 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 131 of file drc_test_provider.h.

Referenced by DRC_TEST_PROVIDER_HOLE_SIZE::checkPad(), DRC_TEST_PROVIDER_HOLE_SIZE::checkVia(), DRC_TEST_PROVIDER::forEachGeometryItem(), DRC_TEST_PROVIDER_LVS::GetNumPhases(), DRC_TEST_PROVIDER::reportAux(), DRC_TEST_PROVIDER::reportPhase(), DRC_TEST_PROVIDER::reportProgress(), DRC_TEST_PROVIDER::reportRuleStatistics(), DRC_TEST_PROVIDER::reportViolation(), DRC_TEST_PROVIDER_VIA_DIAMETER::Run(), DRC_TEST_PROVIDER_TRACK_WIDTH::Run(), DRC_TEST_PROVIDER_DISALLOW::Run(), DRC_TEST_PROVIDER_HOLE_SIZE::Run(), DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run(), DRC_TEST_PROVIDER_CONNECTIVITY::Run(), DRC_TEST_PROVIDER_SILK_TO_MASK::Run(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::Run(), Run(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run(), DRC_TEST_PROVIDER_SILK_CLEARANCE::Run(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::Run(), DRC_TEST_PROVIDER_LVS::Run(), test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run(), DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal(), DRC_TEST_PROVIDER::SetDRCEngine(), DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances(), DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testFootprintCourtyardDefinitions(), DRC_TEST_PROVIDER_LVS::testFootprints(), DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZones(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem(), testTextVars(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem(), DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones(), and DRC_TEST_PROVIDER::userUnits().

◆ m_enabled

bool DRC_TEST_PROVIDER::m_enabled = true
protectedinherited

Definition at line 134 of file drc_test_provider.h.

Referenced by DRC_TEST_PROVIDER::Enable(), and DRC_TEST_PROVIDER::IsEnabled().

◆ m_isRuleDriven

◆ m_msg

◆ m_stats

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

◆ s_allBasicItems

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

◆ s_allBasicItemsButZones

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

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