Use more precise formatting in DRC messages when less precise values are identical.

Fixes https://gitlab.com/kicad/code/kicad/issues/12587
This commit is contained in:
Jeff Young 2022-10-06 21:52:17 +01:00
parent 9119b5072a
commit 098e96f1c7
18 changed files with 214 additions and 252 deletions

View File

@ -360,3 +360,20 @@ bool DRC_TEST_PROVIDER::isInvisibleText( const BOARD_ITEM* aItem ) const
return false; return false;
} }
wxString DRC_TEST_PROVIDER::formatMsg( const wxString& aFormatString, const wxString& aSource,
int aConstraint, int aActual )
{
wxString constraint_str = MessageTextFromValue( aConstraint );
wxString actual_str = MessageTextFromValue( aActual );
if( constraint_str == actual_str )
{
// Use more precise formatting if the message-text strings were equal.
constraint_str = StringFromValue( aConstraint );
actual_str = StringFromValue( aActual );
}
return wxString::Format( aFormatString, aSource, constraint_str, actual_str );
}

View File

@ -113,6 +113,9 @@ protected:
bool isInvisibleText( const BOARD_ITEM* aItem ) const; bool isInvisibleText( const BOARD_ITEM* aItem ) const;
wxString formatMsg( const wxString& aFormatString, const wxString& aSource, int aConstraint,
int aActual );
// List of basic (ie: non-compound) geometry items // List of basic (ie: non-compound) geometry items
static std::vector<KICAD_T> s_allBasicItems; static std::vector<KICAD_T> s_allBasicItems;
static std::vector<KICAD_T> s_allBasicItemsButZones; static std::vector<KICAD_T> s_allBasicItemsButZones;

View File

@ -245,18 +245,18 @@ bool DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run()
if( fail_min ) if( fail_min )
{ {
msg.Printf( _( "(%s min annular width %s; actual %s)" ), msg = formatMsg( _( "(%s min annular width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( v_min ), v_min,
MessageTextFromValue( annularWidth ) ); annularWidth );
} }
if( fail_max ) if( fail_max )
{ {
msg.Printf( _( "(%s max annular width %s; actual %s)" ), msg = formatMsg( _( "(%s max annular width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( v_max ), v_max,
MessageTextFromValue( annularWidth ) ); annularWidth );
} }
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );

View File

@ -756,11 +756,14 @@ bool DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run()
auto drce = DRC_ITEM::Create( DRCE_CONNECTION_WIDTH ); auto drce = DRC_ITEM::Create( DRCE_CONNECTION_WIDTH );
wxString msg; wxString msg;
msg.Printf( _( "Minimum connection width %s; actual %s" ), msg = formatMsg( _( "(%s minimum connection width %s; actual %s)" ),
MessageTextFromValue( aMinWidth ), c.GetName(),
MessageTextFromValue( dist ) ); aMinWidth,
dist );
drce->SetErrorMessage( msg + wxS( " " ) + layerDesc( aLayer ) ); msg += wxS( " " ) + layerDesc( aLayer );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetViolatingRule( c.GetParentRule() ); drce->SetViolatingRule( c.GetParentRule() );
for( BOARD_ITEM* item : contributingItems ) for( BOARD_ITEM* item : contributingItems )

View File

@ -218,12 +218,10 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( PCB_TRACK* track,
else else
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance,
constraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( track, other ); drce->SetItems( track, other );
@ -271,13 +269,13 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( PCB_TRACK* track,
if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && clearance > 0 ) if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && clearance > 0 )
{ {
if( a_shape[ii]->Collide( holeShape.get(), std::max( 0, clearance - m_drcEpsilon ), if( a_shape[ii]->Collide( holeShape.get(), std::max( 0, clearance - m_drcEpsilon ),
&actual, &pos ) ) &actual, &pos ) )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), clearance,
MessageTextFromValue( clearance ), MessageTextFromValue( actual ) ); actual );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( a[ii], b[ii] ); drce->SetItems( a[ii], b[ii] );
@ -357,12 +355,10 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone( BOARD_ITEM* aItem,
std::max( 0, clearance - m_drcEpsilon ), &actual, &pos ) ) std::max( 0, clearance - m_drcEpsilon ), &actual, &pos ) )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance,
constraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, aZone ); drce->SetItems( aItem, aZone );
@ -397,13 +393,11 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone( BOARD_ITEM* aItem,
std::max( 0, clearance - m_drcEpsilon ), std::max( 0, clearance - m_drcEpsilon ),
&actual, &pos ) ) &actual, &pos ) )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance,
constraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, aZone ); drce->SetItems( aItem, aZone );
@ -619,12 +613,10 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa
&actual, &pos ) ) &actual, &pos ) )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance,
constraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( pad, other ); drce->SetItems( pad, other );
@ -652,12 +644,10 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa
&actual, &pos ) ) &actual, &pos ) )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance,
constraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( pad, other ); drce->SetItems( pad, other );
@ -675,12 +665,10 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa
&actual, &pos ) ) &actual, &pos ) )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance,
constraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( pad, other ); drce->SetItems( pad, other );
@ -698,12 +686,10 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa
&actual, &pos ) ) &actual, &pos ) )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance,
constraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( pad, otherVia ); drce->SetItems( pad, otherVia );
@ -951,12 +937,10 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones()
else if( testClearance ) else if( testClearance )
{ {
drce = DRC_ITEM::Create( DRCE_CLEARANCE ); drce = DRC_ITEM::Create( DRCE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), zone2zoneClearance,
constraint.GetName(), std::max( actual, 0 ) );
MessageTextFromValue( zone2zoneClearance ),
MessageTextFromValue( std::max( actual, 0 ) ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
} }

View File

@ -229,11 +229,10 @@ bool DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances()
if( clearance > 0 ) if( clearance > 0 )
{ {
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(),
constraint.GetName(), clearance,
MessageTextFromValue( clearance ), actual );
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
@ -263,11 +262,10 @@ bool DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances()
if( clearance > 0 ) if( clearance > 0 )
{ {
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(),
constraint.GetName(), clearance,
MessageTextFromValue( clearance ), actual );
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );

View File

@ -157,14 +157,16 @@ struct DIFF_PAIR_COUPLED_SEGMENTS
PCB_TRACK* parentP; PCB_TRACK* parentP;
int computedGap; int computedGap;
PCB_LAYER_ID layer; PCB_LAYER_ID layer;
bool couplingOK; bool couplingFailMin;
bool couplingFailMax;
DIFF_PAIR_COUPLED_SEGMENTS() : DIFF_PAIR_COUPLED_SEGMENTS() :
parentN( nullptr ), parentN( nullptr ),
parentP( nullptr ), parentP( nullptr ),
computedGap( 0 ), computedGap( 0 ),
layer( UNDEFINED_LAYER ), layer( UNDEFINED_LAYER ),
couplingOK( false ) couplingFailMin( false ),
couplingFailMax( false )
{} {}
}; };
@ -398,22 +400,15 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run()
if( gapConstraint ) if( gapConstraint )
{ {
const MINOPTMAX<int>& val = gapConstraint->GetValue(); const MINOPTMAX<int>& val = gapConstraint->GetValue();
bool insideRange = true;
if( val.HasMin() && gap < val.Min() - epsilon ) if( val.HasMin() && gap < val.Min() - epsilon )
insideRange = false; dp.couplingFailMin = true;
if( val.HasMax() && gap > val.Max() + epsilon ) if( val.HasMax() && gap > val.Max() + epsilon )
insideRange = false; dp.couplingFailMax = true;
dp.couplingOK = insideRange;
}
else
{
dp.couplingOK = true;
} }
if( dp.couplingOK ) if( !dp.couplingFailMin && !dp.couplingFailMax )
itemSet.totalCoupled += length; itemSet.totalCoupled += length;
} }
@ -433,12 +428,10 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run()
if ( val.HasMax() && totalUncoupled > val.Max() ) if ( val.HasMax() && totalUncoupled > val.Max() )
{ {
auto drce = DRC_ITEM::Create( DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG ); auto drce = DRC_ITEM::Create( DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG );
wxString msg; wxString msg = formatMsg( _( "(%s maximum uncoupled length %s; actual %s)" ),
msg = wxString::Format( _( "(%s maximum uncoupled length: %s; actual: %s)" ),
maxUncoupledConstraint->GetParentRule()->m_Name, maxUncoupledConstraint->GetParentRule()->m_Name,
MessageTextFromValue( val.Max() ), val.Max(),
MessageTextFromValue( totalUncoupled ) ); totalUncoupled );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
@ -478,31 +471,28 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run()
{ {
for( DIFF_PAIR_COUPLED_SEGMENTS& dp : itemSet.coupled ) for( DIFF_PAIR_COUPLED_SEGMENTS& dp : itemSet.coupled )
{ {
if( !dp.couplingOK && ( dp.parentP || dp.parentN ) ) if( ( dp.couplingFailMin || dp.couplingFailMax ) && ( dp.parentP || dp.parentN ) )
{ {
MINOPTMAX<int> val = gapConstraint->GetValue(); MINOPTMAX<int> val = gapConstraint->GetValue();
auto drcItem = DRC_ITEM::Create( DRCE_DIFF_PAIR_GAP_OUT_OF_RANGE ); auto drcItem = DRC_ITEM::Create( DRCE_DIFF_PAIR_GAP_OUT_OF_RANGE );
wxString msg; wxString msg;
msg = drcItem->GetErrorText() + wxT( " (" ) + if( dp.couplingFailMin )
gapConstraint->GetParentRule()->m_Name + wxS( " " );
if( val.HasMin() )
{ {
msg += wxString::Format( _( "minimum gap: %s; " ), msg = formatMsg( _( "(%s minimum gap %s; actual %s)" ),
MessageTextFromValue( val.Min() ) ); gapConstraint->GetParentRule()->m_Name,
val.Min(),
dp.computedGap );
}
else if( dp.couplingFailMax )
{
msg = formatMsg( _( "(%s maximum gap %s; actual %s)" ),
gapConstraint->GetParentRule()->m_Name,
val.Max(),
dp.computedGap );
} }
if( val.HasMax() ) drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
{
msg += wxString::Format( _( "maximum gap: %s; " ),
MessageTextFromValue( val.Max() ) );
}
msg += wxString::Format( _( "actual: %s)" ),
MessageTextFromValue( dp.computedGap ) );
drcItem->SetErrorMessage( msg );
BOARD_CONNECTED_ITEM* item = nullptr; BOARD_CONNECTED_ITEM* item = nullptr;

View File

@ -117,12 +117,10 @@ bool DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge( BOARD_ITEM* item, SHAPE*
// Only report clearance info if there is any; otherwise it's just a straight collision // Only report clearance info if there is any; otherwise it's just a straight collision
if( minClearance > 0 ) if( minClearance > 0 )
{ {
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), minClearance,
constraint.GetName(), actual );
MessageTextFromValue( minClearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
} }

View File

@ -155,17 +155,17 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole( PAD* aPad )
if( fail_min ) if( fail_min )
{ {
msg.Printf( _( "(%s min width %s; actual %s)" ), msg = formatMsg( _( "(%s min width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( constraintValue ), constraintValue,
MessageTextFromValue( holeMinor ) ); holeMinor );
} }
else else
{ {
msg.Printf( _( "(%s max width %s; actual %s)" ), msg = formatMsg( _( "(%s max width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( constraintValue ), constraintValue,
MessageTextFromValue( holeMajor ) ); holeMajor );
} }
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
@ -224,17 +224,17 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole( PCB_VIA* via, bool aExceedMicro,
if( fail_min ) if( fail_min )
{ {
msg.Printf( _( "(%s min width %s; actual %s)" ), msg = formatMsg( _( "(%s min width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( constraintValue ), constraintValue,
MessageTextFromValue( via->GetDrillValue() ) ); via->GetDrillValue() );
} }
else else
{ {
msg.Printf( _( "(%s max width %s; actual %s)" ), msg = formatMsg( _( "(%s max width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( constraintValue ), constraintValue,
MessageTextFromValue( via->GetDrillValue() ) ); via->GetDrillValue() );
} }
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );

View File

@ -301,12 +301,10 @@ bool DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole( BOARD_ITEM* aItem, SHA
&& actual < minClearance ) && actual < minClearance )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_DRILLED_HOLES_TOO_CLOSE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_DRILLED_HOLES_TOO_CLOSE );
wxString msg; wxString msg = formatMsg( _( "(%s min %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s min %s; actual %s)" ), minClearance,
constraint.GetName(), actual );
MessageTextFromValue( minClearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, aOther ); drce->SetItems( aItem, aOther );

View File

@ -113,17 +113,17 @@ void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengths( const DRC_CONSTRAINT& aCons
if( minViolation ) if( minViolation )
{ {
msg.Printf( _( "(%s min length: %s; actual: %s)" ), msg = formatMsg( _( "(%s min length %s; actual %s)" ),
aConstraint.GetName(), aConstraint.GetName(),
MessageTextFromValue( minLen ), minLen,
MessageTextFromValue( ent.total ) ); ent.total );
} }
else if( maxViolation ) else if( maxViolation )
{ {
msg.Printf( _( "(%s max length: %s; actual: %s)" ), msg = formatMsg( _( "(%s max length %s; actual %s)" ),
aConstraint.GetName(), aConstraint.GetName(),
MessageTextFromValue( maxLen ), maxLen,
MessageTextFromValue( ent.total ) ); ent.total );
} }
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
@ -157,7 +157,7 @@ void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkews( const DRC_CONSTRAINT& aConstr
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; wxString msg;
msg.Printf( _( "(%s max skew: %s; actual: %s; average net length: %s; actual: %s)" ), msg.Printf( _( "(%s max skew %s; actual %s; average net length %s; actual %s)" ),
aConstraint.GetName(), aConstraint.GetName(),
MessageTextFromValue( aConstraint.GetValue().Max() ), MessageTextFromValue( aConstraint.GetValue().Max() ),
MessageTextFromValue( skew ), MessageTextFromValue( skew ),
@ -186,12 +186,10 @@ void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkViaCounts( const DRC_CONSTRAINT& aCo
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; wxString msg = wxString::Format( _( "(%s max count %d; actual %d)" ),
aConstraint.GetName(),
msg.Printf( _( "(%s max count: %d; actual: %d)" ), aConstraint.GetValue().Max(),
aConstraint.GetName(), ent.viaCount );
aConstraint.GetValue().Max(),
ent.viaCount );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );

View File

@ -489,16 +489,15 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testShapeLineChain( const SHAPE_LINE_
for( std::pair<VECTOR2I, int> collision : collisions ) for( std::pair<VECTOR2I, int> collision : collisions )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
wxString msg;
VECTOR2I pt = collision.first; VECTOR2I pt = collision.first;
if( aParentItem->GetParentFootprint() ) if( aParentItem->GetParentFootprint() )
pt += aParentItem->GetParentFootprint()->GetPosition(); pt += aParentItem->GetParentFootprint()->GetPosition();
msg.Printf( _( "Internal clearance violation (%s clearance %s; actual %s)" ), wxString msg = formatMsg( _( "Internal clearance violation (%s clearance %s; actual %s)" ),
aConstraint.GetName(), aConstraint.GetName(),
MessageTextFromValue( clearance ), clearance,
MessageTextFromValue( collision.second ) ); collision.second );
drce->SetErrorMessage( msg ); drce->SetErrorMessage( msg );
drce->SetItems( aParentItem ); drce->SetItems( aParentItem );
@ -544,12 +543,10 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer( ZONE* aZone, PCB_LAYER
if( firstOutline->Collide( secondSeg, clearance - epsilon, &actual, &pos ) ) if( firstOutline->Collide( secondSeg, clearance - epsilon, &actual, &pos ) )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
aConstraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance,
aConstraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aZone ); drce->SetItems( aZone );
@ -603,12 +600,10 @@ bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* aIte
if( aItemShape->Collide( otherShape.get(), clearance, &actual, &pos ) ) if( aItemShape->Collide( otherShape.get(), clearance, &actual, &pos ) )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance,
constraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, other ); drce->SetItems( aItem, other );
@ -656,12 +651,10 @@ bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* aIte
if( itemHoleShape && itemHoleShape->Collide( otherShape.get(), clearance, &actual, &pos ) ) if( itemHoleShape && itemHoleShape->Collide( otherShape.get(), clearance, &actual, &pos ) )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance ,
constraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, other ); drce->SetItems( aItem, other );
@ -673,12 +666,10 @@ bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* aIte
if( otherHoleShape && otherHoleShape->Collide( aItemShape, clearance, &actual, &pos ) ) if( otherHoleShape && otherHoleShape->Collide( aItemShape, clearance, &actual, &pos ) )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance,
constraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, other ); drce->SetItems( aItem, other );
@ -762,12 +753,10 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aIt
if( colliding ) if( colliding )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance,
constraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, zone ); drce->SetItems( aItem, zone );
@ -803,12 +792,10 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aIt
&actual, &pos ) ) &actual, &pos ) )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance,
constraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, zone ); drce->SetItems( aItem, zone );

View File

@ -237,12 +237,10 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run()
if( minClearance > 0 ) if( minClearance > 0 )
{ {
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetParentRule()->m_Name,
msg.Printf( _( "(%s clearance %s; actual %s)" ), minClearance,
constraint.GetParentRule()->m_Name, actual );
MessageTextFromValue( minClearance ),
MessageTextFromValue( actual ) );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
} }

View File

@ -276,12 +276,10 @@ void DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance()
clearance, &actual, &pos ) ) clearance, &actual, &pos ) )
{ {
auto drce = DRC_ITEM::Create( DRCE_SILK_CLEARANCE ); auto drce = DRC_ITEM::Create( DRCE_SILK_CLEARANCE );
wxString msg; wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s clearance %s; actual %s)" ), clearance,
constraint.GetName(), actual );
MessageTextFromValue( clearance ),
MessageTextFromValue( actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( item ); drce->SetItems( item );

View File

@ -105,12 +105,10 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run()
if( constraint.Value().HasMin() && actualHeight < constraint.Value().Min() ) if( constraint.Value().HasMin() && actualHeight < constraint.Value().Min() )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TEXT_HEIGHT ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TEXT_HEIGHT );
wxString msg; wxString msg = formatMsg( _( "(%s min height %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s min height %s; actual %s)" ), constraint.Value().Min(),
constraint.GetName(), actualHeight );
MessageTextFromValue( constraint.Value().Min() ),
MessageTextFromValue( actualHeight ) );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
@ -122,12 +120,10 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run()
if( constraint.Value().HasMax() && actualHeight > constraint.Value().Max() ) if( constraint.Value().HasMax() && actualHeight > constraint.Value().Max() )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TEXT_HEIGHT ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TEXT_HEIGHT );
wxString msg; wxString msg = formatMsg( _( "(%s max height %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s max height %s; actual %s)" ), constraint.Value().Max(),
constraint.GetName(), actualHeight );
MessageTextFromValue( constraint.Value().Max() ),
MessageTextFromValue( actualHeight ) );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
@ -225,12 +221,10 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run()
if( constraint.Value().HasMin() && actualThickness < constraint.Value().Min() ) if( constraint.Value().HasMin() && actualThickness < constraint.Value().Min() )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TEXT_THICKNESS ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TEXT_THICKNESS );
wxString msg; wxString msg = formatMsg( _( "(%s min thickness %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s min thickness %s; actual %s)" ), constraint.Value().Min(),
constraint.GetName(), actualThickness );
MessageTextFromValue( constraint.Value().Min() ),
MessageTextFromValue( actualThickness ) );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
@ -242,12 +236,10 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run()
if( constraint.Value().HasMax() && actualThickness > constraint.Value().Max() ) if( constraint.Value().HasMax() && actualThickness > constraint.Value().Max() )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TEXT_THICKNESS ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TEXT_THICKNESS );
wxString msg; wxString msg = formatMsg( _( "(%s max thickness %s; actual %s)" ),
constraint.GetName(),
msg.Printf( _( "(%s max thickness %s; actual %s)" ), constraint.Value().Max(),
constraint.GetName(), actualThickness );
MessageTextFromValue( constraint.Value().Max() ),
MessageTextFromValue( actualThickness ) );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( item ); drcItem->SetItems( item );

View File

@ -128,17 +128,17 @@ bool DRC_TEST_PROVIDER_TRACK_WIDTH::Run()
if( fail_min ) if( fail_min )
{ {
msg.Printf( _( "(%s min width %s; actual %s)" ), msg = formatMsg( _( "(%s min width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( constraintWidth ), constraintWidth,
MessageTextFromValue( actual ) ); actual );
} }
else else
{ {
msg.Printf( _( "(%s max width %s; actual %s)" ), msg = formatMsg( _( "(%s max width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( constraintWidth ), constraintWidth,
MessageTextFromValue( actual ) ); actual );
} }
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );

View File

@ -118,17 +118,17 @@ bool DRC_TEST_PROVIDER_VIA_DIAMETER::Run()
if( fail_min ) if( fail_min )
{ {
msg.Printf( _( "(%s min diameter %s; actual %s)" ), msg = formatMsg( _( "(%s min diameter %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( constraintDiameter ), constraintDiameter,
MessageTextFromValue( actual ) ); actual );
} }
else if( fail_max ) else if( fail_max )
{ {
msg.Printf( _( "(%s max diameter %s; actual %s)" ), msg = formatMsg( _( "(%s max diameter %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( constraintDiameter ), constraintDiameter,
MessageTextFromValue( actual ) ); actual );
} }
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );

View File

@ -168,12 +168,10 @@ void DRC_TEST_PROVIDER_ZONE_CONNECTIONS::testZoneLayer( ZONE* aZone, PCB_LAYER_I
if( spokes < minCount ) if( spokes < minCount )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_STARVED_THERMAL ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_STARVED_THERMAL );
wxString msg; wxString msg = wxString::Format( _( "(%s min spoke count %d; actual %d)" ),
constraint.GetName(),
msg.Printf( _( "(%s min spoke count %d; actual %d)" ), minCount,
constraint.GetName(), spokes );
minCount,
spokes );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aZone, pad ); drce->SetItems( aZone, pad );