diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index b1982296e7..bf0d6744ae 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -55,6 +55,11 @@ static int DEFAULT_SINGLE_COL_WIDTH = 660; +static SCHEMATIC* g_lastERCSchematic = nullptr; +static bool g_lastERCRun = false; +static std::vector g_lastERCIgnored; + + DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) : DIALOG_ERC_BASE( parent ), PROGRESS_REPORTER_BASE( 1 ), @@ -64,6 +69,8 @@ DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) : m_centerMarkerOnIdle( nullptr ), 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( Kiface().KifaceSettings() ); @@ -80,6 +87,14 @@ DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) : m_ignoredList->InsertColumn( 0, wxEmptyString, wxLIST_FORMAT_LEFT, DEFAULT_SINGLE_COL_WIDTH ); + if( m_currentSchematic == g_lastERCSchematic ) + { + m_ercRun = g_lastERCRun; + + for( const wxString& str : g_lastERCIgnored ) + m_ignoredList->InsertItem( m_ignoredList->GetItemCount(), str ); + } + m_notebook->SetSelection( 0 ); SetupStandardButtons( { { wxID_OK, _( "Run ERC" ) }, @@ -108,6 +123,14 @@ DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) : DIALOG_ERC::~DIALOG_ERC() { + g_lastERCSchematic = m_currentSchematic; + g_lastERCRun = m_ercRun; + + g_lastERCIgnored.clear(); + + for( int ii = 0; ii < m_ignoredList->GetItemCount(); ++ii ) + g_lastERCIgnored.push_back( m_ignoredList->GetItemText( ii ) ); + EESCHEMA_SETTINGS* settings = dynamic_cast( Kiface().KifaceSettings() ); wxASSERT( settings ); @@ -190,34 +213,49 @@ 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 ); } + 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 && m_markerProvider && m_ignoredList ) + if( m_ercRun ) { - msg.sprintf( m_violationsTitleTemplate, m_markerProvider->GetCount() ); - m_notebook->SetPageText( 0, msg ); - - msg.sprintf( m_ignoredTitleTemplate, m_ignoredList->GetItemCount() ); - m_notebook->SetPageText( 1, msg ); + num.Printf( markersOverflowed ? wxT( "%d+" ) : wxT( "%d" ), numMarkers ); + msg.Printf( m_violationsTitleTemplate, num ); } else { msg = m_violationsTitleTemplate; - msg.Replace( wxT( "(%d)" ), wxEmptyString ); - m_notebook->SetPageText( 0, msg ); - - msg = m_ignoredTitleTemplate; - msg.Replace( wxT( "(%d)" ), wxEmptyString ); - m_notebook->SetPageText( 1, msg ); + msg.Replace( wxT( "(%s)" ), wxEmptyString ); } + m_notebook->SetPageText( 0, msg ); + + if( m_ercRun ) + { + num.Printf( wxT( "%d" ), m_ignoredList->GetItemCount() ); + msg.sprintf( m_ignoredTitleTemplate, num ); + } + else + { + msg = m_ignoredTitleTemplate; + msg.Replace( wxT( "(%s)" ), wxEmptyString ); + } + + m_notebook->SetPageText( 1, msg ); + if( !m_ercRun && numErrors == 0 ) numErrors = -1; @@ -275,8 +313,6 @@ void DIALOG_ERC::OnDeleteAllClick( wxCommandEvent& event ) // redraw the schematic redrawDrawPanel(); - - m_ercRun = false; updateDisplayedCounts(); } diff --git a/eeschema/dialogs/dialog_erc.h b/eeschema/dialogs/dialog_erc.h index bd9b1d2e79..8f2d1e6fc7 100644 --- a/eeschema/dialogs/dialog_erc.h +++ b/eeschema/dialogs/dialog_erc.h @@ -97,6 +97,7 @@ private: private: SCH_EDIT_FRAME* m_parent; + SCHEMATIC* m_currentSchematic; wxString m_violationsTitleTemplate; wxString m_ignoredTitleTemplate; diff --git a/eeschema/dialogs/dialog_erc_base.cpp b/eeschema/dialogs/dialog_erc_base.cpp index c19dfd6b7e..0e8ad06622 100644 --- a/eeschema/dialogs/dialog_erc_base.cpp +++ b/eeschema/dialogs/dialog_erc_base.cpp @@ -84,7 +84,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 (%d)"), false ); + m_notebook->AddPage( violationsPanel, _("Violations (%s)"), false ); m_panelIgnored = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer15; bSizer15 = new wxBoxSizer( wxVERTICAL ); @@ -96,7 +96,7 @@ DIALOG_ERC_BASE::DIALOG_ERC_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, 5 ); diff --git a/eeschema/dialogs/dialog_erc_base.fbp b/eeschema/dialogs/dialog_erc_base.fbp index d85c273a15..c293e43391 100644 --- a/eeschema/dialogs/dialog_erc_base.fbp +++ b/eeschema/dialogs/dialog_erc_base.fbp @@ -619,7 +619,7 @@ - Violations (%d) + Violations (%s) 0 1 @@ -712,7 +712,7 @@ - Ignored Tests (%d) + Ignored Tests (%s) 0 1