Cleanup (consistent naming, 100-char line width, message precision).

This commit is contained in:
Jeff Young 2020-09-15 12:06:15 +01:00
parent 98339cd5eb
commit 665212341d
20 changed files with 64 additions and 79 deletions

View File

@ -111,8 +111,16 @@ int BOARD_CONNECTED_ITEM::GetClearance( PCB_LAYER_ID aLayer, BOARD_ITEM* aItem,
// LEVEL 2: Rules
//
if( GetRuleClearance( aItem, aLayer, &clearance, aSource ) )
return clearance;
const DRC_CONSTRAINT* constraint = GetConstraint( this, aItem, DRC_CONSTRAINT_TYPE_CLEARANCE,
aLayer, aSource );
if( constraint )
{
if( aSource )
*aSource = wxString::Format( _( "'%s' rule" ), *aSource );
return constraint->m_Value.Min();
}
// LEVEL 3: Accumulated local settings, netclass settings, & board design settings
//
@ -152,26 +160,6 @@ int BOARD_CONNECTED_ITEM::GetClearance( PCB_LAYER_ID aLayer, BOARD_ITEM* aItem,
}
bool BOARD_CONNECTED_ITEM::GetRuleClearance( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer,
int* aClearance, wxString* aSource ) const
{
const DRC_CONSTRAINT* constraint = GetConstraint( this, aItem, DRC_CONSTRAINT_TYPE_CLEARANCE,
aLayer, aSource );
if( constraint )
{
if( aSource )
*aSource = wxString::Format( _( "'%s' rule" ), *aSource );
*aClearance = constraint->m_Value.Min();
return true;
}
return false;
}
// Note: do NOT return a std::shared_ptr from this. It is used heavily in DRC, and the
// std::shared_ptr stuff shows up large in performance profiling.
NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const

View File

@ -170,17 +170,6 @@ public:
virtual int GetClearance( PCB_LAYER_ID aLayer, BOARD_ITEM* aItem = nullptr,
wxString* aSource = nullptr, REPORTER* aReporter = nullptr ) const;
/**
* Function GetRuleClearance
* returns any rule-based clearance.
* @param aLayer the current layer under test
* @param aClearance [out] the clearance value in internal units
* @param aSource [out] reports the source as a user-readable string
* @return true if a rule was fired
*/
virtual bool GetRuleClearance( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer, int* aClearance,
wxString* aSource ) const;
/**
* Function GetLocalClearanceOverrides
* returns any local clearance overrides set in the "classic" (ie: pre-rule) system.

View File

@ -33,7 +33,7 @@
#include <drc/drc_test_provider.h>
#include <drc/drc.h>
void drcPrintDebugMessage( int level, wxString msg, const char *function, int line )
void drcPrintDebugMessage( int level, const wxString& msg, const char *function, int line )
{
wxString valueStr;
@ -54,10 +54,17 @@ DRC_ENGINE::DRC_ENGINE( BOARD* aBoard, BOARD_DESIGN_SETTINGS *aSettings ) :
m_board( aBoard ),
m_worksheet( nullptr ),
m_schematicNetlist( nullptr ),
m_userUnits( EDA_UNITS::MILLIMETRES ),
m_testTracksAgainstZones( false ),
m_reportAllTrackErrors( false ),
m_testFootprints( false ),
m_reporter( nullptr ),
m_progressReporter( nullptr )
{
m_errorLimits.resize( DRCE_LAST );
for( int ii = DRCE_FIRST; ii < DRCE_LAST; ++ii )
m_errorLimits[ ii ] = INT_MAX;
}
@ -422,6 +429,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
REPORTER* aReporter )
{
#define REPORT( s ) { if( aReporter ) { aReporter->Report( s ); } }
#define UNITS aReporter ? aReporter->GetUnits() : EDA_UNITS::MILLIMETRES
auto* connectedA = a && a->IsConnected() ? static_cast<BOARD_CONNECTED_ITEM*>( a ) : nullptr;
auto* connectedB = b && b->IsConnected() ? static_cast<BOARD_CONNECTED_ITEM*>( b ) : nullptr;
@ -438,8 +446,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
REPORT( "" )
REPORT( wxString::Format( _( "Local override on %s; clearance: %s." ),
a->GetSelectMenuText( aReporter->GetUnits() ),
StringFromValue( aReporter->GetUnits(), overrideA, true ) ) )
a->GetSelectMenuText( UNITS ),
MessageTextFromValue( UNITS, overrideA, true ) ) )
}
if( connectedB && connectedB->GetLocalClearanceOverrides( nullptr ) > 0 )
@ -448,8 +456,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
REPORT( "" )
REPORT( wxString::Format( _( "Local override on %s; clearance: %s." ),
b->GetSelectMenuText( aReporter->GetUnits() ),
StringFromValue( aReporter->GetUnits(), overrideB, true ) ) )
b->GetSelectMenuText( UNITS ),
MessageTextFromValue( UNITS, overrideB, true ) ) )
}
if( overrideA || overrideB )
@ -479,7 +487,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
REPORT( wxString::Format( _( "Checking %s %s; clearance: %s." ),
implicit ? _( "" ) : _( "rule" ),
rcons->parentRule->m_Name,
StringFromValue( aReporter->GetUnits(), clearance, true ) ) )
MessageTextFromValue( UNITS, clearance, true ) ) )
}
else
{
@ -544,8 +552,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
{
REPORT( "" )
REPORT( wxString::Format( _( "Local clearance on %s; clearance: %s." ),
a->GetSelectMenuText( aReporter->GetUnits() ),
StringFromValue( aReporter->GetUnits(), localA, true ) ) )
a->GetSelectMenuText( UNITS ),
MessageTextFromValue( UNITS, localA, true ) ) )
if( localA > clearance )
clearance = connectedA->GetLocalClearance( &m_msg );
@ -555,8 +563,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
{
REPORT( "" )
REPORT( wxString::Format( _( "Local clearance on %s; clearance: %s." ),
b->GetSelectMenuText( aReporter->GetUnits() ),
StringFromValue( aReporter->GetUnits(), localB, true ) ) )
b->GetSelectMenuText( UNITS ),
MessageTextFromValue( UNITS, localB, true ) ) )
if( localB > clearance )
clearance = connectedB->GetLocalClearance( &m_msg );
@ -578,6 +586,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRulesForItems( DRC_CONSTRAINT_TYPE_T aConstraintI
return constraintRef ? *constraintRef : nullConstraint;
#undef REPORT
#undef UNITS
}
@ -634,12 +643,12 @@ void DRC_ENGINE::ReportProgress( double aProgress )
}
void DRC_ENGINE::ReportStage ( const wxString& aStageName )
void DRC_ENGINE::ReportPhase( const wxString& aMessage )
{
if( !m_progressReporter )
return;
m_progressReporter->AdvancePhase( aStageName );
m_progressReporter->AdvancePhase( aMessage );
}

View File

@ -48,7 +48,7 @@ namespace KIGFX
class WS_PROXY_VIEW_ITEM;
};
void drcPrintDebugMessage( int level, wxString msg, const char *function, int line );
void drcPrintDebugMessage( int level, const wxString& msg, const char *function, int line );
#define drc_dbg(level, fmt, ...) \
drcPrintDebugMessage(level, wxString::Format( fmt, __VA_ARGS__ ), __FUNCTION__, __LINE__ );
@ -141,7 +141,7 @@ public:
void ReportViolation( const std::shared_ptr<DRC_ITEM>& aItem, wxPoint aPos );
void ReportProgress( double aProgress );
void ReportStage( const wxString& aStageName );
void ReportPhase( const wxString& aMessage );
void ReportAux( const wxString& aStr );
bool QueryWorstConstraint( DRC_CONSTRAINT_TYPE_T aRuleId, DRC_CONSTRAINT& aConstraint,

View File

@ -39,7 +39,7 @@ const wxString DRC_TEST_PROVIDER::GetName() const { return "<no name test>"; }
const wxString DRC_TEST_PROVIDER::GetDescription() const { return ""; }
void DRC_TEST_PROVIDER::reportViolation( std::shared_ptr<DRC_ITEM> item, wxPoint aMarkerPos )
void DRC_TEST_PROVIDER::reportViolation( std::shared_ptr<DRC_ITEM>& item, wxPoint aMarkerPos )
{
item->SetViolatingTest( this );
m_drcEngine->ReportViolation( item, aMarkerPos );
@ -52,10 +52,10 @@ void DRC_TEST_PROVIDER::reportProgress( double aProgress )
}
void DRC_TEST_PROVIDER::reportStage( const wxString& aStageName )
void DRC_TEST_PROVIDER::reportPhase( const wxString& aMessage )
{
m_drcEngine->ReportStage( aStageName );
reportAux( aStageName );
m_drcEngine->ReportPhase( aMessage );
reportAux( aMessage );
}

View File

@ -102,9 +102,9 @@ protected:
const std::function<bool(BOARD_ITEM*)>& aFunc );
virtual void reportAux( wxString fmt, ... );
virtual void reportViolation( std::shared_ptr<DRC_ITEM> item, wxPoint aMarkerPos );
virtual void reportViolation( std::shared_ptr<DRC_ITEM>& item, wxPoint aMarkerPos );
virtual void reportProgress( double aProgress );
virtual void reportStage( const wxString& aStageName );
virtual void reportPhase( const wxString& aStageName );
virtual void reportRuleStatistics();
virtual void accountCheck( const DRC_RULE* ruleToTest );

View File

@ -76,7 +76,7 @@ bool DRC_TEST_PROVIDER_ANNULUS::Run()
return false;
}
reportStage( _( "Via annular rings..." ));
reportPhase( _( "Via annular rings..." ));
auto checkAnnulus =
[&]( BOARD_ITEM* item ) -> bool
@ -115,7 +115,6 @@ bool DRC_TEST_PROVIDER_ANNULUS::Run()
if( fail_min || fail_max )
{
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ANNULUS );
wxString msg;
m_msg.Printf( drcItem->GetErrorText() + _( " (%s %s annulus %s; actual %s)" ),
constraint.GetName(),
@ -123,7 +122,7 @@ bool DRC_TEST_PROVIDER_ANNULUS::Run()
MessageTextFromValue( userUnits(), annulus, true ),
MessageTextFromValue( userUnits(), fail_min ? v_min : v_max, true ) );
drcItem->SetErrorMessage( msg );
drcItem->SetErrorMessage( m_msg );
drcItem->SetItems( item );
drcItem->SetViolatingRule( constraint.GetParentRule() );

View File

@ -73,7 +73,7 @@ public:
bool DRC_TEST_PROVIDER_CONNECTIVITY::Run()
{
reportStage( _( "Dangling pads/vias..." ));
reportPhase( _( "Dangling pads/vias..." ));
BOARD* board = m_drcEngine->GetBoard();
@ -106,7 +106,7 @@ bool DRC_TEST_PROVIDER_CONNECTIVITY::Run()
}
}
reportStage( _( "Starved zones..." ));
reportPhase( _( "Starved zones..." ));
/* test starved zones */
for( ZONE_CONTAINER* zone : board->Zones() )
@ -131,7 +131,7 @@ bool DRC_TEST_PROVIDER_CONNECTIVITY::Run()
}
}
reportStage( _( "Unconnected nets..." ));
reportPhase( _( "Unconnected nets..." ));
connectivity->RecalculateRatsnest();
std::vector<CN_EDGE> edges;

View File

@ -113,16 +113,16 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run()
reportAux( "Worst clearance : %d nm", m_largestClearance );
reportStage( _( "Pad clerances..." ));
reportPhase( _( "Pad clerances..." ));
testPadClearances();
reportStage( _( "Track/via clerances..." ));
reportPhase( _( "Track/via clerances..." ));
testTrackClearances();
reportStage( _( "Copper drawing/text clerances..." ));
reportPhase( _( "Copper drawing/text clerances..." ));
testCopperTextAndGraphics();
reportStage( _( "Zone clearances..." ));
reportPhase( _( "Zone clearances..." ));
testZones();
reportRuleStatistics();

View File

@ -77,7 +77,7 @@ private:
void DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testFootprintCourtyardDefinitions()
{
// Detects missing (or malformed) footprint courtyards
reportStage( _( "Footprint courtyard definitions..." ));
reportPhase( _( "Footprint courtyard definitions..." ));
for( MODULE* footprint : m_board->Modules() )
{
@ -118,7 +118,7 @@ void DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testFootprintCourtyardDefinitions()
void DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testOverlappingComponentCourtyards()
{
reportStage( _( "Footprint courtyard overlap..." ));
reportPhase( _( "Footprint courtyard overlap..." ));
for( auto it1 = m_board->Modules().begin(); it1 != m_board->Modules().end(); it1++ )
{

View File

@ -71,7 +71,7 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run()
return false;
}
reportStage( _( "Keepouts & disallow constraints..." ));
reportPhase( _( "Keepouts & disallow constraints..." ));
auto checkItem = [&]( BOARD_ITEM *item ) -> bool
{

View File

@ -90,7 +90,7 @@ bool DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run()
reportAux( "Worst clearance : %d nm", m_largestClearance );
reportStage( _( "Board edge clearances..." ));
reportPhase( _( "Board edge clearances..." ));
std::vector<DRAWSEGMENT*> boardOutline;
std::vector<BOARD_ITEM*> boardItems;

View File

@ -115,10 +115,10 @@ bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::Run()
buildDrilledHoleList();
reportStage( _( "Hole to pad clearances..." ));
reportPhase( _( "Hole to pad clearances..." ));
testPads2Holes();
reportStage( _( "Hole to hole clearances..." ));
reportPhase( _( "Hole to hole clearances..." ));
testHoles2Holes();
reportRuleStatistics();

View File

@ -76,7 +76,7 @@ private:
bool DRC_TEST_PROVIDER_HOLE_SIZE::Run()
{
reportStage( _( "Pad holes..." ));
reportPhase( _( "Pad holes..." ));
m_board = m_drcEngine->GetBoard();
@ -94,7 +94,7 @@ bool DRC_TEST_PROVIDER_HOLE_SIZE::Run()
}
}
reportStage( _( "Via holes..." ));
reportPhase( _( "Via holes..." ));
std::vector<VIA*> vias;

View File

@ -209,7 +209,7 @@ bool DRC_TEST_PROVIDER_LVS::Run()
{
if( m_drcEngine->GetTestFootprints() )
{
reportStage( _( "Layout-vs-Schematic checks..." ));
reportPhase( _( "Layout-vs-Schematic checks..." ));
testFootprints( *m_drcEngine->GetSchematicNetlist() );

View File

@ -191,13 +191,13 @@ bool DRC_TEST_PROVIDER_MISC::Run()
{
m_board = m_drcEngine->GetBoard();
reportStage( _( "Board outline..." ));
reportPhase( _( "Board outline..." ));
testOutline();
reportStage( _( "Disabled layers..." ));
reportPhase( _( "Disabled layers..." ));
testDisabledLayers();
reportStage( _( "Text variables..." ));
reportPhase( _( "Text variables..." ));
testTextVars();
return true;

View File

@ -73,7 +73,7 @@ bool DRC_TEST_PROVIDER_TRACK_WIDTH::Run()
return false;
}
reportStage( _( "Track widths..." ));
reportPhase( _( "Track widths..." ));
auto checkTrackWidth =
[&]( BOARD_ITEM* item ) -> bool

View File

@ -74,7 +74,7 @@ bool DRC_TEST_PROVIDER_VIA_DIAMETER::Run()
return false;
}
reportStage(( "Via diameters..." ));
reportPhase(( "Via diameters..." ));
auto checkViaDiameter =
[&]( BOARD_ITEM* item ) -> bool

View File

@ -95,7 +95,7 @@ bool test::DRC_TEST_PROVIDER_SILK_TO_PAD::Run()
}
reportAux( "Worst clearance : %d nm", m_largestClearance );
reportStage(( "Pad to silkscreen clearances..." ));
reportPhase(( "Pad to silkscreen clearances..." ));
std::vector<DRAWSEGMENT*> boardOutline;
std::vector<BOARD_ITEM*> boardItems;