Show DRC overflows in both tab titles and number badges.

Fixes https://gitlab.com/kicad/code/kicad/issues/10617
This commit is contained in:
Jeff Young 2022-02-09 15:34:22 +00:00
parent e93b7b05ec
commit ca56de7816
5 changed files with 84 additions and 30 deletions

View File

@ -90,6 +90,8 @@ void NUMBER_BADGE::UpdateNumber( int aNumber, SEVERITY aSeverity )
}
}
computeSize();
// Force the badge UI to refresh so the new number and color is displayed
Refresh();
}
@ -98,7 +100,6 @@ void NUMBER_BADGE::UpdateNumber( int aNumber, SEVERITY aSeverity )
void NUMBER_BADGE::SetMaximumNumber( int aMax )
{
m_maxNumber = aMax;
computeSize();
}
@ -113,7 +114,7 @@ void NUMBER_BADGE::SetTextSize( int aSize )
// match those. Other platforms may also need tweaks to spacing, fontweight, etc.
#ifdef __WXMAC__
#define BADGE_FONTWEIGHT wxFONTWEIGHT_NORMAL
#define PLATFORM_FUDGE_X 0.8
#define PLATFORM_FUDGE_X 0.92
#define PLATFORM_FUDGE_Y 1.6
#endif
@ -133,13 +134,15 @@ void NUMBER_BADGE::computeSize()
{
wxClientDC dc( this );
wxString test = wxString::Format( wxT( "%d" ), m_maxNumber );
wxString test = wxString::Format( wxT( "%d" ), m_currentNumber );
int len = test.length();
// Determine the size using the string "-999+" where the - on the front is for spacing from
// the start of the rectangle so the number isn't close to the curved edge.
test = "-";
// Determine the size using the string "m999{+}" where the 'm' on the front serves as a margin
// so the number isn't too close to the curved edge.
test = "m";
test.Pad( len, '9' );
if( m_currentNumber > m_maxNumber )
test += "+";
dc.SetFont( wxFont( m_textSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, BADGE_FONTWEIGHT ) );

View File

@ -1071,6 +1071,10 @@ void DIALOG_DRC::OnDeleteAllClick( wxCommandEvent& aEvent )
void DIALOG_DRC::updateDisplayedCounts()
{
BOARD_DESIGN_SETTINGS& bds = m_frame->GetDesignSettings();
DRC_TOOL* drcTool = m_frame->GetToolManager()->GetTool<DRC_TOOL>();
DRC_ENGINE* drcEngine = drcTool->GetDRCEngine().get();
// Collect counts:
int numMarkers = 0;
@ -1105,49 +1109,91 @@ void DIALOG_DRC::updateDisplayedCounts()
numExcluded += m_footprintWarningsProvider->GetCount( RPT_SEVERITY_EXCLUSION );
}
bool errorsOverflowed = false;
bool warningsOverflowed = false;
bool markersOverflowed = false;
bool unconnectedOverflowed = false;
bool footprintsOverflowed = false;
for( int ii = DRCE_FIRST; ii < DRCE_LAST; ++ii )
{
if( drcEngine->IsErrorLimitExceeded( ii ) && bds.GetSeverity( ii ) != RPT_SEVERITY_IGNORE )
{
if( bds.GetSeverity( ii ) == RPT_SEVERITY_ERROR )
{
errorsOverflowed = true;
}
else if( bds.GetSeverity( ii ) == RPT_SEVERITY_WARNING )
{
warningsOverflowed = true;
}
if( ii == DRCE_UNCONNECTED_ITEMS )
{
unconnectedOverflowed = true;
}
else if( ii == DRCE_MISSING_FOOTPRINT
|| ii == DRCE_DUPLICATE_FOOTPRINT
|| ii == DRCE_EXTRA_FOOTPRINT
|| ii == DRCE_NET_CONFLICT )
{
footprintsOverflowed = true;
}
else
{
markersOverflowed = true;
}
}
}
wxString msg;
wxString num;
// Update tab headers:
if( m_drcRun )
{
msg.sprintf( m_markersTitleTemplate, numMarkers );
num.Printf( markersOverflowed ? wxT( "%d+" ) : wxT( "%d" ), numMarkers );
msg.Printf( m_markersTitleTemplate, num );
m_Notebook->SetPageText( 0, msg );
msg.sprintf( m_unconnectedTitleTemplate, numUnconnected );
num.Printf( unconnectedOverflowed ? wxT( "%d+" ) : wxT( "%d" ), numUnconnected );
msg.sprintf( m_unconnectedTitleTemplate, num );
m_Notebook->SetPageText( 1, msg );
if( m_footprintTestsRun )
{
msg.sprintf( m_footprintsTitleTemplate, numFootprints );
num.Printf( footprintsOverflowed ? wxT( "%d+" ) : wxT( "%d" ), numFootprints );
msg.sprintf( m_footprintsTitleTemplate, num );
}
else
{
msg = m_footprintsTitleTemplate;
msg.Replace( wxT( "%d" ), _( "not run" ) );
msg.Replace( wxT( "%s" ), _( "not run" ) );
}
m_Notebook->SetPageText( 2, msg );
msg.sprintf( m_ignoredTitleTemplate, m_ignoredList->GetItemCount() );
num.Printf( wxT( "%d" ), m_ignoredList->GetItemCount() );
msg.sprintf( m_ignoredTitleTemplate, num );
m_Notebook->SetPageText( 3, msg );
}
else
{
msg = m_markersTitleTemplate;
msg.Replace( wxT( "(%d)" ), wxEmptyString );
msg.Replace( wxT( "(%s)" ), wxEmptyString );
m_Notebook->SetPageText( 0, msg );
msg = m_unconnectedTitleTemplate;
msg.Replace( wxT( "(%d)" ), wxEmptyString );
msg.Replace( wxT( "(%s)" ), wxEmptyString );
m_Notebook->SetPageText( 1, msg );
msg = m_footprintsTitleTemplate;
msg.Replace( wxT( "(%d)" ), wxEmptyString );
msg.Replace( wxT( "(%s)" ), wxEmptyString );
m_Notebook->SetPageText( 2, msg );
msg = m_ignoredTitleTemplate;
msg.Replace( wxT( "(%d)" ), wxEmptyString );
msg.Replace( wxT( "(%s)" ), wxEmptyString );
m_Notebook->SetPageText( 3, msg );
}
@ -1160,10 +1206,12 @@ void DIALOG_DRC::updateDisplayedCounts()
numWarnings = -1;
m_errorsBadge->SetMaximumNumber( numErrors );
m_errorsBadge->UpdateNumber( numErrors, RPT_SEVERITY_ERROR );
m_errorsBadge->UpdateNumber( errorsOverflowed ? numErrors + 1 : numErrors,
RPT_SEVERITY_ERROR );
m_warningsBadge->SetMaximumNumber( numWarnings );
m_warningsBadge->UpdateNumber( numWarnings, RPT_SEVERITY_WARNING );
m_warningsBadge->UpdateNumber( warningsOverflowed ? numWarnings + 1 : numWarnings,
RPT_SEVERITY_WARNING );
m_exclusionsBadge->SetMaximumNumber( numExcluded );
m_exclusionsBadge->UpdateNumber( numExcluded, RPT_SEVERITY_EXCLUSION );

View File

@ -104,7 +104,7 @@ DIALOG_DRC_BASE::DIALOG_DRC_BASE( wxWindow* parent, wxWindowID id, const wxStrin
m_panelViolations->SetSizer( bSizerViolationsBox );
m_panelViolations->Layout();
bSizerViolationsBox->Fit( m_panelViolations );
m_Notebook->AddPage( m_panelViolations, _("Violations (%d)"), false );
m_Notebook->AddPage( m_panelViolations, _("Violations (%s)"), false );
m_panelUnconnectedItems = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerUnconnectedBox;
bSizerUnconnectedBox = new wxBoxSizer( wxVERTICAL );
@ -116,7 +116,7 @@ DIALOG_DRC_BASE::DIALOG_DRC_BASE( wxWindow* parent, wxWindowID id, const wxStrin
m_panelUnconnectedItems->SetSizer( bSizerUnconnectedBox );
m_panelUnconnectedItems->Layout();
bSizerUnconnectedBox->Fit( m_panelUnconnectedItems );
m_Notebook->AddPage( m_panelUnconnectedItems, _("Unconnected Items (%d)"), false );
m_Notebook->AddPage( m_panelUnconnectedItems, _("Unconnected Items (%s)"), false );
m_panelFootprintWarnings = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerFootprintsBox;
bSizerFootprintsBox = new wxBoxSizer( wxVERTICAL );
@ -128,7 +128,7 @@ DIALOG_DRC_BASE::DIALOG_DRC_BASE( wxWindow* parent, wxWindowID id, const wxStrin
m_panelFootprintWarnings->SetSizer( bSizerFootprintsBox );
m_panelFootprintWarnings->Layout();
bSizerFootprintsBox->Fit( m_panelFootprintWarnings );
m_Notebook->AddPage( m_panelFootprintWarnings, _("Schematic Parity (%d)"), false );
m_Notebook->AddPage( m_panelFootprintWarnings, _("Schematic Parity (%s)"), false );
m_panelIgnored = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer15;
bSizer15 = new wxBoxSizer( wxVERTICAL );
@ -140,7 +140,7 @@ DIALOG_DRC_BASE::DIALOG_DRC_BASE( wxWindow* parent, wxWindowID id, const wxStrin
m_panelIgnored->SetSizer( bSizer15 );
m_panelIgnored->Layout();
bSizer15->Fit( m_panelIgnored );
m_Notebook->AddPage( m_panelIgnored, _("Ignored Tests (%d)"), false );
m_Notebook->AddPage( m_panelIgnored, _("Ignored Tests (%s)"), false );
bSizer13->Add( m_Notebook, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );

View File

@ -777,7 +777,7 @@
<event name="OnNotebookPageChanged">OnChangingNotebookPage</event>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">Violations (%d)</property>
<property name="label">Violations (%s)</property>
<property name="select">0</property>
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
@ -870,7 +870,7 @@
</object>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">Unconnected Items (%d)</property>
<property name="label">Unconnected Items (%s)</property>
<property name="select">0</property>
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
@ -963,7 +963,7 @@
</object>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">Schematic Parity (%d)</property>
<property name="label">Schematic Parity (%s)</property>
<property name="select">0</property>
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
@ -1056,7 +1056,7 @@
</object>
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">Ignored Tests (%d)</property>
<property name="label">Ignored Tests (%s)</property>
<property name="select">0</property>
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>

View File

@ -45,7 +45,8 @@
// wxListBox's performance degrades horrifically with very large datasets. It's not clear
// they're useful to the user anyway.
#define ERROR_LIMIT_MAX 199
#define ERROR_LIMIT 199
#define EXTENDED_ERROR_LIMIT 499
void drcPrintDebugMessage( int level, const wxString& msg, const char *function, int line )
@ -77,7 +78,7 @@ DRC_ENGINE::DRC_ENGINE( BOARD* aBoard, BOARD_DESIGN_SETTINGS *aSettings ) :
m_errorLimits.resize( DRCE_LAST + 1 );
for( int ii = DRCE_FIRST; ii <= DRCE_LAST; ++ii )
m_errorLimits[ ii ] = ERROR_LIMIT_MAX;
m_errorLimits[ ii ] = ERROR_LIMIT;
}
@ -578,7 +579,7 @@ void DRC_ENGINE::InitEngine( const wxFileName& aRulePath )
}
for( int ii = DRCE_FIRST; ii < DRCE_LAST; ++ii )
m_errorLimits[ ii ] = ERROR_LIMIT_MAX;
m_errorLimits[ ii ] = ERROR_LIMIT;
m_rulesValid = true;
}
@ -595,8 +596,10 @@ void DRC_ENGINE::RunTests( EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aT
{
if( m_designSettings->Ignore( ii ) )
m_errorLimits[ ii ] = 0;
else if( ii == DRCE_CLEARANCE || ii == DRCE_UNCONNECTED_ITEMS )
m_errorLimits[ ii ] = EXTENDED_ERROR_LIMIT;
else
m_errorLimits[ ii ] = ERROR_LIMIT_MAX;
m_errorLimits[ ii ] = ERROR_LIMIT;
}
m_board->IncrementTimeStamp(); // Invalidate all caches