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>
|
2020-10-07 13:15:31 +00:00
|
|
|
* Copyright (C) 1992-2020 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
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gestfich.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.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>
|
2015-12-20 12:40:17 +00:00
|
|
|
#include <kiface_i.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.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>
|
2018-09-04 20:53:04 +00:00
|
|
|
#include <sch_view.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>
|
2019-06-13 21:04:31 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_erc.h>
|
|
|
|
#include <erc.h>
|
2013-06-07 20:56:55 +00:00
|
|
|
#include <id.h>
|
2020-03-16 11:05:01 +00:00
|
|
|
#include <confirm.h>
|
2020-08-26 01:17:40 +00:00
|
|
|
#include <widgets/infobar.h>
|
2020-10-19 14:17:49 +00:00
|
|
|
#include <dialogs/wx_html_report_box.h>
|
2020-03-16 11:05:01 +00:00
|
|
|
#include <wx/ffile.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>
|
2020-10-14 11:03:58 +00:00
|
|
|
#include <kicad_string.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
|
|
|
|
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 ),
|
2020-10-19 14:17:49 +00:00
|
|
|
PROGRESS_REPORTER( 1 ),
|
2020-03-16 11:05:01 +00:00
|
|
|
m_parent( parent ),
|
2020-10-19 14:17:49 +00:00
|
|
|
m_running( false ),
|
2020-09-21 10:37:20 +00:00
|
|
|
m_ercRun( false ),
|
2020-03-16 11:05:01 +00:00
|
|
|
m_severities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
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();
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
m_markerProvider = new SHEETLIST_ERC_ITEMS_PROVIDER( &m_parent->Schematic() );
|
2020-03-16 11:05:01 +00:00
|
|
|
m_markerTreeModel = new RC_TREE_MODEL( parent, m_markerDataView );
|
|
|
|
m_markerDataView->AssociateModel( m_markerTreeModel );
|
2018-07-18 16:59:05 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
m_markerTreeModel->SetSeverities( m_severities );
|
|
|
|
m_markerTreeModel->SetProvider( m_markerProvider );
|
|
|
|
syncCheckboxes();
|
|
|
|
updateDisplayedCounts();
|
2009-07-03 18:25:06 +00:00
|
|
|
|
2018-07-27 13:52:30 +00:00
|
|
|
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but
|
|
|
|
// that requires us to correct the button labels here.
|
2020-10-19 14:17:49 +00:00
|
|
|
m_sdbSizer1OK->SetLabel( _( "Run ERC" ) );
|
2018-07-27 13:52:30 +00:00
|
|
|
m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
|
|
|
|
m_sdbSizer1->Layout();
|
|
|
|
|
|
|
|
m_sdbSizer1OK->SetDefault();
|
|
|
|
|
2020-10-20 01:32:49 +00:00
|
|
|
m_errorsBadge->SetMaximumNumber( 999 );
|
|
|
|
m_warningsBadge->SetMaximumNumber( 999 );
|
|
|
|
m_exclusionsBadge->SetMaximumNumber( 999 );
|
|
|
|
|
2020-08-26 01:17:40 +00:00
|
|
|
if( m_parent->CheckAnnotate( NULL_REPORTER::GetInstance(), false ) )
|
2020-10-19 14:17:49 +00:00
|
|
|
{
|
|
|
|
wxHyperlinkCtrl* button = new wxHyperlinkCtrl( m_infoBar, wxID_ANY,
|
|
|
|
_("Show Annotation dialog"),
|
|
|
|
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 );
|
2020-10-30 19:49:32 +00:00
|
|
|
m_infoBar->ShowMessage( _( "Annotation not complete. ERC cannot be run." ) );
|
2020-10-19 14:17:49 +00:00
|
|
|
}
|
2020-08-26 01:17:40 +00:00
|
|
|
|
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
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
// PROGRESS_REPORTER calls
|
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
PROGRESS_REPORTER::AdvancePhase( aMessage );
|
|
|
|
SetCurrentProgress( 0.0 );
|
|
|
|
|
|
|
|
m_messages->Report( aMessage );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
if( m_markerProvider )
|
|
|
|
{
|
|
|
|
numErrors += m_markerProvider->GetCount( RPT_SEVERITY_ERROR );
|
|
|
|
numWarnings += m_markerProvider->GetCount( RPT_SEVERITY_WARNING );
|
|
|
|
numExcluded += m_markerProvider->GetCount( RPT_SEVERITY_EXCLUSION );
|
|
|
|
}
|
|
|
|
|
2020-09-21 10:37:20 +00:00
|
|
|
if( !m_ercRun )
|
|
|
|
{
|
|
|
|
numErrors = -1;
|
|
|
|
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
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
/* Delete the old ERC markers, over the whole hierarchy
|
|
|
|
*/
|
2011-10-07 14:41:30 +00:00
|
|
|
void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event )
|
|
|
|
{
|
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 );
|
|
|
|
dlg.SetYesNoLabels( _( "Errors and Warnings Only" ) , _( "Errors, Warnings and Exclusions" ) );
|
|
|
|
|
|
|
|
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
|
|
|
|
2020-09-21 10:37:20 +00:00
|
|
|
m_ercRun = false;
|
2020-03-16 11:05:01 +00:00
|
|
|
updateDisplayedCounts();
|
2012-11-30 12:28:23 +00:00
|
|
|
m_parent->GetCanvas()->Refresh();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2018-08-06 20:30:49 +00:00
|
|
|
// This is a modeless dialog so we have to handle these ourselves.
|
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 );
|
|
|
|
|
2018-08-06 20:30:49 +00:00
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::OnCloseErcDialog( wxCloseEvent& event )
|
|
|
|
{
|
2020-03-16 11:05:01 +00:00
|
|
|
m_parent->FocusOnItem( nullptr );
|
|
|
|
|
2020-11-04 01:07:46 +00:00
|
|
|
m_parent->GetToolManager()->GetTool<EE_INSPECTION_TOOL>()->DestroyERCDialog();
|
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 );
|
|
|
|
|
|
|
|
// We don't actually get notified when the annotation error is resolved, but we can assume
|
|
|
|
// that the user will take corrective action. If they don't, we can just show the infobar
|
|
|
|
// again.
|
|
|
|
m_infoBar->Hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
// Build the whole sheet list in hierarchy (sheet, not screen)
|
|
|
|
sch->GetSheets().AnnotatePowerSymbols();
|
|
|
|
|
|
|
|
if( m_parent->CheckAnnotate( NULL_REPORTER::GetInstance(), false ) )
|
|
|
|
{
|
|
|
|
m_notebook->ChangeSelection( 0 ); // Display the "Tests Running..." tab
|
|
|
|
|
|
|
|
m_messages->Clear();
|
2020-10-30 19:49:32 +00:00
|
|
|
m_messages->Report( _( "Annotation not complete. ERC cannot be run." )
|
|
|
|
+ wxT( " <a href='annotate'>" )
|
2020-10-19 14:17:49 +00:00
|
|
|
+ _( "Show Annotation dialog." )
|
|
|
|
+ wxT( "</a>" ) );
|
|
|
|
|
|
|
|
m_messages->Flush();
|
|
|
|
m_infoBar->Hide(); // No need for duplicated error messages
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_infoBar->Hide();
|
|
|
|
|
2020-11-18 22:55:38 +00:00
|
|
|
m_parent->RecordERCExclusions();
|
2020-08-02 21:45:06 +00:00
|
|
|
deleteAllMarkers( true );
|
2015-09-10 12:03:16 +00:00
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
m_notebook->ChangeSelection( 0 ); // Display the "Tests Running..." tab
|
|
|
|
m_messages->Clear();
|
|
|
|
wxYield(); // Allow time slice to refresh Messages
|
|
|
|
|
|
|
|
m_running = true;
|
|
|
|
m_sdbSizer1Cancel->SetLabel( _( "Cancel" ) );
|
|
|
|
m_sdbSizer1OK->Enable( false );
|
|
|
|
m_buttondelmarkers->Enable( false );
|
|
|
|
m_saveReport->Enable( false );
|
|
|
|
|
|
|
|
testErc();
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
if( m_cancelled )
|
|
|
|
m_messages->Report( _( "-------- ERC cancelled by user.<br><br>" ) );
|
|
|
|
else
|
|
|
|
m_messages->Report( _( "Done.<br><br>" ) );
|
|
|
|
|
|
|
|
Raise();
|
|
|
|
wxYield(); // Allow time slice to refresh Messages
|
|
|
|
|
|
|
|
m_running = false;
|
|
|
|
m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
|
|
|
|
m_sdbSizer1OK->Enable( true );
|
|
|
|
m_buttondelmarkers->Enable( true );
|
|
|
|
m_saveReport->Enable( true );
|
|
|
|
|
|
|
|
if( !m_cancelled )
|
|
|
|
{
|
|
|
|
wxMilliSleep( 500 );
|
|
|
|
m_notebook->ChangeSelection( 1 );
|
|
|
|
KIPLATFORM::UI::ForceFocus( m_markerDataView );
|
|
|
|
}
|
2020-09-21 10:37:20 +00:00
|
|
|
|
|
|
|
m_ercRun = true;
|
|
|
|
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();
|
|
|
|
|
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
|
|
|
// Build the whole sheet list in hierarchy (sheet, not screen)
|
2020-05-13 02:00:37 +00:00
|
|
|
sch->GetSheets().AnnotatePowerSymbols();
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
if( m_parent->CheckAnnotate( NULL_REPORTER::GetInstance(), false ) )
|
2010-11-11 21:10:27 +00:00
|
|
|
{
|
2020-10-30 19:49:32 +00:00
|
|
|
Report( _( "Annotation not complete. ERC cannot be run." )
|
|
|
|
+ wxT( " <a href='annotate'>" )
|
2020-10-19 14:17:49 +00:00
|
|
|
+ _( "Show Annotation dialog." )
|
|
|
|
+ wxT( "</a>" ) );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
m_infoBar->Hide(); // No need for duplicated error messages
|
2010-11-11 21:10:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-26 01:17:40 +00:00
|
|
|
m_infoBar->Hide();
|
|
|
|
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SCREENS screens( sch->Root() );
|
2020-06-08 02:19:46 +00:00
|
|
|
ERC_SETTINGS& settings = sch->ErcSettings();
|
2020-07-03 21:08:17 +00:00
|
|
|
ERC_TESTER tester( sch );
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2019-08-07 18:23:59 +00:00
|
|
|
// Test duplicate sheet names inside a given sheet. While one can have multiple references
|
|
|
|
// to the same file, each must have a unique name.
|
2020-06-08 02:19:46 +00:00
|
|
|
if( settings.IsTestEnabled( ERCE_DUPLICATE_SHEET_NAME ) )
|
2020-03-16 11:05:01 +00:00
|
|
|
{
|
2020-10-19 14:17:49 +00:00
|
|
|
AdvancePhase( _( "Checking sheet names..." ) );
|
2020-07-03 21:08:17 +00:00
|
|
|
tester.TestDuplicateSheetNames( true );
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
if( settings.IsTestEnabled( ERCE_BUS_ALIAS_CONFLICT ) )
|
2020-03-16 11:05:01 +00:00
|
|
|
{
|
2020-10-19 14:17:49 +00:00
|
|
|
AdvancePhase( _( "Checking bus conflicts..." ) );
|
2020-07-03 21:08:17 +00:00
|
|
|
tester.TestConflictingBusAliases();
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
2019-03-11 21:32:05 +00:00
|
|
|
|
|
|
|
// The connection graph has a whole set of ERC checks it can run
|
2020-10-19 14:17:49 +00:00
|
|
|
AdvancePhase( _( "Checking conflicts..." ) );
|
2019-11-10 23:24:27 +00:00
|
|
|
m_parent->RecalculateConnections( NO_CLEANUP );
|
2020-05-13 02:00:37 +00:00
|
|
|
sch->ConnectionGraph()->RunERC();
|
2019-03-11 21:32:05 +00:00
|
|
|
|
2019-08-07 18:23:59 +00:00
|
|
|
// Test is all units of each multiunit component have the same footprint assigned.
|
2020-06-08 02:19:46 +00:00
|
|
|
if( settings.IsTestEnabled( ERCE_DIFFERENT_UNIT_FP ) )
|
2020-03-16 11:05:01 +00:00
|
|
|
{
|
2020-10-19 14:17:49 +00:00
|
|
|
AdvancePhase( _( "Checking footprints..." ) );
|
2020-07-03 21:08:17 +00:00
|
|
|
tester.TestMultiunitFootprints();
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
2018-01-19 15:12:36 +00:00
|
|
|
|
2020-10-19 14:17:49 +00:00
|
|
|
AdvancePhase( _( "Checking pins..." ) );
|
2019-03-29 01:15:36 +00:00
|
|
|
|
2020-08-30 19:25:31 +00:00
|
|
|
if( settings.IsTestEnabled( ERCE_DIFFERENT_UNIT_NET ) )
|
|
|
|
tester.TestMultUnitPinConflicts();
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2020-08-30 19:25:31 +00:00
|
|
|
// Test pins on each net against the pin connection table
|
|
|
|
if( settings.IsTestEnabled( ERCE_PIN_TO_PIN_ERROR ) )
|
|
|
|
tester.TestPinToPin();
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2015-12-20 12:40:17 +00:00
|
|
|
// Test similar labels (i;e. labels which are identical when
|
|
|
|
// using case insensitive comparisons)
|
2020-06-08 02:19:46 +00:00
|
|
|
if( settings.IsTestEnabled( ERCE_SIMILAR_LABELS ) )
|
2020-03-10 18:46:57 +00:00
|
|
|
{
|
2020-10-19 14:17:49 +00:00
|
|
|
AdvancePhase( _( "Checking labels..." ) );
|
2020-08-30 19:42:46 +00:00
|
|
|
tester.TestSimilarLabels();
|
2020-03-10 18:46:57 +00:00
|
|
|
}
|
2015-12-20 12:40:17 +00:00
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
if( settings.IsTestEnabled( ERCE_UNRESOLVED_VARIABLE ) )
|
2020-10-07 13:15:31 +00:00
|
|
|
{
|
2020-10-19 14:17:49 +00:00
|
|
|
AdvancePhase( _( "Checking for unresolved variables..." ) );
|
2020-07-03 21:08:17 +00:00
|
|
|
tester.TestTextVars( m_parent->GetCanvas()->GetView()->GetWorksheet() );
|
2020-10-07 13:15:31 +00:00
|
|
|
}
|
2020-03-29 01:12:29 +00:00
|
|
|
|
2020-07-07 00:10:08 +00:00
|
|
|
if( settings.IsTestEnabled( ERCE_NOCONNECT_CONNECTED ) )
|
2020-10-07 13:15:31 +00:00
|
|
|
{
|
2020-10-19 14:17:49 +00:00
|
|
|
AdvancePhase( _( "Checking no connect pins for connections..." ) );
|
2020-07-07 00:10:08 +00:00
|
|
|
tester.TestNoConnectPins();
|
2020-10-07 13:15:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( settings.IsTestEnabled( ERCE_LIB_SYMBOL_ISSUES ) )
|
|
|
|
{
|
2020-10-19 14:17:49 +00:00
|
|
|
AdvancePhase( _( "Checking for library symbol issues..." ) );
|
2020-10-07 13:15:31 +00:00
|
|
|
tester.TestLibSymbolIssues();
|
|
|
|
}
|
2020-07-07 00:10:08 +00:00
|
|
|
|
2020-11-18 22:55:38 +00:00
|
|
|
m_parent->ResolveERCExclusions();
|
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
// Display diags:
|
2020-03-16 11:05:01 +00:00
|
|
|
m_markerTreeModel->SetProvider( m_markerProvider );
|
|
|
|
|
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
|
|
|
|
2016-03-12 00:23:44 +00:00
|
|
|
// Display message
|
2020-10-19 14:17:49 +00:00
|
|
|
Report( _( "Done.<br><br>" ) );
|
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
|
|
|
|
2020-06-19 21:00:41 +00:00
|
|
|
if( item && item->GetClass() != wxT( "DELETED_SHEET_ITEM" ) )
|
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
|
|
|
{
|
|
|
|
m_parent->GetToolManager()->RunAction( ACTIONS::cancelInteractive, true );
|
|
|
|
m_parent->GetToolManager()->RunAction( EE_ACTIONS::clearSelection, true );
|
|
|
|
|
|
|
|
m_parent->SetCurrentSheet( sheet );
|
|
|
|
m_parent->DisplayCurrentSheet();
|
|
|
|
m_parent->RedrawScreen( (wxPoint) m_parent->GetScreen()->m_ScrollCenter, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aEvent.GetItem() );
|
|
|
|
|
|
|
|
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
|
|
|
|
2020-08-11 13:33:16 +00:00
|
|
|
std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
|
2020-03-16 11:05:01 +00:00
|
|
|
wxString listName;
|
|
|
|
wxMenu menu;
|
2020-04-24 18:56:44 +00:00
|
|
|
wxString msg;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( rcItem->GetParent()->IsExcluded() )
|
|
|
|
{
|
|
|
|
menu.Append( 1, _( "Remove exclusion for this violation" ),
|
|
|
|
wxString::Format( _( "It will be placed back in the %s list" ), listName ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menu.Append( 2, _( "Exclude this violation" ),
|
|
|
|
wxString::Format( _( "It will be excluded from the %s list" ), listName ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
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 )
|
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
|
|
|
{
|
|
|
|
menu.Append( 4, wxString::Format( _( "Change severity to Error for all '%s' violations" ),
|
2020-06-08 02:19:46 +00:00
|
|
|
rcItem->GetErrorText() ),
|
2020-04-28 08:55:44 +00:00
|
|
|
_( "Violation severities can also be edited in the Board Setup... dialog" ) );
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-28 08:55:44 +00:00
|
|
|
menu.Append( 5, wxString::Format( _( "Change severity to Warning for all '%s' violations" ),
|
2020-06-08 02:19:46 +00:00
|
|
|
rcItem->GetErrorText() ),
|
2020-04-28 08:55:44 +00:00
|
|
|
_( "Violation severities can also be edited in the Board Setup... dialog" ) );
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
menu.Append( 6, 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 )
|
|
|
|
{
|
|
|
|
menu.Append( 7, _( "Edit pin-to-pin conflict map..." ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menu.Append( 8, _( "Edit violation severities..." ),
|
|
|
|
_( "Open the Schematic Setup... dialog" ) );
|
|
|
|
}
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
bool modified = false;
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
switch( GetPopupMenuSelectionFromUser( menu ) )
|
|
|
|
{
|
|
|
|
case 1:
|
2020-12-01 22:35:11 +00:00
|
|
|
{
|
|
|
|
SCH_MARKER* marker = dynamic_cast<SCH_MARKER*>( node->m_RcItem->GetParent() );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
if( marker )
|
|
|
|
{
|
|
|
|
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
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2020-12-01 22:35:11 +00:00
|
|
|
{
|
|
|
|
SCH_MARKER* marker = dynamic_cast<SCH_MARKER*>( node->m_RcItem->GetParent() );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
if( marker )
|
|
|
|
{
|
|
|
|
marker->SetExcluded( true );
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2020-03-16 11:05:01 +00:00
|
|
|
break;
|
|
|
|
|
2020-04-28 08:55:44 +00:00
|
|
|
case 4:
|
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
|
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markerProvider );
|
2020-12-01 22:35:11 +00:00
|
|
|
modified = true;
|
2020-03-16 11:05:01 +00:00
|
|
|
break;
|
|
|
|
|
2020-04-28 08:55:44 +00:00
|
|
|
case 5:
|
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
|
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markerProvider );
|
2020-12-01 22:35:11 +00:00
|
|
|
modified = true;
|
2020-03-16 11:05:01 +00:00
|
|
|
break;
|
|
|
|
|
2020-04-28 08:55:44 +00:00
|
|
|
case 6:
|
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
|
|
|
|
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
|
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markerProvider );
|
2020-12-01 22:35:11 +00:00
|
|
|
modified = true;
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2020-04-28 08:55:44 +00:00
|
|
|
case 7:
|
2020-05-24 14:54:26 +00:00
|
|
|
m_parent->ShowSchematicSetupDialog( _( "Pin Conflicts Map" ) );
|
2020-04-28 08:55:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
2020-05-24 14:54:26 +00:00
|
|
|
m_parent->ShowSchematicSetupDialog( _( "Violation Severity" ) );
|
2020-03-16 11:05:01 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-12-01 22:35:11 +00:00
|
|
|
|
|
|
|
if( modified )
|
|
|
|
{
|
|
|
|
updateDisplayedCounts();
|
|
|
|
redrawDrawPanel();
|
|
|
|
m_parent->OnModify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::PrevMarker()
|
|
|
|
{
|
|
|
|
if( m_notebook->GetSelection() != 1 )
|
|
|
|
m_notebook->SetSelection( 1 );
|
|
|
|
|
|
|
|
m_markerTreeModel->PrevMarker();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::NextMarker()
|
|
|
|
{
|
|
|
|
if( m_notebook->GetSelection() != 1 )
|
|
|
|
m_notebook->SetSelection( 1 );
|
|
|
|
|
|
|
|
m_markerTreeModel->NextMarker();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::ExcludeMarker()
|
|
|
|
{
|
|
|
|
if( m_notebook->GetSelection() != 1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( m_markerDataView->GetCurrentItem() );
|
|
|
|
SCH_MARKER* marker = dynamic_cast<SCH_MARKER*>( node->m_RcItem->GetParent() );
|
|
|
|
|
|
|
|
if( marker && !marker->IsExcluded() )
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
// Set the provider's severity levels through the TreeModel so that the old tree
|
|
|
|
// can be torn down before the severity changes.
|
|
|
|
//
|
|
|
|
// It's not clear this is required, but we've had a lot of issues with wxDataView
|
|
|
|
// being cranky on various platforms.
|
|
|
|
|
|
|
|
m_markerTreeModel->SetSeverities( m_severities );
|
|
|
|
|
|
|
|
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
|
|
|
|
m_parent->GetToolManager()->RunAction( EE_ACTIONS::clearSelection, true );
|
|
|
|
|
2020-08-30 19:25:31 +00:00
|
|
|
m_markerTreeModel->DeleteItems( false, aIncludeExclusions, true );
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::OnSaveReport( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
wxFileName fn( "./ERC." + ReportFileExtension );
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Save Report to File" ), fn.GetPath(), fn.GetFullName(),
|
|
|
|
ReportFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
fn = dlg.GetPath();
|
|
|
|
|
|
|
|
if( fn.GetExt().IsEmpty() )
|
|
|
|
fn.SetExt( ReportFileExtension );
|
|
|
|
|
|
|
|
if( !fn.IsAbsolute() )
|
|
|
|
{
|
|
|
|
wxString prj_path = Prj().GetProjectPath();
|
|
|
|
fn.MakeAbsolute( prj_path );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( writeReport( fn.GetFullPath() ) )
|
|
|
|
{
|
2020-10-19 14:17:49 +00:00
|
|
|
m_messages->Report( wxString::Format( _( "Report file '%s' created\n" ),
|
|
|
|
fn.GetFullPath() ) );
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DisplayError( this, wxString::Format( _( "Unable to create report file '%s'" ),
|
|
|
|
fn.GetFullPath() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_ERC::writeReport( const wxString& aFullFileName )
|
|
|
|
{
|
|
|
|
wxFFile file( aFullFileName, wxT( "wt" ) );
|
|
|
|
|
|
|
|
if( !file.IsOpened() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
wxString msg = wxString::Format( _( "ERC report (%s, Encoding UTF8)\n" ), DateAndTime() );
|
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
std::map<KIID, EDA_ITEM*> itemMap;
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
int err_count = 0;
|
|
|
|
int warn_count = 0;
|
|
|
|
int total_count = 0;
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SHEET_LIST sheetList = m_parent->Schematic().GetSheets();
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
sheetList.FillItemMap( itemMap );
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
ERC_SETTINGS& settings = m_parent->Schematic().ErcSettings();
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
for( unsigned i = 0; i < sheetList.size(); i++ )
|
|
|
|
{
|
|
|
|
msg << wxString::Format( _( "\n***** Sheet %s\n" ), sheetList[i].PathHumanReadable() );
|
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
for( SCH_ITEM* aItem : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) )
|
2020-03-16 11:05:01 +00:00
|
|
|
{
|
2020-04-24 13:36:10 +00:00
|
|
|
const SCH_MARKER* marker = static_cast<const SCH_MARKER*>( aItem );
|
2020-09-21 10:36:07 +00:00
|
|
|
RC_ITEM* item = marker->GetRCItem().get();
|
2020-12-14 13:33:51 +00:00
|
|
|
SEVERITY severity = settings.GetSeverity( item->GetErrorCode() );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
|
|
|
if( marker->GetMarkerType() != MARKER_BASE::MARKER_ERC )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
total_count++;
|
|
|
|
|
2020-09-21 10:36:07 +00:00
|
|
|
switch( severity )
|
2020-03-16 11:05:01 +00:00
|
|
|
{
|
|
|
|
case RPT_SEVERITY_ERROR: err_count++; break;
|
|
|
|
case RPT_SEVERITY_WARNING: warn_count++; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
2020-09-21 10:36:07 +00:00
|
|
|
msg << marker->GetRCItem()->ShowReport( GetUserUnits(), severity, itemMap );
|
2020-03-16 11:05:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msg << wxString::Format( _( "\n ** ERC messages: %d Errors %d Warnings %d\n" ),
|
|
|
|
total_count, err_count, warn_count );
|
|
|
|
|
|
|
|
// Currently: write report using UTF8 (as usual in Kicad).
|
|
|
|
// TODO: see if we can use the current encoding page (mainly for Windows users),
|
|
|
|
// Or other format (HTML?)
|
|
|
|
file.Write( msg );
|
|
|
|
|
|
|
|
// wxFFile dtor will close the file.
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|