2011-10-07 14:41:30 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-12-20 12:40:17 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-11-12 00:31:38 +00:00
|
|
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
|
2024-03-11 09:17:11 +00:00
|
|
|
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-07 14:41:30 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2023-04-21 20:25:01 +00:00
|
|
|
#include <advanced_config.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gestfich.h>
|
2018-01-30 08:56:43 +00:00
|
|
|
#include <sch_screen.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
#include <project.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2018-02-17 11:43:56 +00:00
|
|
|
#include <reporter.h>
|
2017-11-12 00:31:38 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_marker.h>
|
2019-03-11 21:32:05 +00:00
|
|
|
#include <connection_graph.h>
|
2019-06-13 21:04:31 +00:00
|
|
|
#include <tools/ee_actions.h>
|
2020-11-04 01:07:46 +00:00
|
|
|
#include <tools/ee_inspection_tool.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_erc.h>
|
|
|
|
#include <erc.h>
|
2023-08-13 21:31:59 +00:00
|
|
|
#include <erc_report.h>
|
2013-06-07 20:56:55 +00:00
|
|
|
#include <id.h>
|
2020-03-16 11:05:01 +00:00
|
|
|
#include <confirm.h>
|
2023-03-12 14:49:57 +00:00
|
|
|
#include <common.h>
|
2022-09-03 18:29:02 +00:00
|
|
|
#include <widgets/wx_html_report_box.h>
|
2024-01-29 15:59:28 +00:00
|
|
|
#include <dialogs/dialog_text_entry.h>
|
2020-03-16 11:05:01 +00:00
|
|
|
#include <wx/ffile.h>
|
2021-06-07 21:56:43 +00:00
|
|
|
#include <wx/filedlg.h>
|
2020-10-19 14:17:49 +00:00
|
|
|
#include <wx/hyperlink.h>
|
2020-03-16 11:05:01 +00:00
|
|
|
#include <erc_item.h>
|
|
|
|
#include <eeschema_settings.h>
|
2021-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2020-10-19 14:17:49 +00:00
|
|
|
#include <kiplatform/ui.h>
|
Eeschema: ERC dialog code improvements.
* Rename the "net", "lastNet" and "nextNet" variables to "item", "lastItem"
and "nextItem", respectively, because these refer to netlist items, not
nets.
* This adds a suffix "Idx" to the indexes into the list, and introduces local
copies of the pointers to the objects we are looking at, in order to have a
shorter way of addressing them.
* The ERC code depends on netlist items to be sorted by net code, so verify
that in debug builds. While this condition is stricter than necessary, it
should still hold with the current code, and provide a good canary if a
change to the sorting code might break ERC.
2016-06-28 12:52:22 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
|
|
|
|
wxDEFINE_EVENT( EDA_EVT_CLOSE_ERC_DIALOG, wxCommandEvent );
|
|
|
|
|
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
// 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;
|
|
|
|
|
|
|
|
|
2022-06-28 03:06:46 +00:00
|
|
|
static SCHEMATIC* g_lastERCSchematic = nullptr;
|
|
|
|
static bool g_lastERCRun = false;
|
|
|
|
static std::vector<wxString> g_lastERCIgnored;
|
|
|
|
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
|
2020-11-03 19:24:05 +00:00
|
|
|
DIALOG_ERC_BASE( parent ),
|
2021-08-14 20:05:21 +00:00
|
|
|
PROGRESS_REPORTER_BASE( 1 ),
|
2020-03-16 11:05:01 +00:00
|
|
|
m_parent( parent ),
|
2022-08-30 11:03:40 +00:00
|
|
|
m_markerTreeModel( nullptr ),
|
2020-10-19 14:17:49 +00:00
|
|
|
m_running( false ),
|
2020-09-21 10:37:20 +00:00
|
|
|
m_ercRun( false ),
|
2022-04-16 23:22:27 +00:00
|
|
|
m_centerMarkerOnIdle( nullptr ),
|
2022-08-30 11:03:40 +00:00
|
|
|
m_severities( 0 )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2022-06-28 03:06:46 +00:00
|
|
|
m_currentSchematic = &parent->Schematic();
|
|
|
|
|
2021-11-29 13:41:02 +00:00
|
|
|
SetName( DIALOG_ERC_WINDOW_NAME ); // Set a window name to be able to find it
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
EESCHEMA_SETTINGS* settings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
|
|
|
|
m_severities = settings->m_Appearance.erc_severities;
|
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
m_messages->SetImmediateMode();
|
|
|
|
|
2022-08-30 11:03:40 +00:00
|
|
|
m_markerProvider = std::make_shared<SHEETLIST_ERC_ITEMS_PROVIDER>( &m_parent->Schematic() );
|
|
|
|
|
2023-01-21 23:25:40 +00:00
|
|
|
m_markerTreeModel = new ERC_TREE_MODEL( parent, m_markerDataView );
|
2020-03-16 11:05:01 +00:00
|
|
|
m_markerDataView->AssociateModel( m_markerTreeModel );
|
2022-08-30 11:03:40 +00:00
|
|
|
m_markerTreeModel->Update( m_markerProvider, m_severities );
|
2022-01-22 21:34:01 +00:00
|
|
|
|
|
|
|
m_ignoredList->InsertColumn( 0, wxEmptyString, wxLIST_FORMAT_LEFT, DEFAULT_SINGLE_COL_WIDTH );
|
|
|
|
|
2022-06-28 03:06:46 +00:00
|
|
|
if( m_currentSchematic == g_lastERCSchematic )
|
|
|
|
{
|
|
|
|
m_ercRun = g_lastERCRun;
|
|
|
|
|
|
|
|
for( const wxString& str : g_lastERCIgnored )
|
|
|
|
m_ignoredList->InsertItem( m_ignoredList->GetItemCount(), str );
|
|
|
|
}
|
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
m_notebook->SetSelection( 0 );
|
2009-07-03 18:25:06 +00:00
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons( { { wxID_OK, _( "Run ERC" ) },
|
|
|
|
{ wxID_CANCEL, _( "Close" ) } } );
|
2018-07-27 13:52:30 +00:00
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
m_violationsTitleTemplate = m_notebook->GetPageText( 0 );
|
|
|
|
m_ignoredTitleTemplate = m_notebook->GetPageText( 1 );
|
|
|
|
|
2020-10-20 01:32:49 +00:00
|
|
|
m_errorsBadge->SetMaximumNumber( 999 );
|
|
|
|
m_warningsBadge->SetMaximumNumber( 999 );
|
|
|
|
m_exclusionsBadge->SetMaximumNumber( 999 );
|
|
|
|
|
2021-11-29 13:41:02 +00:00
|
|
|
UpdateAnnotationWarning();
|
2020-08-26 01:17:40 +00:00
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
Layout();
|
|
|
|
|
|
|
|
SetFocus();
|
|
|
|
|
|
|
|
syncCheckboxes();
|
|
|
|
updateDisplayedCounts();
|
|
|
|
|
2016-07-16 10:54:55 +00:00
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
Eeschema: ERC dialog code improvements.
* Rename the "net", "lastNet" and "nextNet" variables to "item", "lastItem"
and "nextItem", respectively, because these refer to netlist items, not
nets.
* This adds a suffix "Idx" to the indexes into the list, and introduces local
copies of the pointers to the objects we are looking at, in order to have a
shorter way of addressing them.
* The ERC code depends on netlist items to be sorted by net code, so verify
that in debug builds. While this condition is stricter than necessary, it
should still hold with the current code, and provide a good canary if a
change to the sorting code might break ERC.
2016-06-28 12:52:22 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
DIALOG_ERC::~DIALOG_ERC()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2022-06-28 03:06:46 +00:00
|
|
|
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 ) );
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
EESCHEMA_SETTINGS* settings = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
|
2020-03-21 16:31:48 +00:00
|
|
|
wxASSERT( settings );
|
|
|
|
|
|
|
|
if( settings )
|
|
|
|
settings->m_Appearance.erc_severities = m_severities;
|
2014-10-08 22:40:47 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
m_markerTreeModel->DecRef();
|
2019-08-07 19:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-29 13:41:02 +00:00
|
|
|
void DIALOG_ERC::UpdateAnnotationWarning()
|
|
|
|
{
|
|
|
|
if( m_parent->CheckAnnotate( []( ERCE_T, const wxString&, SCH_REFERENCE*, SCH_REFERENCE* )
|
|
|
|
{ } ) )
|
|
|
|
{
|
2021-08-19 21:28:54 +00:00
|
|
|
if( !m_infoBar->IsShownOnScreen() )
|
2021-11-29 13:41:02 +00:00
|
|
|
{
|
|
|
|
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( m_infoBar, wxID_ANY,
|
2022-09-15 22:43:00 +00:00
|
|
|
_( "Show Annotation dialog" ),
|
2021-11-29 13:41:02 +00:00
|
|
|
wxEmptyString );
|
|
|
|
|
|
|
|
button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
|
|
|
|
[&]( wxHyperlinkEvent& aEvent )
|
|
|
|
{
|
|
|
|
wxHtmlLinkEvent htmlEvent( aEvent.GetId(),
|
|
|
|
wxHtmlLinkInfo( aEvent.GetURL() ) );
|
|
|
|
OnLinkClicked( htmlEvent );
|
|
|
|
} ) );
|
|
|
|
|
|
|
|
m_infoBar->RemoveAllButtons();
|
|
|
|
m_infoBar->AddButton( button );
|
|
|
|
m_infoBar->ShowMessage( _( "Schematic is not fully annotated. "
|
|
|
|
"ERC results will be incomplete." ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-19 21:28:54 +00:00
|
|
|
if( m_infoBar->IsShownOnScreen() )
|
2021-11-29 13:41:02 +00:00
|
|
|
{
|
|
|
|
m_infoBar->RemoveAllButtons();
|
|
|
|
m_infoBar->Hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
bool DIALOG_ERC::updateUI()
|
|
|
|
{
|
|
|
|
// If ERC checks ever get slow enough we'll want a progress indicator...
|
|
|
|
//
|
|
|
|
// double cur = (double) m_progress.load() / m_maxProgress;
|
|
|
|
// cur = std::max( 0.0, std::min( cur, 1.0 ) );
|
|
|
|
//
|
|
|
|
// m_gauge->SetValue( KiROUND( cur * 1000.0 ) );
|
|
|
|
// wxSafeYield( this );
|
|
|
|
|
|
|
|
return !m_cancelled;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::AdvancePhase( const wxString& aMessage )
|
|
|
|
{
|
2021-02-28 14:52:14 +00:00
|
|
|
// Will also call Report( aMessage ):
|
2021-08-14 20:05:21 +00:00
|
|
|
PROGRESS_REPORTER_BASE::AdvancePhase( aMessage );
|
2020-10-19 14:17:49 +00:00
|
|
|
SetCurrentProgress( 0.0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::Report( const wxString& aMessage )
|
|
|
|
{
|
|
|
|
m_messages->Report( aMessage );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_ERC::updateDisplayedCounts()
|
2014-10-08 22:40:47 +00:00
|
|
|
{
|
2020-03-16 11:05:01 +00:00
|
|
|
int numErrors = 0;
|
|
|
|
int numWarnings = 0;
|
|
|
|
int numExcluded = 0;
|
|
|
|
|
2022-06-28 03:06:46 +00:00
|
|
|
int numMarkers = 0;
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
if( m_markerProvider )
|
|
|
|
{
|
2022-06-28 03:06:46 +00:00
|
|
|
numMarkers += m_markerProvider->GetCount();
|
2020-03-16 11:05:01 +00:00
|
|
|
numErrors += m_markerProvider->GetCount( RPT_SEVERITY_ERROR );
|
|
|
|
numWarnings += m_markerProvider->GetCount( RPT_SEVERITY_WARNING );
|
|
|
|
numExcluded += m_markerProvider->GetCount( RPT_SEVERITY_EXCLUSION );
|
|
|
|
}
|
|
|
|
|
2022-06-28 03:06:46 +00:00
|
|
|
bool markersOverflowed = false;
|
|
|
|
|
|
|
|
// We don't currently have a limit on ERC violations, so the above is always false.
|
|
|
|
|
|
|
|
wxString num;
|
2022-01-22 21:34:01 +00:00
|
|
|
wxString msg;
|
|
|
|
|
2022-06-28 03:06:46 +00:00
|
|
|
if( m_ercRun )
|
2022-01-22 21:34:01 +00:00
|
|
|
{
|
2022-06-28 03:06:46 +00:00
|
|
|
num.Printf( markersOverflowed ? wxT( "%d+" ) : wxT( "%d" ), numMarkers );
|
|
|
|
msg.Printf( m_violationsTitleTemplate, num );
|
2022-01-22 21:34:01 +00:00
|
|
|
}
|
|
|
|
else
|
2020-09-21 10:37:20 +00:00
|
|
|
{
|
2022-01-22 21:34:01 +00:00
|
|
|
msg = m_violationsTitleTemplate;
|
2022-06-28 03:06:46 +00:00
|
|
|
msg.Replace( wxT( "(%s)" ), wxEmptyString );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_notebook->SetPageText( 0, msg );
|
2022-01-22 21:34:01 +00:00
|
|
|
|
2022-06-28 03:06:46 +00:00
|
|
|
if( m_ercRun )
|
|
|
|
{
|
|
|
|
num.Printf( wxT( "%d" ), m_ignoredList->GetItemCount() );
|
|
|
|
msg.sprintf( m_ignoredTitleTemplate, num );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-22 21:34:01 +00:00
|
|
|
msg = m_ignoredTitleTemplate;
|
2022-06-28 03:06:46 +00:00
|
|
|
msg.Replace( wxT( "(%s)" ), wxEmptyString );
|
2022-01-22 21:34:01 +00:00
|
|
|
}
|
|
|
|
|
2022-06-28 03:06:46 +00:00
|
|
|
m_notebook->SetPageText( 1, msg );
|
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
if( !m_ercRun && numErrors == 0 )
|
2020-09-21 10:37:20 +00:00
|
|
|
numErrors = -1;
|
2022-01-22 21:34:01 +00:00
|
|
|
|
|
|
|
if( !m_ercRun && numWarnings == 0 )
|
2020-09-21 10:37:20 +00:00
|
|
|
numWarnings = -1;
|
|
|
|
|
2020-10-20 01:32:49 +00:00
|
|
|
m_errorsBadge->UpdateNumber( numErrors, RPT_SEVERITY_ERROR );
|
|
|
|
m_warningsBadge->UpdateNumber( numWarnings, RPT_SEVERITY_WARNING );
|
|
|
|
m_exclusionsBadge->UpdateNumber( numExcluded, RPT_SEVERITY_EXCLUSION );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 23:54:51 +00:00
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
void DIALOG_ERC::OnDeleteOneClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( m_notebook->GetSelection() == 0 )
|
|
|
|
{
|
|
|
|
// Clear the selection. It may be the selected ERC marker.
|
2023-06-26 22:16:51 +00:00
|
|
|
m_parent->GetToolManager()->RunAction( EE_ACTIONS::clearSelection );
|
2022-01-22 21:34:01 +00:00
|
|
|
|
|
|
|
m_markerTreeModel->DeleteCurrentItem( true );
|
|
|
|
|
|
|
|
// redraw the schematic
|
|
|
|
redrawDrawPanel();
|
|
|
|
}
|
|
|
|
|
|
|
|
updateDisplayedCounts();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::OnDeleteAllClick( wxCommandEvent& event )
|
2011-10-07 14:41:30 +00:00
|
|
|
{
|
2020-08-02 21:45:06 +00:00
|
|
|
bool includeExclusions = false;
|
|
|
|
int numExcluded = 0;
|
|
|
|
|
|
|
|
if( m_markerProvider )
|
|
|
|
numExcluded += m_markerProvider->GetCount( RPT_SEVERITY_EXCLUSION );
|
|
|
|
|
|
|
|
if( numExcluded > 0 )
|
|
|
|
{
|
|
|
|
wxMessageDialog dlg( this, _( "Delete exclusions too?" ), _( "Delete All Markers" ),
|
|
|
|
wxYES_NO | wxCANCEL | wxCENTER | wxICON_QUESTION );
|
2023-01-24 17:21:52 +00:00
|
|
|
dlg.SetYesNoLabels( _( "Errors and Warnings Only" ),
|
|
|
|
_( "Errors, Warnings and Exclusions" ) );
|
2020-08-02 21:45:06 +00:00
|
|
|
|
|
|
|
int ret = dlg.ShowModal();
|
|
|
|
|
|
|
|
if( ret == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
else if( ret == wxID_NO )
|
|
|
|
includeExclusions = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteAllMarkers( includeExclusions );
|
2014-10-08 22:40:47 +00:00
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
// redraw the schematic
|
|
|
|
redrawDrawPanel();
|
2020-03-16 11:05:01 +00:00
|
|
|
updateDisplayedCounts();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
void DIALOG_ERC::OnCancelClick( wxCommandEvent& aEvent )
|
2018-08-06 20:30:49 +00:00
|
|
|
{
|
2020-10-19 14:17:49 +00:00
|
|
|
if( m_running )
|
|
|
|
{
|
|
|
|
m_cancelled = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
m_parent->FocusOnItem( nullptr );
|
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
aEvent.Skip();
|
2018-08-06 20:30:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
void DIALOG_ERC::OnCloseErcDialog( wxCloseEvent& aEvent )
|
2018-08-06 20:30:49 +00:00
|
|
|
{
|
2020-03-16 11:05:01 +00:00
|
|
|
m_parent->FocusOnItem( nullptr );
|
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
// Dialog is mode-less so let the parent know that it needs to be destroyed.
|
|
|
|
if( !IsModal() && !IsQuasiModal() )
|
|
|
|
{
|
|
|
|
wxCommandEvent* evt = new wxCommandEvent( EDA_EVT_CLOSE_ERC_DIALOG, wxID_ANY );
|
|
|
|
|
|
|
|
wxWindow* parent = GetParent();
|
|
|
|
|
|
|
|
if( parent )
|
|
|
|
wxQueueEvent( parent, evt );
|
|
|
|
}
|
|
|
|
|
|
|
|
aEvent.Skip();
|
2018-08-06 20:30:49 +00:00
|
|
|
}
|
|
|
|
|
2015-09-10 12:03:16 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
static int RPT_SEVERITY_ALL = RPT_SEVERITY_WARNING | RPT_SEVERITY_ERROR | RPT_SEVERITY_EXCLUSION;
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::syncCheckboxes()
|
|
|
|
{
|
|
|
|
m_showAll->SetValue( m_severities == RPT_SEVERITY_ALL );
|
|
|
|
m_showErrors->SetValue( m_severities & RPT_SEVERITY_ERROR );
|
|
|
|
m_showWarnings->SetValue( m_severities & RPT_SEVERITY_WARNING );
|
|
|
|
m_showExclusions->SetValue( m_severities & RPT_SEVERITY_EXCLUSION );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
void DIALOG_ERC::OnLinkClicked( wxHtmlLinkEvent& event )
|
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
m_parent->OnAnnotate( dummy );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_ERC::OnRunERCClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2019-06-13 13:34:38 +00:00
|
|
|
wxBusyCursor busy;
|
2020-10-19 14:17:49 +00:00
|
|
|
|
|
|
|
SCHEMATIC* sch = &m_parent->Schematic();
|
|
|
|
|
2021-11-29 13:41:02 +00:00
|
|
|
UpdateAnnotationWarning();
|
2020-10-19 14:17:49 +00:00
|
|
|
|
2023-08-13 23:50:05 +00:00
|
|
|
sch->RecordERCExclusions();
|
2020-08-02 21:45:06 +00:00
|
|
|
deleteAllMarkers( true );
|
2015-09-10 12:03:16 +00:00
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
std::vector<std::reference_wrapper<RC_ITEM>> violations = ERC_ITEM::GetItemsWithSeverities();
|
|
|
|
m_ignoredList->DeleteAllItems();
|
|
|
|
|
|
|
|
for( std::reference_wrapper<RC_ITEM>& item : violations )
|
|
|
|
{
|
|
|
|
if( sch->ErcSettings().GetSeverity( item.get().GetErrorCode() ) == RPT_SEVERITY_IGNORE )
|
|
|
|
{
|
|
|
|
m_ignoredList->InsertItem( m_ignoredList->GetItemCount(),
|
|
|
|
wxT( " • " ) + item.get().GetErrorText() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-19 22:53:25 +00:00
|
|
|
m_ignoredList->SetColumnWidth( 0, m_ignoredList->GetParent()->GetClientSize().x - 20 );
|
|
|
|
|
2024-01-07 17:20:34 +00:00
|
|
|
m_cancelled = false;
|
2022-01-22 21:34:01 +00:00
|
|
|
Raise();
|
|
|
|
|
|
|
|
m_runningResultsBook->ChangeSelection( 0 ); // Display the "Tests Running..." tab
|
2020-10-19 14:17:49 +00:00
|
|
|
m_messages->Clear();
|
2022-01-22 21:34:01 +00:00
|
|
|
wxYield(); // Allow time slice to refresh Messages
|
2020-10-19 14:17:49 +00:00
|
|
|
|
|
|
|
m_running = true;
|
|
|
|
m_sdbSizer1Cancel->SetLabel( _( "Cancel" ) );
|
|
|
|
m_sdbSizer1OK->Enable( false );
|
2022-01-22 21:34:01 +00:00
|
|
|
m_deleteOneMarker->Enable( false );
|
|
|
|
m_deleteAllMarkers->Enable( false );
|
2020-10-19 14:17:49 +00:00
|
|
|
m_saveReport->Enable( false );
|
|
|
|
|
2021-01-24 22:25:32 +00:00
|
|
|
sch->GetSheets().AnnotatePowerSymbols();
|
2021-02-24 22:36:11 +00:00
|
|
|
|
|
|
|
int itemsNotAnnotated = m_parent->CheckAnnotate(
|
2021-01-24 22:25:32 +00:00
|
|
|
[]( ERCE_T aType, const wxString& aMsg, SCH_REFERENCE* aItemA, SCH_REFERENCE* aItemB )
|
|
|
|
{
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( aType );
|
|
|
|
ercItem->SetErrorMessage( aMsg );
|
|
|
|
|
|
|
|
if( aItemB )
|
|
|
|
ercItem->SetItems( aItemA->GetSymbol(), aItemB->GetSymbol() );
|
|
|
|
else
|
|
|
|
ercItem->SetItems( aItemA->GetSymbol() );
|
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, aItemA->GetSymbol()->GetPosition() );
|
|
|
|
aItemA->GetSheetPath().LastScreen()->Append( marker );
|
|
|
|
} );
|
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
testErc();
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2021-02-24 22:36:11 +00:00
|
|
|
if( itemsNotAnnotated )
|
|
|
|
m_messages->ReportHead( wxString::Format( _( "%d symbol(s) require annotation.<br><br>" ),
|
|
|
|
itemsNotAnnotated ), RPT_SEVERITY_INFO );
|
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
if( m_cancelled )
|
2021-02-24 22:36:11 +00:00
|
|
|
m_messages->Report( _( "-------- ERC cancelled by user.<br><br>" ), RPT_SEVERITY_INFO );
|
2020-10-19 14:17:49 +00:00
|
|
|
else
|
2022-01-22 21:34:01 +00:00
|
|
|
m_messages->Report( _( "Done.<br><br>" ), RPT_SEVERITY_INFO );
|
2020-10-19 14:17:49 +00:00
|
|
|
|
|
|
|
Raise();
|
|
|
|
wxYield(); // Allow time slice to refresh Messages
|
|
|
|
|
|
|
|
m_running = false;
|
|
|
|
m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
|
|
|
|
m_sdbSizer1OK->Enable( true );
|
2022-01-22 21:34:01 +00:00
|
|
|
m_deleteOneMarker->Enable( true );
|
|
|
|
m_deleteAllMarkers->Enable( true );
|
2020-10-19 14:17:49 +00:00
|
|
|
m_saveReport->Enable( true );
|
|
|
|
|
|
|
|
if( !m_cancelled )
|
|
|
|
{
|
2024-01-10 17:23:29 +00:00
|
|
|
m_sdbSizer1Cancel->SetDefault();
|
|
|
|
// wxWidgets has a tendency to keep both buttons highlighted without the following:
|
|
|
|
m_sdbSizer1OK->Enable( false );
|
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
wxMilliSleep( 500 );
|
2022-01-22 21:34:01 +00:00
|
|
|
m_runningResultsBook->ChangeSelection( 1 );
|
2023-08-08 13:02:54 +00:00
|
|
|
KIPLATFORM::UI::ForceFocus( m_notebook );
|
2024-01-12 14:38:25 +00:00
|
|
|
|
|
|
|
// now re-enable m_sdbSizerOK button
|
|
|
|
m_sdbSizer1OK->Enable( true );
|
2020-10-19 14:17:49 +00:00
|
|
|
}
|
2020-09-21 10:37:20 +00:00
|
|
|
|
|
|
|
m_ercRun = true;
|
2022-01-22 21:34:01 +00:00
|
|
|
redrawDrawPanel();
|
2020-09-21 10:37:20 +00:00
|
|
|
updateDisplayedCounts();
|
2009-07-08 15:42:45 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 23:54:51 +00:00
|
|
|
|
2020-09-21 10:37:20 +00:00
|
|
|
void DIALOG_ERC::redrawDrawPanel()
|
2018-11-14 23:34:32 +00:00
|
|
|
{
|
|
|
|
WINDOW_THAWER thawer( m_parent );
|
|
|
|
|
|
|
|
m_parent->GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
void DIALOG_ERC::testErc()
|
2010-11-11 21:10:27 +00:00
|
|
|
{
|
|
|
|
wxFileName fn;
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCHEMATIC* sch = &m_parent->Schematic();
|
|
|
|
|
|
|
|
SCH_SCREENS screens( sch->Root() );
|
2020-07-03 21:08:17 +00:00
|
|
|
ERC_TESTER tester( sch );
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
{
|
2023-08-13 23:44:10 +00:00
|
|
|
wxBusyCursor dummy;
|
2024-02-02 23:04:56 +00:00
|
|
|
tester.RunTests( m_parent->GetCanvas()->GetView()->GetDrawingSheet(), m_parent,
|
|
|
|
m_parent->Kiway().KiFACE( KIWAY::FACE_CVPCB ), &m_parent->Prj(), this );
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2022-08-30 11:03:40 +00:00
|
|
|
// Update marker list:
|
|
|
|
m_markerTreeModel->Update( m_markerProvider, m_severities );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2018-09-04 20:53:04 +00:00
|
|
|
// Display new markers from the current screen:
|
2020-12-20 17:48:15 +00:00
|
|
|
for( SCH_ITEM* marker : m_parent->GetScreen()->Items().OfType( SCH_MARKER_T ) )
|
|
|
|
{
|
|
|
|
m_parent->GetCanvas()->GetView()->Remove( marker );
|
|
|
|
m_parent->GetCanvas()->GetView()->Add( marker );
|
|
|
|
}
|
2018-09-04 20:53:04 +00:00
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
m_parent->GetCanvas()->Refresh();
|
2010-11-11 21:10:27 +00:00
|
|
|
}
|
2013-06-07 20:56:55 +00:00
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_ERC::OnERCItemSelected( wxDataViewEvent& aEvent )
|
|
|
|
{
|
|
|
|
const KIID& itemID = RC_TREE_MODEL::ToUUID( aEvent.GetItem() );
|
|
|
|
SCH_SHEET_PATH sheet;
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_ITEM* item = m_parent->Schematic().GetSheets().GetItem( itemID, &sheet );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2022-04-16 23:22:27 +00:00
|
|
|
if( m_centerMarkerOnIdle )
|
|
|
|
{
|
|
|
|
// we already came from a cross-probe of the marker in the document; don't go
|
|
|
|
// around in circles
|
|
|
|
}
|
|
|
|
else if( item && item->GetClass() != wxT( "DELETED_SHEET_ITEM" ) )
|
2020-03-16 11:05:01 +00:00
|
|
|
{
|
2023-01-21 23:25:40 +00:00
|
|
|
const RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aEvent.GetItem() );
|
|
|
|
|
|
|
|
if( node )
|
|
|
|
{
|
|
|
|
// Determine the owning sheet for sheet-specific items
|
|
|
|
std::shared_ptr<ERC_ITEM> ercItem =
|
|
|
|
std::static_pointer_cast<ERC_ITEM>( node->m_RcItem );
|
|
|
|
switch( node->m_Type )
|
|
|
|
{
|
|
|
|
case RC_TREE_NODE::MARKER:
|
|
|
|
if( ercItem->IsSheetSpecific() )
|
|
|
|
sheet = ercItem->GetSpecificSheetPath();
|
|
|
|
break;
|
|
|
|
case RC_TREE_NODE::MAIN_ITEM:
|
|
|
|
if( ercItem->MainItemHasSheetPath() )
|
|
|
|
sheet = ercItem->GetMainItemSheetPath();
|
|
|
|
break;
|
|
|
|
case RC_TREE_NODE::AUX_ITEM:
|
|
|
|
if( ercItem->AuxItemHasSheetPath() )
|
|
|
|
sheet = ercItem->GetAuxItemSheetPath();
|
|
|
|
break;
|
2023-01-24 17:21:52 +00:00
|
|
|
default:
|
|
|
|
break;
|
2023-01-21 23:25:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
WINDOW_THAWER thawer( m_parent );
|
|
|
|
|
2020-06-19 21:00:41 +00:00
|
|
|
if( !sheet.empty() && sheet != m_parent->GetCurrentSheet() )
|
2020-03-16 11:05:01 +00:00
|
|
|
{
|
2023-06-26 22:16:51 +00:00
|
|
|
m_parent->GetToolManager()->RunAction( ACTIONS::cancelInteractive );
|
|
|
|
m_parent->GetToolManager()->RunAction( EE_ACTIONS::clearSelection );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
|
|
|
m_parent->SetCurrentSheet( sheet );
|
|
|
|
m_parent->DisplayCurrentSheet();
|
2023-02-19 03:40:07 +00:00
|
|
|
m_parent->RedrawScreen( m_parent->GetScreen()->m_ScrollCenter, false );
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_parent->FocusOnItem( item );
|
2020-09-21 10:37:20 +00:00
|
|
|
redrawDrawPanel();
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::OnERCItemDClick( wxDataViewEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( aEvent.GetItem().IsOk() )
|
|
|
|
{
|
|
|
|
// turn control over to m_parent, hide this DIALOG_ERC window,
|
|
|
|
// no destruction so we can preserve listbox cursor
|
|
|
|
if( !IsModal() )
|
|
|
|
Show( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::OnERCItemRClick( wxDataViewEvent& aEvent )
|
|
|
|
{
|
2024-02-16 13:22:17 +00:00
|
|
|
TOOL_MANAGER* toolMgr = m_parent->GetToolManager();
|
|
|
|
EE_INSPECTION_TOOL* inspectionTool = toolMgr->GetTool<EE_INSPECTION_TOOL>();
|
|
|
|
RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aEvent.GetItem() );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
|
|
|
if( !node )
|
|
|
|
return;
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
ERC_SETTINGS& settings = m_parent->Schematic().ErcSettings();
|
2020-05-13 02:00:37 +00:00
|
|
|
|
2024-02-16 13:22:17 +00:00
|
|
|
std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
|
|
|
|
wxString listName;
|
|
|
|
wxMenu menu;
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
switch( settings.GetSeverity( rcItem->GetErrorCode() ) )
|
2020-03-16 11:05:01 +00:00
|
|
|
{
|
|
|
|
case RPT_SEVERITY_ERROR: listName = _( "errors" ); break;
|
|
|
|
case RPT_SEVERITY_WARNING: listName = _( "warnings" ); break;
|
|
|
|
default: listName = _( "appropriate" ); break;
|
|
|
|
}
|
|
|
|
|
2024-01-29 15:59:28 +00:00
|
|
|
enum MENU_IDS
|
|
|
|
{
|
|
|
|
ID_EDIT_EXCLUSION_COMMENT = 4467,
|
|
|
|
ID_REMOVE_EXCLUSION,
|
|
|
|
ID_REMOVE_EXCLUSION_ALL,
|
|
|
|
ID_ADD_EXCLUSION,
|
|
|
|
ID_ADD_EXCLUSION_ALL,
|
2024-02-16 13:22:17 +00:00
|
|
|
ID_INSPECT_VIOLATION,
|
2024-01-29 15:59:28 +00:00
|
|
|
ID_EDIT_PIN_CONFLICT_MAP,
|
|
|
|
ID_EDIT_CONNECTION_GRID,
|
|
|
|
ID_SET_SEVERITY_TO_ERROR,
|
|
|
|
ID_SET_SEVERITY_TO_WARNING,
|
|
|
|
ID_SET_SEVERITY_TO_IGNORE,
|
|
|
|
ID_EDIT_SEVERITIES,
|
|
|
|
};
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
if( rcItem->GetParent()->IsExcluded() )
|
|
|
|
{
|
2024-01-29 15:59:28 +00:00
|
|
|
menu.Append( ID_EDIT_EXCLUSION_COMMENT,
|
|
|
|
_( "Edit exclusion comment..." ) );
|
|
|
|
|
|
|
|
menu.Append( ID_REMOVE_EXCLUSION,
|
|
|
|
_( "Remove exclusion for this violation" ),
|
2020-03-16 11:05:01 +00:00
|
|
|
wxString::Format( _( "It will be placed back in the %s list" ), listName ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-29 15:59:28 +00:00
|
|
|
menu.Append( ID_ADD_EXCLUSION,
|
|
|
|
_( "Exclude this violation..." ),
|
2020-03-16 11:05:01 +00:00
|
|
|
wxString::Format( _( "It will be excluded from the %s list" ), listName ) );
|
|
|
|
}
|
|
|
|
|
2024-02-16 13:22:17 +00:00
|
|
|
wxString inspectERCErrorMenuText = inspectionTool->InspectERCErrorMenuText( rcItem );
|
|
|
|
|
|
|
|
if( !inspectERCErrorMenuText.IsEmpty() )
|
|
|
|
menu.Append( ID_INSPECT_VIOLATION, inspectERCErrorMenuText );
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
menu.AppendSeparator();
|
|
|
|
|
2020-04-28 08:55:44 +00:00
|
|
|
if( rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_WARNING
|
2023-03-13 16:03:48 +00:00
|
|
|
|| rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_ERROR )
|
2020-03-16 11:05:01 +00:00
|
|
|
{
|
2020-04-28 08:55:44 +00:00
|
|
|
// Pin to pin severities edited through pin conflict map
|
|
|
|
}
|
2020-06-08 02:19:46 +00:00
|
|
|
else if( settings.GetSeverity( rcItem->GetErrorCode() ) == RPT_SEVERITY_WARNING )
|
2020-04-28 08:55:44 +00:00
|
|
|
{
|
2024-01-29 15:59:28 +00:00
|
|
|
menu.Append( ID_SET_SEVERITY_TO_ERROR,
|
|
|
|
wxString::Format( _( "Change severity to Error for all '%s' violations" ),
|
|
|
|
rcItem->GetErrorText() ),
|
2023-03-13 23:35:07 +00:00
|
|
|
_( "Violation severities can also be edited in the Schematic Setup... dialog" ) );
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-29 15:59:28 +00:00
|
|
|
menu.Append( ID_SET_SEVERITY_TO_WARNING,
|
|
|
|
wxString::Format( _( "Change severity to Warning for all '%s' violations" ),
|
|
|
|
rcItem->GetErrorText() ),
|
2023-03-13 23:35:07 +00:00
|
|
|
_( "Violation severities can also be edited in the Schematic Setup... dialog" ) );
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
|
2024-01-29 15:59:28 +00:00
|
|
|
menu.Append( ID_SET_SEVERITY_TO_IGNORE,
|
|
|
|
wxString::Format( _( "Ignore all '%s' violations" ), rcItem->GetErrorText() ),
|
2020-04-28 08:55:44 +00:00
|
|
|
_( "Violations will not be checked or reported" ) );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
|
|
|
menu.AppendSeparator();
|
|
|
|
|
2020-04-28 08:55:44 +00:00
|
|
|
if( rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_WARNING
|
|
|
|
|| rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_ERROR )
|
|
|
|
{
|
2024-01-29 15:59:28 +00:00
|
|
|
menu.Append( ID_EDIT_PIN_CONFLICT_MAP,
|
|
|
|
_( "Edit pin-to-pin conflict map..." ),
|
|
|
|
_( "Open the Schematic Setup... dialog" ) );
|
2020-04-28 08:55:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-01-29 15:59:28 +00:00
|
|
|
menu.Append( ID_EDIT_SEVERITIES,
|
|
|
|
_( "Edit violation severities..." ),
|
2020-04-28 08:55:44 +00:00
|
|
|
_( "Open the Schematic Setup... dialog" ) );
|
|
|
|
}
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2023-10-20 20:00:51 +00:00
|
|
|
if( rcItem->GetErrorCode() == ERCE_ENDPOINT_OFF_GRID )
|
|
|
|
{
|
2024-01-29 15:59:28 +00:00
|
|
|
menu.Append( ID_EDIT_CONNECTION_GRID,
|
|
|
|
_( "Edit connection grid spacing..." ),
|
2023-10-20 20:00:51 +00:00
|
|
|
_( "Open the Schematic Setup... dialog" ) );
|
|
|
|
}
|
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
bool modified = false;
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
switch( GetPopupMenuSelectionFromUser( menu ) )
|
|
|
|
{
|
2024-01-29 15:59:28 +00:00
|
|
|
case ID_EDIT_EXCLUSION_COMMENT:
|
|
|
|
if( SCH_MARKER* marker = dynamic_cast<SCH_MARKER*>( node->m_RcItem->GetParent() ) )
|
|
|
|
{
|
|
|
|
WX_TEXT_ENTRY_DIALOG dlg( this, _( "Optional comment:" ), _( "Exclusion Comment" ),
|
|
|
|
marker->GetComment(), true );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
break;
|
|
|
|
|
|
|
|
marker->SetExcluded( true, dlg.GetValue() );
|
|
|
|
|
|
|
|
// Update view
|
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
|
|
|
|
modified = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2024-01-29 15:59:28 +00:00
|
|
|
case ID_REMOVE_EXCLUSION:
|
|
|
|
if( SCH_MARKER* marker = dynamic_cast<SCH_MARKER*>( node->m_RcItem->GetParent() ) )
|
2020-12-01 22:35:11 +00:00
|
|
|
{
|
|
|
|
marker->SetExcluded( false );
|
|
|
|
m_parent->GetCanvas()->GetView()->Update( marker );
|
|
|
|
|
|
|
|
// Update view
|
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
|
|
|
|
modified = true;
|
|
|
|
}
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2024-01-29 15:59:28 +00:00
|
|
|
break;
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2024-01-29 15:59:28 +00:00
|
|
|
case ID_ADD_EXCLUSION:
|
|
|
|
if( SCH_MARKER* marker = dynamic_cast<SCH_MARKER*>( node->m_RcItem->GetParent() ) )
|
2020-12-01 22:35:11 +00:00
|
|
|
{
|
2024-01-29 15:59:28 +00:00
|
|
|
WX_TEXT_ENTRY_DIALOG dlg( this, _( "Optional comment:" ), _( "Exclusion Comment" ),
|
|
|
|
wxEmptyString, true );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
break;
|
|
|
|
|
|
|
|
marker->SetExcluded( true, dlg.GetValue() );
|
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
m_parent->GetCanvas()->GetView()->Update( marker );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
// Update view
|
|
|
|
if( m_severities & RPT_SEVERITY_EXCLUSION )
|
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
|
|
|
|
else
|
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->DeleteCurrentItem( false );
|
|
|
|
|
|
|
|
modified = true;
|
|
|
|
}
|
2024-01-29 15:59:28 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
break;
|
|
|
|
|
2024-02-16 13:22:17 +00:00
|
|
|
case ID_INSPECT_VIOLATION:
|
|
|
|
inspectionTool->InspectERCError( node->m_RcItem );
|
|
|
|
break;
|
|
|
|
|
2024-01-29 15:59:28 +00:00
|
|
|
case ID_SET_SEVERITY_TO_ERROR:
|
2020-06-08 02:19:46 +00:00
|
|
|
settings.SetSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_ERROR );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
for( SCH_ITEM* item : m_parent->GetScreen()->Items().OfType( SCH_MARKER_T ) )
|
|
|
|
{
|
|
|
|
SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
|
|
|
|
|
|
|
|
if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
|
|
|
|
m_parent->GetCanvas()->GetView()->Update( marker );
|
|
|
|
}
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
// Rebuild model and view
|
2022-08-30 11:03:40 +00:00
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->Update( m_markerProvider, m_severities );
|
2020-12-01 22:35:11 +00:00
|
|
|
modified = true;
|
2020-03-16 11:05:01 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-29 15:59:28 +00:00
|
|
|
case ID_SET_SEVERITY_TO_WARNING:
|
2020-06-08 02:19:46 +00:00
|
|
|
settings.SetSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_WARNING );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
for( SCH_ITEM* item : m_parent->GetScreen()->Items().OfType( SCH_MARKER_T ) )
|
|
|
|
{
|
|
|
|
SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
|
|
|
|
|
|
|
|
if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
|
|
|
|
m_parent->GetCanvas()->GetView()->Update( marker );
|
|
|
|
}
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
// Rebuild model and view
|
2022-08-30 11:03:40 +00:00
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->Update( m_markerProvider, m_severities );
|
2020-12-01 22:35:11 +00:00
|
|
|
modified = true;
|
2020-03-16 11:05:01 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-29 15:59:28 +00:00
|
|
|
case ID_SET_SEVERITY_TO_IGNORE:
|
2020-03-16 11:05:01 +00:00
|
|
|
{
|
2020-06-08 02:19:46 +00:00
|
|
|
settings.SetSeverity( rcItem->GetErrorCode(), RPT_SEVERITY_IGNORE );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2020-04-28 08:55:44 +00:00
|
|
|
if( rcItem->GetErrorCode() == ERCE_PIN_TO_PIN_ERROR )
|
2020-06-08 02:19:46 +00:00
|
|
|
settings.SetSeverity( ERCE_PIN_TO_PIN_WARNING, RPT_SEVERITY_IGNORE );
|
2020-04-28 08:55:44 +00:00
|
|
|
|
2024-03-11 09:17:11 +00:00
|
|
|
// Clear the selection before deleting markers. It may be some selected ERC markers.
|
|
|
|
// Deleting a selected marker without deselecting it first generates a crash
|
|
|
|
m_parent->GetToolManager()->RunAction( EE_ACTIONS::clearSelection );
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
SCH_SCREENS ScreenList( m_parent->Schematic().Root() );
|
2020-03-16 11:05:01 +00:00
|
|
|
ScreenList.DeleteMarkers( MARKER_BASE::MARKER_ERC, rcItem->GetErrorCode() );
|
|
|
|
|
|
|
|
// Rebuild model and view
|
2022-08-30 11:03:40 +00:00
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->Update( m_markerProvider, m_severities );
|
2020-12-01 22:35:11 +00:00
|
|
|
modified = true;
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2024-01-29 15:59:28 +00:00
|
|
|
case ID_EDIT_PIN_CONFLICT_MAP:
|
2020-05-24 14:54:26 +00:00
|
|
|
m_parent->ShowSchematicSetupDialog( _( "Pin Conflicts Map" ) );
|
2020-04-28 08:55:44 +00:00
|
|
|
break;
|
|
|
|
|
2024-01-29 15:59:28 +00:00
|
|
|
case ID_EDIT_SEVERITIES:
|
2020-05-24 14:54:26 +00:00
|
|
|
m_parent->ShowSchematicSetupDialog( _( "Violation Severity" ) );
|
2020-03-16 11:05:01 +00:00
|
|
|
break;
|
2023-10-20 20:00:51 +00:00
|
|
|
|
2024-01-29 15:59:28 +00:00
|
|
|
case ID_EDIT_CONNECTION_GRID:
|
2023-10-20 20:00:51 +00:00
|
|
|
m_parent->ShowSchematicSetupDialog( _( "Formatting" ) );
|
|
|
|
break;
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
2020-12-01 22:35:11 +00:00
|
|
|
|
|
|
|
if( modified )
|
|
|
|
{
|
|
|
|
updateDisplayedCounts();
|
|
|
|
redrawDrawPanel();
|
|
|
|
m_parent->OnModify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::PrevMarker()
|
|
|
|
{
|
2022-01-22 21:34:01 +00:00
|
|
|
if( m_notebook->IsShown() )
|
|
|
|
{
|
|
|
|
if( m_notebook->GetSelection() != 0 )
|
|
|
|
m_notebook->SetSelection( 0 );
|
2020-12-01 22:35:11 +00:00
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
m_markerTreeModel->PrevMarker();
|
|
|
|
}
|
2020-12-01 22:35:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::NextMarker()
|
|
|
|
{
|
2022-01-22 21:34:01 +00:00
|
|
|
if( m_notebook->IsShown() )
|
|
|
|
{
|
|
|
|
if( m_notebook->GetSelection() != 0 )
|
|
|
|
m_notebook->SetSelection( 0 );
|
2020-12-01 22:35:11 +00:00
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
m_markerTreeModel->NextMarker();
|
|
|
|
}
|
2020-12-01 22:35:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-16 23:22:27 +00:00
|
|
|
void DIALOG_ERC::SelectMarker( const SCH_MARKER* aMarker )
|
|
|
|
{
|
|
|
|
if( m_notebook->IsShown() )
|
|
|
|
{
|
|
|
|
m_notebook->SetSelection( 0 );
|
|
|
|
m_markerTreeModel->SelectMarker( aMarker );
|
|
|
|
|
|
|
|
// wxWidgets on some platforms fails to correctly ensure that a selected item is
|
|
|
|
// visible, so we have to do it in a separate idle event.
|
|
|
|
m_centerMarkerOnIdle = aMarker;
|
|
|
|
Bind( wxEVT_IDLE, &DIALOG_ERC::centerMarkerIdleHandler, this );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::centerMarkerIdleHandler( wxIdleEvent& aEvent )
|
|
|
|
{
|
|
|
|
m_markerTreeModel->CenterMarker( m_centerMarkerOnIdle );
|
|
|
|
m_centerMarkerOnIdle = nullptr;
|
|
|
|
Unbind( wxEVT_IDLE, &DIALOG_ERC::centerMarkerIdleHandler, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-30 16:51:04 +00:00
|
|
|
void DIALOG_ERC::ExcludeMarker( SCH_MARKER* aMarker )
|
2020-12-01 22:35:11 +00:00
|
|
|
{
|
2021-12-30 16:51:04 +00:00
|
|
|
SCH_MARKER* marker = aMarker;
|
|
|
|
|
|
|
|
if( marker != nullptr )
|
|
|
|
m_markerTreeModel->SelectMarker( marker );
|
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
if( m_notebook->GetSelection() != 0 )
|
2020-12-01 22:35:11 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( m_markerDataView->GetCurrentItem() );
|
|
|
|
|
2021-12-30 16:51:04 +00:00
|
|
|
if( node && node->m_RcItem )
|
|
|
|
marker = dynamic_cast<SCH_MARKER*>( node->m_RcItem->GetParent() );
|
|
|
|
|
|
|
|
if( node && marker && !marker->IsExcluded() )
|
2020-12-01 22:35:11 +00:00
|
|
|
{
|
|
|
|
marker->SetExcluded( true );
|
|
|
|
m_parent->GetCanvas()->GetView()->Update( marker );
|
|
|
|
|
|
|
|
// Update view
|
|
|
|
if( m_severities & RPT_SEVERITY_EXCLUSION )
|
|
|
|
m_markerTreeModel->ValueChanged( node );
|
|
|
|
else
|
|
|
|
m_markerTreeModel->DeleteCurrentItem( false );
|
|
|
|
|
|
|
|
updateDisplayedCounts();
|
|
|
|
redrawDrawPanel();
|
|
|
|
m_parent->OnModify();
|
|
|
|
}
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-19 22:53:25 +00:00
|
|
|
void DIALOG_ERC::OnEditViolationSeverities( wxHyperlinkEvent& aEvent )
|
2022-01-22 21:34:01 +00:00
|
|
|
{
|
2023-06-19 22:53:25 +00:00
|
|
|
m_parent->ShowSchematicSetupDialog( _( "Violation Severity" ) );
|
2022-01-22 21:34:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_ERC::OnSeverity( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
int flag = 0;
|
|
|
|
|
|
|
|
if( aEvent.GetEventObject() == m_showAll )
|
|
|
|
flag = RPT_SEVERITY_ALL;
|
|
|
|
else if( aEvent.GetEventObject() == m_showErrors )
|
|
|
|
flag = RPT_SEVERITY_ERROR;
|
|
|
|
else if( aEvent.GetEventObject() == m_showWarnings )
|
|
|
|
flag = RPT_SEVERITY_WARNING;
|
|
|
|
else if( aEvent.GetEventObject() == m_showExclusions )
|
|
|
|
flag = RPT_SEVERITY_EXCLUSION;
|
|
|
|
|
|
|
|
if( aEvent.IsChecked() )
|
|
|
|
m_severities |= flag;
|
|
|
|
else if( aEvent.GetEventObject() == m_showAll )
|
|
|
|
m_severities = RPT_SEVERITY_ERROR;
|
|
|
|
else
|
|
|
|
m_severities &= ~flag;
|
|
|
|
|
|
|
|
syncCheckboxes();
|
|
|
|
|
2022-08-30 11:03:40 +00:00
|
|
|
m_markerTreeModel->Update( m_markerProvider, m_severities );
|
2020-03-16 11:05:01 +00:00
|
|
|
updateDisplayedCounts();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-02 21:45:06 +00:00
|
|
|
void DIALOG_ERC::deleteAllMarkers( bool aIncludeExclusions )
|
2020-03-16 11:05:01 +00:00
|
|
|
{
|
|
|
|
// Clear current selection list to avoid selection of deleted items
|
2023-06-26 22:16:51 +00:00
|
|
|
m_parent->GetToolManager()->RunAction( EE_ACTIONS::clearSelection );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2022-08-08 21:00:37 +00:00
|
|
|
m_markerTreeModel->DeleteItems( false, aIncludeExclusions, false );
|
|
|
|
|
|
|
|
SCH_SCREENS screens( m_parent->Schematic().Root() );
|
|
|
|
screens.DeleteAllMarkers( MARKER_BASE::MARKER_ERC, aIncludeExclusions );
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::OnSaveReport( wxCommandEvent& aEvent )
|
|
|
|
{
|
2023-12-28 02:10:01 +00:00
|
|
|
wxFileName fn( wxS( "ERC." ) + FILEEXT::ReportFileExtension );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2023-10-23 17:01:04 +00:00
|
|
|
wxFileDialog dlg( this, _( "Save Report File" ), Prj().GetProjectPath(), fn.GetFullName(),
|
2023-12-28 02:10:01 +00:00
|
|
|
FILEEXT::ReportFileWildcard() + wxS( "|" ) + FILEEXT::JsonFileWildcard(),
|
2023-08-13 22:48:29 +00:00
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
2023-08-13 22:48:29 +00:00
|
|
|
fn = dlg.GetPath();
|
|
|
|
|
|
|
|
if( fn.GetExt().IsEmpty() )
|
2023-12-28 02:10:01 +00:00
|
|
|
fn.SetExt( FILEEXT::ReportFileExtension );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
|
|
|
if( !fn.IsAbsolute() )
|
|
|
|
{
|
|
|
|
wxString prj_path = Prj().GetProjectPath();
|
|
|
|
fn.MakeAbsolute( prj_path );
|
|
|
|
}
|
|
|
|
|
2023-08-13 21:31:59 +00:00
|
|
|
ERC_REPORT reportWriter( &m_parent->Schematic(), m_parent->GetUserUnits() );
|
|
|
|
|
2023-08-13 22:48:29 +00:00
|
|
|
bool success = false;
|
2023-12-28 02:10:01 +00:00
|
|
|
if( fn.GetExt() == FILEEXT::JsonFileExtension )
|
2023-08-13 22:48:29 +00:00
|
|
|
success = reportWriter.WriteJsonReport( fn.GetFullPath() );
|
|
|
|
else
|
|
|
|
success = reportWriter.WriteTextReport( fn.GetFullPath() );
|
|
|
|
|
|
|
|
if( success )
|
2020-03-16 11:05:01 +00:00
|
|
|
{
|
2021-07-05 12:40:38 +00:00
|
|
|
m_messages->Report( wxString::Format( _( "Report file '%s' created." ),
|
2020-10-19 14:17:49 +00:00
|
|
|
fn.GetFullPath() ) );
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-05 12:40:38 +00:00
|
|
|
DisplayError( this, wxString::Format( _( "Failed to create file '%s'." ),
|
2020-03-16 11:05:01 +00:00
|
|
|
fn.GetFullPath() ) );
|
|
|
|
}
|
2023-08-13 21:31:59 +00:00
|
|
|
}
|