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
|
2016-02-20 14:59:42 +00:00
|
|
|
* Copyright (C) 2012-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2016 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file dialog_erc.cpp
|
|
|
|
* @brief Electrical Rules Check dialog implementation.
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <kicad_string.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>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_sch_screen.h>
|
2015-02-21 09:46:44 +00:00
|
|
|
#include <schframe.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>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <netlist.h>
|
2013-09-25 19:09:57 +00:00
|
|
|
#include <class_netlist_object.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <sch_marker.h>
|
|
|
|
#include <sch_sheet.h>
|
|
|
|
#include <lib_pin.h>
|
|
|
|
|
|
|
|
#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
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
extern int DiagErc[PINTYPE_COUNT][PINTYPE_COUNT];
|
|
|
|
extern int DefaultDiagErc[PINTYPE_COUNT][PINTYPE_COUNT];
|
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_writeErcFile = false; // saved only for the current session
|
|
|
|
bool DIALOG_ERC::m_TestSimilarLabels = true; // Save in project config
|
|
|
|
bool DIALOG_ERC::m_diagErcTableInit = false; // saved only for the current session
|
|
|
|
bool DIALOG_ERC::m_tstUniqueGlobalLabels = true; // 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 )
|
2016-02-28 17:33:29 +00:00
|
|
|
EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PINTYPE_COUNT * PINTYPE_COUNT ) - 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 ) :
|
2015-09-10 12:03:16 +00:00
|
|
|
DIALOG_ERC_BASE( parent, ID_DIALOG_ERC // parent looks for this ID explicitly
|
2013-06-07 20:56:55 +00:00
|
|
|
)
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-11-30 12:28:23 +00:00
|
|
|
m_parent = parent;
|
2015-02-28 20:50:35 +00:00
|
|
|
m_lastMarkerFound = NULL;
|
2009-07-08 15:42:45 +00:00
|
|
|
Init();
|
2009-07-03 18:25:06 +00:00
|
|
|
|
2016-07-16 10:54:55 +00:00
|
|
|
FixOSXCancelButtonIssue();
|
|
|
|
|
|
|
|
// 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()
|
|
|
|
{
|
2015-12-20 12:40:17 +00:00
|
|
|
m_TestSimilarLabels = m_cbTestSimilarLabels->GetValue();
|
|
|
|
m_tstUniqueGlobalLabels = m_cbTestUniqueGlbLabels->GetValue();
|
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
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
for( int ii = 0; ii < PINTYPE_COUNT; ii++ )
|
2015-09-10 12:03:16 +00:00
|
|
|
{
|
2016-02-28 17:33:29 +00:00
|
|
|
for( int jj = 0; jj < PINTYPE_COUNT; jj++ )
|
2012-11-30 12:28:23 +00:00
|
|
|
m_buttonList[ii][jj] = NULL;
|
2015-09-10 12:03:16 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
m_WriteResultOpt->SetValue( m_writeErcFile );
|
2015-12-20 12:40:17 +00:00
|
|
|
m_cbTestSimilarLabels->SetValue( m_TestSimilarLabels );
|
|
|
|
m_cbTestUniqueGlbLabels->SetValue( m_tstUniqueGlobalLabels );
|
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();
|
|
|
|
|
|
|
|
// Set the run ERC button as the default button.
|
|
|
|
m_buttonERC->SetDefault();
|
|
|
|
}
|
|
|
|
|
2014-10-08 23:54:51 +00:00
|
|
|
|
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
|
|
|
|
2015-09-10 12:03:16 +00:00
|
|
|
|
2012-12-10 19:08:09 +00:00
|
|
|
/* event handler for Close button
|
|
|
|
*/
|
|
|
|
void DIALOG_ERC::OnButtonCloseClick( wxCommandEvent& event )
|
2008-04-14 19:22:48 +00:00
|
|
|
{
|
2012-12-10 19:08:09 +00:00
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
void DIALOG_ERC::OnCloseErcDialog( wxCloseEvent& event )
|
|
|
|
{
|
|
|
|
Destroy();
|
2007-06-05 12:10:51 +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
|
|
|
{
|
2009-07-08 15:42:45 +00:00
|
|
|
wxBusyCursor();
|
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
|
2009-07-08 15:42:45 +00:00
|
|
|
wxArrayString messageList;
|
|
|
|
TestErc( &messageList );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
for( unsigned ii = 0; ii < messageList.GetCount(); ii++ )
|
|
|
|
m_MessagesList->AppendText( messageList[ii] );
|
2009-07-08 15:42:45 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 23:54:51 +00:00
|
|
|
|
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();
|
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
m_lastMarkerFound = NULL;
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
if( marker == NULL )
|
|
|
|
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 );
|
2012-11-30 12:28:23 +00:00
|
|
|
bool notFound = true;
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2016-03-06 21:22:01 +00:00
|
|
|
for( i = 0; i < sheetList.size(); i++ )
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
SCH_ITEM* item = (SCH_ITEM*) sheetList[i].LastDrawList();
|
2014-10-08 23:54:51 +00:00
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
for( ; item; item = item->Next() )
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
|
|
|
if( item == marker )
|
|
|
|
{
|
2012-11-30 12:28:23 +00:00
|
|
|
notFound = false;
|
2009-07-08 15:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
if( notFound == false )
|
2009-07-08 15:42:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
if( notFound ) // 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
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
sheetList[i].LastScreen()->SetZoom( m_parent->GetScreen()->GetZoom() );
|
|
|
|
m_parent->SetCurrentSheet( sheetList[i] );
|
2016-02-15 20:17:51 +00:00
|
|
|
m_parent->GetCurrentSheet().UpdateAllScreenReferences();
|
2009-07-08 15:42:45 +00:00
|
|
|
}
|
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
m_lastMarkerFound = marker;
|
2013-08-03 05:15:23 +00:00
|
|
|
m_parent->SetCrossHairPosition( marker->m_Pos );
|
2012-11-30 12:28:23 +00:00
|
|
|
m_parent->RedrawScreen( marker->m_Pos, false);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2015-12-20 12:40:17 +00:00
|
|
|
// Remember: OnLeftClickMarkersList was called just before
|
2012-11-30 12:28:23 +00:00
|
|
|
// and therefore m_lastMarkerFound was initialized.
|
|
|
|
// (NULL if not found)
|
|
|
|
if( m_lastMarkerFound )
|
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
m_parent->SetCrossHairPosition( m_lastMarkerFound->m_Pos );
|
2014-10-08 23:54:51 +00:00
|
|
|
m_parent->RedrawScreen( m_lastMarkerFound->m_Pos, true );
|
2012-12-07 10:05:19 +00:00
|
|
|
// prevent a mouse left button release event in
|
2012-12-06 21:53:00 +00:00
|
|
|
// coming from the ERC dialog double click
|
2012-12-07 10:05:19 +00:00
|
|
|
// ( the button is released after closing this dialog and will generate
|
|
|
|
// an unwanted event in parent frame)
|
|
|
|
m_parent->SkipNextLeftButtonReleaseEvent();
|
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
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
if( m_initialized == false )
|
2009-07-03 18:25:06 +00:00
|
|
|
{
|
2011-09-11 11:38:01 +00:00
|
|
|
// Print row labels
|
2016-02-28 17:33:29 +00:00
|
|
|
for( int ii = 0; ii < PINTYPE_COUNT; 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) ) );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
for( int ii = 0; ii < PINTYPE_COUNT; 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
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
int event_id = ID_MATRIX_0 + ii + ( jj * PINTYPE_COUNT );
|
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 )
|
|
|
|
{
|
|
|
|
BITMAP_DEF bitmap_butt = NULL;
|
|
|
|
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;
|
|
|
|
}
|
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
|
|
|
{
|
2016-03-06 21:22:01 +00:00
|
|
|
SCH_ITEM* item = sheetList[i].LastDrawList();
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
for( ; item != NULL; item = item->Next() )
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2012-11-30 12:28:23 +00:00
|
|
|
if( item->Type() != SCH_MARKER_T )
|
2009-07-07 17:50:02 +00:00
|
|
|
continue;
|
|
|
|
|
2015-09-10 12:03:16 +00:00
|
|
|
SCH_MARKER* marker = (SCH_MARKER*) item;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2015-09-10 12:03:16 +00:00
|
|
|
if( marker->GetMarkerType() != MARKER_BASE::MARKER_ERC )
|
2009-07-07 17:50:02 +00:00
|
|
|
continue;
|
2011-09-11 11:38:01 +00:00
|
|
|
|
2015-09-10 12:03:16 +00:00
|
|
|
m_MarkersList->AppendToList( marker );
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-11 11:38:01 +00:00
|
|
|
|
2015-09-10 12:03:16 +00:00
|
|
|
m_MarkersList->DisplayList();
|
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();
|
2015-12-20 12:40:17 +00:00
|
|
|
m_TestSimilarLabels = true;
|
|
|
|
m_cbTestSimilarLabels->SetValue( m_TestSimilarLabels );
|
|
|
|
m_tstUniqueGlobalLabels = true;
|
|
|
|
m_cbTestUniqueGlbLabels->SetValue( m_tstUniqueGlobalLabels );
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event )
|
|
|
|
{
|
2009-07-07 17:50:02 +00:00
|
|
|
int id, level, ii, x, y;
|
|
|
|
wxPoint pos;
|
|
|
|
|
|
|
|
id = event.GetId();
|
|
|
|
ii = id - ID_MATRIX_0;
|
2012-11-30 12:28:23 +00:00
|
|
|
wxBitmapButton* butt = (wxBitmapButton*) event.GetEventObject();
|
|
|
|
pos = butt->GetPosition();
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2016-02-28 17:33:29 +00:00
|
|
|
x = ii / PINTYPE_COUNT; y = ii % PINTYPE_COUNT;
|
2009-07-07 17:50:02 +00:00
|
|
|
|
|
|
|
level = DiagErc[y][x];
|
|
|
|
|
2014-10-08 04:02:48 +00:00
|
|
|
//change to the next error level
|
2009-07-07 17:50:02 +00:00
|
|
|
switch( level )
|
|
|
|
{
|
|
|
|
case OK:
|
|
|
|
level = WAR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WAR:
|
|
|
|
level = ERR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ERR:
|
|
|
|
level = OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
|
|
|
|
{
|
|
|
|
wxFileName fn;
|
|
|
|
|
|
|
|
m_writeErcFile = m_WriteResultOpt->GetValue();
|
2015-12-20 12:40:17 +00:00
|
|
|
m_TestSimilarLabels = m_cbTestSimilarLabels->GetValue();
|
|
|
|
m_tstUniqueGlobalLabels = m_cbTestUniqueGlbLabels->GetValue();
|
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 );
|
2016-02-15 20:18:32 +00:00
|
|
|
sheets.AnnotatePowerSymbols( Prj().SchLibs() );
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
if( m_parent->CheckAnnotate( aMessagesList, false ) )
|
2010-11-11 21:10:27 +00:00
|
|
|
{
|
|
|
|
if( aMessagesList )
|
|
|
|
{
|
|
|
|
wxString msg = _( "Annotation required!" );
|
|
|
|
msg += wxT( "\n" );
|
|
|
|
aMessagesList->Add( msg );
|
|
|
|
}
|
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
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
|
2010-11-11 21:10:27 +00:00
|
|
|
{
|
2011-10-07 14:41:30 +00:00
|
|
|
/* Ff wire list has changed, delete Undo Redo list to avoid pointers on deleted
|
|
|
|
* data problems.
|
|
|
|
*/
|
2016-02-20 14:59:42 +00:00
|
|
|
if( screen->SchematicCleanUp() )
|
2011-10-07 14:41:30 +00:00
|
|
|
screen->ClearUndoRedoList();
|
2010-11-11 21:10:27 +00:00
|
|
|
}
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
/* Test duplicate sheet names inside a given sheet, one cannot have sheets with
|
|
|
|
* duplicate names (file names can be duplicated).
|
2010-11-11 21:10:27 +00:00
|
|
|
*/
|
2011-10-07 14:41:30 +00:00
|
|
|
TestDuplicateSheetNames( true );
|
2010-11-11 21:10:27 +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
|
|
|
|
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
|
|
|
unsigned lastItemIdx;
|
|
|
|
unsigned nextItemIdx = lastItemIdx = 0;
|
2012-11-30 12:28:23 +00:00
|
|
|
int MinConn = NOC;
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2016-06-08 06:32:01 +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" ) );
|
|
|
|
|
|
|
|
if( lastNet != net )
|
2011-09-11 11:38:01 +00:00
|
|
|
{
|
2011-10-07 14:41:30 +00:00
|
|
|
// New net found:
|
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
|
|
|
MinConn = NOC;
|
|
|
|
nextItemIdx = 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
|
|
|
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
|
2010-11-11 21:10:27 +00:00
|
|
|
case NET_ITEM_UNSPECIFIED:
|
|
|
|
case NET_SEGMENT:
|
|
|
|
case NET_BUS:
|
2011-10-07 14:41:30 +00:00
|
|
|
case NET_JUNCTION:
|
2010-11-11 21:10:27 +00:00
|
|
|
case NET_LABEL:
|
|
|
|
case NET_BUSLABELMEMBER:
|
|
|
|
case NET_PINLABEL:
|
|
|
|
case NET_GLOBBUSLABELMEMBER:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_HIERLABEL:
|
|
|
|
case NET_HIERBUSLABELMEMBER:
|
|
|
|
case NET_SHEETLABEL:
|
|
|
|
case NET_SHEETBUSLABELMEMBER:
|
|
|
|
// ERC problems when pin sheets do not match hierarchical labels.
|
|
|
|
// Each pin sheet must match a hierarchical label
|
|
|
|
// Each hierarchical label must match a pin sheet
|
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
|
|
|
objectsConnectedList->TestforNonOrphanLabel( itemIdx, nextItemIdx );
|
2015-12-20 12:40:17 +00:00
|
|
|
break;
|
|
|
|
case NET_GLOBLABEL:
|
|
|
|
if( m_tstUniqueGlobalLabels )
|
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
|
|
|
objectsConnectedList->TestforNonOrphanLabel( itemIdx, nextItemIdx );
|
2010-11-11 21:10:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_NOCONNECT:
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
// ERC problems when a noconnect symbol is connected to more than one pin.
|
2010-11-11 21:10:27 +00:00
|
|
|
MinConn = NET_NC;
|
2011-10-07 14:41:30 +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
|
|
|
if( objectsConnectedList->CountPinsInNet( nextItemIdx ) > 1 )
|
|
|
|
Diagnose( item, NULL, MinConn, UNC );
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NET_PIN:
|
|
|
|
|
|
|
|
// Look for ERC problems between pins:
|
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
|
|
|
TestOthersItems( objectsConnectedList.get(), itemIdx, nextItemIdx, &MinConn );
|
2010-11-11 21:10:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
if( m_TestSimilarLabels )
|
|
|
|
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();
|
|
|
|
|
|
|
|
// Display new markers:
|
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
|
|
|
|
wxString msg = _( "Finished" );
|
|
|
|
msg += wxT( "\n" );
|
|
|
|
aMessagesList->Add( msg );
|
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
if( m_writeErcFile )
|
|
|
|
{
|
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(),
|
|
|
|
_( "Electronic rule check file (.erc)|*.erc" ),
|
2015-07-29 12:18:53 +00:00
|
|
|
wxFD_SAVE );
|
2010-11-11 21:10:27 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( WriteDiagnosticERC( 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.
|
|
|
|
}
|