2007-12-01 03:42:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
*
|
2010-09-18 17:55:08 +00:00
|
|
|
* Copyright (C) 2004-2007 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
|
2007-12-01 03:42:52 +00:00
|
|
|
* Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com
|
|
|
|
* Copyright (C) 2007 Kicad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2007-08-08 20:51:08 +00:00
|
|
|
/****************************/
|
|
|
|
/* DRC control */
|
|
|
|
/****************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "pcbnew.h"
|
|
|
|
#include "wxPcbStruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "trigo.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
#include "drc_stuff.h"
|
2009-06-18 13:30:52 +00:00
|
|
|
#include "dialog_drc.h"
|
2007-11-27 01:34:35 +00:00
|
|
|
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
void DRC::ShowDialog()
|
|
|
|
{
|
|
|
|
if( !m_ui )
|
|
|
|
{
|
2009-06-18 13:30:52 +00:00
|
|
|
m_ui = new DIALOG_DRC_CONTROL( this, m_mainWindow );
|
2007-12-04 18:23:38 +00:00
|
|
|
updatePointers();
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
// copy data retained in this DRC object into the m_ui DrcPanel:
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2010-09-15 14:53:33 +00:00
|
|
|
PutValueInLocalUnits( *m_ui->m_SetTrackMinWidthCtrl,
|
|
|
|
m_pcb->GetBoardDesignSettings()->m_TrackMinWidth,
|
2010-09-19 17:44:46 +00:00
|
|
|
m_mainWindow->m_InternalUnits );
|
2010-09-15 14:53:33 +00:00
|
|
|
PutValueInLocalUnits( *m_ui->m_SetViaMinSizeCtrl,
|
|
|
|
m_pcb->GetBoardDesignSettings()->m_ViasMinSize,
|
2010-09-19 17:44:46 +00:00
|
|
|
m_mainWindow->m_InternalUnits );
|
2010-09-15 14:53:33 +00:00
|
|
|
PutValueInLocalUnits( *m_ui->m_SetMicroViakMinSizeCtrl,
|
|
|
|
m_pcb->GetBoardDesignSettings()->m_MicroViasMinSize,
|
2010-09-19 17:44:46 +00:00
|
|
|
m_mainWindow->m_InternalUnits );
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
m_ui->m_CreateRptCtrl->SetValue( m_doCreateRptFile );
|
|
|
|
m_ui->m_RptFilenameCtrl->SetValue( m_rptFilename );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
updatePointers();
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
m_ui->Show( true );
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
void DRC::DestroyDialog( int aReason )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2007-12-03 05:14:51 +00:00
|
|
|
if( m_ui )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2007-12-04 18:23:38 +00:00
|
|
|
if( aReason == wxID_OK )
|
|
|
|
{
|
2008-02-09 08:34:45 +00:00
|
|
|
// if user clicked OK, save his choices in this DRC object.
|
2010-09-15 14:53:33 +00:00
|
|
|
m_doCreateRptFile = m_ui->m_CreateRptCtrl->GetValue();
|
|
|
|
m_rptFilename = m_ui->m_RptFilenameCtrl->GetValue();
|
2007-12-04 18:23:38 +00:00
|
|
|
}
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
m_ui->Destroy();
|
|
|
|
m_ui = 0;
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
DRC::DRC( WinEDA_PcbFrame* aPcbWindow )
|
|
|
|
{
|
|
|
|
m_mainWindow = aPcbWindow;
|
2009-03-23 19:54:15 +00:00
|
|
|
m_pcb = aPcbWindow->GetBoard();
|
|
|
|
m_ui = 0;
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2008-02-09 08:34:45 +00:00
|
|
|
// establish initial values for everything:
|
2009-06-27 06:26:41 +00:00
|
|
|
m_doPad2PadTest = true; // enable pad to pad clearance tests
|
|
|
|
m_doUnconnectedTest = true; // enable unconnected tests
|
|
|
|
m_doZonesTest = true; // enable zone to items clearance tests
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
m_doCreateRptFile = false;
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
// m_rptFilename set to empty by its constructor
|
|
|
|
|
2010-09-18 08:29:40 +00:00
|
|
|
m_currentMarker = NULL;
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
m_segmAngle = 0;
|
2007-12-01 03:42:52 +00:00
|
|
|
m_segmLength = 0;
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
m_xcliplo = 0;
|
|
|
|
m_ycliplo = 0;
|
|
|
|
m_xcliphi = 0;
|
|
|
|
m_ycliphi = 0;
|
|
|
|
}
|
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
DRC::~DRC()
|
|
|
|
{
|
2008-02-09 08:34:45 +00:00
|
|
|
// maybe someday look at pointainer.h <- google for "pointainer.h"
|
2009-03-23 19:54:15 +00:00
|
|
|
for( unsigned i = 0; i<m_unconnected.size(); ++i )
|
2007-12-04 18:23:38 +00:00
|
|
|
delete m_unconnected[i];
|
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
|
2008-01-20 19:55:22 +00:00
|
|
|
/*********************************************/
|
2007-12-01 03:42:52 +00:00
|
|
|
int DRC::Drc( TRACK* aRefSegm, TRACK* aList )
|
2008-01-20 19:55:22 +00:00
|
|
|
/*********************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-12-01 03:42:52 +00:00
|
|
|
updatePointers();
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( !doTrackDrc( aRefSegm, aList, true ) )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2007-12-01 05:37:44 +00:00
|
|
|
wxASSERT( m_currentMarker );
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2009-04-17 08:51:02 +00:00
|
|
|
m_currentMarker->DisplayInfo( m_mainWindow );
|
2007-12-01 03:42:52 +00:00
|
|
|
return BAD_DRC;
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
return OK_DRC;
|
|
|
|
}
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
|
2008-01-31 20:53:44 +00:00
|
|
|
/**************************************************************/
|
2009-03-23 19:54:15 +00:00
|
|
|
int DRC::Drc( ZONE_CONTAINER* aArea, int CornerIndex )
|
2008-01-31 20:53:44 +00:00
|
|
|
/*************************************************************/
|
2009-03-23 19:54:15 +00:00
|
|
|
|
2008-01-20 19:55:22 +00:00
|
|
|
/**
|
|
|
|
* Function Drc
|
2008-01-31 20:53:44 +00:00
|
|
|
* tests the outline segment starting at CornerIndex and returns the result and displays the error
|
2008-01-20 19:55:22 +00:00
|
|
|
* in the status panel only if one exists.
|
|
|
|
* Test Edge inside other areas
|
|
|
|
* Test Edge too close other areas
|
2008-01-31 20:53:44 +00:00
|
|
|
* @param aEdge The areaparent which contains the corner.
|
|
|
|
* @param CornerIndex The starting point of the segment to test.
|
2008-01-20 19:55:22 +00:00
|
|
|
* @return int - BAD_DRC (1) if DRC error or OK_DRC (0) if OK
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
updatePointers();
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
if( !doEdgeZoneDrc( aArea, CornerIndex ) )
|
2008-01-20 19:55:22 +00:00
|
|
|
{
|
|
|
|
wxASSERT( m_currentMarker );
|
2009-04-17 08:51:02 +00:00
|
|
|
m_currentMarker->DisplayInfo( m_mainWindow );
|
2008-01-20 19:55:22 +00:00
|
|
|
return BAD_DRC;
|
|
|
|
}
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2008-01-20 19:55:22 +00:00
|
|
|
return OK_DRC;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-18 13:30:52 +00:00
|
|
|
/**
|
|
|
|
* Function RunTests
|
|
|
|
* will actually run all the tests specified with a previous call to
|
|
|
|
* SetSettings()
|
|
|
|
*/
|
2010-09-15 14:53:33 +00:00
|
|
|
void DRC::RunTests( wxTextCtrl* aMessages )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2009-02-26 09:33:14 +00:00
|
|
|
// Ensure ratsnest is up to date:
|
2009-05-24 18:28:36 +00:00
|
|
|
if( (m_pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
|
2009-06-27 06:26:41 +00:00
|
|
|
{
|
2009-09-10 15:22:26 +00:00
|
|
|
if( aMessages )
|
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
aMessages->AppendText( _( "Compile ratsnest...\n" ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
wxSafeYield();
|
|
|
|
}
|
|
|
|
|
2009-02-26 09:33:14 +00:00
|
|
|
m_mainWindow->Compile_Ratsnest( NULL, true );
|
2009-06-27 06:26:41 +00:00
|
|
|
}
|
2009-02-26 09:33:14 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
// someone should have cleared the two lists before calling this.
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( !testNetClasses() )
|
|
|
|
{
|
|
|
|
// testing the netclasses is a special case because if the netclasses
|
|
|
|
// do not pass the g_DesignSettings checks, then every member of a net
|
|
|
|
// class (a NET) will cause its items such as tracks, vias, and pads
|
|
|
|
// to also fail. So quit after *all* netclass errors have been reported.
|
|
|
|
if( aMessages )
|
2010-09-15 14:53:33 +00:00
|
|
|
aMessages->AppendText( _( "Aborting\n" ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
// update the m_ui listboxes
|
|
|
|
updatePointers();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
// test pad to pad clearances, nothing to do with tracks, vias or zones.
|
|
|
|
if( m_doPad2PadTest )
|
2009-06-27 06:26:41 +00:00
|
|
|
{
|
2009-09-10 15:22:26 +00:00
|
|
|
if( aMessages )
|
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
aMessages->AppendText( _( "Pad clearances...\n" ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
wxSafeYield();
|
|
|
|
}
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
testPad2Pad();
|
2009-06-27 06:26:41 +00:00
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2007-12-01 05:37:44 +00:00
|
|
|
// test track and via clearances to other tracks, pads, and vias
|
2009-09-10 15:22:26 +00:00
|
|
|
if( aMessages )
|
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
aMessages->AppendText( _( "Track clearances...\n" ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
wxSafeYield();
|
|
|
|
}
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
testTracks();
|
|
|
|
|
2008-12-04 20:53:11 +00:00
|
|
|
// Before testing segments and unconnected, refill all zones:
|
2009-02-26 09:33:14 +00:00
|
|
|
// this is a good caution, because filled areas can be outdated.
|
2009-09-10 15:22:26 +00:00
|
|
|
if( aMessages )
|
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
aMessages->AppendText( _( "Fill zones...\n" ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
wxSafeYield();
|
|
|
|
}
|
2008-12-04 20:53:11 +00:00
|
|
|
m_mainWindow->Fill_All_Zones( false );
|
|
|
|
|
2008-02-09 08:34:45 +00:00
|
|
|
// test zone clearances to other zones, pads, tracks, and vias
|
2010-09-15 14:53:33 +00:00
|
|
|
if( aMessages && m_doZonesTest )
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
aMessages->AppendText( _( "Test zones...\n" ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
wxSafeYield();
|
|
|
|
}
|
|
|
|
|
2008-03-18 04:04:17 +00:00
|
|
|
testZones( m_doZonesTest );
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2008-02-09 08:34:45 +00:00
|
|
|
// find and gather unconnected pads.
|
2007-12-01 03:42:52 +00:00
|
|
|
if( m_doUnconnectedTest )
|
2009-06-27 06:26:41 +00:00
|
|
|
{
|
2009-09-10 15:22:26 +00:00
|
|
|
if( aMessages )
|
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
aMessages->AppendText( _( "Unconnected pads...\n" ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
wxSafeYield();
|
|
|
|
}
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
testUnconnected();
|
2009-06-27 06:26:41 +00:00
|
|
|
}
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
// update the m_ui listboxes
|
2007-12-03 05:14:51 +00:00
|
|
|
updatePointers();
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
if( aMessages )
|
|
|
|
{
|
|
|
|
// no newline on this one because it is last, don't want the window
|
|
|
|
// to unnecessarily scroll.
|
2010-09-15 14:53:33 +00:00
|
|
|
aMessages->AppendText( _( "Finished" ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
}
|
2007-12-03 05:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************/
|
|
|
|
void DRC::ListUnconnectedPads()
|
|
|
|
/***************************************************************/
|
|
|
|
{
|
|
|
|
testUnconnected();
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
// update the m_ui listboxes
|
|
|
|
updatePointers();
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
void DRC::updatePointers()
|
|
|
|
{
|
|
|
|
// update my pointers, m_mainWindow is the only unchangable one
|
2009-01-05 05:21:35 +00:00
|
|
|
m_pcb = m_mainWindow->GetBoard();
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
if( m_ui ) // Use diag list boxes only in DRC dialog
|
2008-02-09 08:34:45 +00:00
|
|
|
{
|
|
|
|
m_ui->m_ClearanceListBox->SetList( new DRC_LIST_MARKERS( m_pcb ) );
|
|
|
|
m_ui->m_UnconnectedListBox->SetList( new DRC_LIST_UNCONNECTED( &m_unconnected ) );
|
|
|
|
}
|
2007-12-03 05:14:51 +00:00
|
|
|
}
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
bool DRC::doNetClass( NETCLASS* nc, wxString& msg )
|
|
|
|
{
|
|
|
|
bool ret = true;
|
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
const BOARD_DESIGN_SETTINGS& g = *m_pcb->GetBoardDesignSettings();
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2010-09-15 14:53:33 +00:00
|
|
|
#define FmtVal( x ) GetChars( ReturnStringFromValue( g_UserUnit, x, PCB_INTERNAL_UNIT ) )
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
#if 0 // set to 1 when (if...) BOARD_DESIGN_SETTINGS has a m_MinClearance value
|
2009-10-21 19:16:25 +00:00
|
|
|
if( nc->GetClearance() < g.m_MinClearance )
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
msg.Printf( _( "NETCLASS: '%s' has Clearance:%s which is less than global:%s" ),
|
|
|
|
GetChars( nc->GetName() ),
|
|
|
|
FmtVal( nc->GetClearance() ),
|
|
|
|
FmtVal( g.m_TrackClearance )
|
|
|
|
);
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
m_currentMarker = fillMarker( DRCE_NETCLASS_CLEARANCE, msg, m_currentMarker );
|
|
|
|
m_pcb->Add( m_currentMarker );
|
|
|
|
m_currentMarker = 0;
|
|
|
|
ret = false;
|
|
|
|
}
|
2009-10-21 19:16:25 +00:00
|
|
|
#endif
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
if( nc->GetTrackWidth() < g.m_TrackMinWidth )
|
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
msg.Printf( _( "NETCLASS: '%s' has TrackWidth:%s which is less than global:%s" ),
|
|
|
|
GetChars( nc->GetName() ),
|
|
|
|
FmtVal( nc->GetTrackWidth() ),
|
|
|
|
FmtVal( g.m_TrackMinWidth )
|
|
|
|
);
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
m_currentMarker = fillMarker( DRCE_NETCLASS_TRACKWIDTH, msg, m_currentMarker );
|
|
|
|
m_pcb->Add( m_currentMarker );
|
|
|
|
m_currentMarker = 0;
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( nc->GetViaDiameter() < g.m_ViasMinSize )
|
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
msg.Printf( _( "NETCLASS: '%s' has Via Dia:%s which is less than global:%s" ),
|
|
|
|
GetChars( nc->GetName() ),
|
|
|
|
FmtVal( nc->GetViaDiameter() ),
|
|
|
|
FmtVal( g.m_ViasMinSize )
|
|
|
|
);
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
m_currentMarker = fillMarker( DRCE_NETCLASS_VIASIZE, msg, m_currentMarker );
|
|
|
|
m_pcb->Add( m_currentMarker );
|
|
|
|
m_currentMarker = 0;
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
if( nc->GetViaDrill() < g.m_ViasMinDrill )
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
msg.Printf( _( "NETCLASS: '%s' has Via Drill:%s which is less than global:%s" ),
|
|
|
|
GetChars( nc->GetName() ),
|
|
|
|
FmtVal( nc->GetViaDrill() ),
|
|
|
|
FmtVal( g.m_ViasMinDrill )
|
|
|
|
);
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
m_currentMarker = fillMarker( DRCE_NETCLASS_VIADRILLSIZE, msg, m_currentMarker );
|
|
|
|
m_pcb->Add( m_currentMarker );
|
|
|
|
m_currentMarker = 0;
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( nc->GetuViaDiameter() < g.m_MicroViasMinSize )
|
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
msg.Printf( _( "NETCLASS: '%s' has uVia Dia:%s which is less than global:%s" ),
|
|
|
|
GetChars( nc->GetName() ),
|
|
|
|
FmtVal( nc->GetuViaDiameter() ),
|
|
|
|
FmtVal( g.m_MicroViasMinSize )
|
|
|
|
);
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
m_currentMarker = fillMarker( DRCE_NETCLASS_uVIASIZE, msg, m_currentMarker );
|
|
|
|
m_pcb->Add( m_currentMarker );
|
|
|
|
m_currentMarker = 0;
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
if( nc->GetuViaDrill() < g.m_MicroViasMinDrill )
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
msg.Printf( _( "NETCLASS: '%s' has uVia Drill:%s which is less than global:%s" ),
|
|
|
|
GetChars( nc->GetName() ),
|
|
|
|
FmtVal( nc->GetuViaDrill() ),
|
|
|
|
FmtVal( g.m_MicroViasMinDrill )
|
|
|
|
);
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
m_currentMarker = fillMarker( DRCE_NETCLASS_uVIADRILLSIZE, msg, m_currentMarker );
|
|
|
|
m_pcb->Add( m_currentMarker );
|
|
|
|
m_currentMarker = 0;
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DRC::testNetClasses()
|
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
bool ret = true;
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
NETCLASSES& netclasses = m_pcb->m_NetClasses;
|
|
|
|
|
|
|
|
wxString msg; // construct this only once here, not in a loop, since somewhat expensive.
|
|
|
|
|
|
|
|
if( !doNetClass( netclasses.GetDefault(), msg ) )
|
|
|
|
ret = false;
|
|
|
|
|
|
|
|
for( NETCLASSES::const_iterator i = netclasses.begin(); i != netclasses.end(); ++i )
|
|
|
|
{
|
|
|
|
NETCLASS* nc = i->second;
|
|
|
|
|
|
|
|
if( !doNetClass( nc, msg ) )
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
/***********************/
|
2007-12-01 03:42:52 +00:00
|
|
|
void DRC::testPad2Pad()
|
2009-03-23 19:54:15 +00:00
|
|
|
/***********************/
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2008-03-18 04:04:17 +00:00
|
|
|
std::vector<D_PAD*> sortedPads;
|
|
|
|
|
|
|
|
CreateSortedPadListByXCoord( m_pcb, &sortedPads );
|
2007-12-01 03:42:52 +00:00
|
|
|
|
|
|
|
// find the max size of the pads (used to stop the test)
|
2009-03-23 19:54:15 +00:00
|
|
|
int max_size = 0;
|
2008-03-18 04:04:17 +00:00
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
for( unsigned i = 0; i<sortedPads.size(); ++i )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2008-03-18 04:04:17 +00:00
|
|
|
D_PAD* pad = sortedPads[i];
|
|
|
|
|
2010-09-18 17:55:08 +00:00
|
|
|
if( pad->m_ShapeMaxRadius > max_size ) // m_ShapeMaxRadius is the radius value of the circle containing the pad
|
|
|
|
max_size = pad->m_ShapeMaxRadius;
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test the pads
|
2008-03-18 04:04:17 +00:00
|
|
|
D_PAD** listEnd = &sortedPads[ sortedPads.size() ];
|
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
for( unsigned i = 0; i<sortedPads.size(); ++i )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2008-03-18 04:04:17 +00:00
|
|
|
D_PAD* pad = sortedPads[i];
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2010-09-15 14:53:33 +00:00
|
|
|
int x_limit = max_size + pad->GetClearance() +
|
2010-09-18 17:55:08 +00:00
|
|
|
pad->m_ShapeMaxRadius + pad->GetPosition().x;
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
if( !doPadToPadsDrc( pad, &sortedPads[i], listEnd, x_limit ) )
|
2007-11-27 01:34:35 +00:00
|
|
|
{
|
2007-12-01 03:42:52 +00:00
|
|
|
wxASSERT( m_currentMarker );
|
|
|
|
m_pcb->Add( m_currentMarker );
|
2008-02-09 08:34:45 +00:00
|
|
|
m_currentMarker = 0;
|
2007-11-27 01:34:35 +00:00
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
}
|
2007-11-27 01:34:35 +00:00
|
|
|
|
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
void DRC::testTracks()
|
|
|
|
{
|
|
|
|
for( TRACK* segm = m_pcb->m_Track; segm && segm->Next(); segm = segm->Next() )
|
|
|
|
{
|
|
|
|
if( !doTrackDrc( segm, segm->Next(), true ) )
|
|
|
|
{
|
|
|
|
wxASSERT( m_currentMarker );
|
|
|
|
m_pcb->Add( m_currentMarker );
|
|
|
|
m_currentMarker = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
void DRC::testUnconnected()
|
|
|
|
{
|
2009-05-24 18:28:36 +00:00
|
|
|
if( (m_pcb->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
|
|
|
wxClientDC dc( m_mainWindow->DrawPanel );
|
|
|
|
m_mainWindow->Compile_Ratsnest( &dc, TRUE );
|
|
|
|
}
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2009-05-28 08:42:24 +00:00
|
|
|
if( m_pcb->GetRatsnestsCount() == 0 )
|
2007-12-01 03:42:52 +00:00
|
|
|
return;
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2009-05-28 08:42:24 +00:00
|
|
|
for( unsigned ii = 0; ii < m_pcb->GetRatsnestsCount(); ++ii )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2009-05-28 08:42:24 +00:00
|
|
|
RATSNEST_ITEM* rat = &m_pcb->m_FullRatsnest[ii];
|
2009-05-24 18:28:36 +00:00
|
|
|
if( (rat->m_Status & CH_ACTIF) == 0 )
|
2007-12-01 03:42:52 +00:00
|
|
|
continue;
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2009-05-24 18:28:36 +00:00
|
|
|
D_PAD* padStart = rat->m_PadStart;
|
|
|
|
D_PAD* padEnd = rat->m_PadEnd;
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2009-07-06 18:02:26 +00:00
|
|
|
DRC_ITEM* uncItem = new DRC_ITEM( DRCE_UNCONNECTED_PADS,
|
2009-03-23 19:54:15 +00:00
|
|
|
padStart->MenuText( m_pcb ), padEnd->MenuText( m_pcb ),
|
|
|
|
padStart->GetPosition(), padEnd->GetPosition() );
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
m_unconnected.push_back( uncItem );
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
}
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
|
2009-01-24 19:30:39 +00:00
|
|
|
/**********************************************/
|
2009-03-23 19:54:15 +00:00
|
|
|
void DRC::testZones( bool adoTestFillSegments )
|
2009-01-24 19:30:39 +00:00
|
|
|
/**********************************************/
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2008-02-09 08:34:45 +00:00
|
|
|
// Test copper areas for valide netcodes
|
|
|
|
// if a netcode is < 0 the netname was not found when reading a netlist
|
2009-01-24 19:30:39 +00:00
|
|
|
// if a netcode is == 0 the netname is void, and the zone is not connected.
|
|
|
|
// This is allowed, but i am not sure this is a good idea
|
2008-02-09 08:34:45 +00:00
|
|
|
for( int ii = 0; ii < m_pcb->GetAreaCount(); ii++ )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* Area_To_Test = m_pcb->GetArea( ii );
|
2009-03-23 19:54:15 +00:00
|
|
|
if( !Area_To_Test->IsOnCopperLayer() )
|
2008-09-26 19:51:36 +00:00
|
|
|
continue;
|
2009-01-24 19:30:39 +00:00
|
|
|
if( Area_To_Test->GetNet() < 0 )
|
2008-02-09 08:34:45 +00:00
|
|
|
{
|
|
|
|
m_currentMarker = fillMarker( Area_To_Test,
|
2009-03-23 19:54:15 +00:00
|
|
|
DRCE_NON_EXISTANT_NET_FOR_ZONE_OUTLINE, m_currentMarker );
|
2008-02-09 08:34:45 +00:00
|
|
|
m_pcb->Add( m_currentMarker );
|
|
|
|
m_currentMarker = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test copper areas outlines, and create markers when needed
|
|
|
|
m_pcb->Test_Drc_Areas_Outlines_To_Areas_Outlines( NULL, true );
|
2008-01-10 20:53:41 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
TRACK* zoneSeg;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( !adoTestFillSegments )
|
|
|
|
return;
|
|
|
|
|
2010-09-18 08:29:40 +00:00
|
|
|
// m_pcb->m_Zone is fully obsolete. Keep this test for compatibility
|
|
|
|
// with old designs. Will be removed on day
|
2008-12-04 04:28:11 +00:00
|
|
|
for( zoneSeg = m_pcb->m_Zone; zoneSeg && zoneSeg->Next(); zoneSeg = zoneSeg->Next() )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
|
|
|
// Test zoneSeg with other zone segments and with all pads
|
2008-12-04 04:28:11 +00:00
|
|
|
if( !doTrackDrc( zoneSeg, zoneSeg->Next(), true ) )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
|
|
|
wxASSERT( m_currentMarker );
|
|
|
|
m_pcb->Add( m_currentMarker );
|
2008-02-09 08:34:45 +00:00
|
|
|
m_currentMarker = 0;
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
// Pads already tested: disable pad test
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
bool rc = doTrackDrc( zoneSeg, m_pcb->m_Track, false );
|
2007-12-01 03:42:52 +00:00
|
|
|
if( !rc )
|
|
|
|
{
|
|
|
|
wxASSERT( m_currentMarker );
|
|
|
|
m_pcb->Add( m_currentMarker );
|
2008-02-09 08:34:45 +00:00
|
|
|
m_currentMarker = 0;
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
2007-08-08 20:51:08 +00:00
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
bool DRC::doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, LISTE_PAD* aEnd,
|
2009-09-10 15:22:26 +00:00
|
|
|
int x_limit )
|
2007-12-01 03:42:52 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
{
|
2010-09-18 17:55:08 +00:00
|
|
|
int layerMask = aRefPad->m_Masque_Layer & ALL_CU_LAYERS;
|
|
|
|
|
|
|
|
// used to test DRC pad to holes: this dummypad is a pad hole to test
|
|
|
|
// pad to pad hole DRC, using pad to pad DRC test.
|
|
|
|
// this dummy pad is a circle or an oval.
|
|
|
|
static D_PAD dummypad( (MODULE*) NULL );
|
2010-09-19 17:44:46 +00:00
|
|
|
dummypad.m_Masque_Layer |= ALL_CU_LAYERS; // Ensure the hole is on all copper layers
|
2010-09-18 17:55:08 +00:00
|
|
|
dummypad.m_LocalClearance = 1; /* Use the minimal local clerance value for the dummy pad
|
|
|
|
* the clearance of the active pad will be used
|
|
|
|
* as minimum distance to a hole
|
|
|
|
* (a value = 0 means use netclass value)
|
|
|
|
*/
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
for( LISTE_PAD* pad_list = aStart; pad_list<aEnd; ++pad_list )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
|
|
|
D_PAD* pad = *pad_list;
|
|
|
|
if( pad == aRefPad )
|
|
|
|
continue;
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
// We can stop the test when pad->m_Pos.x > x_limit
|
|
|
|
// because the list is sorted by X values
|
|
|
|
if( pad->m_Pos.x > x_limit )
|
2007-12-01 03:42:52 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
// No problem if pads are on different copper layers,
|
|
|
|
// but their hole (if any ) can create RDC error because they are on all
|
|
|
|
// copper layers, so we test them
|
2007-12-01 03:42:52 +00:00
|
|
|
if( (pad->m_Masque_Layer & layerMask ) == 0 )
|
2009-03-23 19:54:15 +00:00
|
|
|
{
|
2009-09-10 15:22:26 +00:00
|
|
|
// if holes are in the same location and have the same size and shape,
|
|
|
|
// this can be accepted
|
2009-03-23 19:54:15 +00:00
|
|
|
if( pad->GetPosition() == aRefPad->GetPosition()
|
|
|
|
&& pad->m_Drill == aRefPad->m_Drill
|
|
|
|
&& pad->m_DrillShape == aRefPad->m_DrillShape )
|
|
|
|
{
|
|
|
|
if( aRefPad->m_DrillShape == PAD_CIRCLE )
|
|
|
|
continue;
|
2010-09-18 17:55:08 +00:00
|
|
|
if( pad->m_Orient == aRefPad->m_Orient ) // for oval holes: must also have the same orientation
|
2009-03-23 19:54:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Here, we must test clearance between holes and pads
|
|
|
|
* dummypad size and shape is adjusted to pad drill size and shape
|
|
|
|
*/
|
2010-09-18 17:55:08 +00:00
|
|
|
if( pad->m_Drill.x ) // pad under testing has a hole, test this hole against pad reference
|
2009-03-23 19:54:15 +00:00
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
dummypad.SetPosition( pad->GetPosition() );
|
2009-03-23 19:54:15 +00:00
|
|
|
dummypad.m_Size = pad->m_Drill;
|
2010-09-18 17:55:08 +00:00
|
|
|
dummypad.m_PadShape = (pad->m_DrillShape == PAD_OVAL) ? PAD_OVAL : PAD_CIRCLE;
|
2009-03-23 19:54:15 +00:00
|
|
|
dummypad.m_Orient = pad->m_Orient;
|
2010-09-18 17:55:08 +00:00
|
|
|
dummypad.ComputeShapeMaxRadius(); // compute the radius of the circle containing this pad
|
2009-09-10 15:22:26 +00:00
|
|
|
if( !checkClearancePadToPad( aRefPad, &dummypad ) )
|
2009-03-23 19:54:15 +00:00
|
|
|
{
|
|
|
|
// here we have a drc error on pad!
|
|
|
|
m_currentMarker = fillMarker( pad, aRefPad,
|
|
|
|
DRCE_HOLE_NEAR_PAD, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
if( aRefPad->m_Drill.x ) // pad reference has a hole
|
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
dummypad.SetPosition( aRefPad->GetPosition() );
|
2009-03-23 19:54:15 +00:00
|
|
|
dummypad.m_Size = aRefPad->m_Drill;
|
2010-09-18 17:55:08 +00:00
|
|
|
dummypad.m_PadShape = (aRefPad->m_DrillShape == PAD_OVAL) ? PAD_OVAL : PAD_CIRCLE;
|
2009-03-23 19:54:15 +00:00
|
|
|
dummypad.m_Orient = aRefPad->m_Orient;
|
2010-09-18 17:55:08 +00:00
|
|
|
dummypad.ComputeShapeMaxRadius(); // compute the radius of the circle containing this pad
|
2009-09-10 15:22:26 +00:00
|
|
|
if( !checkClearancePadToPad( pad, &dummypad ) )
|
2009-03-23 19:54:15 +00:00
|
|
|
{
|
|
|
|
// here we have a drc erroron aRefPad!
|
|
|
|
m_currentMarker = fillMarker( aRefPad, pad,
|
|
|
|
DRCE_HOLE_NEAR_PAD, m_currentMarker );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
continue;
|
2009-03-23 19:54:15 +00:00
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2010-09-18 17:55:08 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
// The pad must be in a net (i.e pt_pad->GetNet() != 0 ),
|
|
|
|
// But no problem if pads have the same netcode (same net)
|
2009-03-23 19:54:15 +00:00
|
|
|
if( pad->GetNet() && ( aRefPad->GetNet() == pad->GetNet() ) )
|
2007-12-01 03:42:52 +00:00
|
|
|
continue;
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
// if pads are from the same footprint
|
|
|
|
if( pad->GetParent() == aRefPad->GetParent() )
|
|
|
|
{
|
|
|
|
// and have the same pad number ( equivalent pads )
|
|
|
|
|
|
|
|
// one can argue that this 2nd test is not necessary, that any
|
|
|
|
// two pads from a single module are acceptable. This 2nd test
|
|
|
|
// should eventually be a configuration option.
|
|
|
|
if( pad->m_NumPadName == aRefPad->m_NumPadName )
|
|
|
|
continue;
|
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( !checkClearancePadToPad( aRefPad, pad ) )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
|
|
|
// here we have a drc error!
|
2008-02-09 08:34:45 +00:00
|
|
|
m_currentMarker = fillMarker( aRefPad, pad,
|
2009-03-23 19:54:15 +00:00
|
|
|
DRCE_PAD_NEAR_PAD1, m_currentMarker );
|
2007-12-01 03:42:52 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|