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>
|
2019-08-07 19:01:50 +00:00
|
|
|
* Copyright (C) 1992-2019 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 <fctsys.h>
|
|
|
|
#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>
|
2013-06-10 12:24:01 +00:00
|
|
|
#include <invoke_sch_dialog.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>
|
2018-01-30 08:56:43 +00:00
|
|
|
#include <netlist_object.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_marker.h>
|
2018-03-15 01:03:26 +00:00
|
|
|
#include <sch_component.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>
|
|
|
|
#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>
|
|
|
|
#include <wx/ffile.h>
|
|
|
|
#include <erc_item.h>
|
|
|
|
#include <eeschema_settings.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-03-16 11:05:01 +00:00
|
|
|
DIALOG_ERC_BASE( parent, ID_DIALOG_ERC ), // parent looks for this ID explicitly
|
|
|
|
m_parent( parent ),
|
|
|
|
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-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
|
|
|
|
|
|
|
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
|
|
|
infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
|
|
|
|
m_textMarkers->SetFont( infoFont );
|
|
|
|
m_titleMessages->SetFont( infoFont );
|
|
|
|
|
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.
|
|
|
|
m_sdbSizer1OK->SetLabel( _( "Run" ) );
|
|
|
|
m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
|
|
|
|
m_sdbSizer1->Layout();
|
|
|
|
|
|
|
|
m_sdbSizer1OK->SetDefault();
|
|
|
|
|
2016-07-16 10:54:55 +00:00
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
|
|
|
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-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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_errorsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_ERROR, numErrors, m_errorsBadge ) );
|
|
|
|
m_warningsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_WARNING, numWarnings, m_warningsBadge ) );
|
|
|
|
m_exclusionsBadge->SetBitmap( MakeBadge( RPT_SEVERITY_EXCLUSION, numExcluded, m_exclusionsBadge ) );
|
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-03-16 11:05:01 +00:00
|
|
|
deleteAllMarkers();
|
2014-10-08 22:40:47 +00:00
|
|
|
|
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.
|
|
|
|
void DIALOG_ERC::OnButtonCloseClick( wxCommandEvent& event )
|
|
|
|
{
|
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 );
|
|
|
|
|
2018-08-06 20:30:49 +00:00
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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-03-16 11:05:01 +00:00
|
|
|
deleteAllMarkers();
|
2015-09-10 12:03:16 +00:00
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
m_MessagesList->Clear();
|
2009-07-08 18:06:11 +00:00
|
|
|
wxSafeYield(); // m_MarkersList must be redraw
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2018-02-17 11:43:56 +00:00
|
|
|
WX_TEXT_CTRL_REPORTER reporter( m_MessagesList );
|
|
|
|
TestErc( reporter );
|
2009-07-08 15:42:45 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 23:54:51 +00:00
|
|
|
|
2018-11-14 23:34:32 +00:00
|
|
|
void DIALOG_ERC::RedrawDrawPanel()
|
|
|
|
{
|
|
|
|
WINDOW_THAWER thawer( m_parent );
|
|
|
|
|
|
|
|
m_parent->GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-17 11:43:56 +00:00
|
|
|
void DIALOG_ERC::TestErc( REPORTER& aReporter )
|
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
|
|
|
|
2018-02-17 11:43:56 +00:00
|
|
|
if( m_parent->CheckAnnotate( aReporter, false ) )
|
2010-11-11 21:10:27 +00:00
|
|
|
{
|
2018-02-17 11:43:56 +00:00
|
|
|
if( aReporter.HasMessage() )
|
2020-03-04 09:48:18 +00:00
|
|
|
aReporter.ReportTail( _( "Annotation required!" ), RPT_SEVERITY_ERROR );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
aReporter.ReportTail( _( "Checking sheet names...\n" ), RPT_SEVERITY_INFO );
|
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
|
|
|
{
|
|
|
|
aReporter.ReportTail( _( "Checking bus conflicts...\n" ), RPT_SEVERITY_INFO );
|
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-03-16 11:05:01 +00:00
|
|
|
aReporter.ReportTail( _( "Checking conflicts...\n" ) );
|
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
|
|
|
{
|
|
|
|
aReporter.ReportTail( _( "Checking footprints...\n" ), RPT_SEVERITY_INFO );
|
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
|
|
|
|
2016-06-07 15:33:12 +00:00
|
|
|
std::unique_ptr<NETLIST_OBJECT_LIST> objectsConnectedList( m_parent->BuildNetListBase() );
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
// Reset the connection type indicator
|
|
|
|
objectsConnectedList->ResetConnectionsType();
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
unsigned lastItemIdx = 0;
|
2019-03-29 01:15:36 +00:00
|
|
|
unsigned nextItemIdx = 0;
|
2020-03-16 11:05:01 +00:00
|
|
|
int MinConn = NOC;
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2019-08-07 18:23:59 +00:00
|
|
|
// Check that a pin appears in only one net. This check is necessary because multi-unit
|
|
|
|
// components that have shared pins could be wired to different nets.
|
2018-03-15 01:03:26 +00:00
|
|
|
std::unordered_map<wxString, wxString> pin_to_net_map;
|
|
|
|
|
2019-08-07 18:23:59 +00:00
|
|
|
// The netlist generated by SCH_EDIT_FRAME::BuildNetListBase is sorted by net number, which
|
|
|
|
// means we can group netlist items into ranges that live in the same net. The range from
|
|
|
|
// nextItem to the current item (exclusive) needs to be checked against the current item.
|
|
|
|
// The lastItem variable is used as a helper to pass the last item's number from one loop
|
|
|
|
// iteration to the next, which simplifies the initial pass.
|
2020-03-16 11:05:01 +00:00
|
|
|
aReporter.ReportTail( _( "Checking connections...\n" ), RPT_SEVERITY_INFO );
|
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
|
|
|
for( unsigned itemIdx = 0; itemIdx < objectsConnectedList->size(); itemIdx++ )
|
2010-11-11 21:10:27 +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
|
|
|
auto item = objectsConnectedList->GetItem( itemIdx );
|
|
|
|
auto lastItem = objectsConnectedList->GetItem( lastItemIdx );
|
|
|
|
|
|
|
|
auto lastNet = lastItem->GetNet();
|
|
|
|
auto net = item->GetNet();
|
|
|
|
|
|
|
|
wxASSERT_MSG( lastNet <= net, wxT( "Netlist not correctly ordered" ) );
|
|
|
|
|
2019-03-29 01:15:36 +00:00
|
|
|
if( lastNet != net )
|
|
|
|
{
|
|
|
|
// New net found:
|
|
|
|
MinConn = NOC;
|
|
|
|
nextItemIdx = itemIdx;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
switch( item->m_Type )
|
2010-11-11 21:10:27 +00:00
|
|
|
{
|
2011-10-07 14:41:30 +00:00
|
|
|
// These items do not create erc problems
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::ITEM_UNSPECIFIED:
|
|
|
|
case NETLIST_ITEM::SEGMENT:
|
|
|
|
case NETLIST_ITEM::BUS:
|
|
|
|
case NETLIST_ITEM::JUNCTION:
|
|
|
|
case NETLIST_ITEM::LABEL:
|
|
|
|
case NETLIST_ITEM::BUSLABELMEMBER:
|
|
|
|
case NETLIST_ITEM::PINLABEL:
|
|
|
|
case NETLIST_ITEM::GLOBBUSLABELMEMBER:
|
2010-11-11 21:10:27 +00:00
|
|
|
break;
|
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
// TODO(JE) Port this to the new system
|
2020-01-18 20:51:28 +00:00
|
|
|
case NETLIST_ITEM::PIN:
|
2018-03-15 01:03:26 +00:00
|
|
|
{
|
|
|
|
// Check if this pin has appeared before on a different net
|
2020-06-08 02:19:46 +00:00
|
|
|
if( item->m_Link && settings.IsTestEnabled( ERCE_DIFFERENT_UNIT_NET ) )
|
2018-03-15 01:03:26 +00:00
|
|
|
{
|
2020-03-16 11:05:01 +00:00
|
|
|
wxString ref = item->GetComponentParent()->GetRef( &item->m_SheetPath );
|
2018-03-15 01:03:26 +00:00
|
|
|
wxString pin_name = ref + "_" + item->m_PinNum;
|
2020-03-16 11:05:01 +00:00
|
|
|
wxString msg;
|
2018-03-15 01:03:26 +00:00
|
|
|
|
|
|
|
if( pin_to_net_map.count( pin_name ) == 0 )
|
|
|
|
{
|
|
|
|
pin_to_net_map[pin_name] = item->GetNetName();
|
|
|
|
}
|
|
|
|
else if( pin_to_net_map[pin_name] != item->GetNetName() )
|
|
|
|
{
|
2020-04-24 13:36:10 +00:00
|
|
|
msg.Printf( _( "Pin %s is connected to both %s and %s" ),
|
2020-03-16 11:05:01 +00:00
|
|
|
item->m_PinNum,
|
|
|
|
pin_to_net_map[pin_name],
|
|
|
|
item->GetNetName() );
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
ERC_ITEM* ercItem = ERC_ITEM::Create( ERCE_DIFFERENT_UNIT_NET );
|
2020-04-24 13:36:10 +00:00
|
|
|
ercItem->SetErrorMessage( msg );
|
|
|
|
ercItem->SetItems( item->m_Comp );
|
|
|
|
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER( ercItem, item->m_Start );
|
2018-03-15 01:03:26 +00:00
|
|
|
item->m_SheetPath.LastScreen()->Append( marker );
|
|
|
|
}
|
|
|
|
}
|
2010-11-11 21:10:27 +00:00
|
|
|
|
|
|
|
// Look for ERC problems between pins:
|
2020-07-03 21:08:17 +00:00
|
|
|
tester.TestOthersItems( objectsConnectedList.get(), itemIdx, nextItemIdx, &MinConn );
|
2010-11-11 21:10:27 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-03-11 21:32:05 +00:00
|
|
|
default:
|
|
|
|
break;
|
2018-03-15 01:03:26 +00:00
|
|
|
}
|
2010-11-11 21:10:27 +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
|
|
|
lastItemIdx = itemIdx;
|
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-03-16 11:05:01 +00:00
|
|
|
aReporter.ReportTail( _( "Checking labels...\n" ), RPT_SEVERITY_INFO );
|
2015-12-20 12:40:17 +00:00
|
|
|
objectsConnectedList->TestforSimilarLabels();
|
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-07-03 21:08:17 +00:00
|
|
|
tester.TestTextVars( m_parent->GetCanvas()->GetView()->GetWorksheet() );
|
2020-03-29 01:12:29 +00:00
|
|
|
|
2020-07-07 00:10:08 +00:00
|
|
|
if( settings.IsTestEnabled( ERCE_NOCONNECT_CONNECTED ) )
|
|
|
|
tester.TestNoConnectPins();
|
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
// Display diags:
|
2020-03-16 11:05:01 +00:00
|
|
|
m_markerTreeModel->SetProvider( m_markerProvider );
|
|
|
|
|
|
|
|
// Displays global results:
|
|
|
|
updateDisplayedCounts();
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2018-09-04 20:53:04 +00:00
|
|
|
// Display new markers from the current screen:
|
|
|
|
KIGFX::VIEW* view = m_parent->GetCanvas()->GetView();
|
|
|
|
|
2019-06-25 23:39:58 +00:00
|
|
|
for( auto item : m_parent->GetScreen()->Items().OfType( SCH_MARKER_T ) )
|
|
|
|
view->Add( item );
|
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-03-04 09:48:18 +00:00
|
|
|
aReporter.ReportTail( _( "Finished" ), RPT_SEVERITY_INFO );
|
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 );
|
|
|
|
RedrawDrawPanel();
|
|
|
|
}
|
|
|
|
|
|
|
|
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-03-16 11:05:01 +00:00
|
|
|
RC_ITEM* rcItem = node->m_RcItem;
|
|
|
|
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
|
|
|
|
|
|
|
switch( GetPopupMenuSelectionFromUser( menu ) )
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
node->m_RcItem->GetParent()->SetExcluded( false );
|
|
|
|
|
|
|
|
// Update view
|
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
|
|
|
|
updateDisplayedCounts();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
node->m_RcItem->GetParent()->SetExcluded( true );
|
|
|
|
|
|
|
|
// 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 );
|
|
|
|
|
|
|
|
updateDisplayedCounts();
|
|
|
|
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
|
|
|
|
|
|
|
// Rebuild model and view
|
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markerProvider );
|
|
|
|
updateDisplayedCounts();
|
|
|
|
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
|
|
|
|
|
|
|
// Rebuild model and view
|
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markerProvider );
|
|
|
|
updateDisplayedCounts();
|
|
|
|
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 );
|
|
|
|
updateDisplayedCounts();
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::deleteAllMarkers()
|
|
|
|
{
|
|
|
|
// Clear current selection list to avoid selection of deleted items
|
|
|
|
m_parent->GetToolManager()->RunAction( EE_ACTIONS::clearSelection, true );
|
|
|
|
|
|
|
|
m_markerTreeModel->DeleteAllItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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() ) )
|
|
|
|
{
|
|
|
|
m_MessagesList->AppendText( wxString::Format( _( "Report file '%s' created\n" ),
|
|
|
|
fn.GetFullPath() ) );
|
|
|
|
}
|
|
|
|
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-03-16 11:05:01 +00:00
|
|
|
|
|
|
|
if( marker->GetMarkerType() != MARKER_BASE::MARKER_ERC )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
total_count++;
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
switch( settings.GetSeverity( marker->GetRCItem()->GetErrorCode() ) )
|
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-04-24 13:36:10 +00:00
|
|
|
msg << marker->GetRCItem()->ShowReport( GetUserUnits(), 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-07 20:56:55 +00:00
|
|
|
wxDialog* InvokeDialogERC( SCH_EDIT_FRAME* aCaller )
|
|
|
|
{
|
|
|
|
// This is a modeless dialog, so new it rather than instantiating on stack.
|
|
|
|
DIALOG_ERC* dlg = new DIALOG_ERC( aCaller );
|
|
|
|
|
|
|
|
dlg->Show( true );
|
|
|
|
|
|
|
|
return dlg; // wxDialog is information hiding about DIALOG_ERC.
|
|
|
|
}
|