Apply DRC fixes to ERC.
Fixes https://gitlab.com/kicad/code/kicad/issues/11844
(cherry picked from commit 83a2f43661
)
This commit is contained in:
parent
e7dd9f9337
commit
58451335cb
|
@ -49,6 +49,10 @@
|
|||
#include <string_utils.h>
|
||||
#include <kiplatform/ui.h>
|
||||
|
||||
static SCHEMATIC* g_lastERCSchematic = nullptr;
|
||||
static bool g_lastERCRun = false;
|
||||
|
||||
|
||||
DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
|
||||
DIALOG_ERC_BASE( parent ),
|
||||
PROGRESS_REPORTER_BASE( 1 ),
|
||||
|
@ -57,6 +61,8 @@ DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
|
|||
m_ercRun( false ),
|
||||
m_severities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING )
|
||||
{
|
||||
m_currentSchematic = &parent->Schematic();
|
||||
|
||||
SetName( DIALOG_ERC_WINDOW_NAME ); // Set a window name to be able to find it
|
||||
|
||||
EESCHEMA_SETTINGS* settings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
|
||||
|
@ -70,8 +76,9 @@ DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
|
|||
|
||||
m_markerTreeModel->SetSeverities( m_severities );
|
||||
m_markerTreeModel->SetProvider( m_markerProvider );
|
||||
syncCheckboxes();
|
||||
updateDisplayedCounts();
|
||||
|
||||
if( m_currentSchematic == g_lastERCSchematic )
|
||||
m_ercRun = g_lastERCRun;
|
||||
|
||||
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but
|
||||
// that requires us to correct the button labels here.
|
||||
|
@ -81,12 +88,21 @@ DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
|
|||
|
||||
m_sdbSizer1OK->SetDefault();
|
||||
|
||||
m_violationsTitleTemplate = m_notebook->GetPageText( 1 );
|
||||
|
||||
m_errorsBadge->SetMaximumNumber( 999 );
|
||||
m_warningsBadge->SetMaximumNumber( 999 );
|
||||
m_exclusionsBadge->SetMaximumNumber( 999 );
|
||||
|
||||
UpdateAnnotationWarning();
|
||||
|
||||
Layout();
|
||||
|
||||
SetFocus();
|
||||
|
||||
syncCheckboxes();
|
||||
updateDisplayedCounts();
|
||||
|
||||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
finishDialogSettings();
|
||||
}
|
||||
|
@ -94,6 +110,9 @@ DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
|
|||
|
||||
DIALOG_ERC::~DIALOG_ERC()
|
||||
{
|
||||
g_lastERCSchematic = m_currentSchematic;
|
||||
g_lastERCRun = m_ercRun;
|
||||
|
||||
EESCHEMA_SETTINGS* settings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
|
||||
wxASSERT( settings );
|
||||
|
||||
|
@ -176,18 +195,41 @@ void DIALOG_ERC::updateDisplayedCounts()
|
|||
int numWarnings = 0;
|
||||
int numExcluded = 0;
|
||||
|
||||
int numMarkers = 0;
|
||||
|
||||
if( m_markerProvider )
|
||||
{
|
||||
numMarkers += m_markerProvider->GetCount();
|
||||
numErrors += m_markerProvider->GetCount( RPT_SEVERITY_ERROR );
|
||||
numWarnings += m_markerProvider->GetCount( RPT_SEVERITY_WARNING );
|
||||
numExcluded += m_markerProvider->GetCount( RPT_SEVERITY_EXCLUSION );
|
||||
}
|
||||
|
||||
if( !m_ercRun )
|
||||
bool markersOverflowed = false;
|
||||
|
||||
// We don't currently have a limit on ERC violations, so the above is always false.
|
||||
|
||||
wxString num;
|
||||
wxString msg;
|
||||
|
||||
if( m_ercRun )
|
||||
{
|
||||
numErrors = -1;
|
||||
numWarnings = -1;
|
||||
num.Printf( markersOverflowed ? wxT( "%d+" ) : wxT( "%d" ), numMarkers );
|
||||
msg.Printf( m_violationsTitleTemplate, num );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = m_violationsTitleTemplate;
|
||||
msg.Replace( wxT( "(%s)" ), wxEmptyString );
|
||||
}
|
||||
|
||||
m_notebook->SetPageText( 0, msg );
|
||||
|
||||
if( !m_ercRun && numErrors == 0 )
|
||||
numErrors = -1;
|
||||
|
||||
if( !m_ercRun && numWarnings == 0 )
|
||||
numWarnings = -1;
|
||||
|
||||
m_errorsBadge->UpdateNumber( numErrors, RPT_SEVERITY_ERROR );
|
||||
m_warningsBadge->UpdateNumber( numWarnings, RPT_SEVERITY_WARNING );
|
||||
|
@ -221,9 +263,9 @@ void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event )
|
|||
|
||||
deleteAllMarkers( includeExclusions );
|
||||
|
||||
m_ercRun = false;
|
||||
// redraw the schematic
|
||||
redrawDrawPanel();
|
||||
updateDisplayedCounts();
|
||||
m_parent->GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -91,6 +91,9 @@ private:
|
|||
|
||||
private:
|
||||
SCH_EDIT_FRAME* m_parent;
|
||||
SCHEMATIC* m_currentSchematic;
|
||||
|
||||
wxString m_violationsTitleTemplate;
|
||||
|
||||
RC_ITEMS_PROVIDER* m_markerProvider;
|
||||
RC_TREE_MODEL* m_markerTreeModel;
|
||||
|
|
|
@ -54,7 +54,7 @@ DIALOG_ERC_BASE::DIALOG_ERC_BASE( wxWindow* parent, wxWindowID id, const wxStrin
|
|||
violationsPanel->SetSizer( bViolationsSizer );
|
||||
violationsPanel->Layout();
|
||||
bViolationsSizer->Fit( violationsPanel );
|
||||
m_notebook->AddPage( violationsPanel, _("Violations"), false );
|
||||
m_notebook->AddPage( violationsPanel, _("Violations (%s)"), false );
|
||||
|
||||
bMainSizer->Add( m_notebook, 1, wxEXPAND, 5 );
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@
|
|||
</object>
|
||||
<object class="notebookpage" expanded="1">
|
||||
<property name="bitmap"></property>
|
||||
<property name="label">Violations</property>
|
||||
<property name="label">Violations (%s)</property>
|
||||
<property name="select">0</property>
|
||||
<object class="wxPanel" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
|
|
|
@ -47,15 +47,9 @@
|
|||
#include <tools/board_inspection_tool.h>
|
||||
#include <kiplatform/ui.h>
|
||||
|
||||
// wxWidgets spends *far* too long calcuating column widths (most of it, believe it or
|
||||
// not, in repeatedly creating/destroying a wxDC to do the measurement in).
|
||||
// Use default column widths instead.
|
||||
static int DEFAULT_SINGLE_COL_WIDTH = 660;
|
||||
|
||||
static BOARD* g_lastDRCBoard = nullptr;
|
||||
static bool g_lastDRCRun = false;
|
||||
static bool g_lastFootprintTestsRun = false;
|
||||
static std::vector<wxString> g_lastIgnored;
|
||||
|
||||
|
||||
DIALOG_DRC::DIALOG_DRC( PCB_EDIT_FRAME* aEditorFrame, wxWindow* aParent ) :
|
||||
|
@ -90,15 +84,10 @@ DIALOG_DRC::DIALOG_DRC( PCB_EDIT_FRAME* aEditorFrame, wxWindow* aParent ) :
|
|||
m_footprintWarningsTreeModel = new RC_TREE_MODEL( m_frame, m_footprintsDataView );
|
||||
m_footprintsDataView->AssociateModel( m_footprintWarningsTreeModel );
|
||||
|
||||
m_ignoredList->InsertColumn( 0, wxEmptyString, wxLIST_FORMAT_LEFT, DEFAULT_SINGLE_COL_WIDTH );
|
||||
|
||||
if( m_currentBoard == g_lastDRCBoard )
|
||||
{
|
||||
m_drcRun = g_lastDRCRun;
|
||||
m_footprintTestsRun = g_lastFootprintTestsRun;
|
||||
|
||||
for( const wxString& str : g_lastIgnored )
|
||||
m_ignoredList->InsertItem( m_ignoredList->GetItemCount(), str );
|
||||
}
|
||||
|
||||
if( Kiface().IsSingle() )
|
||||
|
@ -126,11 +115,6 @@ DIALOG_DRC::~DIALOG_DRC()
|
|||
g_lastDRCRun = m_drcRun;
|
||||
g_lastFootprintTestsRun = m_footprintTestsRun;
|
||||
|
||||
g_lastIgnored.clear();
|
||||
|
||||
for( int ii = 0; ii < m_ignoredList->GetItemCount(); ++ii )
|
||||
g_lastIgnored.push_back( m_ignoredList->GetItemText( ii ) );
|
||||
|
||||
PCBNEW_SETTINGS* settings = m_frame->GetPcbNewSettings();
|
||||
settings->m_DrcDialog.refill_zones = m_cbRefillZones->GetValue();
|
||||
settings->m_DrcDialog.test_all_track_errors = m_cbReportAllTrackErrors->GetValue();
|
||||
|
@ -993,6 +977,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;
|
||||
|
@ -1122,10 +1110,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 );
|
||||
|
|
Loading…
Reference in New Issue