Remove shared wxString instance in DRC

Threaded DRC access will write to this string, re-allocating the memory
without any synchronization between threads using the string.  Comment
adding this listed performance as a reason for using shared strings.
Measured performance does not seem noticeably different in either case,
even with high-error count boards.  If there is a case where the
performance is limiting, we can replace these wxStrings with
std::wstring and utilize fmt

Fixes https://gitlab.com/kicad/code/kicad/issues/9888
This commit is contained in:
Seth Hillbrand 2022-06-15 16:42:34 -07:00
parent 8725c3a35f
commit 5327b10064
21 changed files with 196 additions and 144 deletions

View File

@ -753,7 +753,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO
// Local overrides take precedence over everything *except* board min clearance // Local overrides take precedence over everything *except* board min clearance
if( aConstraintType == CLEARANCE_CONSTRAINT || aConstraintType == HOLE_CLEARANCE_CONSTRAINT ) if( aConstraintType == CLEARANCE_CONSTRAINT || aConstraintType == HOLE_CLEARANCE_CONSTRAINT )
{ {
int override = 0; int override_val = 0;
wxString msg;
if( ac && !b_is_non_copper ) if( ac && !b_is_non_copper )
{ {
@ -766,7 +767,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO
EscapeHTML( a->GetSelectMenuText( UNITS ) ), EscapeHTML( a->GetSelectMenuText( UNITS ) ),
REPORT_VALUE( overrideA ) ) ) REPORT_VALUE( overrideA ) ) )
override = ac->GetLocalClearanceOverrides( &m_msg ); override_val = ac->GetLocalClearanceOverrides( &msg );
} }
} }
@ -781,40 +782,40 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO
EscapeHTML( b->GetSelectMenuText( UNITS ) ), EscapeHTML( b->GetSelectMenuText( UNITS ) ),
EscapeHTML( REPORT_VALUE( overrideB ) ) ) ) EscapeHTML( REPORT_VALUE( overrideB ) ) ) )
if( overrideB > override ) if( overrideB > override_val )
override = bc->GetLocalClearanceOverrides( &m_msg ); override_val = bc->GetLocalClearanceOverrides( &msg );
} }
} }
if( override ) if( override_val )
{ {
if( aConstraintType == CLEARANCE_CONSTRAINT ) if( aConstraintType == CLEARANCE_CONSTRAINT )
{ {
if( override < m_designSettings->m_MinClearance ) if( override_val < m_designSettings->m_MinClearance )
{ {
override = m_designSettings->m_MinClearance; override_val = m_designSettings->m_MinClearance;
m_msg = _( "board minimum" ); msg = _( "board minimum" );
REPORT( "" ) REPORT( "" )
REPORT( wxString::Format( _( "Board minimum clearance: %s." ), REPORT( wxString::Format( _( "Board minimum clearance: %s." ),
REPORT_VALUE( override ) ) ) REPORT_VALUE( override_val ) ) )
} }
} }
else else
{ {
if( override < m_designSettings->m_HoleClearance ) if( override_val < m_designSettings->m_HoleClearance )
{ {
override = m_designSettings->m_HoleClearance; override_val = m_designSettings->m_HoleClearance;
m_msg = _( "board minimum hole" ); msg = _( "board minimum hole" );
REPORT( "" ) REPORT( "" )
REPORT( wxString::Format( _( "Board minimum hole clearance: %s." ), REPORT( wxString::Format( _( "Board minimum hole clearance: %s." ),
REPORT_VALUE( override ) ) ) REPORT_VALUE( override_val ) ) )
} }
} }
constraint.SetName( m_msg ); constraint.SetName( msg );
constraint.m_Value.SetMin( override ); constraint.m_Value.SetMin( override_val );
return constraint; return constraint;
} }
} }
@ -822,14 +823,15 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO
{ {
if( pad && pad->GetLocalZoneConnectionOverride( nullptr ) != ZONE_CONNECTION::INHERITED ) if( pad && pad->GetLocalZoneConnectionOverride( nullptr ) != ZONE_CONNECTION::INHERITED )
{ {
ZONE_CONNECTION override = pad->GetLocalZoneConnectionOverride( &m_msg ); wxString msg;
ZONE_CONNECTION override = pad->GetLocalZoneConnectionOverride( &msg );
REPORT( "" ) REPORT( "" )
REPORT( wxString::Format( _( "Local override on %s; zone connection: %s." ), REPORT( wxString::Format( _( "Local override on %s; zone connection: %s." ),
EscapeHTML( pad->GetSelectMenuText( UNITS ) ), EscapeHTML( pad->GetSelectMenuText( UNITS ) ),
EscapeHTML( PrintZoneConnection( override ) ) ) ) EscapeHTML( PrintZoneConnection( override ) ) ) )
constraint.SetName( m_msg ); constraint.SetName( msg );
constraint.m_ZoneConnection = override; constraint.m_ZoneConnection = override;
return constraint; return constraint;
} }
@ -838,14 +840,15 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO
{ {
if( pad && pad->GetLocalThermalGapOverride( nullptr ) > 0 ) if( pad && pad->GetLocalThermalGapOverride( nullptr ) > 0 )
{ {
int gap_override = pad->GetLocalThermalGapOverride( &m_msg ); wxString msg;
int gap_override = pad->GetLocalThermalGapOverride( &msg );
REPORT( "" ) REPORT( "" )
REPORT( wxString::Format( _( "Local override on %s; thermal relief gap: %s." ), REPORT( wxString::Format( _( "Local override on %s; thermal relief gap: %s." ),
EscapeHTML( pad->GetSelectMenuText( UNITS ) ), EscapeHTML( pad->GetSelectMenuText( UNITS ) ),
EscapeHTML( REPORT_VALUE( gap_override ) ) ) ) EscapeHTML( REPORT_VALUE( gap_override ) ) ) )
constraint.SetName( m_msg ); constraint.SetName( msg );
constraint.m_Value.SetMin( gap_override ); constraint.m_Value.SetMin( gap_override );
return constraint; return constraint;
} }
@ -854,7 +857,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO
{ {
if( pad && pad->GetLocalSpokeWidthOverride( nullptr ) > 0 ) if( pad && pad->GetLocalSpokeWidthOverride( nullptr ) > 0 )
{ {
int spoke_override = pad->GetLocalSpokeWidthOverride( &m_msg ); wxString msg;
int spoke_override = pad->GetLocalSpokeWidthOverride( &msg );
REPORT( "" ) REPORT( "" )
REPORT( wxString::Format( _( "Local override on %s; thermal spoke width: %s." ), REPORT( wxString::Format( _( "Local override on %s; thermal spoke width: %s." ),
@ -871,7 +875,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO
EscapeHTML( REPORT_VALUE( spoke_override ) ) ) ) EscapeHTML( REPORT_VALUE( spoke_override ) ) ) )
} }
constraint.SetName( m_msg ); constraint.SetName( msg );
constraint.m_Value.SetMin( spoke_override ); constraint.m_Value.SetMin( spoke_override );
return constraint; return constraint;
} }
@ -1312,9 +1316,10 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO
if( localA > clearance ) if( localA > clearance )
{ {
clearance = ac->GetLocalClearance( &m_msg ); wxString msg;
clearance = ac->GetLocalClearance( &msg );
constraint.SetParentRule( nullptr ); constraint.SetParentRule( nullptr );
constraint.SetName( m_msg ); constraint.SetName( msg );
constraint.m_Value.SetMin( clearance ); constraint.m_Value.SetMin( clearance );
} }
} }
@ -1328,9 +1333,10 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO
if( localB > clearance ) if( localB > clearance )
{ {
clearance = bc->GetLocalClearance( &m_msg ); wxString msg;
clearance = bc->GetLocalClearance( &msg );
constraint.SetParentRule( nullptr ); constraint.SetParentRule( nullptr );
constraint.SetName( m_msg ); constraint.SetName( msg );
constraint.m_Value.SetMin( clearance ); constraint.m_Value.SetMin( clearance );
} }
} }

View File

@ -240,7 +240,6 @@ protected:
REPORTER* m_reporter; REPORTER* m_reporter;
PROGRESS_REPORTER* m_progressReporter; PROGRESS_REPORTER* m_progressReporter;
wxString m_msg; // Allocating strings gets expensive enough to want to avoid it
std::shared_ptr<KIGFX::VIEW_OVERLAY> m_debugOverlay; std::shared_ptr<KIGFX::VIEW_OVERLAY> m_debugOverlay;
}; };

View File

@ -117,8 +117,6 @@ protected:
DRC_ENGINE* m_drcEngine; DRC_ENGINE* m_drcEngine;
std::unordered_map<const DRC_RULE*, int> m_stats; std::unordered_map<const DRC_RULE*, int> m_stats;
bool m_isRuleDriven = true; bool m_isRuleDriven = true;
wxString m_msg; // Allocating strings gets expensive enough to want to avoid it
}; };
#endif // DRC_TEST_PROVIDER__H #endif // DRC_TEST_PROVIDER__H

View File

@ -122,20 +122,21 @@ bool DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run()
if( fail_min || fail_max ) if( fail_min || fail_max )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ANNULAR_WIDTH ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ANNULAR_WIDTH );
wxString msg;
if( fail_min ) if( fail_min )
m_msg.Printf( _( "(%s min annular width %s; actual %s)" ), msg.Printf( _( "(%s min annular width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), v_min ), MessageTextFromValue( userUnits(), v_min ),
MessageTextFromValue( userUnits(), annularWidth ) ); MessageTextFromValue( userUnits(), annularWidth ) );
if( fail_max ) if( fail_max )
m_msg.Printf( _( "(%s max annular width %s; actual %s)" ), msg.Printf( _( "(%s max annular width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), v_max ), MessageTextFromValue( userUnits(), v_max ),
MessageTextFromValue( userUnits(), annularWidth ) ); MessageTextFromValue( userUnits(), annularWidth ) );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );

View File

@ -305,13 +305,14 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( PCB_TRACK* track,
if( trackShape->Collide( otherShape.get(), clearance - m_drcEpsilon, &actual, &pos ) ) if( trackShape->Collide( otherShape.get(), 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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( track, other ); drce->SetItems( track, other );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
@ -353,13 +354,14 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( PCB_TRACK* track,
&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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( track, other ); drce->SetItems( track, other );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
@ -457,13 +459,14 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone( BOARD_ITEM* aItem,
&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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, aZone ); drce->SetItems( aItem, aZone );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
@ -497,13 +500,14 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone( BOARD_ITEM* aItem,
&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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, aZone ); drce->SetItems( aItem, aZone );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
@ -666,12 +670,13 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa
&& testShorting ) && testShorting )
{ {
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_SHORTING_ITEMS ); std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_SHORTING_ITEMS );
wxString msg;
m_msg.Printf( _( "(nets %s and %s)" ), msg.Printf( _( "(nets %s and %s)" ),
pad->GetNetname(), pad->GetNetname(),
otherPad->GetNetname() ); otherPad->GetNetname() );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( pad, otherPad ); drce->SetItems( pad, otherPad );
reportViolation( drce, otherPad->GetPosition(), aLayer ); reportViolation( drce, otherPad->GetPosition(), aLayer );
@ -691,13 +696,14 @@ 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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( pad, other ); drce->SetItems( pad, other );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
@ -723,13 +729,14 @@ 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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( pad, other ); drce->SetItems( pad, other );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
@ -745,13 +752,14 @@ 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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( pad, other ); drce->SetItems( pad, other );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
@ -770,13 +778,14 @@ 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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( pad, otherVia ); drce->SetItems( pad, otherVia );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
@ -1011,13 +1020,14 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones()
else else
{ {
drce = DRC_ITEM::Create( DRCE_CLEARANCE ); drce = DRC_ITEM::Create( DRCE_CLEARANCE );
wxString msg;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), zone2zoneClearance ), MessageTextFromValue( userUnits(), zone2zoneClearance ),
MessageTextFromValue( userUnits(), conflict.second ) ); MessageTextFromValue( userUnits(), conflict.second ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
} }
drce->SetItems( zoneA, zoneB ); drce->SetItems( zoneA, zoneB );

View File

@ -207,12 +207,13 @@ bool DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances()
if( clearance > 0 ) if( clearance > 0 )
{ {
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), wxString msg;
msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
} }
@ -236,12 +237,13 @@ bool DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances()
if( clearance > 0 ) if( clearance > 0 )
{ {
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), wxString msg;
msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
} }

View File

@ -448,13 +448,14 @@ 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;
m_msg = wxString::Format( _( "(%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( userUnits(), val.Max() ), MessageTextFromValue( userUnits(), val.Max() ),
MessageTextFromValue( userUnits(), totalUncoupled ) ); MessageTextFromValue( userUnits(), totalUncoupled ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
auto pit = it.second.itemsP.begin(); auto pit = it.second.itemsP.begin();
auto nit = it.second.itemsN.begin(); auto nit = it.second.itemsN.begin();
@ -485,22 +486,23 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run()
{ {
auto val = gapConstraint->GetValue(); auto 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;
m_msg = drcItem->GetErrorText() + wxT( " (" ) + msg = drcItem->GetErrorText() + wxT( " (" ) +
gapConstraint->GetParentRule()->m_Name + wxS( " " ); gapConstraint->GetParentRule()->m_Name + wxS( " " );
if( val.HasMin() ) if( val.HasMin() )
m_msg += wxString::Format( _( "minimum gap: %s; " ), msg += wxString::Format( _( "minimum gap: %s; " ),
MessageTextFromValue( userUnits(), val.Min() ) ); MessageTextFromValue( userUnits(), val.Min() ) );
if( val.HasMax() ) if( val.HasMax() )
m_msg += wxString::Format( _( "maximum gap: %s; " ), msg += wxString::Format( _( "maximum gap: %s; " ),
MessageTextFromValue( userUnits(), val.Max() ) ); MessageTextFromValue( userUnits(), val.Max() ) );
m_msg += wxString::Format( _( "actual: %s)" ), msg += wxString::Format( _( "actual: %s)" ),
MessageTextFromValue( userUnits(), cpair.computedGap ) ); MessageTextFromValue( userUnits(), cpair.computedGap ) );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( msg );
drcItem->AddItem( cpair.parentP ); drcItem->AddItem( cpair.parentP );
drcItem->AddItem( cpair.parentN ); drcItem->AddItem( cpair.parentN );

View File

@ -211,10 +211,11 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run()
if( constraint.m_DisallowFlags && constraint.GetSeverity() != RPT_SEVERITY_IGNORE ) if( constraint.m_DisallowFlags && constraint.GetSeverity() != RPT_SEVERITY_IGNORE )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ALLOWED_ITEMS ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ALLOWED_ITEMS );
wxString msg;
m_msg.Printf( drcItem->GetErrorText() + wxS( " (%s)" ), constraint.GetName() ); msg.Printf( drcItem->GetErrorText() + wxS( " (%s)" ), constraint.GetName() );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );

View File

@ -114,12 +114,14 @@ 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 )
{ {
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), wxString msg;
msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), minClearance ), MessageTextFromValue( userUnits(), minClearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
} }
drce->SetItems( edge->m_Uuid, item->m_Uuid ); drce->SetItems( edge->m_Uuid, item->m_Uuid );

View File

@ -169,23 +169,24 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole( PAD* aPad )
if( fail_min || fail_max ) if( fail_min || fail_max )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_DRILL_OUT_OF_RANGE ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_DRILL_OUT_OF_RANGE );
wxString msg;
if( fail_min ) if( fail_min )
{ {
m_msg.Printf( _( "(%s min width %s; actual %s)" ), msg.Printf( _( "(%s min width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), constraintValue ), MessageTextFromValue( userUnits(), constraintValue ),
MessageTextFromValue( userUnits(), holeMinor ) ); MessageTextFromValue( userUnits(), holeMinor ) );
} }
else else
{ {
m_msg.Printf( _( "(%s max width %s; actual %s)" ), msg.Printf( _( "(%s max width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), constraintValue ), MessageTextFromValue( userUnits(), constraintValue ),
MessageTextFromValue( userUnits(), holeMajor ) ); MessageTextFromValue( userUnits(), holeMajor ) );
} }
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( aPad ); drcItem->SetItems( aPad );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );
@ -237,23 +238,24 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole( PCB_VIA* via, bool aExceedMicro,
if( fail_min || fail_max ) if( fail_min || fail_max )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( errorCode ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( errorCode );
wxString msg;
if( fail_min ) if( fail_min )
{ {
m_msg.Printf( _( "(%s min width %s; actual %s)" ), msg.Printf( _( "(%s min width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), constraintValue ), MessageTextFromValue( userUnits(), constraintValue ),
MessageTextFromValue( userUnits(), via->GetDrillValue() ) ); MessageTextFromValue( userUnits(), via->GetDrillValue() ) );
} }
else else
{ {
m_msg.Printf( _( "(%s max width %s; actual %s)" ), msg.Printf( _( "(%s max width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), constraintValue ), MessageTextFromValue( userUnits(), constraintValue ),
MessageTextFromValue( userUnits(), via->GetDrillValue() ) ); MessageTextFromValue( userUnits(), via->GetDrillValue() ) );
} }
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( via ); drcItem->SetItems( via );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );

View File

@ -300,13 +300,14 @@ 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;
m_msg.Printf( _( "(%s min %s; actual %s)" ), msg.Printf( _( "(%s min %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), minClearance ), MessageTextFromValue( userUnits(), minClearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, aOther ); drce->SetItems( aItem, aOther );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );

View File

@ -109,23 +109,24 @@ void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengths( const DRC_CONSTRAINT& aCons
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;
if( minViolation ) if( minViolation )
{ {
m_msg.Printf( _( "(%s min length: %s; actual: %s)" ), msg.Printf( _( "(%s min length: %s; actual: %s)" ),
aConstraint.GetName(), aConstraint.GetName(),
MessageTextFromValue( userUnits(), minLen ), MessageTextFromValue( userUnits(), minLen ),
MessageTextFromValue( userUnits(), ent.total ) ); MessageTextFromValue( userUnits(), ent.total ) );
} }
else if( maxViolation ) else if( maxViolation )
{ {
m_msg.Printf( _( "(%s max length: %s; actual: %s)" ), msg.Printf( _( "(%s max length: %s; actual: %s)" ),
aConstraint.GetName(), aConstraint.GetName(),
MessageTextFromValue( userUnits(), maxLen ), MessageTextFromValue( userUnits(), maxLen ),
MessageTextFromValue( userUnits(), ent.total ) ); MessageTextFromValue( userUnits(), ent.total ) );
} }
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
for( auto offendingTrack : ent.items ) for( auto offendingTrack : ent.items )
drcItem->AddItem( offendingTrack ); drcItem->AddItem( offendingTrack );
@ -154,15 +155,16 @@ void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkews( const DRC_CONSTRAINT& aConstr
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;
m_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( 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( drcItem->GetErrorText() + " " + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + " " + msg );
for( BOARD_CONNECTED_ITEM* offendingTrack : ent.items ) for( BOARD_CONNECTED_ITEM* offendingTrack : ent.items )
drcItem->SetItems( offendingTrack ); drcItem->SetItems( offendingTrack );
@ -184,13 +186,14 @@ 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;
m_msg.Printf( _( "(%s max count: %d; actual: %d)" ), msg.Printf( _( "(%s max count: %d; actual: %d)" ),
aConstraint.GetName(), aConstraint.GetName(),
aConstraint.GetValue().Max(), aConstraint.GetValue().Max(),
ent.viaCount ); ent.viaCount );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
for( auto offendingTrack : ent.items ) for( auto offendingTrack : ent.items )
drcItem->SetItems( offendingTrack ); drcItem->SetItems( offendingTrack );

View File

@ -108,10 +108,11 @@ void DRC_TEST_PROVIDER_MISC::testOutline()
else else
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_INVALID_OUTLINE ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_INVALID_OUTLINE );
wxString msg;
m_msg.Printf( _( "(no edges found on Edge.Cuts layer)" ) ); msg.Printf( _( "(no edges found on Edge.Cuts layer)" ) );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( m_board ); drcItem->SetItems( m_board );
reportViolation( drcItem, m_board->GetBoundingBox().Centre(), Edge_Cuts ); reportViolation( drcItem, m_board->GetBoundingBox().Centre(), Edge_Cuts );
@ -195,10 +196,11 @@ void DRC_TEST_PROVIDER_MISC::testDisabledLayers()
if( badLayer != UNDEFINED_LAYER ) if( badLayer != UNDEFINED_LAYER )
{ {
auto drcItem = DRC_ITEM::Create( DRCE_DISABLED_LAYER_ITEM ); auto drcItem = DRC_ITEM::Create( DRCE_DISABLED_LAYER_ITEM );
wxString msg;
m_msg.Printf( _( "(layer %s)" ), LayerName( badLayer ) ); msg.Printf( _( "(layer %s)" ), LayerName( badLayer ) );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
reportViolation( drcItem, item->GetPosition(), UNDEFINED_LAYER ); reportViolation( drcItem, item->GetPosition(), UNDEFINED_LAYER );

View File

@ -507,13 +507,14 @@ 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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
aConstraint.GetName(), aConstraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), collision.second ) ); MessageTextFromValue( userUnits(), collision.second ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aParentItem ); drce->SetItems( aParentItem );
drce->SetViolatingRule( aConstraint.GetParentRule() ); drce->SetViolatingRule( aConstraint.GetParentRule() );
@ -554,13 +555,14 @@ 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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
aConstraint.GetName(), aConstraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aZone ); drce->SetItems( aZone );
drce->SetViolatingRule( aConstraint.GetParentRule() ); drce->SetViolatingRule( aConstraint.GetParentRule() );
@ -610,13 +612,14 @@ bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* item
if( itemShape->Collide( otherShape.get(), clearance, &actual, &pos ) ) if( itemShape->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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( item, other ); drce->SetItems( item, other );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
@ -674,13 +677,14 @@ bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* item
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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( item, other ); drce->SetItems( item, other );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
@ -690,13 +694,14 @@ bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* item
if( otherHoleShape && otherHoleShape->Collide( itemShape, clearance, &actual, &pos ) ) if( otherHoleShape && otherHoleShape->Collide( itemShape, 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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( item, other ); drce->SetItems( item, other );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
@ -779,13 +784,14 @@ 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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, zone ); drce->SetItems( aItem, zone );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );
@ -825,13 +831,14 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aIt
clearance, &actual, &pos ) ) 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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, zone ); drce->SetItems( aItem, zone );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );

View File

@ -112,13 +112,14 @@ void DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist( NETLIST& aNetlist )
if( m_drcEngine->IsErrorLimitExceeded( DRCE_MISSING_FOOTPRINT ) ) if( m_drcEngine->IsErrorLimitExceeded( DRCE_MISSING_FOOTPRINT ) )
break; break;
m_msg.Printf( _( "Missing footprint %s (%s)" ), wxString msg;
msg.Printf( _( "Missing footprint %s (%s)" ),
component->GetReference(), component->GetReference(),
component->GetValue() ); component->GetValue() );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_MISSING_FOOTPRINT ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_MISSING_FOOTPRINT );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( msg );
reportViolation( drcItem, wxPoint(), UNDEFINED_LAYER ); reportViolation( drcItem, wxPoint(), UNDEFINED_LAYER );
} }
else else
@ -136,31 +137,34 @@ void DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist( NETLIST& aNetlist )
if( !pcb_netname.IsEmpty() && sch_net.GetPinName().IsEmpty() ) if( !pcb_netname.IsEmpty() && sch_net.GetPinName().IsEmpty() )
{ {
m_msg.Printf( _( "No corresponding pin found in schematic." ) ); wxString msg;
msg.Printf( _( "No corresponding pin found in schematic." ) );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_NET_CONFLICT ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_NET_CONFLICT );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( msg );
drcItem->SetItems( pad ); drcItem->SetItems( pad );
reportViolation( drcItem, footprint->GetPosition(), UNDEFINED_LAYER ); reportViolation( drcItem, footprint->GetPosition(), UNDEFINED_LAYER );
} }
else if( pcb_netname.IsEmpty() && !sch_net.GetNetName().IsEmpty() ) else if( pcb_netname.IsEmpty() && !sch_net.GetNetName().IsEmpty() )
{ {
m_msg.Printf( _( "Pad missing net given by schematic (%s)." ), wxString msg;
msg.Printf( _( "Pad missing net given by schematic (%s)." ),
sch_net.GetNetName() ); sch_net.GetNetName() );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_NET_CONFLICT ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_NET_CONFLICT );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( msg );
drcItem->SetItems( pad ); drcItem->SetItems( pad );
reportViolation( drcItem, footprint->GetPosition(), UNDEFINED_LAYER ); reportViolation( drcItem, footprint->GetPosition(), UNDEFINED_LAYER );
} }
else if( pcb_netname != sch_net.GetNetName() ) else if( pcb_netname != sch_net.GetNetName() )
{ {
m_msg.Printf( _( "Pad net (%s) doesn't match net given by schematic (%s)." ), wxString msg;
msg.Printf( _( "Pad net (%s) doesn't match net given by schematic (%s)." ),
pcb_netname, pcb_netname,
sch_net.GetNetName() ); sch_net.GetNetName() );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_NET_CONFLICT ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_NET_CONFLICT );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( msg );
drcItem->SetItems( pad ); drcItem->SetItems( pad );
reportViolation( drcItem, footprint->GetPosition(), UNDEFINED_LAYER ); reportViolation( drcItem, footprint->GetPosition(), UNDEFINED_LAYER );
} }
@ -175,11 +179,12 @@ void DRC_TEST_PROVIDER_SCHEMATIC_PARITY::testNetlist( NETLIST& aNetlist )
if( !footprint->FindPadByNumber( sch_net.GetPinName() ) ) if( !footprint->FindPadByNumber( sch_net.GetPinName() ) )
{ {
m_msg.Printf( _( "No pad found for pin %s in schematic." ), wxString msg;
msg.Printf( _( "No pad found for pin %s in schematic." ),
sch_net.GetPinName() ); sch_net.GetPinName() );
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_NET_CONFLICT ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_NET_CONFLICT );
drcItem->SetErrorMessage( m_msg ); drcItem->SetErrorMessage( msg );
drcItem->SetItems( footprint ); drcItem->SetItems( footprint );
reportViolation( drcItem, footprint->GetPosition(), UNDEFINED_LAYER ); reportViolation( drcItem, footprint->GetPosition(), UNDEFINED_LAYER );
} }

View File

@ -221,12 +221,14 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run()
if( minClearance > 0 ) if( minClearance > 0 )
{ {
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), wxString msg;
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( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
} }
drcItem->SetItems( aRefItem, aTestItem ); drcItem->SetItems( aRefItem, aTestItem );

View File

@ -279,13 +279,14 @@ 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;
m_msg.Printf( _( "(%s clearance %s; actual %s)" ), msg.Printf( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), clearance ), MessageTextFromValue( userUnits(), clearance ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( item ); drce->SetItems( item );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );

View File

@ -105,13 +105,14 @@ 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;
m_msg.Printf( _( "(%s min height %s; actual %s)" ), msg.Printf( _( "(%s min height %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), constraint.Value().Min() ), MessageTextFromValue( userUnits(), constraint.Value().Min() ),
MessageTextFromValue( userUnits(), actualHeight ) ); MessageTextFromValue( userUnits(), actualHeight ) );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );
@ -121,13 +122,14 @@ 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;
m_msg.Printf( _( "(%s max height %s; actual %s)" ), msg.Printf( _( "(%s max height %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), constraint.Value().Max() ), MessageTextFromValue( userUnits(), constraint.Value().Max() ),
MessageTextFromValue( userUnits(), actualHeight ) ); MessageTextFromValue( userUnits(), actualHeight ) );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );
@ -205,10 +207,11 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run()
if( collapsedStroke || collapsedArea ) if( collapsedStroke || collapsedArea )
{ {
auto drcItem = DRC_ITEM::Create( DRCE_TEXT_THICKNESS ); auto drcItem = DRC_ITEM::Create( DRCE_TEXT_THICKNESS );
wxString msg;
m_msg = _( "(TrueType font characters with insufficient stroke weight)" ); msg = _( "(TrueType font characters with insufficient stroke weight)" );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );
@ -222,13 +225,14 @@ 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;
m_msg.Printf( _( "(%s min thickness %s; actual %s)" ), msg.Printf( _( "(%s min thickness %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), constraint.Value().Min() ), MessageTextFromValue( userUnits(), constraint.Value().Min() ),
MessageTextFromValue( userUnits(), actualThickness ) ); MessageTextFromValue( userUnits(), actualThickness ) );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );
@ -238,13 +242,14 @@ 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;
m_msg.Printf( _( "(%s max thickness %s; actual %s)" ), msg.Printf( _( "(%s max thickness %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), constraint.Value().Max() ), MessageTextFromValue( userUnits(), constraint.Value().Max() ),
MessageTextFromValue( userUnits(), actualThickness ) ); MessageTextFromValue( userUnits(), actualThickness ) );
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );

View File

@ -126,23 +126,24 @@ bool DRC_TEST_PROVIDER_TRACK_WIDTH::Run()
if( fail_min || fail_max ) if( fail_min || fail_max )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TRACK_WIDTH ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_TRACK_WIDTH );
wxString msg;
if( fail_min ) if( fail_min )
{ {
m_msg.Printf( _( "(%s min width %s; actual %s)" ), msg.Printf( _( "(%s min width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), constraintWidth ), MessageTextFromValue( userUnits(), constraintWidth ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
} }
else else
{ {
m_msg.Printf( _( "(%s max width %s; actual %s)" ), msg.Printf( _( "(%s max width %s; actual %s)" ),
constraint.GetName(), constraint.GetName(),
MessageTextFromValue( userUnits(), constraintWidth ), MessageTextFromValue( userUnits(), constraintWidth ),
MessageTextFromValue( userUnits(), actual ) ); MessageTextFromValue( userUnits(), actual ) );
} }
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );

View File

@ -113,26 +113,27 @@ bool DRC_TEST_PROVIDER_VIA_DIAMETER::Run()
} }
} }
if( fail_min )
{
m_msg.Printf( _( "(%s min diameter %s; actual %s)" ),
constraint.GetName(),
MessageTextFromValue( userUnits(), constraintDiameter ),
MessageTextFromValue( userUnits(), actual ) );
}
else if( fail_max )
{
m_msg.Printf( _( "(%s max diameter %s; actual %s)" ),
constraint.GetName(),
MessageTextFromValue( userUnits(), constraintDiameter ),
MessageTextFromValue( userUnits(), actual ) );
}
if( fail_min || fail_max ) if( fail_min || fail_max )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_VIA_DIAMETER ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_VIA_DIAMETER );
wxString msg;
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + m_msg ); if( fail_min )
{
msg.Printf( _( "(%s min diameter %s; actual %s)" ),
constraint.GetName(),
MessageTextFromValue( userUnits(), constraintDiameter ),
MessageTextFromValue( userUnits(), actual ) );
}
else if( fail_max )
{
msg.Printf( _( "(%s max diameter %s; actual %s)" ),
constraint.GetName(),
MessageTextFromValue( userUnits(), constraintDiameter ),
MessageTextFromValue( userUnits(), actual ) );
}
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg );
drcItem->SetItems( item ); drcItem->SetItems( item );
drcItem->SetViolatingRule( constraint.GetParentRule() ); drcItem->SetViolatingRule( constraint.GetParentRule() );

View File

@ -175,13 +175,14 @@ bool DRC_TEST_PROVIDER_ZONE_CONNECTIONS::Run()
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;
m_msg.Printf( _( "(%s min spoke count %d; actual %d)" ), msg.Printf( _( "(%s min spoke count %d; actual %d)" ),
constraint.GetName(), constraint.GetName(),
minCount, minCount,
spokes ); spokes );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + m_msg ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( zone, pad ); drce->SetItems( zone, pad );
drce->SetViolatingRule( constraint.GetParentRule() ); drce->SetViolatingRule( constraint.GetParentRule() );