SNR. (Mostly for progammers, but a little for user messages.)

This commit is contained in:
Jeff Young 2020-11-02 16:20:00 +00:00
parent 3b10d15835
commit ae9afdd169
26 changed files with 300 additions and 355 deletions

View File

@ -85,8 +85,8 @@ int BOARD_CONNECTED_ITEM::GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSourc
{ {
BOARD_DESIGN_SETTINGS& bds = GetBoard()->GetDesignSettings(); BOARD_DESIGN_SETTINGS& bds = GetBoard()->GetDesignSettings();
constraint = bds.m_DRCEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_CLEARANCE, this, constraint = bds.m_DRCEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, this, nullptr,
nullptr, aLayer ); aLayer );
} }
if( constraint.Value().HasMin() ) if( constraint.Value().HasMin() )

View File

@ -849,10 +849,7 @@ int BOARD_DESIGN_SETTINGS::GetBiggestClearanceValue()
DRC_CONSTRAINT constraint; DRC_CONSTRAINT constraint;
if( m_DRCEngine ) if( m_DRCEngine )
{ m_DRCEngine->QueryWorstConstraint( CLEARANCE_CONSTRAINT, constraint );
m_DRCEngine->QueryWorstConstraint( DRC_CONSTRAINT_TYPE_CLEARANCE, constraint,
DRCCQ_LARGEST_MINIMUM );
}
return constraint.Value().HasMin() ? constraint.Value().Min() : 0; return constraint.Value().HasMin() ? constraint.Value().Min() : 0;
} }

View File

@ -117,8 +117,8 @@ void TRACK::GetWidthConstraints( int* aMin, int* aMax, wxString* aSource ) const
{ {
BOARD_DESIGN_SETTINGS& bds = GetBoard()->GetDesignSettings(); BOARD_DESIGN_SETTINGS& bds = GetBoard()->GetDesignSettings();
constraint = bds.m_DRCEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_TRACK_WIDTH, this, constraint = bds.m_DRCEngine->EvalRulesForItems( TRACK_WIDTH_CONSTRAINT, this, nullptr,
nullptr, GetLayer() ); GetLayer() );
} }
if( constraint.Value().HasMin() || constraint.Value().HasMax() ) if( constraint.Value().HasMin() || constraint.Value().HasMax() )
@ -151,8 +151,8 @@ int VIA::GetMinAnnulus( PCB_LAYER_ID aLayer, wxString* aSource ) const
{ {
BOARD_DESIGN_SETTINGS& bds = GetBoard()->GetDesignSettings(); BOARD_DESIGN_SETTINGS& bds = GetBoard()->GetDesignSettings();
constraint = bds.m_DRCEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_ANNULAR_WIDTH, this, constraint = bds.m_DRCEngine->EvalRulesForItems( ANNULAR_WIDTH_CONSTRAINT, this, nullptr,
nullptr, aLayer ); aLayer );
} }
if( constraint.Value().HasMin() ) if( constraint.Value().HasMin() )

View File

@ -123,45 +123,45 @@ void DRC_ENGINE::loadImplicitRules()
DRC_RULE* rule = createImplicitRule( _( "board setup constraints" ) ); DRC_RULE* rule = createImplicitRule( _( "board setup constraints" ) );
DRC_CONSTRAINT clearanceConstraint( DRC_CONSTRAINT_TYPE_CLEARANCE ); DRC_CONSTRAINT clearanceConstraint( CLEARANCE_CONSTRAINT );
clearanceConstraint.Value().SetMin( bds.m_MinClearance ); clearanceConstraint.Value().SetMin( bds.m_MinClearance );
rule->AddConstraint( clearanceConstraint ); rule->AddConstraint( clearanceConstraint );
DRC_CONSTRAINT widthConstraint( DRC_CONSTRAINT_TYPE_TRACK_WIDTH ); DRC_CONSTRAINT widthConstraint( TRACK_WIDTH_CONSTRAINT );
widthConstraint.Value().SetMin( bds.m_TrackMinWidth ); widthConstraint.Value().SetMin( bds.m_TrackMinWidth );
rule->AddConstraint( widthConstraint ); rule->AddConstraint( widthConstraint );
DRC_CONSTRAINT drillConstraint( DRC_CONSTRAINT_TYPE_HOLE_SIZE ); DRC_CONSTRAINT drillConstraint( HOLE_SIZE_CONSTRAINT );
drillConstraint.Value().SetMin( bds.m_MinThroughDrill ); drillConstraint.Value().SetMin( bds.m_MinThroughDrill );
rule->AddConstraint( drillConstraint ); rule->AddConstraint( drillConstraint );
DRC_CONSTRAINT annulusConstraint( DRC_CONSTRAINT_TYPE_ANNULAR_WIDTH ); DRC_CONSTRAINT annulusConstraint( ANNULAR_WIDTH_CONSTRAINT );
annulusConstraint.Value().SetMin( bds.m_ViasMinAnnulus ); annulusConstraint.Value().SetMin( bds.m_ViasMinAnnulus );
rule->AddConstraint( annulusConstraint ); rule->AddConstraint( annulusConstraint );
DRC_CONSTRAINT diameterConstraint( DRC_CONSTRAINT_TYPE_VIA_DIAMETER ); DRC_CONSTRAINT diameterConstraint( VIA_DIAMETER_CONSTRAINT );
diameterConstraint.Value().SetMin( bds.m_ViasMinSize ); diameterConstraint.Value().SetMin( bds.m_ViasMinSize );
rule->AddConstraint( diameterConstraint ); rule->AddConstraint( diameterConstraint );
DRC_CONSTRAINT edgeClearanceConstraint( DRC_CONSTRAINT_TYPE_EDGE_CLEARANCE ); DRC_CONSTRAINT edgeClearanceConstraint( EDGE_CLEARANCE_CONSTRAINT );
edgeClearanceConstraint.Value().SetMin( bds.m_CopperEdgeClearance ); edgeClearanceConstraint.Value().SetMin( bds.m_CopperEdgeClearance );
rule->AddConstraint( edgeClearanceConstraint ); rule->AddConstraint( edgeClearanceConstraint );
DRC_CONSTRAINT holeClearanceConstraint( DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE ); DRC_CONSTRAINT holeClearanceConstraint( HOLE_CLEARANCE_CONSTRAINT );
holeClearanceConstraint.Value().SetMin( bds.m_HoleToHoleMin ); holeClearanceConstraint.Value().SetMin( bds.m_HoleToHoleMin );
rule->AddConstraint( holeClearanceConstraint ); rule->AddConstraint( holeClearanceConstraint );
DRC_CONSTRAINT courtyardClearanceConstraint( DRC_CONSTRAINT_TYPE_COURTYARD_CLEARANCE ); DRC_CONSTRAINT courtyardClearanceConstraint( COURTYARD_CLEARANCE_CONSTRAINT );
holeClearanceConstraint.Value().SetMin( 0 ); holeClearanceConstraint.Value().SetMin( 0 );
rule->AddConstraint( courtyardClearanceConstraint ); rule->AddConstraint( courtyardClearanceConstraint );
DRC_CONSTRAINT diffPairGapConstraint( DRC_CONSTRAINT_TYPE_DIFF_PAIR_GAP ); DRC_CONSTRAINT diffPairGapConstraint( DIFF_PAIR_GAP_CONSTRAINT );
diffPairGapConstraint.Value().SetMin( bds.GetDefault()->GetClearance() ); diffPairGapConstraint.Value().SetMin( bds.GetDefault()->GetClearance() );
rule->AddConstraint( diffPairGapConstraint ); rule->AddConstraint( diffPairGapConstraint );
rule = createImplicitRule( _( "board setup constraints" ) ); rule = createImplicitRule( _( "board setup constraints" ) );
rule->m_LayerCondition = LSET( 2, F_SilkS, B_SilkS ); rule->m_LayerCondition = LSET( 2, F_SilkS, B_SilkS );
DRC_CONSTRAINT silkClearanceConstraint( DRC_CONSTRAINT_TYPE_SILK_CLEARANCE ); DRC_CONSTRAINT silkClearanceConstraint( SILK_CLEARANCE_CONSTRAINT );
silkClearanceConstraint.Value().SetMin( bds.m_SilkClearance ); silkClearanceConstraint.Value().SetMin( bds.m_SilkClearance );
rule->AddConstraint( silkClearanceConstraint ); rule->AddConstraint( silkClearanceConstraint );
@ -172,17 +172,17 @@ void DRC_ENGINE::loadImplicitRules()
uViaRule->m_Condition = new DRC_RULE_CONDITION( "A.Via_Type == 'Micro'" ); uViaRule->m_Condition = new DRC_RULE_CONDITION( "A.Via_Type == 'Micro'" );
DRC_CONSTRAINT uViaDrillConstraint( DRC_CONSTRAINT_TYPE_HOLE_SIZE ); DRC_CONSTRAINT uViaDrillConstraint( HOLE_SIZE_CONSTRAINT );
uViaDrillConstraint.Value().SetMin( bds.m_MicroViasMinDrill ); uViaDrillConstraint.Value().SetMin( bds.m_MicroViasMinDrill );
uViaRule->AddConstraint( uViaDrillConstraint ); uViaRule->AddConstraint( uViaDrillConstraint );
DRC_CONSTRAINT uViaDiameterConstraint( DRC_CONSTRAINT_TYPE_VIA_DIAMETER ); DRC_CONSTRAINT uViaDiameterConstraint( VIA_DIAMETER_CONSTRAINT );
uViaDiameterConstraint.Value().SetMin( bds.m_MicroViasMinSize ); uViaDiameterConstraint.Value().SetMin( bds.m_MicroViasMinSize );
uViaRule->AddConstraint( uViaDiameterConstraint ); uViaRule->AddConstraint( uViaDiameterConstraint );
if( !bds.m_MicroViasAllowed ) if( !bds.m_MicroViasAllowed )
{ {
DRC_CONSTRAINT disallowConstraint( DRC_CONSTRAINT_TYPE_DISALLOW ); DRC_CONSTRAINT disallowConstraint( DISALLOW_CONSTRAINT );
disallowConstraint.m_DisallowFlags = DRC_DISALLOW_MICRO_VIAS; disallowConstraint.m_DisallowFlags = DRC_DISALLOW_MICRO_VIAS;
uViaRule->AddConstraint( disallowConstraint ); uViaRule->AddConstraint( disallowConstraint );
} }
@ -193,7 +193,7 @@ void DRC_ENGINE::loadImplicitRules()
bbViaRule->m_Condition = new DRC_RULE_CONDITION( "A.Via_Type == 'Blind/buried'" ); bbViaRule->m_Condition = new DRC_RULE_CONDITION( "A.Via_Type == 'Blind/buried'" );
DRC_CONSTRAINT disallowConstraint( DRC_CONSTRAINT_TYPE_DISALLOW ); DRC_CONSTRAINT disallowConstraint( DISALLOW_CONSTRAINT );
disallowConstraint.m_DisallowFlags = DRC_DISALLOW_BB_VIAS; disallowConstraint.m_DisallowFlags = DRC_DISALLOW_BB_VIAS;
bbViaRule->AddConstraint( disallowConstraint ); bbViaRule->AddConstraint( disallowConstraint );
} }
@ -224,14 +224,14 @@ void DRC_ENGINE::loadImplicitRules()
if( nc->GetClearance() ) if( nc->GetClearance() )
{ {
DRC_CONSTRAINT constraint( DRC_CONSTRAINT_TYPE_CLEARANCE ); DRC_CONSTRAINT constraint( CLEARANCE_CONSTRAINT );
constraint.Value().SetMin( std::max( bds.m_MinClearance, nc->GetClearance() ) ); constraint.Value().SetMin( std::max( bds.m_MinClearance, nc->GetClearance() ) );
rule->AddConstraint( constraint ); rule->AddConstraint( constraint );
} }
if( nc->GetTrackWidth() ) if( nc->GetTrackWidth() )
{ {
DRC_CONSTRAINT constraint( DRC_CONSTRAINT_TYPE_TRACK_WIDTH ); DRC_CONSTRAINT constraint( TRACK_WIDTH_CONSTRAINT );
constraint.Value().SetMin( bds.m_TrackMinWidth ); constraint.Value().SetMin( bds.m_TrackMinWidth );
constraint.Value().SetOpt( nc->GetTrackWidth() ); constraint.Value().SetOpt( nc->GetTrackWidth() );
rule->AddConstraint( constraint ); rule->AddConstraint( constraint );
@ -251,7 +251,7 @@ void DRC_ENGINE::loadImplicitRules()
if( nc->GetDiffPairWidth() ) if( nc->GetDiffPairWidth() )
{ {
DRC_CONSTRAINT constraint( DRC_CONSTRAINT_TYPE_TRACK_WIDTH ); DRC_CONSTRAINT constraint( TRACK_WIDTH_CONSTRAINT );
constraint.Value().SetMin( bds.m_TrackMinWidth ); constraint.Value().SetMin( bds.m_TrackMinWidth );
constraint.Value().SetOpt( nc->GetDiffPairWidth() ); constraint.Value().SetOpt( nc->GetDiffPairWidth() );
rule->AddConstraint( constraint ); rule->AddConstraint( constraint );
@ -259,7 +259,7 @@ void DRC_ENGINE::loadImplicitRules()
if( nc->GetDiffPairGap() ) if( nc->GetDiffPairGap() )
{ {
DRC_CONSTRAINT constraint( DRC_CONSTRAINT_TYPE_DIFF_PAIR_GAP ); DRC_CONSTRAINT constraint( DIFF_PAIR_GAP_CONSTRAINT );
constraint.Value().SetMin( std::max( bds.m_MinClearance, nc->GetClearance() ) ); constraint.Value().SetMin( std::max( bds.m_MinClearance, nc->GetClearance() ) );
constraint.Value().SetOpt( nc->GetDiffPairGap() ); constraint.Value().SetOpt( nc->GetDiffPairGap() );
rule->AddConstraint( constraint ); rule->AddConstraint( constraint );
@ -279,7 +279,7 @@ void DRC_ENGINE::loadImplicitRules()
if( nc->GetViaDiameter() ) if( nc->GetViaDiameter() )
{ {
DRC_CONSTRAINT constraint( DRC_CONSTRAINT_TYPE_VIA_DIAMETER ); DRC_CONSTRAINT constraint( VIA_DIAMETER_CONSTRAINT );
constraint.Value().SetMin( bds.m_ViasMinSize ); constraint.Value().SetMin( bds.m_ViasMinSize );
constraint.Value().SetOpt( nc->GetViaDiameter() ); constraint.Value().SetOpt( nc->GetViaDiameter() );
rule->AddConstraint( constraint ); rule->AddConstraint( constraint );
@ -287,7 +287,7 @@ void DRC_ENGINE::loadImplicitRules()
if( nc->GetViaDrill() ) if( nc->GetViaDrill() )
{ {
DRC_CONSTRAINT constraint( DRC_CONSTRAINT_TYPE_HOLE_SIZE ); DRC_CONSTRAINT constraint( HOLE_SIZE_CONSTRAINT );
constraint.Value().SetMin( bds.m_MinThroughDrill ); constraint.Value().SetMin( bds.m_MinThroughDrill );
constraint.Value().SetOpt( nc->GetViaDrill() ); constraint.Value().SetOpt( nc->GetViaDrill() );
rule->AddConstraint( constraint ); rule->AddConstraint( constraint );
@ -307,7 +307,7 @@ void DRC_ENGINE::loadImplicitRules()
if( nc->GetuViaDiameter() ) if( nc->GetuViaDiameter() )
{ {
DRC_CONSTRAINT constraint( DRC_CONSTRAINT_TYPE_VIA_DIAMETER ); DRC_CONSTRAINT constraint( VIA_DIAMETER_CONSTRAINT );
constraint.Value().SetMin( bds.m_MicroViasMinSize ); constraint.Value().SetMin( bds.m_MicroViasMinSize );
constraint.Value().SetMin( nc->GetuViaDiameter() ); constraint.Value().SetMin( nc->GetuViaDiameter() );
rule->AddConstraint( constraint ); rule->AddConstraint( constraint );
@ -315,7 +315,7 @@ void DRC_ENGINE::loadImplicitRules()
if( nc->GetuViaDrill() ) if( nc->GetuViaDrill() )
{ {
DRC_CONSTRAINT constraint( DRC_CONSTRAINT_TYPE_HOLE_SIZE ); DRC_CONSTRAINT constraint( HOLE_SIZE_CONSTRAINT );
constraint.Value().SetMin( bds.m_MicroViasMinDrill ); constraint.Value().SetMin( bds.m_MicroViasMinDrill );
constraint.Value().SetOpt( nc->GetuViaDrill() ); constraint.Value().SetOpt( nc->GetuViaDrill() );
rule->AddConstraint( constraint ); rule->AddConstraint( constraint );
@ -352,7 +352,7 @@ void DRC_ENGINE::loadImplicitRules()
auto addKeepoutConstraint = auto addKeepoutConstraint =
[&rule]( int aConstraint ) [&rule]( int aConstraint )
{ {
DRC_CONSTRAINT disallowConstraint( DRC_CONSTRAINT_TYPE_DISALLOW ); DRC_CONSTRAINT disallowConstraint( DISALLOW_CONSTRAINT );
disallowConstraint.m_DisallowFlags = aConstraint; disallowConstraint.m_DisallowFlags = aConstraint;
rule->AddConstraint( disallowConstraint ); rule->AddConstraint( disallowConstraint );
}; };
@ -440,20 +440,19 @@ static wxString formatConstraint( const DRC_CONSTRAINT& constraint )
std::vector<Formatter> formats = std::vector<Formatter> formats =
{ {
{ DRC_CONSTRAINT_TYPE_UNKNOWN, "unknown", nullptr }, { CLEARANCE_CONSTRAINT, "clearance", formatMinMax },
{ DRC_CONSTRAINT_TYPE_CLEARANCE, "clearance", formatMinMax }, { HOLE_CLEARANCE_CONSTRAINT, "hole_clearance", formatMinMax },
{ DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE, "hole_clearance", formatMinMax }, { EDGE_CLEARANCE_CONSTRAINT, "edge_clearance", formatMinMax },
{ DRC_CONSTRAINT_TYPE_EDGE_CLEARANCE, "edge_clearance", formatMinMax }, { HOLE_SIZE_CONSTRAINT, "hole_size", formatMinMax },
{ DRC_CONSTRAINT_TYPE_HOLE_SIZE, "hole_size", formatMinMax }, { COURTYARD_CLEARANCE_CONSTRAINT, "courtyard_clearance", formatMinMax },
{ DRC_CONSTRAINT_TYPE_COURTYARD_CLEARANCE, "courtyard_clearance", formatMinMax }, { SILK_CLEARANCE_CONSTRAINT, "silk_clearance", formatMinMax },
{ DRC_CONSTRAINT_TYPE_SILK_CLEARANCE, "silk_clearance", formatMinMax }, { TRACK_WIDTH_CONSTRAINT, "track_width", formatMinMax },
{ DRC_CONSTRAINT_TYPE_TRACK_WIDTH, "track_width", formatMinMax }, { ANNULAR_WIDTH_CONSTRAINT, "annular_width", formatMinMax },
{ DRC_CONSTRAINT_TYPE_ANNULAR_WIDTH, "annular_width", formatMinMax }, { DISALLOW_CONSTRAINT, "disallow", nullptr },
{ DRC_CONSTRAINT_TYPE_DISALLOW, "disallow", nullptr }, { VIA_DIAMETER_CONSTRAINT, "via_diameter", formatMinMax },
{ DRC_CONSTRAINT_TYPE_VIA_DIAMETER, "via_diameter", formatMinMax }, { LENGTH_CONSTRAINT, "length", formatMinMax },
{ DRC_CONSTRAINT_TYPE_LENGTH, "length", formatMinMax }, { SKEW_CONSTRAINT, "skew", formatMinMax },
{ DRC_CONSTRAINT_TYPE_SKEW, "skew", formatMinMax }, { VIA_COUNT_CONSTRAINT, "via_count", formatMinMax }
{ DRC_CONSTRAINT_TYPE_VIA_COUNT, "via_count", formatMinMax }
}; };
for( auto& fmt : formats ) for( auto& fmt : formats )
@ -694,7 +693,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
* kills performance when running bulk DRC tests (where aReporter is nullptr). * kills performance when running bulk DRC tests (where aReporter is nullptr).
*/ */
if( aConstraintId == DRC_CONSTRAINT_TYPE_CLEARANCE ) if( aConstraintId == CLEARANCE_CONSTRAINT )
{ {
// A PTH pad has a plated cylinder around the hole so copper clearances apply // A PTH pad has a plated cylinder around the hole so copper clearances apply
// whether or not there's a flashed pad. Not true for NPTHs. // whether or not there's a flashed pad. Not true for NPTHs.
@ -703,7 +702,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
const D_PAD* pad = static_cast<const D_PAD*>( a ); const D_PAD* pad = static_cast<const D_PAD*>( a );
if( pad->GetAttribute() == PAD_ATTRIB_NPTH && !pad->FlashLayer( aLayer ) ) if( pad->GetAttribute() == PAD_ATTRIB_NPTH && !pad->FlashLayer( aLayer ) )
aConstraintId = DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE; aConstraintId = HOLE_CLEARANCE_CONSTRAINT;
} }
} }
@ -713,7 +712,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
bool implicit = false; bool implicit = false;
// Local overrides take precedence // Local overrides take precedence
if( aConstraintId == DRC_CONSTRAINT_TYPE_CLEARANCE ) if( aConstraintId == CLEARANCE_CONSTRAINT )
{ {
int overrideA = 0; int overrideA = 0;
int overrideB = 0; int overrideB = 0;
@ -740,7 +739,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
if( overrideA || overrideB ) if( overrideA || overrideB )
{ {
DRC_CONSTRAINT constraint( DRC_CONSTRAINT_TYPE_CLEARANCE, m_msg ); DRC_CONSTRAINT constraint( CLEARANCE_CONSTRAINT, m_msg );
constraint.m_Value.SetMin( std::max( overrideA, overrideB ) ); constraint.m_Value.SetMin( std::max( overrideA, overrideB ) );
return constraint; return constraint;
} }
@ -753,35 +752,35 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
REPORT( "" ) REPORT( "" )
if( aConstraintId == DRC_CONSTRAINT_TYPE_CLEARANCE ) if( aConstraintId == CLEARANCE_CONSTRAINT )
{ {
int clearance = c->constraint.m_Value.Min(); int clearance = c->constraint.m_Value.Min();
REPORT( wxString::Format( _( "Checking %s; clearance: %s." ), REPORT( wxString::Format( _( "Checking %s; clearance: %s." ),
c->constraint.GetName(), c->constraint.GetName(),
MessageTextFromValue( UNITS, clearance ) ) ) MessageTextFromValue( UNITS, clearance ) ) )
} }
else if( aConstraintId == DRC_CONSTRAINT_TYPE_COURTYARD_CLEARANCE ) else if( aConstraintId == COURTYARD_CLEARANCE_CONSTRAINT )
{ {
int clearance = c->constraint.m_Value.Min(); int clearance = c->constraint.m_Value.Min();
REPORT( wxString::Format( _( "Checking %s; courtyard clearance: %s." ), REPORT( wxString::Format( _( "Checking %s; courtyard clearance: %s." ),
c->constraint.GetName(), c->constraint.GetName(),
MessageTextFromValue( UNITS, clearance ) ) ) MessageTextFromValue( UNITS, clearance ) ) )
} }
else if( aConstraintId == DRC_CONSTRAINT_TYPE_SILK_CLEARANCE ) else if( aConstraintId == SILK_CLEARANCE_CONSTRAINT )
{ {
int clearance = c->constraint.m_Value.Min(); int clearance = c->constraint.m_Value.Min();
REPORT( wxString::Format( _( "Checking %s; silk clearance: %s." ), REPORT( wxString::Format( _( "Checking %s; silk clearance: %s." ),
c->constraint.GetName(), c->constraint.GetName(),
MessageTextFromValue( UNITS, clearance ) ) ) MessageTextFromValue( UNITS, clearance ) ) )
} }
else if( aConstraintId == DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE ) else if( aConstraintId == HOLE_CLEARANCE_CONSTRAINT )
{ {
int clearance = c->constraint.m_Value.Min(); int clearance = c->constraint.m_Value.Min();
REPORT( wxString::Format( _( "Checking %s; hole clearance: %s." ), REPORT( wxString::Format( _( "Checking %s; hole clearance: %s." ),
c->constraint.GetName(), c->constraint.GetName(),
MessageTextFromValue( UNITS, clearance ) ) ) MessageTextFromValue( UNITS, clearance ) ) )
} }
else if( aConstraintId == DRC_CONSTRAINT_TYPE_EDGE_CLEARANCE ) else if( aConstraintId == EDGE_CLEARANCE_CONSTRAINT )
{ {
int clearance = c->constraint.m_Value.Min(); int clearance = c->constraint.m_Value.Min();
REPORT( wxString::Format( _( "Checking %s; edge clearance: %s." ), REPORT( wxString::Format( _( "Checking %s; edge clearance: %s." ),
@ -793,7 +792,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
REPORT( wxString::Format( _( "Checking %s." ), c->constraint.GetName() ) ) REPORT( wxString::Format( _( "Checking %s." ), c->constraint.GetName() ) )
} }
if( aConstraintId == DRC_CONSTRAINT_TYPE_CLEARANCE ) if( aConstraintId == CLEARANCE_CONSTRAINT )
{ {
if( implicit && ( isKeepoutZone( a ) || isKeepoutZone( b ) ) ) if( implicit && ( isKeepoutZone( a ) || isKeepoutZone( b ) ) )
{ {
@ -801,7 +800,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
return true; return true;
} }
} }
else if( aConstraintId == DRC_CONSTRAINT_TYPE_DISALLOW ) else if( aConstraintId == DISALLOW_CONSTRAINT )
{ {
int mask; int mask;
@ -954,7 +953,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
// Unfortunately implicit rules don't work for local clearances (such as zones) because // Unfortunately implicit rules don't work for local clearances (such as zones) because
// they have to be max'ed with netclass values (which are already implicit rules), and our // they have to be max'ed with netclass values (which are already implicit rules), and our
// rule selection paradigm is "winner takes all". // rule selection paradigm is "winner takes all".
if( constraintRef && aConstraintId == DRC_CONSTRAINT_TYPE_CLEARANCE && implicit ) if( constraintRef && aConstraintId == CLEARANCE_CONSTRAINT && implicit )
{ {
int global = constraintRef->m_Value.Min(); int global = constraintRef->m_Value.Min();
int localA = connectedA ? connectedA->GetLocalClearance( nullptr ) : 0; int localA = connectedA ? connectedA->GetLocalClearance( nullptr ) : 0;
@ -985,7 +984,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
if( localA > global || localB > global ) if( localA > global || localB > global )
{ {
DRC_CONSTRAINT constraint( DRC_CONSTRAINT_TYPE_CLEARANCE, m_msg ); DRC_CONSTRAINT constraint( CLEARANCE_CONSTRAINT, m_msg );
constraint.m_Value.SetMin( clearance ); constraint.m_Value.SetMin( clearance );
return constraint; return constraint;
} }
@ -993,7 +992,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
// fixme: return optional<drc_constraint>, let the particular test decide what to do if no matching constraint // fixme: return optional<drc_constraint>, let the particular test decide what to do if no matching constraint
// is found // is found
static DRC_CONSTRAINT nullConstraint( DRC_CONSTRAINT_TYPE_NULL ); static DRC_CONSTRAINT nullConstraint( NULL_CONSTRAINT );
nullConstraint.m_DisallowFlags = 0; nullConstraint.m_DisallowFlags = 0;
return constraintRef ? *constraintRef : nullConstraint; return constraintRef ? *constraintRef : nullConstraint;
@ -1114,11 +1113,8 @@ bool DRC_ENGINE::HasRulesForConstraintType( DRC_CONSTRAINT_TYPE_T constraintID )
bool DRC_ENGINE::QueryWorstConstraint( DRC_CONSTRAINT_TYPE_T aConstraintId, bool DRC_ENGINE::QueryWorstConstraint( DRC_CONSTRAINT_TYPE_T aConstraintId,
DRC_CONSTRAINT& aConstraint, DRC_CONSTRAINT& aConstraint )
DRC_CONSTRAINT_QUERY_T aQueryType )
{ {
if( aQueryType == DRCCQ_LARGEST_MINIMUM )
{
int worst = 0; int worst = 0;
for( const DRC_CONSTRAINT& constraint : QueryConstraintsById( aConstraintId ) ) for( const DRC_CONSTRAINT& constraint : QueryConstraintsById( aConstraintId ) )
@ -1136,9 +1132,6 @@ bool DRC_ENGINE::QueryWorstConstraint( DRC_CONSTRAINT_TYPE_T aConstraintId,
} }
return worst > 0; return worst > 0;
}
return false;
} }

View File

@ -61,11 +61,6 @@ class DRC_ITEM;
class DRC_RULE; class DRC_RULE;
class DRC_CONSTRAINT; class DRC_CONSTRAINT;
enum DRC_CONSTRAINT_QUERY_T
{
DRCCQ_LARGEST_MINIMUM = 0
// fixme: more to come I guess...
};
typedef typedef
std::function<void( const std::shared_ptr<DRC_ITEM>& aItem, wxPoint aPos )> DRC_VIOLATION_HANDLER; std::function<void( const std::shared_ptr<DRC_ITEM>& aItem, wxPoint aPos )> DRC_VIOLATION_HANDLER;
@ -166,8 +161,7 @@ public:
bool ReportPhase( const wxString& aMessage ); bool ReportPhase( const wxString& aMessage );
void ReportAux( const wxString& aStr ); void ReportAux( const wxString& aStr );
bool QueryWorstConstraint( DRC_CONSTRAINT_TYPE_T aRuleId, DRC_CONSTRAINT& aConstraint, bool QueryWorstConstraint( DRC_CONSTRAINT_TYPE_T aRuleId, DRC_CONSTRAINT& aConstraint );
DRC_CONSTRAINT_QUERY_T aQueryType );
std::vector<DRC_TEST_PROVIDER* > GetTestProviders() const { return m_testProviders; }; std::vector<DRC_TEST_PROVIDER* > GetTestProviders() const { return m_testProviders; };

View File

@ -40,24 +40,23 @@ class DRC_RULE_CONDITION;
enum DRC_CONSTRAINT_TYPE_T enum DRC_CONSTRAINT_TYPE_T
{ {
DRC_CONSTRAINT_TYPE_UNKNOWN = -1, NULL_CONSTRAINT = 0,
DRC_CONSTRAINT_TYPE_NULL = 0, CLEARANCE_CONSTRAINT,
DRC_CONSTRAINT_TYPE_CLEARANCE, HOLE_CLEARANCE_CONSTRAINT,
DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE, EDGE_CLEARANCE_CONSTRAINT,
DRC_CONSTRAINT_TYPE_EDGE_CLEARANCE, HOLE_SIZE_CONSTRAINT,
DRC_CONSTRAINT_TYPE_HOLE_SIZE, COURTYARD_CLEARANCE_CONSTRAINT,
DRC_CONSTRAINT_TYPE_COURTYARD_CLEARANCE, SILK_CLEARANCE_CONSTRAINT,
DRC_CONSTRAINT_TYPE_SILK_CLEARANCE, TRACK_WIDTH_CONSTRAINT,
DRC_CONSTRAINT_TYPE_TRACK_WIDTH, ANNULAR_WIDTH_CONSTRAINT,
DRC_CONSTRAINT_TYPE_ANNULAR_WIDTH, DISALLOW_CONSTRAINT,
DRC_CONSTRAINT_TYPE_DISALLOW, VIA_DIAMETER_CONSTRAINT,
DRC_CONSTRAINT_TYPE_VIA_DIAMETER, LENGTH_CONSTRAINT,
DRC_CONSTRAINT_TYPE_LENGTH, SKEW_CONSTRAINT,
DRC_CONSTRAINT_TYPE_SKEW, DIFF_PAIR_GAP_CONSTRAINT,
DRC_CONSTRAINT_TYPE_DIFF_PAIR_GAP, DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT,
DRC_CONSTRAINT_TYPE_DIFF_PAIR_MAX_UNCOUPLED, DIFF_PAIR_INTRA_SKEW_CONSTRAINT,
DRC_CONSTRAINT_TYPE_DIFF_PAIR_INTRA_SKEW, VIA_COUNT_CONSTRAINT
DRC_CONSTRAINT_TYPE_VIA_COUNT
}; };
@ -104,7 +103,7 @@ public:
class DRC_CONSTRAINT class DRC_CONSTRAINT
{ {
public: public:
DRC_CONSTRAINT( DRC_CONSTRAINT_TYPE_T aType = DRC_CONSTRAINT_TYPE_UNKNOWN, DRC_CONSTRAINT( DRC_CONSTRAINT_TYPE_T aType = NULL_CONSTRAINT,
const wxString& aName = wxEmptyString ) : const wxString& aName = wxEmptyString ) :
m_Type( aType ), m_Type( aType ),
m_DisallowFlags( 0 ), m_DisallowFlags( 0 ),
@ -115,7 +114,7 @@ class DRC_CONSTRAINT
bool IsNull() const bool IsNull() const
{ {
return m_Type == DRC_CONSTRAINT_TYPE_NULL; return m_Type == NULL_CONSTRAINT;
} }
const MINOPTMAX<int>& GetValue() const { return m_Value; } const MINOPTMAX<int>& GetValue() const { return m_Value; }

View File

@ -271,20 +271,20 @@ void DRC_RULES_PARSER::parseConstraint( DRC_RULE* aRule )
switch( token ) switch( token )
{ {
case T_clearance: constraint.m_Type = DRC_CONSTRAINT_TYPE_CLEARANCE; break; case T_clearance: constraint.m_Type = CLEARANCE_CONSTRAINT; break;
case T_hole_clearance: constraint.m_Type = DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE; break; case T_hole_clearance: constraint.m_Type = HOLE_CLEARANCE_CONSTRAINT; break;
case T_edge_clearance: constraint.m_Type = DRC_CONSTRAINT_TYPE_EDGE_CLEARANCE; break; case T_edge_clearance: constraint.m_Type = EDGE_CLEARANCE_CONSTRAINT; break;
case T_hole: constraint.m_Type = DRC_CONSTRAINT_TYPE_HOLE_SIZE; break; case T_hole: constraint.m_Type = HOLE_SIZE_CONSTRAINT; break;
case T_courtyard_clearance: constraint.m_Type = DRC_CONSTRAINT_TYPE_COURTYARD_CLEARANCE; break; case T_courtyard_clearance: constraint.m_Type = COURTYARD_CLEARANCE_CONSTRAINT; break;
case T_silk_clearance: constraint.m_Type = DRC_CONSTRAINT_TYPE_SILK_CLEARANCE; break; case T_silk_clearance: constraint.m_Type = SILK_CLEARANCE_CONSTRAINT; break;
case T_track_width: constraint.m_Type = DRC_CONSTRAINT_TYPE_TRACK_WIDTH; break; case T_track_width: constraint.m_Type = TRACK_WIDTH_CONSTRAINT; break;
case T_annular_width: constraint.m_Type = DRC_CONSTRAINT_TYPE_ANNULAR_WIDTH; break; case T_annular_width: constraint.m_Type = ANNULAR_WIDTH_CONSTRAINT; break;
case T_disallow: constraint.m_Type = DRC_CONSTRAINT_TYPE_DISALLOW; break; case T_disallow: constraint.m_Type = DISALLOW_CONSTRAINT; break;
case T_length: constraint.m_Type = DRC_CONSTRAINT_TYPE_LENGTH; break; case T_length: constraint.m_Type = LENGTH_CONSTRAINT; break;
case T_skew: constraint.m_Type = DRC_CONSTRAINT_TYPE_SKEW; break; case T_skew: constraint.m_Type = SKEW_CONSTRAINT; break;
case T_via_count: constraint.m_Type = DRC_CONSTRAINT_TYPE_VIA_COUNT; break; case T_via_count: constraint.m_Type = VIA_COUNT_CONSTRAINT; break;
case T_diff_pair_gap: constraint.m_Type = DRC_CONSTRAINT_TYPE_DIFF_PAIR_GAP; break; case T_diff_pair_gap: constraint.m_Type = DIFF_PAIR_GAP_CONSTRAINT; break;
case T_diff_pair_uncoupled: constraint.m_Type = DRC_CONSTRAINT_TYPE_DIFF_PAIR_MAX_UNCOUPLED; break; case T_diff_pair_uncoupled: constraint.m_Type = DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT; break;
default: default:
// fixme: message // fixme: message
msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ), msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ),
@ -294,7 +294,7 @@ void DRC_RULES_PARSER::parseConstraint( DRC_RULE* aRule )
reportError( msg ); reportError( msg );
} }
if( constraint.m_Type == DRC_CONSTRAINT_TYPE_DISALLOW ) if( constraint.m_Type == DISALLOW_CONSTRAINT )
{ {
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {

View File

@ -28,7 +28,8 @@
#include <drc/drc_test_provider.h> #include <drc/drc_test_provider.h>
/* /*
Via/pad annular ring width test. Checks if there's sufficient copper ring around PTH/NPTH holes (vias/pads) Via/pad annular ring width test. Checks if there's sufficient copper ring around
PTH/NPTH holes (vias/pads)
Errors generated: Errors generated:
- DRCE_ANNULUS - DRCE_ANNULUS
@ -70,7 +71,7 @@ bool DRC_TEST_PROVIDER_ANNULUS::Run()
{ {
const int delta = 250; // This is the number of tests between 2 calls to the progress bar const int delta = 250; // This is the number of tests between 2 calls to the progress bar
if( !m_drcEngine->HasRulesForConstraintType( DRC_CONSTRAINT_TYPE_ANNULAR_WIDTH ) ) if( !m_drcEngine->HasRulesForConstraintType( ANNULAR_WIDTH_CONSTRAINT ) )
{ {
reportAux( "No annulus constraints found. Skipping check." ); reportAux( "No annulus constraints found. Skipping check." );
return false; return false;
@ -93,8 +94,7 @@ bool DRC_TEST_PROVIDER_ANNULUS::Run()
if( !via ) if( !via )
return true; return true;
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_ANNULAR_WIDTH, auto constraint = m_drcEngine->EvalRulesForItems( ANNULAR_WIDTH_CONSTRAINT, via );
via );
int annulus = ( via->GetWidth() - via->GetDrillValue() ) / 2; int annulus = ( via->GetWidth() - via->GetDrillValue() ) / 2;
bool fail_min = false; bool fail_min = false;
bool fail_max = false; bool fail_max = false;
@ -118,18 +118,18 @@ bool DRC_TEST_PROVIDER_ANNULUS::Run()
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ANNULAR_WIDTH ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ANNULAR_WIDTH );
if( fail_min ) if( fail_min )
m_msg.Printf( drcItem->GetErrorText() + wxS( " " ) + _( "(%s min annular width %s; actual %s)" ), m_msg.Printf( _( "(%s min annular width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), v_min ), MessageTextFromValue( userUnits(), v_min ),
MessageTextFromValue( userUnits(), annulus ) ); MessageTextFromValue( userUnits(), annulus ) );
if( fail_max ) if( fail_max )
m_msg.Printf( drcItem->GetErrorText() + wxS( " " ) + _( "(%s max annular width %s; actual %s)" ), m_msg.Printf( _( "(%s max annular width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), v_max ), MessageTextFromValue( userUnits(), v_max ),
MessageTextFromValue( userUnits(), annulus ) ); MessageTextFromValue( userUnits(), annulus ) );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );
@ -165,7 +165,7 @@ int DRC_TEST_PROVIDER_ANNULUS::GetNumPhases() const
std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_ANNULUS::GetConstraintTypes() const std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_ANNULUS::GetConstraintTypes() const
{ {
return { DRC_CONSTRAINT_TYPE_ANNULAR_WIDTH }; return { ANNULAR_WIDTH_CONSTRAINT };
} }

View File

@ -107,8 +107,7 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run()
m_board = m_drcEngine->GetBoard(); m_board = m_drcEngine->GetBoard();
DRC_CONSTRAINT worstClearanceConstraint; DRC_CONSTRAINT worstClearanceConstraint;
if( m_drcEngine->QueryWorstConstraint( DRC_CONSTRAINT_TYPE_CLEARANCE, if( m_drcEngine->QueryWorstConstraint( CLEARANCE_CONSTRAINT, worstClearanceConstraint ) )
worstClearanceConstraint, DRCCQ_LARGEST_MINIMUM ) )
{ {
m_largestClearance = worstClearanceConstraint.GetValue().Min(); m_largestClearance = worstClearanceConstraint.GetValue().Min();
} }
@ -256,8 +255,8 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( TRACK* track, SHA
if( m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE ) ) if( m_drcEngine->IsErrorLimitExceeded( DRCE_CLEARANCE ) )
return false; return false;
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_CLEARANCE, auto constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, track, other,
track, other, layer ); layer );
int minClearance = constraint.GetValue().Min(); int minClearance = constraint.GetValue().Min();
int actual; int actual;
VECTOR2I pos; VECTOR2I pos;
@ -325,8 +324,8 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aItem
if( aItem->GetBoundingBox().Intersects( zone->GetCachedBoundingBox() ) ) if( aItem->GetBoundingBox().Intersects( zone->GetCachedBoundingBox() ) )
{ {
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_CLEARANCE, auto constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, aItem, zone,
aItem, zone, aLayer ); aLayer );
int clearance = constraint.GetValue().Min(); int clearance = constraint.GetValue().Min();
int actual; int actual;
VECTOR2I pos; VECTOR2I pos;
@ -370,6 +369,7 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackClearances()
std::shared_ptr<SHAPE> trackShape = track->GetEffectiveShape( layer ); std::shared_ptr<SHAPE> trackShape = track->GetEffectiveShape( layer );
m_copperTree.QueryColliding( track, layer, layer, m_copperTree.QueryColliding( track, layer, layer,
// Filter:
[&]( BOARD_ITEM* other ) -> bool [&]( BOARD_ITEM* other ) -> bool
{ {
if( other->HasFlag( SKIP_STRUCT ) ) if( other->HasFlag( SKIP_STRUCT ) )
@ -382,6 +382,7 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackClearances()
return true; return true;
}, },
// Visitor:
[&]( BOARD_ITEM* other ) -> bool [&]( BOARD_ITEM* other ) -> bool
{ {
return testTrackAgainstItem( track, trackShape.get(), layer, other ); return testTrackAgainstItem( track, trackShape.get(), layer, other );
@ -449,8 +450,8 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( D_PAD* pad, SHAPE*
if( ( pad->FlashLayer( layer ) && otherPad->GetDrillSize().x ) if( ( pad->FlashLayer( layer ) && otherPad->GetDrillSize().x )
|| ( pad->GetDrillSize().x && otherPad->FlashLayer( layer ) ) ) || ( pad->GetDrillSize().x && otherPad->FlashLayer( layer ) ) )
{ {
constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE, constraint = m_drcEngine->EvalRulesForItems( HOLE_CLEARANCE_CONSTRAINT, pad,
pad, otherPad ); otherPad );
clearance = constraint.GetValue().Min(); clearance = constraint.GetValue().Min();
accountCheck( constraint.GetParentRule() ); accountCheck( constraint.GetParentRule() );
@ -480,8 +481,7 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( D_PAD* pad, SHAPE*
if( testClearance ) if( testClearance )
{ {
constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_CLEARANCE, constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, pad, other, layer );
pad, other, layer );
clearance = constraint.GetValue().Min(); clearance = constraint.GetValue().Min();
accountCheck( constraint ); accountCheck( constraint );
@ -532,6 +532,7 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadClearances( )
std::shared_ptr<SHAPE> padShape = getShape( pad, layer ); std::shared_ptr<SHAPE> padShape = getShape( pad, layer );
m_copperTree.QueryColliding( pad, layer, layer, m_copperTree.QueryColliding( pad, layer, layer,
// Filter:
[&]( BOARD_ITEM* other ) -> bool [&]( BOARD_ITEM* other ) -> bool
{ {
if( other->HasFlag( SKIP_STRUCT ) ) if( other->HasFlag( SKIP_STRUCT ) )
@ -539,6 +540,7 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadClearances( )
return true; return true;
}, },
// Visitor
[&]( BOARD_ITEM* other ) -> bool [&]( BOARD_ITEM* other ) -> bool
{ {
return testPadAgainstItem( pad, padShape.get(), layer, other ); return testPadAgainstItem( pad, padShape.get(), layer, other );
@ -619,8 +621,8 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZones()
// Examine a candidate zone: compare zoneToTest to zoneRef // Examine a candidate zone: compare zoneToTest to zoneRef
// Get clearance used in zone to zone test. // Get clearance used in zone to zone test.
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_CLEARANCE, auto constraint = m_drcEngine->EvalRulesForItems( CLEARANCE_CONSTRAINT, zoneRef,
zoneRef, zoneToTest ); zoneToTest );
int zone2zoneClearance = constraint.GetValue().Min(); int zone2zoneClearance = constraint.GetValue().Min();
accountCheck( constraint ); accountCheck( constraint );
@ -746,7 +748,7 @@ int DRC_TEST_PROVIDER_COPPER_CLEARANCE::GetNumPhases() const
std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_COPPER_CLEARANCE::GetConstraintTypes() const std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_COPPER_CLEARANCE::GetConstraintTypes() const
{ {
return { DRC_CONSTRAINT_TYPE_CLEARANCE }; return { CLEARANCE_CONSTRAINT };
} }

View File

@ -219,7 +219,7 @@ int DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::GetNumPhases() const
std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::GetConstraintTypes() const std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::GetConstraintTypes() const
{ {
return { DRC_CONSTRAINT_TYPE_COURTYARD_CLEARANCE }; return { COURTYARD_CLEARANCE_CONSTRAINT };
} }

View File

@ -277,8 +277,8 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run()
drc_dbg( 10, "eval dp %p\n", item ); drc_dbg( 10, "eval dp %p\n", item );
const DRC_CONSTRAINT_TYPE_T constraintsToCheck[] = { const DRC_CONSTRAINT_TYPE_T constraintsToCheck[] = {
DRC_CONSTRAINT_TYPE_DIFF_PAIR_GAP, DIFF_PAIR_GAP_CONSTRAINT,
DRC_CONSTRAINT_TYPE_DIFF_PAIR_MAX_UNCOUPLED DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT
}; };
for( int i = 0; i < 2; i++ ) for( int i = 0; i < 2; i++ )
@ -348,8 +348,8 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run()
drc_dbg(10, " coupled prims : %d\n", (int) it.second.coupled.size() ); drc_dbg(10, " coupled prims : %d\n", (int) it.second.coupled.size() );
OPT<DRC_CONSTRAINT> gapConstraint = it.first.parentRule->FindConstraint( DRC_CONSTRAINT_TYPE_DIFF_PAIR_GAP ); OPT<DRC_CONSTRAINT> gapConstraint = it.first.parentRule->FindConstraint( DIFF_PAIR_GAP_CONSTRAINT );
OPT<DRC_CONSTRAINT> maxUncoupledConstraint = it.first.parentRule->FindConstraint( DRC_CONSTRAINT_TYPE_DIFF_PAIR_MAX_UNCOUPLED ); OPT<DRC_CONSTRAINT> maxUncoupledConstraint = it.first.parentRule->FindConstraint( DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT );
for( auto& item : it.second.itemsN ) for( auto& item : it.second.itemsN )
{ {
@ -495,7 +495,7 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run()
std::set<DRC_CONSTRAINT_TYPE_T> test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::GetConstraintTypes() const std::set<DRC_CONSTRAINT_TYPE_T> test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::GetConstraintTypes() const
{ {
return { DRC_CONSTRAINT_TYPE_DIFF_PAIR_GAP, DRC_CONSTRAINT_TYPE_DIFF_PAIR_MAX_UNCOUPLED }; return { DIFF_PAIR_GAP_CONSTRAINT, DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT };
} }

View File

@ -64,7 +64,7 @@ public:
bool DRC_TEST_PROVIDER_DISALLOW::Run() bool DRC_TEST_PROVIDER_DISALLOW::Run()
{ {
if( !m_drcEngine->HasRulesForConstraintType( DRC_CONSTRAINT_TYPE_DISALLOW ) ) if( !m_drcEngine->HasRulesForConstraintType( DISALLOW_CONSTRAINT ) )
{ {
reportAux( "No disallow constraints found. Skipping check." ); reportAux( "No disallow constraints found. Skipping check." );
return false; return false;
@ -76,8 +76,7 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run()
auto doCheckItem = auto doCheckItem =
[&]( BOARD_ITEM* item ) [&]( BOARD_ITEM* item )
{ {
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_DISALLOW, auto constraint = m_drcEngine->EvalRulesForItems( DISALLOW_CONSTRAINT, item );
item );
if( constraint.m_DisallowFlags ) if( constraint.m_DisallowFlags )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ALLOWED_ITEMS ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ALLOWED_ITEMS );
@ -127,7 +126,7 @@ int DRC_TEST_PROVIDER_DISALLOW::GetNumPhases() const
std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_DISALLOW::GetConstraintTypes() const std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_DISALLOW::GetConstraintTypes() const
{ {
return { DRC_CONSTRAINT_TYPE_DISALLOW }; return { DISALLOW_CONSTRAINT };
} }

View File

@ -124,11 +124,8 @@ bool DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run()
DRC_CONSTRAINT worstClearanceConstraint; DRC_CONSTRAINT worstClearanceConstraint;
if( m_drcEngine->QueryWorstConstraint( DRC_CONSTRAINT_TYPE_EDGE_CLEARANCE, if( m_drcEngine->QueryWorstConstraint( EDGE_CLEARANCE_CONSTRAINT, worstClearanceConstraint ) )
worstClearanceConstraint, DRCCQ_LARGEST_MINIMUM ) )
{
m_largestClearance = worstClearanceConstraint.GetValue().Min(); m_largestClearance = worstClearanceConstraint.GetValue().Min();
}
reportAux( "Worst clearance : %d nm", m_largestClearance ); reportAux( "Worst clearance : %d nm", m_largestClearance );
@ -226,7 +223,7 @@ bool DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run()
[&]( BOARD_ITEM* edge ) -> bool [&]( BOARD_ITEM* edge ) -> bool
{ {
return testAgainstEdge( item, itemShape.get(), edge, return testAgainstEdge( item, itemShape.get(), edge,
DRC_CONSTRAINT_TYPE_EDGE_CLEARANCE, EDGE_CLEARANCE_CONSTRAINT,
DRCE_COPPER_EDGE_CLEARANCE ); DRCE_COPPER_EDGE_CLEARANCE );
}, },
m_largestClearance ); m_largestClearance );
@ -238,7 +235,7 @@ bool DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run()
[&]( BOARD_ITEM* edge ) -> bool [&]( BOARD_ITEM* edge ) -> bool
{ {
return testAgainstEdge( item, itemShape.get(), edge, return testAgainstEdge( item, itemShape.get(), edge,
DRC_CONSTRAINT_TYPE_SILK_CLEARANCE, SILK_CLEARANCE_CONSTRAINT,
DRCE_SILK_MASK_CLEARANCE ); DRCE_SILK_MASK_CLEARANCE );
}, },
m_largestClearance ); m_largestClearance );
@ -259,7 +256,7 @@ int DRC_TEST_PROVIDER_EDGE_CLEARANCE::GetNumPhases() const
std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_EDGE_CLEARANCE::GetConstraintTypes() const std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_EDGE_CLEARANCE::GetConstraintTypes() const
{ {
return { DRC_CONSTRAINT_TYPE_EDGE_CLEARANCE, DRC_CONSTRAINT_TYPE_SILK_CLEARANCE }; return { EDGE_CLEARANCE_CONSTRAINT, SILK_CLEARANCE_CONSTRAINT };
} }

View File

@ -26,7 +26,6 @@
#include <class_track.h> #include <class_track.h>
#include <geometry/shape_segment.h> #include <geometry/shape_segment.h>
#include <geometry/shape_circle.h> #include <geometry/shape_circle.h>
#include <drc/drc_engine.h>
#include <drc/drc_item.h> #include <drc/drc_item.h>
#include <drc/drc_rule.h> #include <drc/drc_rule.h>
#include <drc/drc_test_provider_clearance_base.h> #include <drc/drc_test_provider_clearance_base.h>
@ -100,8 +99,7 @@ bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::Run()
DRC_CONSTRAINT worstClearanceConstraint; DRC_CONSTRAINT worstClearanceConstraint;
if( m_drcEngine->QueryWorstConstraint( DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE, if( m_drcEngine->QueryWorstConstraint( HOLE_CLEARANCE_CONSTRAINT, worstClearanceConstraint ) )
worstClearanceConstraint, DRCCQ_LARGEST_MINIMUM ) )
{ {
m_largestClearance = worstClearanceConstraint.GetValue().Min(); m_largestClearance = worstClearanceConstraint.GetValue().Min();
reportAux( "Worst hole clearance : %d nm", m_largestClearance ); reportAux( "Worst hole clearance : %d nm", m_largestClearance );
@ -180,6 +178,7 @@ bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::Run()
std::shared_ptr<SHAPE_CIRCLE> holeShape = getDrilledHoleShape( via ); std::shared_ptr<SHAPE_CIRCLE> holeShape = getDrilledHoleShape( via );
m_holeTree.QueryColliding( via, F_Cu, F_Cu, m_holeTree.QueryColliding( via, F_Cu, F_Cu,
// Filter:
[&]( BOARD_ITEM* other ) -> bool [&]( BOARD_ITEM* other ) -> bool
{ {
if( other->HasFlag( SKIP_STRUCT ) ) if( other->HasFlag( SKIP_STRUCT ) )
@ -187,6 +186,7 @@ bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::Run()
return true; return true;
}, },
// Visitor:
[&]( BOARD_ITEM* other ) -> bool [&]( BOARD_ITEM* other ) -> bool
{ {
return testHoleAgainstHole( via, holeShape.get(), other ); return testHoleAgainstHole( via, holeShape.get(), other );
@ -206,6 +206,7 @@ bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::Run()
std::shared_ptr<SHAPE_CIRCLE> holeShape = getDrilledHoleShape( pad ); std::shared_ptr<SHAPE_CIRCLE> holeShape = getDrilledHoleShape( pad );
m_holeTree.QueryColliding( pad, F_Cu, F_Cu, m_holeTree.QueryColliding( pad, F_Cu, F_Cu,
// Filter:
[&]( BOARD_ITEM* other ) -> bool [&]( BOARD_ITEM* other ) -> bool
{ {
if( other->HasFlag( SKIP_STRUCT ) ) if( other->HasFlag( SKIP_STRUCT ) )
@ -213,6 +214,7 @@ bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::Run()
return true; return true;
}, },
// Visitor:
[&]( BOARD_ITEM* other ) -> bool [&]( BOARD_ITEM* other ) -> bool
{ {
return testHoleAgainstHole( pad, holeShape.get(), other ); return testHoleAgainstHole( pad, holeShape.get(), other );
@ -244,8 +246,7 @@ bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::testHoleAgainstHole( BOARD_ITEM* aItem, S
int actual = ( aHole->GetCenter() - otherHole->GetCenter() ).EuclideanNorm(); int actual = ( aHole->GetCenter() - otherHole->GetCenter() ).EuclideanNorm();
actual = std::max( 0, actual - aHole->GetRadius() - otherHole->GetRadius() ); actual = std::max( 0, actual - aHole->GetRadius() - otherHole->GetRadius() );
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE, auto constraint = m_drcEngine->EvalRulesForItems( HOLE_CLEARANCE_CONSTRAINT, aItem, aOther );
aItem, aOther );
int minClearance = constraint.GetValue().Min(); int minClearance = constraint.GetValue().Min();
accountCheck( constraint.GetParentRule() ); accountCheck( constraint.GetParentRule() );
@ -278,7 +279,7 @@ int DRC_TEST_PROVIDER_HOLE_CLEARANCE::GetNumPhases() const
std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_HOLE_CLEARANCE::GetConstraintTypes() const std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_HOLE_CLEARANCE::GetConstraintTypes() const
{ {
return { DRC_CONSTRAINT_TYPE_HOLE_CLEARANCE }; return { HOLE_CLEARANCE_CONSTRAINT };
} }

View File

@ -131,7 +131,7 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkPad( D_PAD* aPad )
if( holeSize == 0 ) if( holeSize == 0 )
return; return;
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_HOLE_SIZE, aPad ); auto constraint = m_drcEngine->EvalRulesForItems( HOLE_SIZE_CONSTRAINT, aPad );
int minHole = constraint.GetValue().Min(); int minHole = constraint.GetValue().Min();
accountCheck( constraint ); accountCheck( constraint );
@ -140,12 +140,12 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkPad( D_PAD* aPad )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TOO_SMALL_DRILL ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TOO_SMALL_DRILL );
m_msg.Printf( drcItem->GetErrorText() + wxS( " " ) + _( "(%s %s; actual %s)" ), m_msg.Printf( _( "(%s %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), minHole ), MessageTextFromValue( userUnits(), minHole ),
MessageTextFromValue( userUnits(), holeSize ) ); MessageTextFromValue( userUnits(), holeSize ) );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
drcItem->SetItems( aPad ); drcItem->SetItems( aPad );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );
@ -173,7 +173,7 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkVia( VIA* via, bool aExceedMicro, bool aE
errorCode = DRCE_TOO_SMALL_DRILL; errorCode = DRCE_TOO_SMALL_DRILL;
} }
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_HOLE_SIZE, via ); auto constraint = m_drcEngine->EvalRulesForItems( HOLE_SIZE_CONSTRAINT, via );
int minHole = constraint.GetValue().Min(); int minHole = constraint.GetValue().Min();
accountCheck( constraint ); accountCheck( constraint );
@ -182,12 +182,12 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkVia( VIA* via, bool aExceedMicro, bool aE
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( errorCode ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( errorCode );
m_msg.Printf( drcItem->GetErrorText() + wxS( " " ) + _( "(%s %s; actual %s)" ), m_msg.Printf( _( "(%s %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), minHole ), MessageTextFromValue( userUnits(), minHole ),
MessageTextFromValue( userUnits(), via->GetDrillValue() ) ); MessageTextFromValue( userUnits(), via->GetDrillValue() ) );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
drcItem->SetItems( via ); drcItem->SetItems( via );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );
@ -204,7 +204,7 @@ int DRC_TEST_PROVIDER_HOLE_SIZE::GetNumPhases() const
std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_HOLE_SIZE::GetConstraintTypes() const std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_HOLE_SIZE::GetConstraintTypes() const
{ {
return { DRC_CONSTRAINT_TYPE_HOLE_SIZE }; return { HOLE_SIZE_CONSTRAINT };
} }

View File

@ -22,7 +22,6 @@
#include <class_pad.h> #include <class_pad.h>
#include <class_track.h> #include <class_track.h>
#include <drc/drc_engine.h>
#include <drc/drc_item.h> #include <drc/drc_item.h>
#include <drc/drc_rule.h> #include <drc/drc_rule.h>
#include <drc/drc_test_provider.h> #include <drc/drc_test_provider.h>
@ -42,8 +41,6 @@
Todo: arc support Todo: arc support
*/ */
namespace test {
class DRC_TEST_PROVIDER_MATCHED_LENGTH : public DRC_TEST_PROVIDER class DRC_TEST_PROVIDER_MATCHED_LENGTH : public DRC_TEST_PROVIDER
{ {
public: public:
@ -93,8 +90,6 @@ private:
DRC_LENGTH_REPORT m_report; DRC_LENGTH_REPORT m_report;
}; };
};
static int computeViaThruLength( VIA *aVia, const std::set<BOARD_CONNECTED_ITEM*> &conns ) static int computeViaThruLength( VIA *aVia, const std::set<BOARD_CONNECTED_ITEM*> &conns )
{ {
@ -102,10 +97,10 @@ static int computeViaThruLength( VIA *aVia, const std::set<BOARD_CONNECTED_ITEM*
} }
void test::DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengthViolations( void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengthViolations( DRC_CONSTRAINT& aConstraint,
DRC_CONSTRAINT& aConstraint, LENGTH_ENTRIES& matchedConnections ) LENGTH_ENTRIES& matchedConnections )
{ {
for( const auto& ent : matchedConnections ) for( const DRC_LENGTH_REPORT::ENTRY& ent : matchedConnections )
{ {
bool minViolation = false; bool minViolation = false;
bool maxViolation = false; bool maxViolation = false;
@ -126,23 +121,23 @@ void test::DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengthViolations(
if( ( minViolation || maxViolation ) ) if( ( minViolation || maxViolation ) )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LENGTH_OUT_OF_RANGE ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LENGTH_OUT_OF_RANGE );
wxString msg =
drcItem->GetErrorText() + " (" + aConstraint.GetParentRule()->m_Name + " ";
if( minViolation ) if( minViolation )
{ {
msg += wxString::Format( _( "minimum length: %s; actual: %s)" ), m_msg.Printf( _( "(%s min length: %s; actual: %s)" ),
aConstraint.GetName(),
MessageTextFromValue( userUnits(), minLen ), MessageTextFromValue( userUnits(), minLen ),
MessageTextFromValue( userUnits(), ent.total ) ); MessageTextFromValue( userUnits(), ent.total ) );
} }
else if( maxViolation ) else if( maxViolation )
{ {
msg += wxString::Format( _( "maximum length: %s; actual: %s)" ), m_msg.Printf( _( "(%s max length: %s; actual: %s)" ),
aConstraint.GetName(),
MessageTextFromValue( userUnits(), maxLen ), MessageTextFromValue( userUnits(), maxLen ),
MessageTextFromValue( userUnits(), ent.total ) ); MessageTextFromValue( userUnits(), ent.total ) );
} }
drcItem->SetErrorMessage( msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
for( auto offendingTrack : ent.items ) for( auto offendingTrack : ent.items )
drcItem->AddItem( offendingTrack ); drcItem->AddItem( offendingTrack );
@ -154,15 +149,13 @@ void test::DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengthViolations(
} }
} }
void test::DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkewViolations( void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkewViolations( DRC_CONSTRAINT& aConstraint,
DRC_CONSTRAINT& aConstraint, LENGTH_ENTRIES& matchedConnections ) LENGTH_ENTRIES& matchedConnections )
{ {
int avgLength = 0; int avgLength = 0;
for( const auto& ent : matchedConnections ) for( const DRC_LENGTH_REPORT::ENTRY& ent : matchedConnections )
{
avgLength += ent.total; avgLength += ent.total;
}
avgLength /= matchedConnections.size(); avgLength /= matchedConnections.size();
@ -172,19 +165,17 @@ void test::DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkewViolations(
if( aConstraint.GetValue().HasMax() && abs( skew ) > aConstraint.GetValue().Max() ) if( aConstraint.GetValue().HasMax() && abs( skew ) > aConstraint.GetValue().Max() )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_SKEW_OUT_OF_RANGE ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_SKEW_OUT_OF_RANGE );
wxString msg =
drcItem->GetErrorText() + " (" + aConstraint.GetParentRule()->m_Name + " ";
msg += wxString::Format( _( "maximum skew: %s; actual skew: %s; average net length: %s; actual net length: %s)" ), m_msg.Printf( _( "(%s max skew: %s; actual: %s; average net length: %s; actual: %s)" ),
aConstraint.GetName(),
MessageTextFromValue( userUnits(), aConstraint.GetValue().Max() ), MessageTextFromValue( userUnits(), aConstraint.GetValue().Max() ),
MessageTextFromValue( userUnits(), skew ), MessageTextFromValue( userUnits(), skew ),
MessageTextFromValue( userUnits(), avgLength ), MessageTextFromValue( userUnits(), avgLength ),
MessageTextFromValue( userUnits(), ent.total ) MessageTextFromValue( userUnits(), ent.total ) );
);
drcItem->SetErrorMessage( msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + " " + m_msg );
for( auto offendingTrack : ent.items ) for( BOARD_CONNECTED_ITEM* offendingTrack : ent.items )
drcItem->SetItems( offendingTrack ); drcItem->SetItems( offendingTrack );
drcItem->SetViolatingRule( aConstraint.GetParentRule() ); drcItem->SetViolatingRule( aConstraint.GetParentRule() );
@ -195,21 +186,21 @@ void test::DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkewViolations(
} }
void test::DRC_TEST_PROVIDER_MATCHED_LENGTH::checkViaCountViolations( void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkViaCountViolations( DRC_CONSTRAINT& aConstraint,
DRC_CONSTRAINT& aConstraint, LENGTH_ENTRIES& matchedConnections ) LENGTH_ENTRIES& matchedConnections )
{ {
for( const auto& ent : matchedConnections ) for( const auto& ent : matchedConnections )
{ {
if( aConstraint.GetValue().HasMax() && ent.viaCount > aConstraint.GetValue().Max() ) if( aConstraint.GetValue().HasMax() && ent.viaCount > aConstraint.GetValue().Max() )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TOO_MANY_VIAS ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TOO_MANY_VIAS );
wxString msg =
drcItem->GetErrorText() + " (" + aConstraint.GetParentRule()->m_Name + " ";
msg += wxString::Format( _( "max vias: %d; actual: %d" ), m_msg.Printf( _( "(%s max count: %d; actual: %d)" ),
aConstraint.GetValue().Max(), ent.viaCount ); aConstraint.GetName(),
aConstraint.GetValue().Max(),
ent.viaCount );
drcItem->SetErrorMessage( msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
for( auto offendingTrack : ent.items ) for( auto offendingTrack : ent.items )
drcItem->SetItems( offendingTrack ); drcItem->SetItems( offendingTrack );
@ -222,13 +213,13 @@ void test::DRC_TEST_PROVIDER_MATCHED_LENGTH::checkViaCountViolations(
} }
bool test::DRC_TEST_PROVIDER_MATCHED_LENGTH::Run() bool DRC_TEST_PROVIDER_MATCHED_LENGTH::Run()
{ {
return runInternal( false ); return runInternal( false );
} }
bool test::DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode ) bool DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode )
{ {
m_board = m_drcEngine->GetBoard(); m_board = m_drcEngine->GetBoard();
m_report.Clear(); m_report.Clear();
@ -245,14 +236,15 @@ bool test::DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode
[&]( BOARD_ITEM *item ) -> bool [&]( BOARD_ITEM *item ) -> bool
{ {
const DRC_CONSTRAINT_TYPE_T constraintsToCheck[] = { const DRC_CONSTRAINT_TYPE_T constraintsToCheck[] = {
DRC_CONSTRAINT_TYPE_LENGTH, LENGTH_CONSTRAINT,
DRC_CONSTRAINT_TYPE_SKEW, SKEW_CONSTRAINT,
DRC_CONSTRAINT_TYPE_VIA_COUNT, VIA_COUNT_CONSTRAINT,
}; };
for( int i = 0; i < 3; i++ ) for( int i = 0; i < 3; i++ )
{ {
auto constraint = m_drcEngine->EvalRulesForItems( constraintsToCheck[i], item, nullptr, item->GetLayer() ); auto constraint = m_drcEngine->EvalRulesForItems( constraintsToCheck[i], item,
nullptr, item->GetLayer() );
if( constraint.IsNull() ) if( constraint.IsNull() )
continue; continue;
@ -269,8 +261,8 @@ bool test::DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode
ftCache->Rebuild( m_board ); ftCache->Rebuild( m_board );
forEachGeometryItem( { PCB_TRACE_T, PCB_VIA_T, PCB_ARC_T }, forEachGeometryItem( { PCB_TRACE_T, PCB_VIA_T, PCB_ARC_T }, LSET::AllCuMask(),
LSET::AllCuMask(), evaluateLengthConstraints ); evaluateLengthConstraints );
std::map<DRC_RULE*, LENGTH_ENTRIES> matches; std::map<DRC_RULE*, LENGTH_ENTRIES> matches;
@ -345,15 +337,17 @@ bool test::DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode
[] ( const LENGTH_ENTRY&a, const LENGTH_ENTRY&b ) -> int [] ( const LENGTH_ENTRY&a, const LENGTH_ENTRY&b ) -> int
{ {
return a.netname < b.netname; return a.netname < b.netname;
} } );
);
reportAux( wxString::Format( _("Length-constrained traces for rule '%s':"), it.first->m_Name ) ); reportAux( wxString::Format( "Length-constrained traces for rule '%s':",
it.first->m_Name ) );
for( auto& ent : matchedConnections ) for( auto& ent : matchedConnections )
{ {
reportAux(wxString::Format( reportAux(wxString::Format( " - net: %s, from: %s, to: %s, "
" - net: %s, from: %s, to: %s, %d matching items, total: %s (tracks: %s, vias: %s, pad-to-die: %s), vias: %d", "%d matching items, "
"total: %s (tracks: %s, vias: %s, pad-to-die: %s), "
"vias: %d",
ent.netname, ent.netname,
ent.from, ent.from,
ent.to, ent.to,
@ -362,29 +356,25 @@ bool test::DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode
MessageTextFromValue( userUnits(), ent.totalRoute ), MessageTextFromValue( userUnits(), ent.totalRoute ),
MessageTextFromValue( userUnits(), ent.totalVia ), MessageTextFromValue( userUnits(), ent.totalVia ),
MessageTextFromValue( userUnits(), ent.totalPadToDie ), MessageTextFromValue( userUnits(), ent.totalPadToDie ),
ent.viaCount ent.viaCount ) );
) );
} }
OPT<DRC_CONSTRAINT> lengthConstraint = rule->FindConstraint( DRC_CONSTRAINT_TYPE_LENGTH ); OPT<DRC_CONSTRAINT> lengthConstraint = rule->FindConstraint( LENGTH_CONSTRAINT );
if( lengthConstraint ) if( lengthConstraint )
{
checkLengthViolations( *lengthConstraint, matchedConnections ); checkLengthViolations( *lengthConstraint, matchedConnections );
}
OPT<DRC_CONSTRAINT> skewConstraint = rule->FindConstraint( DRC_CONSTRAINT_TYPE_SKEW ); OPT<DRC_CONSTRAINT> skewConstraint = rule->FindConstraint( SKEW_CONSTRAINT );
if( skewConstraint ) if( skewConstraint )
{
checkSkewViolations( *skewConstraint, matchedConnections ); checkSkewViolations( *skewConstraint, matchedConnections );
}
OPT<DRC_CONSTRAINT> viaCountConstraint = rule->FindConstraint( DRC_CONSTRAINT_TYPE_VIA_COUNT ); OPT<DRC_CONSTRAINT> viaCountConstraint = rule->FindConstraint( VIA_COUNT_CONSTRAINT );
if( viaCountConstraint ) if( viaCountConstraint )
{
checkViaCountViolations( *viaCountConstraint, matchedConnections ); checkViaCountViolations( *viaCountConstraint, matchedConnections );
} }
}
reportRuleStatistics(); reportRuleStatistics();
} }
@ -393,13 +383,13 @@ bool test::DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode
} }
std::set<DRC_CONSTRAINT_TYPE_T> test::DRC_TEST_PROVIDER_MATCHED_LENGTH::GetConstraintTypes() const std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_MATCHED_LENGTH::GetConstraintTypes() const
{ {
return { DRC_CONSTRAINT_TYPE_LENGTH, DRC_CONSTRAINT_TYPE_SKEW, DRC_CONSTRAINT_TYPE_VIA_COUNT }; return { LENGTH_CONSTRAINT, SKEW_CONSTRAINT, VIA_COUNT_CONSTRAINT };
} }
namespace detail namespace detail
{ {
static DRC_REGISTER_TEST_PROVIDER<test::DRC_TEST_PROVIDER_MATCHED_LENGTH> dummy; static DRC_REGISTER_TEST_PROVIDER<DRC_TEST_PROVIDER_MATCHED_LENGTH> dummy;
} }

View File

@ -95,9 +95,9 @@ void DRC_TEST_PROVIDER_MISC::testOutline()
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_INVALID_OUTLINE ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_INVALID_OUTLINE );
m_msg.Printf( drcItem->GetErrorText() + wxS( " " ) + _( "(not a closed shape)" ) ); m_msg.Printf( _( "(not a closed shape)" ) );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
drcItem->SetItems( m_board ); drcItem->SetItems( m_board );
reportViolation( drcItem, pt ); reportViolation( drcItem, pt );
@ -107,9 +107,9 @@ void DRC_TEST_PROVIDER_MISC::testOutline()
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_INVALID_OUTLINE ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_INVALID_OUTLINE );
m_msg.Printf( drcItem->GetErrorText() + wxS( " " ) + _( "(self-intersecting)" ) ); m_msg.Printf( _( "(self-intersecting)" ) );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
drcItem->SetItems( m_board ); drcItem->SetItems( m_board );
reportViolation( drcItem, pt ); reportViolation( drcItem, pt );
@ -133,10 +133,10 @@ void DRC_TEST_PROVIDER_MISC::testDisabledLayers()
{ {
std::shared_ptr<DRC_ITEM>drcItem = DRC_ITEM::Create( DRCE_DISABLED_LAYER_ITEM ); std::shared_ptr<DRC_ITEM>drcItem = DRC_ITEM::Create( DRCE_DISABLED_LAYER_ITEM );
m_msg.Printf( drcItem->GetErrorText() + wxS( " " ) + _( "(layer %s)" ), m_msg.Printf( _( "(layer %s)" ),
item->GetLayerName() ); item->GetLayerName() );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
reportViolation( drcItem, item->GetPosition()); reportViolation( drcItem, item->GetPosition());

View File

@ -28,7 +28,6 @@
#include <geometry/seg.h> #include <geometry/seg.h>
#include <geometry/shape_segment.h> #include <geometry/shape_segment.h>
#include <drc/drc_engine.h>
#include <drc/drc_item.h> #include <drc/drc_item.h>
#include <drc/drc_rule.h> #include <drc/drc_rule.h>
#include <drc/drc_test_provider_clearance_base.h> #include <drc/drc_test_provider_clearance_base.h>
@ -97,11 +96,8 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run()
return true; return true;
} }
if( m_drcEngine->QueryWorstConstraint( DRC_CONSTRAINT_TYPE_SILK_CLEARANCE, if( m_drcEngine->QueryWorstConstraint( SILK_CLEARANCE_CONSTRAINT, worstClearanceConstraint ) )
worstClearanceConstraint, DRCCQ_LARGEST_MINIMUM ) )
{
m_largestClearance = worstClearanceConstraint.m_Value.Min(); m_largestClearance = worstClearanceConstraint.m_Value.Min();
}
reportAux( "Worst clearance : %d nm", m_largestClearance ); reportAux( "Worst clearance : %d nm", m_largestClearance );
@ -150,7 +146,7 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run()
if ( isInvisibleText( aTestItem->parent ) ) if ( isInvisibleText( aTestItem->parent ) )
return true; return true;
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_SILK_CLEARANCE, auto constraint = m_drcEngine->EvalRulesForItems( SILK_CLEARANCE_CONSTRAINT,
aRefItem->parent, aRefItem->parent,
aTestItem->parent, aTestItem->parent,
aLayers.second ); aLayers.second );
@ -185,12 +181,12 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run()
if( minClearance > 0 ) if( minClearance > 0 )
{ {
m_msg.Printf( drcItem->GetErrorText() + wxS( " " ) + _( "(%s clearance %s; actual %s)" ), m_msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetParentRule()->m_Name, constraint.GetParentRule()->m_Name,
MessageTextFromValue( userUnits(), minClearance ), MessageTextFromValue( userUnits(), minClearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
} }
drcItem->SetItems( aRefItem->parent, aTestItem->parent ); drcItem->SetItems( aRefItem->parent, aTestItem->parent );
@ -247,7 +243,7 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run()
std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_SILK_CLEARANCE::GetConstraintTypes() const std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_SILK_CLEARANCE::GetConstraintTypes() const
{ {
return { DRC_CONSTRAINT_TYPE_SILK_CLEARANCE }; return { SILK_CLEARANCE_CONSTRAINT };
} }

View File

@ -27,7 +27,6 @@
#include <geometry/seg.h> #include <geometry/seg.h>
#include <geometry/shape_segment.h> #include <geometry/shape_segment.h>
#include <drc/drc_engine.h>
#include <drc/drc_item.h> #include <drc/drc_item.h>
#include <drc/drc_rule.h> #include <drc/drc_rule.h>
#include <drc/drc_test_provider_clearance_base.h> #include <drc/drc_test_provider_clearance_base.h>
@ -92,11 +91,8 @@ bool DRC_TEST_PROVIDER_SILK_TO_MASK::Run()
DRC_CONSTRAINT worstClearanceConstraint; DRC_CONSTRAINT worstClearanceConstraint;
m_largestClearance = 0; m_largestClearance = 0;
if( m_drcEngine->QueryWorstConstraint( DRC_CONSTRAINT_TYPE_SILK_CLEARANCE, if( m_drcEngine->QueryWorstConstraint( SILK_CLEARANCE_CONSTRAINT, worstClearanceConstraint ) )
worstClearanceConstraint, DRCCQ_LARGEST_MINIMUM ) )
{
m_largestClearance = worstClearanceConstraint.m_Value.Min(); m_largestClearance = worstClearanceConstraint.m_Value.Min();
}
reportAux( "Worst clearance : %d nm", m_largestClearance ); reportAux( "Worst clearance : %d nm", m_largestClearance );
@ -126,7 +122,7 @@ bool DRC_TEST_PROVIDER_SILK_TO_MASK::Run()
if( m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_MASK_CLEARANCE ) ) if( m_drcEngine->IsErrorLimitExceeded( DRCE_SILK_MASK_CLEARANCE ) )
return false; return false;
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_SILK_CLEARANCE, auto constraint = m_drcEngine->EvalRulesForItems( SILK_CLEARANCE_CONSTRAINT,
aRefItem->parent, aRefItem->parent,
aTestItem->parent ); aTestItem->parent );
@ -149,12 +145,12 @@ bool DRC_TEST_PROVIDER_SILK_TO_MASK::Run()
if( minClearance > 0 ) if( minClearance > 0 )
{ {
m_msg.Printf( drcItem->GetErrorText() + wxS( " " ) + _( "(%s clearance %s; actual %s)" ), m_msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), minClearance ), MessageTextFromValue( userUnits(), minClearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
} }
drcItem->SetItems( aRefItem->parent, aTestItem->parent ); drcItem->SetItems( aRefItem->parent, aTestItem->parent );
@ -194,7 +190,7 @@ bool DRC_TEST_PROVIDER_SILK_TO_MASK::Run()
std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_SILK_TO_MASK::GetConstraintTypes() const std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_SILK_TO_MASK::GetConstraintTypes() const
{ {
return { DRC_CONSTRAINT_TYPE_SILK_CLEARANCE }; return { SILK_CLEARANCE_CONSTRAINT };
} }

View File

@ -23,7 +23,6 @@
//#include <common.h> //#include <common.h>
#include <class_track.h> #include <class_track.h>
#include <drc/drc_engine.h>
#include <drc/drc_item.h> #include <drc/drc_item.h>
#include <drc/drc_rule.h> #include <drc/drc_rule.h>
#include <drc/drc_test_provider.h> #include <drc/drc_test_provider.h>
@ -68,7 +67,7 @@ bool DRC_TEST_PROVIDER_TRACK_WIDTH::Run()
{ {
const int delta = 100; // This is the number of tests between 2 calls to the progress bar const int delta = 100; // This is the number of tests between 2 calls to the progress bar
if( !m_drcEngine->HasRulesForConstraintType( DRC_CONSTRAINT_TYPE_T::DRC_CONSTRAINT_TYPE_TRACK_WIDTH ) ) if( !m_drcEngine->HasRulesForConstraintType( DRC_CONSTRAINT_TYPE_T::TRACK_WIDTH_CONSTRAINT ) )
{ {
reportAux( "No track width constraints found. Skipping check." ); reportAux( "No track width constraints found. Skipping check." );
return false; return false;
@ -101,8 +100,7 @@ bool DRC_TEST_PROVIDER_TRACK_WIDTH::Run()
return true; return true;
} }
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_TRACK_WIDTH, auto constraint = m_drcEngine->EvalRulesForItems( TRACK_WIDTH_CONSTRAINT, item );
item );
bool fail_min = false; bool fail_min = false;
bool fail_max = false; bool fail_max = false;
int constraintWidth; int constraintWidth;
@ -173,7 +171,7 @@ int DRC_TEST_PROVIDER_TRACK_WIDTH::GetNumPhases() const
std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_TRACK_WIDTH::GetConstraintTypes() const std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_TRACK_WIDTH::GetConstraintTypes() const
{ {
return { DRC_CONSTRAINT_TYPE_TRACK_WIDTH }; return { TRACK_WIDTH_CONSTRAINT };
} }

View File

@ -66,7 +66,7 @@ bool DRC_TEST_PROVIDER_VIA_DIAMETER::Run()
{ {
const int delta = 100; // This is the number of tests between 2 calls to the progress bar const int delta = 100; // This is the number of tests between 2 calls to the progress bar
if( !m_drcEngine->HasRulesForConstraintType( DRC_CONSTRAINT_TYPE_VIA_DIAMETER ) ) if( !m_drcEngine->HasRulesForConstraintType( VIA_DIAMETER_CONSTRAINT ) )
{ {
reportAux( "No diameter constraints found. Skipping check." ); reportAux( "No diameter constraints found. Skipping check." );
return false; return false;
@ -87,8 +87,7 @@ bool DRC_TEST_PROVIDER_VIA_DIAMETER::Run()
if( !via ) if( !via )
return true; return true;
auto constraint = m_drcEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_VIA_DIAMETER, auto constraint = m_drcEngine->EvalRulesForItems( VIA_DIAMETER_CONSTRAINT, item );
item );
bool fail_min = false; bool fail_min = false;
bool fail_max = false; bool fail_max = false;
int constraintDiameter = 0; int constraintDiameter = 0;
@ -108,14 +107,14 @@ bool DRC_TEST_PROVIDER_VIA_DIAMETER::Run()
if( fail_min ) if( fail_min )
{ {
m_msg.Printf( wxS( " " ) + _( "(%s min diameter %s; actual %s)" ), m_msg.Printf( _( "(%s min diameter %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), constraintDiameter ), MessageTextFromValue( userUnits(), constraintDiameter ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
} }
else if( fail_max ) else if( fail_max )
{ {
m_msg.Printf( wxS( " " ) + _( "(%s max diameter %s; actual %s)" ), m_msg.Printf( _( "(%s max diameter %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), constraintDiameter ), MessageTextFromValue( userUnits(), constraintDiameter ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
@ -125,7 +124,7 @@ bool DRC_TEST_PROVIDER_VIA_DIAMETER::Run()
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_VIA_DIAMETER ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_VIA_DIAMETER );
drcItem->SetErrorMessage( drcItem->GetErrorText() + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );
@ -160,7 +159,7 @@ int DRC_TEST_PROVIDER_VIA_DIAMETER::GetNumPhases() const
std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_VIA_DIAMETER::GetConstraintTypes() const std::set<DRC_CONSTRAINT_TYPE_T> DRC_TEST_PROVIDER_VIA_DIAMETER::GetConstraintTypes() const
{ {
return { DRC_CONSTRAINT_TYPE_VIA_DIAMETER }; return { VIA_DIAMETER_CONSTRAINT };
} }

View File

@ -206,30 +206,17 @@ bool PNS_PCBNEW_RULE_RESOLVER::QueryConstraint( PNS::CONSTRAINT_TYPE aType,
if( !drcEngine ) if( !drcEngine )
return false; return false;
DRC_CONSTRAINT_TYPE_T hostRuleType; DRC_CONSTRAINT_TYPE_T hostType;
switch ( aType ) switch ( aType )
{ {
case PNS::CONSTRAINT_TYPE::CT_CLEARANCE: case PNS::CONSTRAINT_TYPE::CT_CLEARANCE: hostType = CLEARANCE_CONSTRAINT; break;
hostRuleType = DRC_CONSTRAINT_TYPE_CLEARANCE; case PNS::CONSTRAINT_TYPE::CT_WIDTH: hostType = TRACK_WIDTH_CONSTRAINT; break;
break; case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_GAP: hostType = DIFF_PAIR_GAP_CONSTRAINT; break;
case PNS::CONSTRAINT_TYPE::CT_WIDTH: case PNS::CONSTRAINT_TYPE::CT_LENGTH: hostType = LENGTH_CONSTRAINT; break;
hostRuleType = DRC_CONSTRAINT_TYPE_TRACK_WIDTH; case PNS::CONSTRAINT_TYPE::CT_VIA_DIAMETER: hostType = VIA_DIAMETER_CONSTRAINT; break;
break; case PNS::CONSTRAINT_TYPE::CT_VIA_HOLE: hostType = HOLE_SIZE_CONSTRAINT; break;
case PNS::CONSTRAINT_TYPE::CT_DIFF_PAIR_GAP: default: return false; // should not happen
hostRuleType = DRC_CONSTRAINT_TYPE_DIFF_PAIR_GAP;
break;
case PNS::CONSTRAINT_TYPE::CT_LENGTH:
hostRuleType = DRC_CONSTRAINT_TYPE_LENGTH;
break;
case PNS::CONSTRAINT_TYPE::CT_VIA_DIAMETER:
hostRuleType = DRC_CONSTRAINT_TYPE_VIA_DIAMETER;
break;
case PNS::CONSTRAINT_TYPE::CT_VIA_HOLE:
hostRuleType = DRC_CONSTRAINT_TYPE_HOLE_SIZE;
break;
default:
return false; // should not happen
} }
BOARD_ITEM* parentA = aItemA ? aItemA->Parent() : nullptr; BOARD_ITEM* parentA = aItemA ? aItemA->Parent() : nullptr;
@ -275,7 +262,7 @@ bool PNS_PCBNEW_RULE_RESOLVER::QueryConstraint( PNS::CONSTRAINT_TYPE aType,
if( parentA ) if( parentA )
{ {
hostConstraint = drcEngine->EvalRulesForItems( hostRuleType, parentA, parentB, hostConstraint = drcEngine->EvalRulesForItems( hostType, parentA, parentB,
(PCB_LAYER_ID) aLayer ); (PCB_LAYER_ID) aLayer );
} }

View File

@ -877,12 +877,12 @@ int ROUTER_TOOL::onViaCommand( const TOOL_EVENT& aEvent )
DRC_CONSTRAINT constraint; DRC_CONSTRAINT constraint;
constraint = bds.m_DRCEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_VIA_DIAMETER, constraint = bds.m_DRCEngine->EvalRulesForItems( VIA_DIAMETER_CONSTRAINT, &dummyVia,
&dummyVia, nullptr, currentLayer ); nullptr, currentLayer );
sizes.SetViaDiameter( constraint.m_Value.OptThenMin() ); sizes.SetViaDiameter( constraint.m_Value.OptThenMin() );
constraint = bds.m_DRCEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_HOLE_SIZE, constraint = bds.m_DRCEngine->EvalRulesForItems( HOLE_SIZE_CONSTRAINT, &dummyVia, nullptr,
&dummyVia, nullptr, currentLayer ); currentLayer );
sizes.SetViaDrill( constraint.m_Value.OptThenMin() ); sizes.SetViaDrill( constraint.m_Value.OptThenMin() );
} }
else else

View File

@ -211,10 +211,10 @@ void PCB_INSPECTION_TOOL::reportClearance( DRC_CONSTRAINT_TYPE_T aClearanceType,
int clearance = 0; int clearance = 0;
if( aClearanceType == DRC_CONSTRAINT_TYPE_CLEARANCE ) if( aClearanceType == CLEARANCE_CONSTRAINT )
{ {
auto edgeConstraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_EDGE_CLEARANCE, auto edgeConstraint = drcEngine.EvalRulesForItems( EDGE_CLEARANCE_CONSTRAINT, aA, aB,
aA, aB, aLayer, r ); aLayer, r );
clearance = edgeConstraint.m_Value.HasMin() ? edgeConstraint.m_Value.Min() : 0; clearance = edgeConstraint.m_Value.HasMin() ? edgeConstraint.m_Value.Min() : 0;
} }
@ -309,7 +309,7 @@ int PCB_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
getItemDescription( a ), getItemDescription( a ),
getItemDescription( b ) ) ); getItemDescription( b ) ) );
reportClearance( DRC_CONSTRAINT_TYPE_SILK_CLEARANCE, layer, a, b, r ); reportClearance( SILK_CLEARANCE_CONSTRAINT, layer, a, b, r );
} }
else if( !( a->GetLayerSet() & LSET( 2, layer, Edge_Cuts ) ).any() ) else if( !( a->GetLayerSet() & LSET( 2, layer, Edge_Cuts ) ).any() )
{ {
@ -353,7 +353,7 @@ int PCB_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
else else
{ {
// Different nets (or one or both unconnected).... // Different nets (or one or both unconnected)....
reportClearance( DRC_CONSTRAINT_TYPE_CLEARANCE, layer, a, b, r ); reportClearance( CLEARANCE_CONSTRAINT, layer, a, b, r );
} }
} }
@ -428,8 +428,8 @@ int PCB_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
} }
else else
{ {
auto constraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_TRACK_WIDTH, item, auto constraint = drcEngine.EvalRulesForItems( TRACK_WIDTH_CONSTRAINT, item, nullptr,
nullptr, UNDEFINED_LAYER, r ); UNDEFINED_LAYER, r );
wxString min = _( "undefined" ); wxString min = _( "undefined" );
wxString max = _( "undefined" ); wxString max = _( "undefined" );
@ -465,8 +465,8 @@ int PCB_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
} }
else else
{ {
auto constraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_VIA_DIAMETER, auto constraint = drcEngine.EvalRulesForItems( VIA_DIAMETER_CONSTRAINT, item, nullptr,
item, nullptr, UNDEFINED_LAYER, r ); UNDEFINED_LAYER, r );
wxString min = _( "undefined" ); wxString min = _( "undefined" );
wxString max = _( "undefined" ); wxString max = _( "undefined" );
@ -499,8 +499,8 @@ int PCB_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
} }
else else
{ {
auto constraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_ANNULAR_WIDTH, auto constraint = drcEngine.EvalRulesForItems( ANNULAR_WIDTH_CONSTRAINT, item, nullptr,
item, nullptr, UNDEFINED_LAYER, r ); UNDEFINED_LAYER, r );
wxString min = _( "undefined" ); wxString min = _( "undefined" );
wxString max = _( "undefined" ); wxString max = _( "undefined" );
@ -537,8 +537,8 @@ int PCB_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
} }
else else
{ {
auto constraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_HOLE_SIZE, item, auto constraint = drcEngine.EvalRulesForItems( HOLE_SIZE_CONSTRAINT, item, nullptr,
nullptr, UNDEFINED_LAYER, r ); UNDEFINED_LAYER, r );
wxString min = _( "undefined" ); wxString min = _( "undefined" );
@ -566,8 +566,8 @@ int PCB_INSPECTION_TOOL::InspectConstraints( const TOOL_EVENT& aEvent )
} }
else else
{ {
auto constraint = drcEngine.EvalRulesForItems( DRC_CONSTRAINT_TYPE_DISALLOW, item, auto constraint = drcEngine.EvalRulesForItems( DISALLOW_CONSTRAINT, item, nullptr,
nullptr, UNDEFINED_LAYER, r ); UNDEFINED_LAYER, r );
r->Report( "" ); r->Report( "" );

View File

@ -280,17 +280,19 @@ void TRACKS_CLEANER::cleanup( bool aDeleteDuplicateVias, bool aDeleteNullSegment
if( via->GetStart() != via->GetEnd() ) if( via->GetStart() != via->GetEnd() )
via->SetEnd( via->GetStart() ); via->SetEnd( via->GetStart() );
rtree.QueryColliding( via, via->GetLayer(), via->GetLayer(), nullptr, rtree.QueryColliding( via, via->GetLayer(), via->GetLayer(),
// Filter:
[&]( BOARD_ITEM* aItem ) -> bool
{
return aItem->Type() == PCB_VIA_T
&& !aItem->HasFlag( SKIP_STRUCT )
&& !aItem->HasFlag( IS_DELETED );
},
// Visitor:
[&]( BOARD_ITEM* aItem ) -> bool [&]( BOARD_ITEM* aItem ) -> bool
{ {
if( aItem->Type() != PCB_VIA_T )
return true;
VIA* other = static_cast<VIA*>( aItem ); VIA* other = static_cast<VIA*>( aItem );
if( other->HasFlag( SKIP_STRUCT ) || other->HasFlag( IS_DELETED ) )
return true;
if( via->GetPosition() == other->GetPosition() if( via->GetPosition() == other->GetPosition()
&& via->GetViaType() == other->GetViaType() && via->GetViaType() == other->GetViaType()
&& via->GetLayerSet() == other->GetLayerSet() ) && via->GetLayerSet() == other->GetLayerSet() )
@ -342,17 +344,19 @@ void TRACKS_CLEANER::cleanup( bool aDeleteDuplicateVias, bool aDeleteNullSegment
if( aDeleteDuplicateSegments && track->Type() == PCB_TRACE_T ) if( aDeleteDuplicateSegments && track->Type() == PCB_TRACE_T )
{ {
rtree.QueryColliding( track, track->GetLayer(), track->GetLayer(), nullptr, rtree.QueryColliding( track, track->GetLayer(), track->GetLayer(),
// Filter:
[&]( BOARD_ITEM* aItem ) -> bool
{
return aItem->Type() == PCB_TRACE_T
&& !aItem->HasFlag( SKIP_STRUCT )
&& !aItem->HasFlag( IS_DELETED );
},
// Visitor:
[&]( BOARD_ITEM* aItem ) -> bool [&]( BOARD_ITEM* aItem ) -> bool
{ {
if( aItem->Type() != PCB_TRACE_T )
return true;
TRACK* other = static_cast<TRACK*>( aItem ); TRACK* other = static_cast<TRACK*>( aItem );
if( other->HasFlag( SKIP_STRUCT )|| other->HasFlag( IS_DELETED ) )
return true;
if( track->IsPointOnEnds( other->GetStart() ) if( track->IsPointOnEnds( other->GetStart() )
&& track->IsPointOnEnds( other->GetEnd() ) && track->IsPointOnEnds( other->GetEnd() )
&& track->GetWidth() == other->GetWidth() && track->GetWidth() == other->GetWidth()

View File

@ -749,14 +749,9 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA
// for pads having the same netcode as the zone, the net clearance has no // for pads having the same netcode as the zone, the net clearance has no
// meaning so use the greater of the zone clearance and the thermal relief // meaning so use the greater of the zone clearance and the thermal relief
if( aPad->GetNetCode() > 0 && aPad->GetNetCode() == aZone->GetNetCode() ) if( aPad->GetNetCode() > 0 && aPad->GetNetCode() == aZone->GetNetCode() )
{
gap = std::max( zone_clearance, aZone->GetThermalReliefGap( aPad ) ); gap = std::max( zone_clearance, aZone->GetThermalReliefGap( aPad ) );
}
else else
{ gap = evalRulesForItems( CLEARANCE_CONSTRAINT, aZone, aPad, aLayer );
gap = evalRulesForItems( DRC_CONSTRAINT_TYPE_CLEARANCE, aZone, aPad,
aLayer );
}
addKnockout( aPad, aLayer, gap, aHoles ); addKnockout( aPad, aLayer, gap, aHoles );
} }
@ -793,8 +788,7 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA
{ {
if( aTrack->GetBoundingBox().Intersects( zone_boundingbox ) ) if( aTrack->GetBoundingBox().Intersects( zone_boundingbox ) )
{ {
int gap = evalRulesForItems( DRC_CONSTRAINT_TYPE_CLEARANCE, aZone, aTrack, int gap = evalRulesForItems( CLEARANCE_CONSTRAINT, aZone, aTrack, aLayer );
aLayer );
gap += extra_margin; gap += extra_margin;
@ -848,13 +842,12 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA
if( aItem->GetBoundingBox().Intersects( zone_boundingbox ) ) if( aItem->GetBoundingBox().Intersects( zone_boundingbox ) )
{ {
int gap = evalRulesForItems( DRC_CONSTRAINT_TYPE_CLEARANCE, aZone, aItem, int gap = evalRulesForItems( CLEARANCE_CONSTRAINT, aZone, aItem, aLayer );
aLayer );
if( aItem->IsOnLayer( Edge_Cuts ) ) if( aItem->IsOnLayer( Edge_Cuts ) )
{ {
gap = std::max( gap, evalRulesForItems( DRC_CONSTRAINT_TYPE_EDGE_CLEARANCE, gap = std::max( gap, evalRulesForItems( EDGE_CLEARANCE_CONSTRAINT, aZone,
aZone, aItem, Edge_Cuts ) ); aItem, Edge_Cuts ) );
} }
addKnockout( aItem, aLayer, gap, aItem->IsOnLayer( Edge_Cuts ), aHoles ); addKnockout( aItem, aLayer, gap, aItem->IsOnLayer( Edge_Cuts ), aHoles );
@ -902,16 +895,16 @@ void ZONE_FILLER::buildCopperItemClearances( const ZONE_CONTAINER* aZone, PCB_LA
else if( bds.m_ZoneFillVersion == 5 ) else if( bds.m_ZoneFillVersion == 5 )
{ {
// 5.x used outline with clearance // 5.x used outline with clearance
int gap = evalRulesForItems( DRC_CONSTRAINT_TYPE_CLEARANCE, aZone, int gap = evalRulesForItems( CLEARANCE_CONSTRAINT, aZone, aKnockout,
aKnockout, aLayer ); aLayer );
aKnockout->TransformSmoothedOutlineToPolygon( aHoles, gap, nullptr ); aKnockout->TransformSmoothedOutlineToPolygon( aHoles, gap, nullptr );
} }
else else
{ {
// 6.0 uses filled areas with clearance // 6.0 uses filled areas with clearance
int gap = evalRulesForItems( DRC_CONSTRAINT_TYPE_CLEARANCE, aZone, int gap = evalRulesForItems( CLEARANCE_CONSTRAINT, aZone, aKnockout,
aKnockout, aLayer ); aLayer );
SHAPE_POLY_SET poly; SHAPE_POLY_SET poly;
aKnockout->TransformShapeWithClearanceToPolygon( poly, aLayer, gap, aKnockout->TransformShapeWithClearanceToPolygon( poly, aLayer, gap,