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>
|
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>
|
|
|
|
#include <sch_sheet.h>
|
|
|
|
#include <lib_pin.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>
|
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-01-18 20:51:28 +00:00
|
|
|
extern int DiagErc[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL];
|
|
|
|
extern int DefaultDiagErc[ELECTRICAL_PINTYPES_TOTAL][ELECTRICAL_PINTYPES_TOTAL];
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2015-12-20 12:40:17 +00:00
|
|
|
bool DIALOG_ERC::m_diagErcTableInit = false; // saved only for the current session
|
|
|
|
|
|
|
|
// Control identifiers for events
|
|
|
|
#define ID_MATRIX_0 1800
|
|
|
|
|
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
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE )
|
2020-01-18 20:51:28 +00:00
|
|
|
EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( ELECTRICAL_PINTYPES_TOTAL * ELECTRICAL_PINTYPES_TOTAL ) - 1,
|
2011-10-07 14:41:30 +00:00
|
|
|
wxEVT_COMMAND_BUTTON_CLICKED, DIALOG_ERC::ChangeErrorLevel )
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
|
2019-06-13 13:34:38 +00:00
|
|
|
DIALOG_ERC_BASE( parent, ID_DIALOG_ERC ), // parent looks for this ID explicitly
|
|
|
|
m_buttonList(),
|
|
|
|
m_initialized( false ),
|
|
|
|
m_settings()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-11-30 12:28:23 +00:00
|
|
|
m_parent = parent;
|
2019-06-13 13:34:38 +00:00
|
|
|
m_lastMarkerFound = nullptr;
|
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 );
|
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
Init();
|
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
|
|
|
|
2012-12-10 19:08:09 +00:00
|
|
|
DIALOG_ERC::~DIALOG_ERC()
|
|
|
|
{
|
2019-03-11 21:32:05 +00:00
|
|
|
transferControlsToSettings();
|
|
|
|
|
|
|
|
if( m_settings != m_parent->GetErcSettings() )
|
|
|
|
{
|
|
|
|
m_parent->UpdateErcSettings( m_settings );
|
|
|
|
m_parent->SaveProjectSettings( false );
|
|
|
|
}
|
2012-12-10 19:08:09 +00:00
|
|
|
}
|
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
void DIALOG_ERC::Init()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-11-30 12:28:23 +00:00
|
|
|
m_initialized = false;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2019-08-07 19:01:50 +00:00
|
|
|
for( auto& buttonRow : m_buttonList )
|
2015-09-10 12:03:16 +00:00
|
|
|
{
|
2019-08-07 19:01:50 +00:00
|
|
|
for( auto& button : buttonRow )
|
|
|
|
button = NULL;
|
2015-09-10 12:03:16 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
m_settings = m_parent->GetErcSettings();
|
|
|
|
transferSettingsToControls();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
SCH_SCREENS screens;
|
2014-10-08 22:40:47 +00:00
|
|
|
updateMarkerCounts( &screens );
|
|
|
|
|
|
|
|
DisplayERC_MarkersList();
|
|
|
|
|
|
|
|
// Init Panel Matrix
|
|
|
|
ReBuildMatrixPanel();
|
|
|
|
}
|
|
|
|
|
2014-10-08 23:54:51 +00:00
|
|
|
|
2019-08-07 19:01:50 +00:00
|
|
|
void DIALOG_ERC::OnUpdateUI( wxUpdateUIEvent& event )
|
|
|
|
{
|
|
|
|
m_buttondelmarkers->Show( m_NoteBook->GetSelection() == 0 );
|
|
|
|
m_ResetOptButton->Show( m_NoteBook->GetSelection() == 1 );
|
|
|
|
m_buttonsSizer->Layout();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
void DIALOG_ERC::transferSettingsToControls()
|
|
|
|
{
|
|
|
|
m_WriteResultOpt->SetValue( m_settings.write_erc_file );
|
|
|
|
m_cbTestSimilarLabels->SetValue( m_settings.check_similar_labels );
|
|
|
|
m_cbTestUniqueGlbLabels->SetValue( m_settings.check_unique_global_labels );
|
|
|
|
m_cbCheckBusDriverConflicts->SetValue( m_settings.check_bus_driver_conflicts );
|
|
|
|
m_cbCheckBusEntries->SetValue( m_settings.check_bus_entry_conflicts );
|
|
|
|
m_cbCheckBusToBusConflicts->SetValue( m_settings.check_bus_to_bus_conflicts );
|
|
|
|
m_cbCheckBusToNetConflicts->SetValue( m_settings.check_bus_to_net_conflicts );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::transferControlsToSettings()
|
|
|
|
{
|
|
|
|
m_settings.write_erc_file = m_WriteResultOpt->GetValue();
|
|
|
|
m_settings.check_similar_labels = m_cbTestSimilarLabels->GetValue();
|
|
|
|
m_settings.check_unique_global_labels = m_cbTestUniqueGlbLabels->GetValue();
|
|
|
|
m_settings.check_bus_driver_conflicts = m_cbCheckBusDriverConflicts->GetValue();
|
|
|
|
m_settings.check_bus_entry_conflicts = m_cbCheckBusEntries->GetValue();
|
|
|
|
m_settings.check_bus_to_bus_conflicts = m_cbCheckBusToBusConflicts->GetValue();
|
|
|
|
m_settings.check_bus_to_net_conflicts = m_cbCheckBusToNetConflicts->GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-08 22:40:47 +00:00
|
|
|
void DIALOG_ERC::updateMarkerCounts( SCH_SCREENS *screens )
|
|
|
|
{
|
2015-07-29 18:06:45 +00:00
|
|
|
int markers = screens->GetMarkerCount( MARKER_BASE::MARKER_ERC,
|
|
|
|
MARKER_BASE::MARKER_SEVERITY_UNSPEC );
|
|
|
|
int warnings = screens->GetMarkerCount( MARKER_BASE::MARKER_ERC,
|
|
|
|
MARKER_BASE::MARKER_SEVERITY_WARNING );
|
|
|
|
int errors = screens->GetMarkerCount( MARKER_BASE::MARKER_ERC,
|
|
|
|
MARKER_BASE::MARKER_SEVERITY_ERROR );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
wxString num;
|
2011-10-07 14:41:30 +00:00
|
|
|
num.Printf( wxT( "%d" ), markers );
|
2014-10-08 04:02:48 +00:00
|
|
|
m_TotalErrCount->SetValue( num );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2015-07-29 12:18:53 +00:00
|
|
|
num.Printf( wxT( "%d" ), errors );
|
2014-10-08 04:02:48 +00:00
|
|
|
m_LastErrCount->SetValue( num );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
num.Printf( wxT( "%d" ), warnings );
|
2014-10-08 04:02:48 +00:00
|
|
|
m_LastWarningCount->SetValue( num );
|
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 )
|
|
|
|
{
|
2011-03-10 19:36:30 +00:00
|
|
|
SCH_SCREENS ScreenList;
|
2011-09-11 11:38:01 +00:00
|
|
|
|
2015-07-29 12:18:53 +00:00
|
|
|
ScreenList.DeleteAllMarkers( MARKER_BASE::MARKER_ERC );
|
2014-10-08 22:40:47 +00:00
|
|
|
updateMarkerCounts( &ScreenList );
|
|
|
|
|
2009-07-08 18:06:11 +00:00
|
|
|
m_MarkersList->ClearList();
|
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 )
|
|
|
|
{
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::OnCloseErcDialog( wxCloseEvent& event )
|
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
2015-09-10 12:03:16 +00:00
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
void DIALOG_ERC::OnResetMatrixClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-07-08 15:42:45 +00:00
|
|
|
ResetDefaultERCDiag( event );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
|
|
|
|
void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2019-06-13 13:34:38 +00:00
|
|
|
wxBusyCursor busy;
|
2015-09-10 12:03:16 +00:00
|
|
|
m_MarkersList->ClearList();
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-10 12:03:16 +00:00
|
|
|
void DIALOG_ERC::OnLeftClickMarkersList( wxHtmlLinkEvent& event )
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
2015-09-10 12:03:16 +00:00
|
|
|
wxString link = event.GetLinkInfo().GetHref();
|
|
|
|
|
2019-06-13 13:34:38 +00:00
|
|
|
m_lastMarkerFound = nullptr;
|
2012-11-30 12:28:23 +00:00
|
|
|
|
2015-09-10 12:03:16 +00:00
|
|
|
long index;
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2015-09-10 12:03:16 +00:00
|
|
|
if( !link.ToLong( &index ) )
|
2009-07-08 15:42:45 +00:00
|
|
|
return;
|
|
|
|
|
2015-09-10 12:03:16 +00:00
|
|
|
const SCH_MARKER* marker = m_MarkersList->GetItem( index );
|
|
|
|
|
2019-06-13 13:34:38 +00:00
|
|
|
if( !marker )
|
2015-09-10 12:03:16 +00:00
|
|
|
return;
|
2009-07-08 15:42:45 +00:00
|
|
|
|
|
|
|
// Search for the selected marker
|
2016-03-06 21:22:01 +00:00
|
|
|
unsigned i;
|
|
|
|
SCH_SHEET_LIST sheetList( g_RootSheet );
|
2019-06-13 13:34:38 +00:00
|
|
|
bool found = false;
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2019-06-25 23:39:58 +00:00
|
|
|
for( i = 0; i < sheetList.size(); i++ )
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
2019-06-25 23:39:58 +00:00
|
|
|
for( auto aItem : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) )
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
2019-06-25 23:39:58 +00:00
|
|
|
if( static_cast<const SCH_MARKER*>( aItem ) == marker )
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
2019-06-13 13:34:38 +00:00
|
|
|
found = true;
|
2009-07-08 15:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-13 13:34:38 +00:00
|
|
|
if( found )
|
2009-07-08 15:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-06-13 13:34:38 +00:00
|
|
|
if( !found ) // Error
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
2012-11-30 12:28:23 +00:00
|
|
|
wxMessageBox( _( "Marker not found" ) );
|
2012-12-10 19:08:09 +00:00
|
|
|
|
|
|
|
// The marker was deleted, so rebuild marker list
|
|
|
|
DisplayERC_MarkersList();
|
2009-07-08 15:42:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
if( sheetList[i] != m_parent->GetCurrentSheet() )
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
2019-06-13 21:04:31 +00:00
|
|
|
m_parent->GetToolManager()->RunAction( ACTIONS::cancelInteractive, true );
|
|
|
|
m_parent->GetToolManager()->RunAction( EE_ACTIONS::clearSelection, true );
|
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
m_parent->SetCurrentSheet( sheetList[i] );
|
2019-04-13 16:24:59 +00:00
|
|
|
m_parent->DisplayCurrentSheet();
|
|
|
|
sheetList[i].LastScreen()->SetZoom( m_parent->GetScreen()->GetZoom() );
|
2019-06-13 13:34:38 +00:00
|
|
|
m_parent->RedrawScreen( (wxPoint) m_parent->GetScreen()->m_ScrollCenter, false );
|
2009-07-08 15:42:45 +00:00
|
|
|
}
|
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
m_lastMarkerFound = marker;
|
2019-06-13 17:28:55 +00:00
|
|
|
m_parent->FocusOnLocation( marker->m_Pos, true );
|
2018-11-14 23:34:32 +00:00
|
|
|
RedrawDrawPanel();
|
2012-11-30 12:28:23 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2015-09-10 12:03:16 +00:00
|
|
|
void DIALOG_ERC::OnLeftDblClickMarkersList( wxMouseEvent& event )
|
2012-11-30 12:28:23 +00:00
|
|
|
{
|
2019-06-13 13:34:38 +00:00
|
|
|
// Remember: OnLeftClickMarkersList was called just before and therefore m_lastMarkerFound
|
|
|
|
// was initialized (NULL if not found).
|
2012-11-30 12:28:23 +00:00
|
|
|
if( m_lastMarkerFound )
|
|
|
|
{
|
2019-06-13 17:28:55 +00:00
|
|
|
m_parent->FocusOnLocation( m_lastMarkerFound->m_Pos, true );
|
2018-11-14 23:34:32 +00:00
|
|
|
RedrawDrawPanel();
|
2012-11-30 12:28:23 +00:00
|
|
|
}
|
2012-12-10 19:08:09 +00:00
|
|
|
|
|
|
|
Close();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
void DIALOG_ERC::ReBuildMatrixPanel()
|
|
|
|
{
|
2011-09-11 13:48:04 +00:00
|
|
|
// Try to know the size of bitmap button used in drc matrix
|
2014-10-08 23:54:51 +00:00
|
|
|
wxBitmapButton * dummy = new wxBitmapButton( m_matrixPanel, wxID_ANY, KiBitmap( ercerr_xpm ) );
|
2011-09-11 13:48:04 +00:00
|
|
|
wxSize bitmap_size = dummy->GetSize();
|
|
|
|
delete dummy;
|
2011-09-11 11:38:01 +00:00
|
|
|
|
2015-12-20 12:40:17 +00:00
|
|
|
if( !m_diagErcTableInit )
|
2009-07-03 18:25:06 +00:00
|
|
|
{
|
|
|
|
memcpy( DiagErc, DefaultDiagErc, sizeof(DefaultDiagErc) );
|
2015-12-20 12:40:17 +00:00
|
|
|
m_diagErcTableInit = true;
|
2009-07-03 18:25:06 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
wxPoint pos;
|
|
|
|
// Get the current text size:use a dummy text.
|
|
|
|
wxStaticText* text = new wxStaticText( m_matrixPanel, -1, wxT( "W" ), pos );
|
|
|
|
int text_height = text->GetRect().GetHeight();
|
2012-09-22 11:19:37 +00:00
|
|
|
bitmap_size.y = std::max( bitmap_size.y, text_height );
|
2013-04-28 14:28:13 +00:00
|
|
|
delete text;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
// compute the Y pos interval:
|
2012-11-30 12:28:23 +00:00
|
|
|
pos.y = text_height;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2019-06-13 13:34:38 +00:00
|
|
|
if( !m_initialized )
|
2009-07-03 18:25:06 +00:00
|
|
|
{
|
2018-04-06 13:46:16 +00:00
|
|
|
std::vector<wxStaticText*> labels;
|
|
|
|
|
2011-09-11 11:38:01 +00:00
|
|
|
// Print row labels
|
2020-01-18 20:51:28 +00:00
|
|
|
for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
|
2009-07-03 18:25:06 +00:00
|
|
|
{
|
2011-09-11 11:38:01 +00:00
|
|
|
int y = pos.y + (ii * bitmap_size.y);
|
2012-11-30 12:28:23 +00:00
|
|
|
text = new wxStaticText( m_matrixPanel, -1, CommentERC_H[ii],
|
2011-10-07 14:41:30 +00:00
|
|
|
wxPoint( 5, y + ( bitmap_size.y / 2) - (text_height / 2) ) );
|
2018-04-06 13:46:16 +00:00
|
|
|
labels.push_back( text );
|
2009-07-03 18:25:06 +00:00
|
|
|
|
2011-09-11 11:38:01 +00:00
|
|
|
int x = text->GetRect().GetRight();
|
2012-09-22 11:19:37 +00:00
|
|
|
pos.x = std::max( pos.x, x );
|
2009-07-03 18:25:06 +00:00
|
|
|
}
|
|
|
|
|
2018-04-06 13:46:16 +00:00
|
|
|
// Right-align
|
2020-01-18 20:51:28 +00:00
|
|
|
for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
|
2018-04-06 13:46:16 +00:00
|
|
|
{
|
|
|
|
wxPoint labelPos = labels[ ii ]->GetPosition();
|
|
|
|
labelPos.x = pos.x - labels[ ii ]->GetRect().GetWidth();
|
|
|
|
labels[ ii ]->SetPosition( labelPos );
|
|
|
|
}
|
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
pos.x += 5;
|
|
|
|
}
|
|
|
|
else
|
2012-11-30 12:28:23 +00:00
|
|
|
pos = m_buttonList[0][0]->GetPosition();
|
2009-07-03 18:25:06 +00:00
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
|
2009-07-03 18:25:06 +00:00
|
|
|
{
|
2011-09-11 11:38:01 +00:00
|
|
|
int y = pos.y + (ii * bitmap_size.y);
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
for( int jj = 0; jj <= ii; jj++ )
|
2009-07-03 18:25:06 +00:00
|
|
|
{
|
2011-09-11 11:38:01 +00:00
|
|
|
// Add column labels (only once)
|
2009-07-03 18:25:06 +00:00
|
|
|
int diag = DiagErc[ii][jj];
|
2011-09-11 11:38:01 +00:00
|
|
|
int x = pos.x + (jj * bitmap_size.x);
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
if( (ii == jj) && !m_initialized )
|
2009-07-03 18:25:06 +00:00
|
|
|
{
|
|
|
|
wxPoint txtpos;
|
2011-09-11 11:38:01 +00:00
|
|
|
txtpos.x = x + (bitmap_size.x / 2);
|
|
|
|
txtpos.y = y - text_height;
|
2014-01-18 09:07:05 +00:00
|
|
|
text = new wxStaticText( m_matrixPanel, -1, CommentERC_V[ii], txtpos );
|
2009-07-03 18:25:06 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2020-01-18 20:51:28 +00:00
|
|
|
int event_id = ID_MATRIX_0 + ii + ( jj * ELECTRICAL_PINTYPES_TOTAL );
|
2014-10-08 04:02:48 +00:00
|
|
|
BITMAP_DEF bitmap_butt = erc_green_xpm;
|
2009-07-03 18:25:06 +00:00
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
delete m_buttonList[ii][jj];
|
|
|
|
m_buttonList[ii][jj] = new wxBitmapButton( m_matrixPanel,
|
|
|
|
event_id,
|
|
|
|
KiBitmap( bitmap_butt ),
|
|
|
|
wxPoint( x, y ) );
|
2014-10-08 04:02:48 +00:00
|
|
|
setDRCMatrixButtonState( m_buttonList[ii][jj], diag );
|
2012-11-30 12:28:23 +00:00
|
|
|
}
|
2009-07-03 18:25:06 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
m_initialized = true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2009-07-03 18:25:06 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2014-10-08 04:02:48 +00:00
|
|
|
void DIALOG_ERC::setDRCMatrixButtonState( wxBitmapButton *aButton, int aState )
|
|
|
|
{
|
2019-06-13 13:34:38 +00:00
|
|
|
BITMAP_DEF bitmap_butt = nullptr;
|
2014-10-08 04:02:48 +00:00
|
|
|
wxString tooltip;
|
|
|
|
|
|
|
|
switch( aState )
|
|
|
|
{
|
|
|
|
case OK:
|
|
|
|
bitmap_butt = erc_green_xpm;
|
2014-10-08 23:54:51 +00:00
|
|
|
tooltip = _( "No error or warning" );
|
2014-10-08 04:02:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WAR:
|
|
|
|
bitmap_butt = ercwarn_xpm;
|
2014-10-08 23:54:51 +00:00
|
|
|
tooltip = _( "Generate warning" );
|
2014-10-08 04:02:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ERR:
|
|
|
|
bitmap_butt = ercerr_xpm;
|
2014-10-08 23:54:51 +00:00
|
|
|
tooltip = _( "Generate error" );
|
2014-10-08 04:02:48 +00:00
|
|
|
break;
|
2019-06-13 13:34:38 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2014-10-08 04:02:48 +00:00
|
|
|
}
|
2014-10-08 23:54:51 +00:00
|
|
|
|
2014-10-08 04:02:48 +00:00
|
|
|
if( bitmap_butt )
|
|
|
|
{
|
2014-10-08 23:54:51 +00:00
|
|
|
aButton->SetBitmap( KiBitmap( bitmap_butt ) );
|
|
|
|
aButton->SetToolTip( tooltip );
|
2014-10-08 04:02:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
void DIALOG_ERC::DisplayERC_MarkersList()
|
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
SCH_SHEET_LIST sheetList( g_RootSheet);
|
2009-07-08 18:06:11 +00:00
|
|
|
m_MarkersList->ClearList();
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
for( unsigned i = 0; i < sheetList.size(); i++ )
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2019-06-25 23:39:58 +00:00
|
|
|
for( auto aItem : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) )
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2019-06-25 23:39:58 +00:00
|
|
|
SCH_MARKER* marker = static_cast<SCH_MARKER*>( aItem );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2019-06-25 23:39:58 +00:00
|
|
|
if( marker->GetMarkerType() == MARKER_BASE::MARKER_ERC )
|
|
|
|
m_MarkersList->AppendToList( marker );
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-11 11:38:01 +00:00
|
|
|
|
2018-06-15 04:49:50 +00:00
|
|
|
m_MarkersList->DisplayList( GetUserUnits() );
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event )
|
|
|
|
{
|
2014-10-08 23:54:51 +00:00
|
|
|
memcpy( DiagErc, DefaultDiagErc, sizeof( DiagErc ) );
|
2009-07-07 17:50:02 +00:00
|
|
|
ReBuildMatrixPanel();
|
2019-03-11 21:32:05 +00:00
|
|
|
m_settings.LoadDefaults();
|
|
|
|
transferSettingsToControls();
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event )
|
|
|
|
{
|
2019-06-13 13:34:38 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
int ii = id - ID_MATRIX_0;
|
2020-01-18 20:51:28 +00:00
|
|
|
int x = ii / ELECTRICAL_PINTYPES_TOTAL;
|
|
|
|
int y = ii % ELECTRICAL_PINTYPES_TOTAL;
|
2012-11-30 12:28:23 +00:00
|
|
|
wxBitmapButton* butt = (wxBitmapButton*) event.GetEventObject();
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2019-06-13 13:34:38 +00:00
|
|
|
int level = ( DiagErc[y][x] + 1 ) % 3;
|
2009-07-07 17:50:02 +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
|
|
|
setDRCMatrixButtonState( butt, level );
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2014-10-08 04:02:48 +00:00
|
|
|
DiagErc[y][x] = DiagErc[x][y] = level;
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
2010-11-11 21:10:27 +00:00
|
|
|
|
|
|
|
|
2018-02-17 11:43:56 +00:00
|
|
|
void DIALOG_ERC::TestErc( REPORTER& aReporter )
|
2010-11-11 21:10:27 +00:00
|
|
|
{
|
|
|
|
wxFileName fn;
|
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
transferControlsToSettings();
|
2010-11-11 21:10:27 +00:00
|
|
|
|
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)
|
2016-03-06 21:22:01 +00:00
|
|
|
SCH_SHEET_LIST sheets( g_RootSheet );
|
2017-10-06 18:07:43 +00:00
|
|
|
sheets.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() )
|
2018-05-21 22:28:26 +00:00
|
|
|
aReporter.ReportTail( _( "Annotation required!" ), REPORTER::RPT_ERROR );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
SCH_SCREENS screens;
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
// Erase all previous DRC markers.
|
2015-07-29 12:18:53 +00:00
|
|
|
screens.DeleteAllMarkers( MARKER_BASE::MARKER_ERC );
|
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.
|
2011-10-07 14:41:30 +00:00
|
|
|
TestDuplicateSheetNames( true );
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
TestConflictingBusAliases();
|
|
|
|
|
|
|
|
// The connection graph has a whole set of ERC checks it can run
|
2019-11-10 23:24:27 +00:00
|
|
|
m_parent->RecalculateConnections( NO_CLEANUP );
|
2019-03-11 21:32:05 +00:00
|
|
|
g_ConnectionGraph->RunERC( m_settings );
|
|
|
|
|
2019-08-07 18:23:59 +00:00
|
|
|
// Test is all units of each multiunit component have the same footprint assigned.
|
2018-01-19 15:12:36 +00:00
|
|
|
TestMultiunitFootprints( sheets );
|
|
|
|
|
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;
|
|
|
|
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.
|
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
|
|
|
|
if( item->m_Link )
|
|
|
|
{
|
|
|
|
auto ref = item->GetComponentParent()->GetRef( &item->m_SheetPath );
|
|
|
|
wxString pin_name = ref + "_" + item->m_PinNum;
|
|
|
|
|
|
|
|
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() )
|
|
|
|
{
|
|
|
|
SCH_MARKER* marker = new SCH_MARKER();
|
|
|
|
|
|
|
|
marker->SetData( ERCE_DIFFERENT_UNIT_NET, item->m_Start,
|
2020-02-20 12:11:04 +00:00
|
|
|
wxString::Format( _( "Pin %s on %s is connected to both %s and %s" ),
|
|
|
|
item->m_PinNum,
|
|
|
|
ref,
|
|
|
|
pin_to_net_map[pin_name],
|
|
|
|
item->GetNetName() ),
|
|
|
|
item->m_Start );
|
2018-03-15 01:03:26 +00:00
|
|
|
marker->SetMarkerType( MARKER_BASE::MARKER_ERC );
|
|
|
|
marker->SetErrorLevel( MARKER_BASE::MARKER_SEVERITY_ERROR );
|
|
|
|
|
|
|
|
item->m_SheetPath.LastScreen()->Append( marker );
|
|
|
|
}
|
|
|
|
}
|
2010-11-11 21:10:27 +00:00
|
|
|
|
|
|
|
// Look for ERC problems between pins:
|
2019-03-29 01:15:36 +00:00
|
|
|
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)
|
2019-03-11 21:32:05 +00:00
|
|
|
if( m_settings.check_similar_labels )
|
2015-12-20 12:40:17 +00:00
|
|
|
objectsConnectedList->TestforSimilarLabels();
|
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
// Displays global results:
|
2014-10-08 23:54:51 +00:00
|
|
|
updateMarkerCounts( &screens );
|
2010-11-11 21:10:27 +00:00
|
|
|
|
|
|
|
// Display diags:
|
|
|
|
DisplayERC_MarkersList();
|
|
|
|
|
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
|
2018-05-21 22:28:26 +00:00
|
|
|
aReporter.ReportTail( _( "Finished" ), REPORTER::RPT_INFO );
|
2016-03-12 00:23:44 +00:00
|
|
|
|
2019-03-11 21:32:05 +00:00
|
|
|
if( m_settings.write_erc_file )
|
2010-11-11 21:10:27 +00:00
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
fn = g_RootSheet->GetScreen()->GetFileName();
|
2010-11-11 21:10:27 +00:00
|
|
|
fn.SetExt( wxT( "erc" ) );
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "ERC File" ), fn.GetPath(), fn.GetFullName(),
|
2017-11-12 00:31:38 +00:00
|
|
|
ErcFileWildcard(), wxFD_SAVE );
|
2010-11-11 21:10:27 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
2018-06-15 04:49:50 +00:00
|
|
|
if( WriteDiagnosticERC( GetUserUnits(), dlg.GetPath() ) )
|
* 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
|
|
|
ExecuteFile( this, Pgm().GetEditorName(), QuoteFullPath( fn ) );
|
2010-11-11 21:10:27 +00:00
|
|
|
}
|
|
|
|
}
|
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.
|
|
|
|
}
|