2011-10-07 14:41:30 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-12-10 19:08:09 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2012 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>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <class_sch_screen.h>
|
|
|
|
#include <wxEeschemaStruct.h>
|
2013-06-10 12:24:01 +00:00
|
|
|
#include <invoke_sch_dialog.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 <dialog_erc_listbox.h>
|
|
|
|
#include <erc.h>
|
2013-06-07 20:56:55 +00:00
|
|
|
#include <id.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
bool DIALOG_ERC::m_writeErcFile = false;
|
|
|
|
|
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE )
|
2011-10-07 14:41:30 +00:00
|
|
|
EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PIN_NMAX * PIN_NMAX ) - 1,
|
|
|
|
wxEVT_COMMAND_BUTTON_CLICKED, DIALOG_ERC::ChangeErrorLevel )
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
|
2013-06-07 20:56:55 +00:00
|
|
|
DIALOG_ERC_BASE(
|
|
|
|
parent,
|
|
|
|
ID_DIALOG_ERC // parent looks for this ID explicitly
|
|
|
|
)
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-11-30 12:28:23 +00:00
|
|
|
m_parent = parent;
|
2009-07-08 15:42:45 +00:00
|
|
|
Init();
|
2009-07-03 18:25:06 +00:00
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2009-12-06 18:04:41 +00:00
|
|
|
Centre();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2012-12-10 19:08:09 +00:00
|
|
|
DIALOG_ERC::~DIALOG_ERC()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
for( int ii = 0; ii < PIN_NMAX; ii++ )
|
|
|
|
for( int jj = 0; jj < PIN_NMAX; jj++ )
|
2012-11-30 12:28:23 +00:00
|
|
|
m_buttonList[ii][jj] = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
m_WriteResultOpt->SetValue( m_writeErcFile );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
SCH_SCREENS screens;
|
|
|
|
int markers = screens.GetMarkerCount();
|
|
|
|
int warnings = screens.GetMarkerCount( WAR );
|
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
wxString num;
|
2011-10-07 14:41:30 +00:00
|
|
|
num.Printf( wxT( "%d" ), markers );
|
2009-07-08 15:42:45 +00:00
|
|
|
m_TotalErrCount->SetLabel( num );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
num.Printf( wxT( "%d" ), markers - warnings );
|
2009-07-08 15:42:45 +00:00
|
|
|
m_LastErrCount->SetLabel( num );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
num.Printf( wxT( "%d" ), warnings );
|
2009-07-08 15:42:45 +00:00
|
|
|
m_LastWarningCount->SetLabel( num );
|
2008-04-14 19:22:48 +00:00
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
DisplayERC_MarkersList();
|
2009-07-05 12:09:41 +00:00
|
|
|
|
2009-07-08 15:42:45 +00:00
|
|
|
// Init Panel Matrix
|
|
|
|
ReBuildMatrixPanel();
|
2010-11-11 21:10:27 +00:00
|
|
|
|
|
|
|
// Set the run ERC button as the default button.
|
|
|
|
m_buttonERC->SetDefault();
|
2007-06-05 12:10: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
|
|
|
|
2011-03-10 19:36:30 +00:00
|
|
|
ScreenList.DeleteAllMarkers( MARK_ERC );
|
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
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DIALOG_ERC::OnCloseErcDialog( wxCloseEvent& event )
|
|
|
|
{
|
|
|
|
Destroy();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
/* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RESET_MATRIX */
|
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
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
/* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERC_CMP */
|
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();
|
2009-07-08 18:06:11 +00:00
|
|
|
m_MarkersList->Clear();
|
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
|
|
|
}
|
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
// Single click on a marker info:
|
|
|
|
void DIALOG_ERC::OnLeftClickMarkersList( wxCommandEvent& event )
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
2012-11-30 12:28:23 +00:00
|
|
|
m_lastMarkerFound = NULL;
|
|
|
|
|
2009-07-08 18:06:11 +00:00
|
|
|
int index = m_MarkersList->GetSelection();
|
2009-07-08 15:42:45 +00:00
|
|
|
|
|
|
|
if( index < 0 )
|
|
|
|
return;
|
|
|
|
|
2009-12-02 21:44:03 +00:00
|
|
|
const SCH_MARKER* marker = m_MarkersList->GetItem( (unsigned) index );
|
2009-07-08 15:42:45 +00:00
|
|
|
|
|
|
|
// Search for the selected marker
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_PATH* sheet;
|
|
|
|
SCH_SHEET_LIST SheetList;
|
2012-11-30 12:28:23 +00:00
|
|
|
bool notFound = true;
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
for( sheet = SheetList.GetFirst(); sheet; sheet = SheetList.GetNext() )
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
2009-11-03 13:26:31 +00:00
|
|
|
SCH_ITEM* item = (SCH_ITEM*) sheet->LastDrawList();
|
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;
|
|
|
|
}
|
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
if( *sheet != m_parent->GetCurrentSheet() )
|
2009-07-08 15:42:45 +00:00
|
|
|
{
|
2012-11-30 12:28:23 +00:00
|
|
|
sheet->LastScreen()->SetZoom( m_parent->GetScreen()->GetZoom() );
|
|
|
|
m_parent->SetCurrentSheet( *sheet );
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Double click on a marker info:
|
|
|
|
// Close the dialog and jump to the selected marker
|
|
|
|
void DIALOG_ERC::OnLeftDblClickMarkersList( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Remember: OnLeftClickMarkersList was called just berfore
|
|
|
|
// 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 );
|
2012-11-30 12:28:23 +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-11-03 13:26:31 +00:00
|
|
|
/* Build or rebuild the panel showing the ERC conflict matrix
|
2009-07-03 18:25:06 +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
|
2012-11-30 12:28:23 +00:00
|
|
|
wxBitmapButton * dummy = new wxBitmapButton( m_matrixPanel, wxID_ANY,
|
2011-10-07 14:41:30 +00:00
|
|
|
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
|
|
|
|
2009-07-03 18:25:06 +00:00
|
|
|
if( !DiagErcTableInit )
|
|
|
|
{
|
|
|
|
memcpy( DiagErc, DefaultDiagErc, sizeof(DefaultDiagErc) );
|
2011-10-07 14:41:30 +00:00
|
|
|
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
|
2012-11-30 12:28:23 +00:00
|
|
|
for( int ii = 0; ii < PIN_NMAX; 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
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
for( int ii = 0; ii < PIN_NMAX; 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;
|
2012-11-30 12:28:23 +00:00
|
|
|
text = new wxStaticText( m_matrixPanel,
|
2009-11-03 13:26:31 +00:00
|
|
|
-1,
|
|
|
|
CommentERC_V[ii],
|
|
|
|
txtpos );
|
2009-07-03 18:25:06 +00:00
|
|
|
}
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
int event_id = ID_MATRIX_0 + ii + ( jj * PIN_NMAX );
|
|
|
|
BITMAP_DEF bitmap_butt = NULL;
|
2009-07-03 18:25:06 +00:00
|
|
|
|
2011-09-11 11:38:01 +00:00
|
|
|
// Add button on matrix
|
2009-07-03 18:25:06 +00:00
|
|
|
switch( diag )
|
|
|
|
{
|
|
|
|
case OK:
|
2012-11-30 12:28:23 +00:00
|
|
|
bitmap_butt = erc_green_xpm;
|
2009-07-03 18:25:06 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WAR:
|
2012-11-30 12:28:23 +00:00
|
|
|
bitmap_butt = ercwarn_xpm ;
|
2009-07-03 18:25:06 +00:00
|
|
|
break;
|
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
default:
|
2009-07-03 18:25:06 +00:00
|
|
|
case ERR:
|
2012-11-30 12:28:23 +00:00
|
|
|
bitmap_butt = ercerr_xpm;
|
2009-07-03 18:25:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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 ) );
|
|
|
|
}
|
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
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
/*
|
2010-11-12 16:36:43 +00:00
|
|
|
* Function DisplayERC_MarkersList
|
2009-07-07 17:50:02 +00:00
|
|
|
* read the schematic and display the list of ERC markers
|
|
|
|
*/
|
|
|
|
void DIALOG_ERC::DisplayERC_MarkersList()
|
|
|
|
{
|
2012-11-30 12:28:23 +00:00
|
|
|
SCH_SHEET_LIST sheetList;
|
2009-07-08 18:06:11 +00:00
|
|
|
m_MarkersList->ClearList();
|
2009-07-08 15:42:45 +00:00
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
SCH_SHEET_PATH* sheet = sheetList.GetFirst();
|
|
|
|
for( ; sheet != NULL; sheet = sheetList.GetNext() )
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2012-11-30 12:28:23 +00:00
|
|
|
SCH_ITEM* item = sheet->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;
|
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
SCH_MARKER* Marker = (SCH_MARKER*) item;
|
2011-10-07 14:41:30 +00:00
|
|
|
|
2009-07-07 17:50:02 +00:00
|
|
|
if( Marker->GetMarkerType() != MARK_ERC )
|
|
|
|
continue;
|
2011-09-11 11:38:01 +00:00
|
|
|
|
2011-08-05 19:53:42 +00:00
|
|
|
// Add marker without refresh the displayed list:
|
|
|
|
m_MarkersList->AppendToList( Marker, false );
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-11 11:38:01 +00:00
|
|
|
|
2011-08-05 19:53:42 +00:00
|
|
|
m_MarkersList->Refresh();
|
2009-07-07 17:50:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* Resets the default values of the ERC matrix.
|
2009-07-07 17:50:02 +00:00
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event )
|
|
|
|
{
|
2009-07-07 17:50:02 +00:00
|
|
|
memcpy( DiagErc, DefaultDiagErc, sizeof(DiagErc) );
|
|
|
|
ReBuildMatrixPanel();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Change the error level for the pressed button, on the matrix table
|
|
|
|
*/
|
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;
|
2012-11-30 12:28:23 +00:00
|
|
|
BITMAP_DEF new_bitmap_butt = NULL;
|
2009-07-07 17:50:02 +00:00
|
|
|
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
|
|
|
|
|
|
|
x = ii / PIN_NMAX; y = ii % PIN_NMAX;
|
|
|
|
|
|
|
|
level = DiagErc[y][x];
|
|
|
|
|
|
|
|
switch( level )
|
|
|
|
{
|
|
|
|
case OK:
|
|
|
|
level = WAR;
|
2012-11-30 12:28:23 +00:00
|
|
|
new_bitmap_butt = ercwarn_xpm;
|
2009-07-07 17:50:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WAR:
|
|
|
|
level = ERR;
|
2012-11-30 12:28:23 +00:00
|
|
|
new_bitmap_butt = ercerr_xpm;
|
2009-07-07 17:50:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ERR:
|
|
|
|
level = OK;
|
2012-11-30 12:28:23 +00:00
|
|
|
new_bitmap_butt = erc_green_xpm;
|
2009-07-07 17:50:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
if( new_bitmap_butt )
|
2009-07-07 17:50:02 +00:00
|
|
|
{
|
2012-11-30 12:28:23 +00:00
|
|
|
delete butt;
|
|
|
|
butt = new wxBitmapButton( m_matrixPanel, id,
|
|
|
|
KiBitmap( new_bitmap_butt ), pos );
|
2009-07-07 17:50:02 +00:00
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
m_buttonList[y][x] = butt;
|
2009-07-07 17:50:02 +00:00
|
|
|
DiagErc[y][x] = DiagErc[x][y] = level;
|
|
|
|
}
|
|
|
|
}
|
2010-11-11 21:10:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
|
|
|
|
{
|
|
|
|
wxFileName fn;
|
|
|
|
|
|
|
|
if( !DiagErcTableInit )
|
|
|
|
{
|
|
|
|
memcpy( DiagErc, DefaultDiagErc, sizeof(DefaultDiagErc) );
|
2011-10-07 14:41:30 +00:00
|
|
|
DiagErcTableInit = true;
|
2010-11-11 21:10:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_writeErcFile = m_WriteResultOpt->GetValue();
|
|
|
|
|
2010-12-31 19:47:39 +00:00
|
|
|
/* Build the whole sheet list in hierarchy (sheet, not screen) */
|
2011-09-11 11:38:01 +00:00
|
|
|
SCH_SHEET_LIST sheets;
|
2010-12-31 19:47:39 +00:00
|
|
|
sheets.AnnotatePowerSymbols();
|
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.
|
|
|
|
screens.DeleteAllMarkers( MARK_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.
|
|
|
|
*/
|
|
|
|
if( screen->SchematicCleanUp( NULL ) )
|
|
|
|
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
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
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
|
|
|
|
2012-11-30 12:28:23 +00:00
|
|
|
unsigned lastNet;
|
|
|
|
unsigned nextNet = lastNet = 0;
|
|
|
|
int NetNbItems = 0;
|
|
|
|
int MinConn = NOC;
|
2010-11-11 21:10:27 +00:00
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
for( unsigned net = 0; net < objectsConnectedList->size(); net++ )
|
2010-11-11 21:10:27 +00:00
|
|
|
{
|
2013-09-27 12:30:35 +00:00
|
|
|
if( objectsConnectedList->GetItemNet( lastNet ) !=
|
|
|
|
objectsConnectedList->GetItemNet( net ) )
|
2011-09-11 11:38:01 +00:00
|
|
|
{
|
2011-10-07 14:41:30 +00:00
|
|
|
// New net found:
|
2010-11-11 21:10:27 +00:00
|
|
|
MinConn = NOC;
|
|
|
|
NetNbItems = 0;
|
2011-10-07 14:41:30 +00:00
|
|
|
nextNet = net;
|
2010-11-11 21:10:27 +00:00
|
|
|
}
|
|
|
|
|
2013-09-27 12:30:35 +00:00
|
|
|
switch( objectsConnectedList->GetItemType( net ) )
|
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_GLOBLABEL:
|
|
|
|
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
|
2013-09-27 12:30:35 +00:00
|
|
|
TestLabel( objectsConnectedList, net, nextNet );
|
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
|
|
|
|
2010-11-11 21:10:27 +00:00
|
|
|
if( NetNbItems != 0 )
|
2013-09-27 12:30:35 +00:00
|
|
|
Diagnose( objectsConnectedList->GetItem( net ), 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:
|
2013-09-27 12:30:35 +00:00
|
|
|
TestOthersItems( objectsConnectedList, net, nextNet, &NetNbItems, &MinConn );
|
2010-11-11 21:10:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
lastNet = net;
|
2010-11-11 21:10:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Displays global results:
|
|
|
|
wxString num;
|
2011-10-07 14:41:30 +00:00
|
|
|
int markers = screens.GetMarkerCount();
|
|
|
|
int warnings = screens.GetMarkerCount( WAR );
|
|
|
|
|
|
|
|
num.Printf( wxT( "%d" ), markers );
|
2010-11-11 21:10:27 +00:00
|
|
|
m_TotalErrCount->SetLabel( num );
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
num.Printf( wxT( "%d" ), markers - warnings );
|
2010-11-11 21:10:27 +00:00
|
|
|
m_LastErrCount->SetLabel( num );
|
|
|
|
|
2011-10-07 14:41:30 +00:00
|
|
|
num.Printf( wxT( "%d" ), warnings );
|
2010-11-11 21:10:27 +00:00
|
|
|
m_LastWarningCount->SetLabel( num );
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
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" ),
|
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( WriteDiagnosticERC( dlg.GetPath() ) )
|
|
|
|
{
|
2011-10-07 14:41:30 +00:00
|
|
|
Close( true );
|
2010-11-11 21:10:27 +00:00
|
|
|
ExecuteFile( this, wxGetApp().GetEditorName(), QuoteFullPath( fn ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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.
|
|
|
|
}
|