48#define ERROR_LIMIT 199
49#define EXTENDED_ERROR_LIMIT 499
56 if( wxGetEnv( wxT(
"DRC_DEBUG" ), &valueStr ) )
58 int setLevel = wxAtoi( valueStr );
60 if( level <= setLevel )
61 printf(
"%-30s:%d | %s\n", function, line, (
const char *) msg.c_str() );
68 m_designSettings ( aSettings ),
70 m_drawingSheet( nullptr ),
71 m_schematicNetlist( nullptr ),
72 m_rulesValid( false ),
73 m_reportAllTrackErrors( false ),
74 m_testFootprints( false ),
75 m_reporter( nullptr ),
76 m_progressReporter( nullptr )
104 const ZONE* zone =
static_cast<const ZONE*
>( aItem );
127 std::shared_ptr<DRC_RULE> rule = std::make_shared<DRC_RULE>();
130 rule->m_Implicit =
true;
140 ReportAux( wxString::Format( wxT(
"Building implicit rules (per-item/class overrides, etc...)" ) ) );
150 rule->AddConstraint( widthConstraint );
154 rule->AddConstraint( connectionConstraint );
158 rule->AddConstraint( drillConstraint );
162 rule->AddConstraint( annulusConstraint );
166 rule->AddConstraint( diameterConstraint );
170 rule->AddConstraint( holeToHoleConstraint );
175 rule->AddConstraint( thermalSpokeCountConstraint );
181 rule->AddConstraint( silkClearanceConstraint );
187 rule->AddConstraint( silkTextHeightConstraint );
193 rule->AddConstraint( silkTextThicknessConstraint );
198 rule->AddConstraint( holeClearanceConstraint );
203 rule->AddConstraint( edgeClearanceConstraint );
208 rule->AddConstraint( courtyardClearanceConstraint );
212 std::shared_ptr<DRC_RULE> uViaRule =
createImplicitRule(
_(
"board setup micro-via constraints" ) );
218 uViaRule->AddConstraint( uViaDrillConstraint );
222 uViaRule->AddConstraint( uViaDiameterConstraint );
226 std::vector<std::shared_ptr<DRC_RULE>> netclassClearanceRules;
227 std::vector<std::shared_ptr<DRC_RULE>> netclassItemSpecificRules;
229 auto makeNetclassRules =
230 [&](
const std::shared_ptr<NETCLASS>& nc,
bool isDefault )
232 wxString ncName = nc->GetName();
235 if( nc->GetClearance() || nc->GetTrackWidth() )
237 std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
238 netclassRule->m_Name = wxString::Format(
_(
"netclass '%s'" ), ncName );
239 netclassRule->m_Implicit =
true;
241 expr = wxString::Format( wxT(
"A.NetClass == '%s'" ), ncName );
243 netclassClearanceRules.push_back( netclassRule );
245 if( nc->GetClearance() )
249 netclassRule->AddConstraint( constraint );
252 if( nc->GetTrackWidth() )
257 netclassRule->AddConstraint( constraint );
261 if( nc->GetDiffPairWidth() )
263 std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
264 netclassRule->m_Name = wxString::Format(
_(
"netclass '%s' (diff pair)" ),
266 netclassRule->m_Implicit =
true;
268 expr = wxString::Format( wxT(
"A.NetClass == '%s' && A.inDiffPair('*')" ),
271 netclassItemSpecificRules.push_back( netclassRule );
275 constraint.
Value().
SetOpt( nc->GetDiffPairWidth() );
276 netclassRule->AddConstraint( constraint );
279 if( nc->GetDiffPairGap() )
281 std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
282 netclassRule->m_Name = wxString::Format(
_(
"netclass '%s' (diff pair)" ),
284 netclassRule->m_Implicit =
true;
286 expr = wxString::Format( wxT(
"A.NetClass == '%s'" ), ncName );
288 netclassItemSpecificRules.push_back( netclassRule );
293 netclassRule->AddConstraint( constraint );
296 if( nc->GetDiffPairGap() < nc->GetClearance() )
298 netclassRule = std::make_shared<DRC_RULE>();
299 netclassRule->m_Name = wxString::Format(
_(
"netclass '%s' (diff pair)" ),
301 netclassRule->m_Implicit =
true;
303 expr = wxString::Format( wxT(
"A.NetClass == '%s' && AB.isCoupledDiffPair()" ),
306 netclassItemSpecificRules.push_back( netclassRule );
309 min_clearanceConstraint.
Value().
SetMin( nc->GetDiffPairGap() );
310 netclassRule->AddConstraint( min_clearanceConstraint );
314 if( nc->GetViaDiameter() || nc->GetViaDrill() )
316 std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
317 netclassRule->m_Name = wxString::Format(
_(
"netclass '%s'" ), ncName );
318 netclassRule->m_Implicit =
true;
320 expr = wxString::Format( wxT(
"A.NetClass == '%s' && A.Via_Type != 'Micro'" ),
323 netclassItemSpecificRules.push_back( netclassRule );
325 if( nc->GetViaDiameter() )
330 netclassRule->AddConstraint( constraint );
333 if( nc->GetViaDrill() )
338 netclassRule->AddConstraint( constraint );
342 if( nc->GetuViaDiameter() || nc->GetuViaDrill() )
344 std::shared_ptr<DRC_RULE> netclassRule = std::make_shared<DRC_RULE>();
345 netclassRule->m_Name = wxString::Format(
_(
"netclass '%s' (uvia)" ), ncName );
346 netclassRule->m_Implicit =
true;
348 expr = wxString::Format( wxT(
"A.NetClass == '%s' && A.Via_Type == 'Micro'" ),
351 netclassItemSpecificRules.push_back( netclassRule );
353 if( nc->GetuViaDiameter() )
357 constraint.
Value().
SetMin( nc->GetuViaDiameter() );
358 netclassRule->AddConstraint( constraint );
361 if( nc->GetuViaDrill() )
366 netclassRule->AddConstraint( constraint );
372 makeNetclassRules( bds.
m_NetSettings->m_DefaultNetClass,
true );
375 makeNetclassRules( netclass,
false );
382 std::sort( netclassClearanceRules.begin(), netclassClearanceRules.end(),
383 [](
const std::shared_ptr<DRC_RULE>& lhs,
const std::shared_ptr<DRC_RULE>& rhs )
385 return lhs->m_Constraints[0].m_Value.Min()
386 < rhs->m_Constraints[0].m_Value.Min();
389 for( std::shared_ptr<DRC_RULE>& ncRule : netclassClearanceRules )
392 for( std::shared_ptr<DRC_RULE>& ncRule : netclassItemSpecificRules )
397 std::vector<ZONE*> keepoutZones;
402 keepoutZones.push_back( zone );
407 for(
ZONE* zone : footprint->Zones() )
410 keepoutZones.push_back( zone );
414 for(
ZONE* zone : keepoutZones )
416 wxString
name = zone->GetZoneName();
423 rule->m_ImplicitItemId = zone->m_Uuid;
425 rule->m_Condition =
new DRC_RULE_CONDITION( wxString::Format( wxT(
"A.intersectsArea('%s')" ),
426 zone->m_Uuid.AsString() ) );
428 rule->m_LayerCondition = zone->GetLayerSet();
430 int disallowFlags = 0;
432 if( zone->GetDoNotAllowTracks() )
435 if( zone->GetDoNotAllowVias() )
438 if( zone->GetDoNotAllowPads() )
441 if( zone->GetDoNotAllowCopperPour() )
444 if( zone->GetDoNotAllowFootprints() )
449 rule->AddConstraint( disallowConstraint );
452 ReportAux( wxString::Format( wxT(
"Building %d implicit netclass rules" ),
453 (
int) netclassClearanceRules.size() ) );
459 if( aPath.FileExists() )
461 std::vector<std::shared_ptr<DRC_RULE>> rules;
463 FILE* fp = wxFopen( aPath.GetFullPath(), wxT(
"rt" ) );
474 for( std::shared_ptr<DRC_RULE>& rule : rules )
482 ReportAux( wxString::Format( wxT(
"Compiling Rules (%d rules): " ), (
int)
m_rules.size() ) );
484 for( std::shared_ptr<DRC_RULE>& rule :
m_rules )
488 if( rule->m_Condition && !rule->m_Condition->GetExpression().IsEmpty() )
490 condition = rule->m_Condition;
501 engineConstraint->
layerTest = rule->m_LayerCondition;
517 ReportAux( wxString::Format( wxT(
"Create DRC provider: '%s'" ), provider->GetName() ) );
518 provider->SetDRCEngine(
this );
551 wxFAIL_MSG( wxT(
"Compiling implicit rules failed." ) );
554 throw original_parse_error;
588 if( !cacheGenerator.
Run() )
595 ReportAux( wxString::Format( wxT(
"Run DRC provider: '%s'" ), provider->GetName() ) );
597 if( !provider->RunTests( aUnits ) )
607#define REPORT( s ) { if( aReporter ) { aReporter->Report( s ); } }
615 REPORT( wxString::Format(
_(
"Resolved zone connection type: %s." ),
623 pad =
static_cast<const PAD*
>( a );
625 pad =
static_cast<const PAD*
>( b );
627 if(
pad &&
pad->GetAttribute() == PAD_ATTRIB::PTH )
633 REPORT( wxString::Format(
_(
"Pad is not a through hole pad; connection will be: %s." ),
648 switch( aItem->
Type() )
655 const PAD*
pad =
static_cast<const PAD*
>( aItem );
657 return pad->GetDrillSizeX() ==
pad->GetDrillSizeY();
684 const ZONE* zone =
nullptr;
685 const FOOTPRINT* parentFootprint =
nullptr;
692 pad =
static_cast<const PAD*
>( a );
694 zone =
static_cast<const ZONE*
>( a );
697 pad =
static_cast<const PAD*
>( b );
699 zone =
static_cast<const ZONE*
>( b );
702 parentFootprint =
pad->GetParentFootprint();
706 constraint.
m_Type = aConstraintType;
708 auto applyConstraint =
711 if( c->constraint.m_Value.HasMin() )
714 if( c->constraint.m_Value.HasOpt() )
717 if( c->constraint.m_Value.HasMax() )
718 constraint .m_Value.SetMax( c->constraint.m_Value.Max() );
733 int override_val = 0;
737 if( ac && !b_is_non_copper )
740 if( bc && !a_is_non_copper )
743 if( overrideA > 0 || overrideB > 0 )
750 REPORT( wxString::Format(
_(
"Local override on %s; clearance: %s." ),
760 REPORT( wxString::Format(
_(
"Local override on %s; clearance: %s." ),
764 if( overrideB > override_val )
772 if( override_val < m_designSettings->m_MinClearance )
775 msg =
_(
"board minimum" );
778 REPORT( wxString::Format(
_(
"Board minimum clearance: %s." ),
784 if( override_val < m_designSettings->m_HoleClearance )
787 msg =
_(
"board minimum hole" );
790 REPORT( wxString::Format(
_(
"Board minimum hole clearance: %s." ),
803 if(
pad &&
pad->GetLocalZoneConnectionOverride(
nullptr ) != ZONE_CONNECTION::INHERITED )
809 REPORT( wxString::Format(
_(
"Local override on %s; zone connection: %s." ),
820 if(
pad &&
pad->GetLocalThermalGapOverride(
nullptr ) > 0 )
823 int gap_override =
pad->GetLocalThermalGapOverride( &msg );
826 REPORT( wxString::Format(
_(
"Local override on %s; thermal relief gap: %s." ),
837 if(
pad &&
pad->GetLocalSpokeWidthOverride(
nullptr ) > 0 )
840 int spoke_override =
pad->GetLocalSpokeWidthOverride( &msg );
843 REPORT( wxString::Format(
_(
"Local override on %s; thermal spoke width: %s." ),
852 REPORT( wxString::Format(
_(
"%s min thickness: %s." ),
866 REPORT( wxString::Format(
_(
"Checking assertion \"%s\"." ),
867 EscapeHTML( c->constraint.m_Test->GetExpression() ) ) )
869 if( c->constraint.m_Test->EvaluateFor( a, b, c->constraint.m_Type, aLayer,
872 REPORT(
_(
"Assertion passed." ) )
880 auto processConstraint =
883 bool implicit = c->parentRule && c->parentRule->m_Implicit;
887 switch( c->constraint.m_Type )
896 REPORT( wxString::Format(
_(
"Checking %s clearance: %s." ),
902 REPORT( wxString::Format(
_(
"Checking %s max uncoupled length: %s." ),
908 REPORT( wxString::Format(
_(
"Checking %s max skew: %s." ),
914 REPORT( wxString::Format(
_(
"Checking %s gap: %s." ),
920 REPORT( wxString::Format(
_(
"Checking %s thermal spoke width: %s." ),
926 REPORT( wxString::Format(
_(
"Checking %s min spoke count: %s." ),
929 c->constraint.m_Value.Min() ) ) )
933 REPORT( wxString::Format(
_(
"Checking %s zone connection: %s." ),
951 wxString min = wxT(
"<i>" ) +
_(
"undefined" ) + wxT(
"</i>" );
952 wxString opt = wxT(
"<i>" ) +
_(
"undefined" ) + wxT(
"</i>" );
953 wxString max = wxT(
"<i>" ) +
_(
"undefined" ) + wxT(
"</i>" );
960 switch( c->constraint.m_Type )
963 if( c->constraint.m_Value.HasOpt() )
965 REPORT( wxString::Format(
_(
"Checking %s track width: opt %s." ),
969 else if( c->constraint.m_Value.HasMin() )
971 REPORT( wxString::Format(
_(
"Checking %s track width: min %s." ),
979 REPORT( wxString::Format(
_(
"Checking %s annular width: min %s." ),
985 if( c->constraint.m_Value.HasOpt() )
987 REPORT( wxString::Format(
_(
"Checking %s via diameter: opt %s." ),
991 else if( c->constraint.m_Value.HasMin() )
993 REPORT( wxString::Format(
_(
"Checking %s via diameter: min %s." ),
1000 if( c->constraint.m_Value.HasOpt() )
1002 REPORT( wxString::Format(
_(
"Checking %s hole size: opt %s." ),
1006 else if( c->constraint.m_Value.HasMin() )
1008 REPORT( wxString::Format(
_(
"Checking %s hole size: min %s." ),
1018 REPORT( wxString::Format(
_(
"Checking %s: min %s." ),
1024 if( c->constraint.m_Value.HasOpt() )
1026 REPORT( wxString::Format(
_(
"Checking %s diff pair gap: opt %s." ),
1030 else if( c->constraint.m_Value.HasMin() )
1032 REPORT( wxString::Format(
_(
"Checking %s clearance: min %s." ),
1040 REPORT( wxString::Format(
_(
"Checking %s hole to hole: min %s." ),
1046 REPORT( wxString::Format(
_(
"Checking %s." ),
1052 if( c->constraint.m_Value.HasMin() )
1055 if( c->constraint.m_Value.HasOpt() )
1058 if( c->constraint.m_Value.HasMax() )
1061 REPORT( wxString::Format(
_(
"Checking %s: min %s; opt %s; max %s." ),
1072 REPORT( wxString::Format(
_(
"Checking %s." ),
1078 if( a_is_non_copper || b_is_non_copper )
1082 REPORT(
_(
"Netclass clearances apply only between copper items." ) )
1084 else if( a_is_non_copper )
1086 REPORT( wxString::Format(
_(
"%s contains no copper. Rule ignored." ),
1089 else if( b_is_non_copper )
1091 REPORT( wxString::Format(
_(
"%s contains no copper. Rule ignored." ),
1110 switch(
static_cast<const PCB_VIA*
>( a )->GetViaType() )
1132 if(
static_cast<const ZONE*
>( a )->IsTeardropArea() )
1140 default: mask = 0;
break;
1144 if( ( c->constraint.m_DisallowFlags & mask ) == 0 )
1147 REPORT(
_(
"Keepout constraint not met." ) )
1149 REPORT(
_(
"Disallow constraint not met." ) )
1167 if( !( c->layerTest & itemLayers ).any() )
1171 REPORT(
_(
"Keepout layer(s) not matched." ) )
1173 else if( c->parentRule )
1175 REPORT( wxString::Format(
_(
"Rule layer '%s' not matched; rule ignored." ),
1176 EscapeHTML( c->parentRule->m_LayerSource ) ) )
1180 REPORT(
_(
"Rule layer not matched; rule ignored." ) )
1192 REPORT(
_(
"Constraint layer not matched." ) )
1194 else if( c->parentRule )
1196 REPORT( wxString::Format(
_(
"Rule layer '%s' not matched; rule ignored." ),
1197 EscapeHTML( c->parentRule->m_LayerSource ) ) )
1201 REPORT(
_(
"Rule layer not matched; rule ignored." ) )
1212 REPORT( wxString::Format(
_(
"%s is not a drilled hole; rule ignored." ),
1216 else if( !c->condition || c->condition->GetExpression().IsEmpty() )
1222 REPORT(
_(
"Unconditional constraint applied." ) )
1226 REPORT(
_(
"Unconditional rule applied." ) )
1231 REPORT(
_(
"Unconditional rule applied; overrides previous constraints." ) )
1235 applyConstraint( c );
1245 REPORT( wxString::Format(
_(
"Checking rule condition \"%s\"." ),
1246 EscapeHTML( c->condition->GetExpression() ) ) )
1249 if( c->condition->EvaluateFor( a, b, c->constraint.m_Type, aLayer, aReporter ) )
1255 REPORT(
_(
"Constraint applied." ) )
1259 REPORT(
_(
"Rule applied." ) )
1264 REPORT(
_(
"Rule applied; overrides previous constraints." ) )
1268 applyConstraint( c );
1272 REPORT( implicit ?
_(
"Membership not satisfied; constraint ignored." )
1273 :
_(
"Condition not satisfied; rule ignored." ) )
1280 std::vector<DRC_ENGINE_CONSTRAINT*>* ruleset =
m_constraintMap[ aConstraintType ];
1282 for(
int ii = 0; ii < (int) ruleset->size(); ++ii )
1283 processConstraint( ruleset->at( ii ) );
1298 a = parentFootprint;
1300 b = parentFootprint;
1304 std::vector<DRC_ENGINE_CONSTRAINT*>* ruleset =
m_constraintMap[ aConstraintType ];
1306 for(
int ii = 0; ii < (int) ruleset->size(); ++ii )
1307 processConstraint( ruleset->at( ii ) );
1322 int clearance = global;
1323 bool needBlankLine =
true;
1330 needBlankLine =
false;
1333 REPORT( wxString::Format(
_(
"Local clearance on %s: %s." ),
1337 if( localA > clearance )
1352 needBlankLine =
false;
1355 REPORT( wxString::Format(
_(
"Local clearance on %s: %s." ),
1359 if( localB > clearance )
1369 if( !a_is_non_copper && !b_is_non_copper )
1374 needBlankLine =
false;
1377 REPORT( wxString::Format(
_(
"Board minimum clearance: %s." ),
1380 if( clearance < m_designSettings->m_MinClearance )
1383 constraint.
SetName(
_(
"board minimum" ) );
1393 REPORT( wxString::Format(
_(
"Board minimum clearance: %s." ),
1399 constraint.
SetName(
_(
"board minimum" ) );
1407 if(
pad && parentFootprint )
1411 if( local != ZONE_CONNECTION::INHERITED )
1414 REPORT( wxString::Format(
_(
"%s zone connection: %s." ),
1419 constraint.
SetName(
_(
"footprint" ) );
1430 REPORT( wxString::Format(
_(
"%s pad connection: %s." ),
1447 REPORT( wxString::Format(
_(
"%s thermal relief gap: %s." ),
1464 REPORT( wxString::Format(
_(
"%s thermal spoke width: %s." ),
1494 auto testAssertion =
1497 REPORT( wxString::Format(
_(
"Checking rule assertion \"%s\"." ),
1498 EscapeHTML( c->constraint.m_Test->GetExpression() ) ) )
1500 if( c->constraint.m_Test->EvaluateFor( a,
nullptr, c->constraint.m_Type,
1503 REPORT(
_(
"Assertion passed." ) )
1508 aFailureHandler( &c->constraint );
1512 auto processConstraint =
1516 REPORT( wxString::Format(
_(
"Checking %s." ), c->constraint.GetName() ) )
1520 REPORT( wxString::Format(
_(
"Rule layer '%s' not matched; rule ignored." ),
1521 EscapeHTML( c->parentRule->m_LayerSource ) ) )
1524 if( !c->condition || c->condition->GetExpression().IsEmpty() )
1526 REPORT(
_(
"Unconditional rule applied." ) )
1531 REPORT( wxString::Format(
_(
"Checking rule condition \"%s\"." ),
1532 EscapeHTML( c->condition->GetExpression() ) ) )
1534 if( c->condition->EvaluateFor( a,
nullptr, c->constraint.m_Type,
1537 REPORT(
_(
"Rule applied." ) )
1542 REPORT(
_(
"Condition not satisfied; rule ignored." ) )
1551 for(
int ii = 0; ii < (int) ruleset->size(); ++ii )
1552 processConstraint( ruleset->at( ii ) );
1562 assert( error_code >= 0 && error_code <=
DRCE_LAST );
1570 static std::mutex globalLock;
1576 std::lock_guard<std::mutex> guard( globalLock );
1582 wxString msg = wxString::Format( wxT(
"Test '%s': %s (code %d)" ),
1583 aItem->GetViolatingTest()->GetName(),
1584 aItem->GetErrorMessage(),
1585 aItem->GetErrorCode() );
1587 DRC_RULE* rule = aItem->GetViolatingRule();
1590 msg += wxString::Format( wxT(
", violating rule: '%s'" ), rule->
m_Name );
1594 wxString violatingItemsStr = wxT(
"Violating items: " );
1596 m_reporter->
Report( wxString::Format( wxT(
" |- violating position (%d, %d)" ),
1679 int current = c->constraint.GetValue().Min();
1681 if( current > worst )
1684 aConstraint = c->constraint;
1695 std::set<int> distinctMinimums;
1700 distinctMinimums.emplace( c->constraint.GetValue().Min() );
1703 return distinctMinimums;
1709 wxString& aBaseDpName )
1714 for(
auto it = aNetName.rbegin(); it != aNetName.rend() && rv == 0; ++it, ++count )
1718 if( ( ch >=
'0' && ch <=
'9' ) || ch ==
'_' )
1722 else if( ch ==
'+' )
1724 aComplementNet = wxT(
"-" );
1727 else if( ch ==
'-' )
1729 aComplementNet = wxT(
"+" );
1732 else if( ch ==
'N' )
1734 aComplementNet = wxT(
"P" );
1737 else if ( ch ==
'P' )
1739 aComplementNet = wxT(
"N" );
1748 if( rv != 0 && count >= 1 )
1750 aBaseDpName = aNetName.Left( aNetName.Length() - count );
1751 aComplementNet = wxString( aBaseDpName ) << aComplementNet << aNetName.Right( count - 1 );
1761 wxString
dummy, coupledNetName;
1797 if( parentFootprint && parentFootprint->
IsNetTie() )
1804 if( padToNetTieGroupMap[
pad->GetNumber() ] >= 0 && aTrackNetCode ==
pad->GetNetCode() )
1806 if(
pad->GetEffectiveShape( aTrackLayer )->Collide( aCollisionPos,
epsilon ) )
1820 if(
name == prov->GetName() )
constexpr EDA_IU_SCALE pcbIUScale
constexpr EDA_IU_SCALE unityScale
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual int GetLocalClearanceOverrides(wxString *aSource) const
Return any local clearance overrides set in the "classic" (ie: pre-rule) system.
virtual int GetLocalClearance(wxString *aSource) const
Return any local clearances set in the "classic" (ie: pre-rule) system.
Container for design settings for a BOARD object.
std::shared_ptr< NET_SETTINGS > m_NetSettings
int m_CopperEdgeClearance
int m_MinSilkTextThickness
bool Ignore(int aDRCErrorCode)
Return true if the DRC error code's severity is SEVERITY_IGNORE.
int GetDRCEpsilon() const
int m_ViasMinAnnularWidth
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual bool IsOnCopperLayer() const
virtual bool HasHole() const
Information pertinent to a Pcbnew printed circuit board.
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
FOOTPRINTS & Footprints()
void IncrementTimeStamp()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
virtual bool Run() override
Run this provider against the given PCB with configured options (if any).
void SetParentRule(DRC_RULE *aParentRule)
MINOPTMAX< int > & Value()
ZONE_CONNECTION m_ZoneConnection
void SetName(const wxString &aName)
DRC_RULE * GetParentRule() const
std::map< DRC_CONSTRAINT_T, std::vector< DRC_ENGINE_CONSTRAINT * > * > m_constraintMap
void addRule(std::shared_ptr< DRC_RULE > &rule)
PROGRESS_REPORTER * m_progressReporter
void loadRules(const wxFileName &aPath)
Load and parse a rule set from an sexpr text file.
std::vector< DRC_TEST_PROVIDER * > m_testProviders
std::set< int > QueryDistinctConstraints(DRC_CONSTRAINT_T aConstraintId)
bool KeepRefreshing(bool aWait=false)
bool m_reportAllTrackErrors
bool ReportProgress(double aProgress)
DRC_TEST_PROVIDER * GetTestProvider(const wxString &name) const
bool HasRulesForConstraintType(DRC_CONSTRAINT_T constraintID)
BOARD_DESIGN_SETTINGS * GetDesignSettings() const
void RunTests(EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aTestFootprints)
Run the DRC tests.
void ReportViolation(const std::shared_ptr< DRC_ITEM > &aItem, const VECTOR2I &aPos, int aMarkerLayer)
void SetMaxProgress(int aSize)
void ReportAux(const wxString &aStr)
DRC_ENGINE(BOARD *aBoard=nullptr, BOARD_DESIGN_SETTINGS *aSettings=nullptr)
std::vector< int > m_errorLimits
bool IsErrorLimitExceeded(int error_code)
void ProcessAssertions(const BOARD_ITEM *a, std::function< void(const DRC_CONSTRAINT *)> aFailureHandler, REPORTER *aReporter=nullptr)
DRC_VIOLATION_HANDLER m_violationHandler
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
std::vector< std::shared_ptr< DRC_RULE > > m_rules
std::shared_ptr< DRC_RULE > createImplicitRule(const wxString &name)
static bool IsNetADiffPair(BOARD *aBoard, NETINFO_ITEM *aNet, int &aNetP, int &aNetN)
bool IsNetTieExclusion(int aTrackNetCode, PCB_LAYER_ID aTrackLayer, const VECTOR2I &aCollisionPos, BOARD_ITEM *aCollidingItem)
Check if the given collision between a track and another item occurs during the track's entry into a ...
bool QueryWorstConstraint(DRC_CONSTRAINT_T aRuleId, DRC_CONSTRAINT &aConstraint)
void InitEngine(const wxFileName &aRulePath)
Initialize the DRC engine.
DRC_CONSTRAINT EvalZoneConnection(const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
static int MatchDpSuffix(const wxString &aNetName, wxString &aComplementNet, wxString &aBaseDpName)
Check if the given net is a diff pair, returning its polarity and complement if so.
bool ReportPhase(const wxString &aMessage)
BOARD_DESIGN_SETTINGS * m_designSettings
void Parse(std::vector< std::shared_ptr< DRC_RULE > > &aRules, REPORTER *aReporter)
bool Compile(REPORTER *aReporter, int aSourceLine=0, int aSourceOffset=0)
std::vector< DRC_TEST_PROVIDER * > GetTestProviders() const
static DRC_TEST_PROVIDER_REGISTRY & Instance()
Represent a DRC "provider" which runs some DRC functions over a BOARD and spits out DRC_ITEM and posi...
void SetDRCEngine(DRC_ENGINE *engine)
KICAD_T Type() const
Returns the type of object.
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const
Return a user-visible description string of this item.
EDA_ITEM_FLAGS GetFlags() const
LSET is a set of PCB_LAYER_IDs.
static LSET FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Handle the data for a net.
const wxString & GetNetname() const
virtual bool IsCancelled() const =0
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void AdvancePhase()=0
Use the next available virtual zone of the dialog progress bar.
virtual void AdvanceProgress()=0
Increment the progress bar length (inside the current virtual zone).
virtual void SetCurrentProgress(double aProgress)=0
Set the progress value to aProgress (0..1).
virtual void SetMaxProgress(int aMaxProgress)=0
Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
void SetUserUnits(EDA_UNITS aUnits)
Handle a list of polygons defining a copper zone.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
bool GetDoNotAllowVias() const
bool GetDoNotAllowPads() const
bool GetDoNotAllowTracks() const
int GetMinThickness() const
ZONE_CONNECTION GetPadConnection() const
int GetThermalReliefSpokeWidth() const
bool GetDoNotAllowFootprints() const
bool GetDoNotAllowCopperPour() const
int GetThermalReliefGap() const
void drcPrintDebugMessage(int level, const wxString &msg, const char *function, int line)
#define EXTENDED_ERROR_LIMIT
static bool isKeepoutZone(const BOARD_ITEM *aItem, bool aCheckFlags)
bool hasDrilledHole(const BOARD_ITEM *aItem)
@ DRC_DISALLOW_FOOTPRINTS
@ DRC_DISALLOW_MICRO_VIAS
@ ANNULAR_WIDTH_CONSTRAINT
@ COURTYARD_CLEARANCE_CONSTRAINT
@ VIA_DIAMETER_CONSTRAINT
@ ZONE_CONNECTION_CONSTRAINT
@ DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT
@ DIFF_PAIR_GAP_CONSTRAINT
@ SILK_CLEARANCE_CONSTRAINT
@ EDGE_CLEARANCE_CONSTRAINT
@ MIN_RESOLVED_SPOKES_CONSTRAINT
@ TEXT_THICKNESS_CONSTRAINT
@ PHYSICAL_HOLE_CLEARANCE_CONSTRAINT
@ THERMAL_SPOKE_WIDTH_CONSTRAINT
@ CONNECTION_WIDTH_CONSTRAINT
@ THERMAL_RELIEF_GAP_CONSTRAINT
@ HOLE_CLEARANCE_CONSTRAINT
@ PHYSICAL_CLEARANCE_CONSTRAINT
@ HOLE_TO_HOLE_CONSTRAINT
#define HOLE_PROXY
Indicates the BOARD_ITEM is a proxy for its hole.
PCB_LAYER_ID
A quick note on layer IDs:
KICOMMON_API 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.
std::vector< FAB_LAYER_COLOR > dummy
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
std::shared_ptr< DRC_RULE > parentRule
DRC_RULE_CONDITION * condition
DRC_CONSTRAINT constraint
A filename or source description, a problem input line, a line number, a byte offset,...
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
wxString PrintZoneConnection(ZONE_CONNECTION aConnection)
ZONE_CONNECTION
How pads are covered by copper in zone.