2007-12-01 03:42:52 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2007-12-01 03:42:52 +00:00
|
|
|
*
|
2017-03-16 17:09:33 +00:00
|
|
|
* Copyright (C) 2004-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2014-08-13 15:47:02 +00:00
|
|
|
* Copyright (C) 2014 Dick Hollenbeck, dick@softplc.com
|
2018-02-10 20:17:11 +00:00
|
|
|
* Copyright (C) 2017-2018 KiCad Developers, see change_log.txt for contributors.
|
2007-12-01 03:42:52 +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
|
|
|
|
*/
|
|
|
|
|
2014-08-13 15:47:02 +00:00
|
|
|
/**
|
|
|
|
* @file drc.cpp
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <trigo.h>
|
2018-02-02 20:57:12 +00:00
|
|
|
#include <board_design_settings.h>
|
2018-08-27 13:50:50 +00:00
|
|
|
#include <class_edge_mod.h>
|
|
|
|
#include <class_drawsegment.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_pad.h>
|
|
|
|
#include <class_zone.h>
|
2014-08-13 15:47:02 +00:00
|
|
|
#include <class_pcb_text.h>
|
2014-04-04 09:56:04 +00:00
|
|
|
#include <class_draw_panel_gal.h>
|
2014-03-19 12:42:46 +00:00
|
|
|
#include <view/view.h>
|
2014-08-13 15:47:02 +00:00
|
|
|
#include <geometry/seg.h>
|
2017-12-08 10:25:13 +00:00
|
|
|
#include <math_for_graphics.h>
|
2018-08-27 13:50:50 +00:00
|
|
|
#include <geometry/geometry_utils.h>
|
2017-11-15 17:33:06 +00:00
|
|
|
#include <connectivity_data.h>
|
2017-03-22 15:47:15 +00:00
|
|
|
#include <connectivity_algo.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2016-01-20 14:22:09 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2017-02-21 12:42:08 +00:00
|
|
|
#include <tools/pcb_actions.h>
|
2016-01-20 14:22:09 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew.h>
|
2018-01-28 21:02:31 +00:00
|
|
|
#include <drc.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_drc.h>
|
2013-03-20 14:50:12 +00:00
|
|
|
#include <wx/progdlg.h>
|
2017-03-03 15:04:58 +00:00
|
|
|
#include <board_commit.h>
|
2018-08-27 13:50:50 +00:00
|
|
|
#include <geometry/shape_segment.h>
|
|
|
|
#include <geometry/shape_arc.h>
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2016-07-28 12:07:35 +00:00
|
|
|
void DRC::ShowDRCDialog( wxWindow* aParent )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2016-07-28 12:07:35 +00:00
|
|
|
bool show_dlg_modal = true;
|
|
|
|
|
|
|
|
// the dialog needs a parent frame. if it is not specified, this is
|
|
|
|
// the PCB editor frame specified in DRC class.
|
|
|
|
if( aParent == NULL )
|
|
|
|
{
|
|
|
|
// if any parent is specified, the dialog is modal.
|
|
|
|
// if this is the default PCB editor frame, it is not modal
|
|
|
|
show_dlg_modal = false;
|
|
|
|
aParent = m_pcbEditorFrame;
|
|
|
|
}
|
|
|
|
|
2018-03-15 23:01:17 +00:00
|
|
|
TOOL_MANAGER* toolMgr = m_pcbEditorFrame->GetToolManager();
|
|
|
|
toolMgr->RunAction( ACTIONS::cancelInteractive, true );
|
|
|
|
toolMgr->DeactivateTool();
|
|
|
|
toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
|
|
|
2016-04-15 18:15:22 +00:00
|
|
|
if( !m_drcDialog )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2016-07-27 12:53:45 +00:00
|
|
|
m_drcDialog = new DIALOG_DRC_CONTROL( this, m_pcbEditorFrame, aParent );
|
2007-12-04 18:23:38 +00:00
|
|
|
updatePointers();
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2018-02-10 20:17:11 +00:00
|
|
|
m_drcDialog->SetRptSettings( m_doCreateRptFile, m_rptFilename );
|
2016-07-28 12:07:35 +00:00
|
|
|
|
|
|
|
if( show_dlg_modal )
|
|
|
|
m_drcDialog->ShowModal();
|
|
|
|
else
|
|
|
|
m_drcDialog->Show( true );
|
2007-12-04 18:23:38 +00:00
|
|
|
}
|
2016-07-28 12:07:35 +00:00
|
|
|
else // The dialog is just not visible (because the user has double clicked on an error item)
|
|
|
|
{
|
2007-12-04 18:23:38 +00:00
|
|
|
updatePointers();
|
2016-07-28 12:07:35 +00:00
|
|
|
m_drcDialog->Show( true );
|
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
|
2017-12-08 10:25:13 +00:00
|
|
|
|
2017-03-03 19:26:18 +00:00
|
|
|
void DRC::addMarkerToPcb( MARKER_PCB* aMarker )
|
2017-03-03 15:04:58 +00:00
|
|
|
{
|
2018-06-04 08:44:25 +00:00
|
|
|
// In legacy routing mode, do not add markers to the board.
|
|
|
|
// only shows the drc error message
|
|
|
|
if( m_drcInLegacyRoutingMode )
|
|
|
|
{
|
|
|
|
m_pcbEditorFrame->SetMsgPanel( aMarker );
|
|
|
|
delete aMarker;
|
|
|
|
m_currentMarker = nullptr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BOARD_COMMIT commit( m_pcbEditorFrame );
|
|
|
|
commit.Add( aMarker );
|
|
|
|
commit.Push( wxEmptyString, false, false );
|
|
|
|
}
|
2017-03-03 15:04:58 +00:00
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2017-12-08 10:25:13 +00:00
|
|
|
|
2016-07-28 12:07:35 +00:00
|
|
|
void DRC::DestroyDRCDialog( int aReason )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2016-04-15 18:15:22 +00:00
|
|
|
if( m_drcDialog )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2018-01-30 14:13:34 +00:00
|
|
|
m_drcDialog->GetRptSettings( &m_doCreateRptFile, m_rptFilename);
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2016-04-15 18:15:22 +00:00
|
|
|
m_drcDialog->Destroy();
|
|
|
|
m_drcDialog = NULL;
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
DRC::DRC( PCB_EDIT_FRAME* aPcbWindow )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2016-07-27 12:53:45 +00:00
|
|
|
m_pcbEditorFrame = aPcbWindow;
|
2009-03-23 19:54:15 +00:00
|
|
|
m_pcb = aPcbWindow->GetBoard();
|
2016-04-15 18:15:22 +00:00
|
|
|
m_drcDialog = NULL;
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2008-02-09 08:34:45 +00:00
|
|
|
// establish initial values for everything:
|
2018-06-04 08:44:25 +00:00
|
|
|
m_drcInLegacyRoutingMode = false;
|
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
|
2015-07-08 07:33:11 +00:00
|
|
|
m_doKeepoutTest = true; // enable keepout areas to items clearance tests
|
2018-02-10 20:17:11 +00:00
|
|
|
m_refillZones = false; // Only fill zones if requested by user.
|
2018-03-20 02:54:16 +00:00
|
|
|
m_reportAllTrackErrors = false;
|
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
|
|
|
|
2018-06-04 08:44:25 +00:00
|
|
|
int DRC::DrcOnCreatingTrack( TRACK* aRefSegm, TRACK* aList )
|
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
|
|
|
|
2018-06-04 08:44:25 +00:00
|
|
|
// Set right options for this on line drc
|
|
|
|
int drc_state = m_drcInLegacyRoutingMode;
|
|
|
|
m_drcInLegacyRoutingMode = true;
|
|
|
|
int rpt_state = m_reportAllTrackErrors;
|
|
|
|
m_reportAllTrackErrors = false;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( !doTrackDrc( aRefSegm, aList, true ) )
|
2007-08-08 20:51:08 +00:00
|
|
|
{
|
2018-03-20 02:54:16 +00:00
|
|
|
if( m_currentMarker )
|
2018-08-27 13:50:50 +00:00
|
|
|
{
|
2018-03-20 02:54:16 +00:00
|
|
|
m_pcbEditorFrame->SetMsgPanel( m_currentMarker );
|
2018-08-27 13:50:50 +00:00
|
|
|
delete m_currentMarker;
|
|
|
|
m_currentMarker = nullptr;
|
|
|
|
}
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2018-06-04 08:44:25 +00:00
|
|
|
m_drcInLegacyRoutingMode = drc_state;
|
|
|
|
m_reportAllTrackErrors = rpt_state;
|
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
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
if( !doTrackKeepoutDrc( aRefSegm ) )
|
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
if( m_currentMarker )
|
|
|
|
{
|
|
|
|
m_pcbEditorFrame->SetMsgPanel( m_currentMarker );
|
|
|
|
delete m_currentMarker;
|
|
|
|
m_currentMarker = nullptr;
|
|
|
|
}
|
2012-07-13 18:55:29 +00:00
|
|
|
|
2018-06-04 08:44:25 +00:00
|
|
|
m_drcInLegacyRoutingMode = drc_state;
|
|
|
|
m_reportAllTrackErrors = rpt_state;
|
2012-07-13 18:55:29 +00:00
|
|
|
return BAD_DRC;
|
|
|
|
}
|
|
|
|
|
2018-06-04 08:44:25 +00:00
|
|
|
m_drcInLegacyRoutingMode = drc_state;
|
|
|
|
m_reportAllTrackErrors = rpt_state;
|
2007-12-01 03:42:52 +00:00
|
|
|
return OK_DRC;
|
|
|
|
}
|
2007-08-08 20:51:08 +00:00
|
|
|
|
|
|
|
|
2017-12-08 10:25:13 +00:00
|
|
|
int DRC::TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers )
|
|
|
|
{
|
|
|
|
BOARD* board = m_pcbEditorFrame->GetBoard();
|
|
|
|
BOARD_COMMIT commit( m_pcbEditorFrame );
|
|
|
|
int nerrors = 0;
|
|
|
|
|
|
|
|
// iterate through all areas
|
|
|
|
for( int ia = 0; ia < board->GetAreaCount(); ia++ )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* zoneRef = board->GetArea( ia );
|
|
|
|
SHAPE_POLY_SET refSmoothedPoly;
|
|
|
|
|
|
|
|
zoneRef->BuildSmoothedPoly( refSmoothedPoly );
|
|
|
|
|
|
|
|
if( !zoneRef->IsOnCopperLayer() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// When testing only a single area, skip all others
|
|
|
|
if( aZone && ( aZone != zoneRef) )
|
|
|
|
continue;
|
|
|
|
|
2018-08-27 16:11:34 +00:00
|
|
|
for( int ia2 = ia + 1; ia2 < board->GetAreaCount(); ia2++ )
|
2017-12-08 10:25:13 +00:00
|
|
|
{
|
|
|
|
ZONE_CONTAINER* zoneToTest = board->GetArea( ia2 );
|
|
|
|
SHAPE_POLY_SET testSmoothedPoly;
|
|
|
|
|
|
|
|
zoneToTest->BuildSmoothedPoly( testSmoothedPoly );
|
|
|
|
|
|
|
|
if( zoneRef == zoneToTest )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// test for same layer
|
|
|
|
if( zoneRef->GetLayer() != zoneToTest->GetLayer() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Test for same net
|
|
|
|
if( zoneRef->GetNetCode() == zoneToTest->GetNetCode() && zoneRef->GetNetCode() >= 0 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// test for different priorities
|
|
|
|
if( zoneRef->GetPriority() != zoneToTest->GetPriority() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// test for different types
|
|
|
|
if( zoneRef->GetIsKeepout() != zoneToTest->GetIsKeepout() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Examine a candidate zone: compare zoneToTest to zoneRef
|
|
|
|
|
|
|
|
// Get clearance used in zone to zone test. The policy used to
|
|
|
|
// obtain that value is now part of the zone object itself by way of
|
|
|
|
// ZONE_CONTAINER::GetClearance().
|
|
|
|
int zone2zoneClearance = zoneRef->GetClearance( zoneToTest );
|
|
|
|
|
|
|
|
// Keepout areas have no clearance, so set zone2zoneClearance to 1
|
|
|
|
// ( zone2zoneClearance = 0 can create problems in test functions)
|
|
|
|
if( zoneRef->GetIsKeepout() )
|
|
|
|
zone2zoneClearance = 1;
|
|
|
|
|
|
|
|
// test for some corners of zoneRef inside zoneToTest
|
|
|
|
for( auto iterator = refSmoothedPoly.IterateWithHoles(); iterator; iterator++ )
|
|
|
|
{
|
|
|
|
VECTOR2I currentVertex = *iterator;
|
2018-08-27 17:34:28 +00:00
|
|
|
wxPoint pt( currentVertex.x, currentVertex.y );
|
2017-12-08 10:25:13 +00:00
|
|
|
|
|
|
|
if( testSmoothedPoly.Contains( currentVertex ) )
|
|
|
|
{
|
|
|
|
if( aCreateMarkers )
|
2018-08-27 17:34:28 +00:00
|
|
|
commit.Add( newMarker( pt, zoneRef, zoneToTest, DRCE_ZONES_INTERSECT ) );
|
2017-12-08 10:25:13 +00:00
|
|
|
|
|
|
|
nerrors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// test for some corners of zoneToTest inside zoneRef
|
|
|
|
for( auto iterator = testSmoothedPoly.IterateWithHoles(); iterator; iterator++ )
|
|
|
|
{
|
|
|
|
VECTOR2I currentVertex = *iterator;
|
2018-08-27 17:34:28 +00:00
|
|
|
wxPoint pt( currentVertex.x, currentVertex.y );
|
2017-12-08 10:25:13 +00:00
|
|
|
|
|
|
|
if( refSmoothedPoly.Contains( currentVertex ) )
|
|
|
|
{
|
|
|
|
if( aCreateMarkers )
|
2018-08-27 17:34:28 +00:00
|
|
|
commit.Add( newMarker( pt, zoneToTest, zoneRef, DRCE_ZONES_INTERSECT ) );
|
2017-12-08 10:25:13 +00:00
|
|
|
|
|
|
|
nerrors++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Iterate through all the segments of refSmoothedPoly
|
2018-08-27 17:34:28 +00:00
|
|
|
std::set<wxPoint> conflictPoints;
|
|
|
|
|
2017-12-08 10:25:13 +00:00
|
|
|
for( auto refIt = refSmoothedPoly.IterateSegmentsWithHoles(); refIt; refIt++ )
|
|
|
|
{
|
|
|
|
// Build ref segment
|
|
|
|
SEG refSegment = *refIt;
|
|
|
|
|
|
|
|
// Iterate through all the segments in testSmoothedPoly
|
|
|
|
for( auto testIt = testSmoothedPoly.IterateSegmentsWithHoles(); testIt; testIt++ )
|
|
|
|
{
|
|
|
|
// Build test segment
|
|
|
|
SEG testSegment = *testIt;
|
|
|
|
wxPoint pt;
|
|
|
|
|
|
|
|
int ax1, ay1, ax2, ay2;
|
|
|
|
ax1 = refSegment.A.x;
|
|
|
|
ay1 = refSegment.A.y;
|
|
|
|
ax2 = refSegment.B.x;
|
|
|
|
ay2 = refSegment.B.y;
|
|
|
|
|
|
|
|
int bx1, by1, bx2, by2;
|
|
|
|
bx1 = testSegment.A.x;
|
|
|
|
by1 = testSegment.A.y;
|
|
|
|
bx2 = testSegment.B.x;
|
|
|
|
by2 = testSegment.B.y;
|
|
|
|
|
|
|
|
int d = GetClearanceBetweenSegments( bx1, by1, bx2, by2,
|
|
|
|
0,
|
|
|
|
ax1, ay1, ax2, ay2,
|
|
|
|
0,
|
|
|
|
zone2zoneClearance,
|
|
|
|
&pt.x, &pt.y );
|
|
|
|
|
|
|
|
if( d < zone2zoneClearance )
|
2018-08-27 17:34:28 +00:00
|
|
|
conflictPoints.insert( pt );
|
2017-12-08 10:25:13 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-27 17:34:28 +00:00
|
|
|
|
|
|
|
for( wxPoint pt : conflictPoints )
|
|
|
|
{
|
|
|
|
if( aCreateMarkers )
|
|
|
|
commit.Add( newMarker( pt, zoneRef, zoneToTest, DRCE_ZONES_TOO_CLOSE ) );
|
|
|
|
|
|
|
|
nerrors++;
|
|
|
|
}
|
2017-12-08 10:25:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aCreateMarkers )
|
2018-04-09 19:56:27 +00:00
|
|
|
commit.Push( wxEmptyString, false, false );
|
2017-12-08 10:25:13 +00:00
|
|
|
|
|
|
|
return nerrors;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-04 08:44:25 +00:00
|
|
|
int DRC::DrcOnCreatingZone( ZONE_CONTAINER* aArea, int aCornerIndex )
|
2008-01-20 19:55:22 +00:00
|
|
|
{
|
|
|
|
updatePointers();
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2018-06-04 08:44:25 +00:00
|
|
|
// Set right options for this on line drc
|
|
|
|
int drc_state = m_drcInLegacyRoutingMode;
|
|
|
|
m_drcInLegacyRoutingMode = true;
|
|
|
|
int rpt_state = m_reportAllTrackErrors;
|
|
|
|
m_reportAllTrackErrors = false;
|
|
|
|
|
2010-12-29 17:47:32 +00:00
|
|
|
if( !doEdgeZoneDrc( aArea, aCornerIndex ) )
|
2008-01-20 19:55:22 +00:00
|
|
|
{
|
|
|
|
wxASSERT( m_currentMarker );
|
2016-07-27 12:53:45 +00:00
|
|
|
m_pcbEditorFrame->SetMsgPanel( m_currentMarker );
|
2018-06-04 08:44:25 +00:00
|
|
|
delete m_currentMarker;
|
|
|
|
m_currentMarker = nullptr;
|
|
|
|
m_drcInLegacyRoutingMode = drc_state;
|
|
|
|
m_reportAllTrackErrors = rpt_state;
|
2008-01-20 19:55:22 +00:00
|
|
|
return BAD_DRC;
|
|
|
|
}
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2018-06-04 08:44:25 +00:00
|
|
|
m_drcInLegacyRoutingMode = drc_state;
|
|
|
|
m_reportAllTrackErrors = rpt_state;
|
2008-01-20 19:55:22 +00:00
|
|
|
return OK_DRC;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-15 14:53:33 +00:00
|
|
|
void DRC::RunTests( wxTextCtrl* aMessages )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2016-04-15 18:15:22 +00:00
|
|
|
// be sure m_pcb is the current board, not a old one
|
|
|
|
// ( the board can be reloaded )
|
2016-07-27 12:53:45 +00:00
|
|
|
m_pcb = m_pcbEditorFrame->GetBoard();
|
2016-04-15 18:15:22 +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
|
2012-02-06 05:44:19 +00:00
|
|
|
// do not pass the BOARD_DESIGN_SETTINGS checks, then every member of a net
|
2009-09-10 15:22:26 +00:00
|
|
|
// 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
|
|
|
|
2016-04-15 18:15:22 +00:00
|
|
|
// update the m_drcDialog listboxes
|
2009-09-10 15:22:26 +00:00
|
|
|
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
|
|
|
|
2018-04-14 14:58:01 +00:00
|
|
|
// test clearances between drilled holes
|
|
|
|
if( aMessages )
|
|
|
|
{
|
|
|
|
aMessages->AppendText( _( "Drill clearances...\n" ) );
|
|
|
|
wxSafeYield();
|
|
|
|
}
|
|
|
|
|
|
|
|
testDrilledHoles();
|
|
|
|
|
2018-01-14 16:38:48 +00:00
|
|
|
// caller (a wxTopLevelFrame) is the wxDialog or the Pcb Editor frame that call DRC:
|
|
|
|
wxWindow* caller = aMessages ? aMessages->GetParent() : m_pcbEditorFrame;
|
2018-02-10 20:17:11 +00:00
|
|
|
|
|
|
|
if( m_refillZones )
|
|
|
|
{
|
2018-05-04 12:01:26 +00:00
|
|
|
if( aMessages )
|
|
|
|
aMessages->AppendText( _( "Refilling all zones...\n" ) );
|
|
|
|
|
2018-02-10 20:17:11 +00:00
|
|
|
m_pcbEditorFrame->Fill_All_Zones( caller );
|
|
|
|
}
|
2018-04-06 10:24:23 +00:00
|
|
|
else
|
|
|
|
{
|
2018-05-04 12:01:26 +00:00
|
|
|
if( aMessages )
|
|
|
|
aMessages->AppendText( _( "Checking zone fills...\n" ) );
|
|
|
|
|
2018-04-06 10:24:23 +00:00
|
|
|
m_pcbEditorFrame->Check_All_Zones( caller );
|
|
|
|
}
|
2008-12-04 20:53:11 +00:00
|
|
|
|
2018-08-23 22:41:57 +00:00
|
|
|
// test track and via clearances to other tracks, pads, and vias
|
|
|
|
if( aMessages )
|
|
|
|
{
|
|
|
|
aMessages->AppendText( _( "Track clearances...\n" ) );
|
|
|
|
wxSafeYield();
|
|
|
|
}
|
|
|
|
|
|
|
|
testTracks( aMessages ? aMessages->GetParent() : m_pcbEditorFrame, true );
|
|
|
|
|
2011-11-10 08:21:11 +00:00
|
|
|
// test zone clearances to other zones
|
|
|
|
if( aMessages )
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
2018-04-06 10:24:23 +00:00
|
|
|
aMessages->AppendText( _( "Zone to zone clearances...\n" ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
wxSafeYield();
|
|
|
|
}
|
|
|
|
|
2011-11-10 08:21:11 +00:00
|
|
|
testZones();
|
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" ) );
|
2011-10-31 20:29:46 +00:00
|
|
|
aMessages->Refresh();
|
2009-09-10 15:22:26 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
// find and gather vias, tracks, pads inside keepout areas.
|
|
|
|
if( m_doKeepoutTest )
|
|
|
|
{
|
|
|
|
if( aMessages )
|
|
|
|
{
|
|
|
|
aMessages->AppendText( _( "Keepout areas ...\n" ) );
|
|
|
|
aMessages->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
testKeepoutAreas();
|
|
|
|
}
|
|
|
|
|
2014-08-13 15:47:02 +00:00
|
|
|
// find and gather vias, tracks, pads inside text boxes.
|
|
|
|
if( aMessages )
|
|
|
|
{
|
|
|
|
aMessages->AppendText( _( "Test texts...\n" ) );
|
|
|
|
wxSafeYield();
|
|
|
|
}
|
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
testCopperTextAndGraphics();
|
2014-08-13 15:47:02 +00:00
|
|
|
|
2018-02-10 20:17:11 +00:00
|
|
|
// find overlapping courtyard ares.
|
2018-04-28 15:22:25 +00:00
|
|
|
if( m_pcb->GetDesignSettings().m_ProhibitOverlappingCourtyards
|
|
|
|
|| m_pcb->GetDesignSettings().m_RequireCourtyards )
|
2017-03-16 17:09:33 +00:00
|
|
|
{
|
|
|
|
if( aMessages )
|
|
|
|
{
|
|
|
|
aMessages->AppendText( _( "Courtyard areas...\n" ) );
|
|
|
|
aMessages->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
doFootprintOverlappingDrc();
|
|
|
|
}
|
|
|
|
|
2018-07-04 08:23:40 +00:00
|
|
|
// Check if there are items on disabled layers
|
|
|
|
testDisabledLayers();
|
|
|
|
|
|
|
|
if( aMessages )
|
|
|
|
{
|
|
|
|
aMessages->AppendText( _( "Items on disabled layers...\n" ) );
|
|
|
|
aMessages->Refresh();
|
|
|
|
}
|
|
|
|
|
2016-04-15 18:15:22 +00:00
|
|
|
// update the m_drcDialog 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
|
|
|
|
2016-04-15 18:15:22 +00:00
|
|
|
// update the m_drcDialog listboxes
|
2007-12-04 18:23:38 +00:00
|
|
|
updatePointers();
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
void DRC::updatePointers()
|
|
|
|
{
|
2016-07-27 12:53:45 +00:00
|
|
|
// update my pointers, m_pcbEditorFrame is the only unchangeable one
|
|
|
|
m_pcb = m_pcbEditorFrame->GetBoard();
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2016-04-15 18:15:22 +00:00
|
|
|
if( m_drcDialog ) // Use diag list boxes only in DRC dialog
|
2008-02-09 08:34:45 +00:00
|
|
|
{
|
2018-06-15 04:49:50 +00:00
|
|
|
m_drcDialog->m_ClearanceListBox->SetList(
|
|
|
|
m_pcbEditorFrame->GetUserUnits(), new DRC_LIST_MARKERS( m_pcb ) );
|
|
|
|
m_drcDialog->m_UnconnectedListBox->SetList(
|
|
|
|
m_pcbEditorFrame->GetUserUnits(), new DRC_LIST_UNCONNECTED( &m_unconnected ) );
|
2016-09-08 18:17:37 +00:00
|
|
|
|
|
|
|
m_drcDialog->UpdateDisplayedCounts();
|
2008-02-09 08:34:45 +00:00
|
|
|
}
|
2007-12-03 05:14:51 +00:00
|
|
|
}
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2017-09-23 09:20:10 +00:00
|
|
|
bool DRC::doNetClass( const NETCLASSPTR& nc, wxString& msg )
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
|
|
|
bool ret = true;
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
const BOARD_DESIGN_SETTINGS& g = m_pcb->GetDesignSettings();
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2018-06-15 04:49:50 +00:00
|
|
|
#define FmtVal( x ) GetChars( StringFromValue( m_pcbEditorFrame->GetUserUnits(), x ) )
|
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
|
|
|
{
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "NETCLASS: \"%s\" has Clearance:%s which is less than global:%s" ),
|
2010-09-15 14:53:33 +00:00
|
|
|
GetChars( nc->GetName() ),
|
|
|
|
FmtVal( nc->GetClearance() ),
|
|
|
|
FmtVal( g.m_TrackClearance )
|
|
|
|
);
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2017-03-03 15:04:58 +00:00
|
|
|
addMarkerToPcb( fillMarker( DRCE_NETCLASS_CLEARANCE, msg, m_currentMarker ) );
|
|
|
|
m_currentMarker = nullptr;
|
2009-09-10 15:22:26 +00:00
|
|
|
ret = false;
|
|
|
|
}
|
2009-10-21 19:16:25 +00:00
|
|
|
#endif
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2011-11-24 17:32:51 +00:00
|
|
|
if( nc->GetTrackWidth() < g.m_TrackMinWidth )
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "NETCLASS: \"%s\" has TrackWidth:%s which is less than global:%s" ),
|
2010-09-15 14:53:33 +00:00
|
|
|
GetChars( nc->GetName() ),
|
|
|
|
FmtVal( nc->GetTrackWidth() ),
|
2011-11-24 17:32:51 +00:00
|
|
|
FmtVal( g.m_TrackMinWidth )
|
2010-09-15 14:53:33 +00:00
|
|
|
);
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
addMarkerToPcb( newMarker( DRCE_NETCLASS_TRACKWIDTH, msg ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2011-11-24 17:32:51 +00:00
|
|
|
if( nc->GetViaDiameter() < g.m_ViasMinSize )
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "NETCLASS: \"%s\" has Via Dia:%s which is less than global:%s" ),
|
2010-09-15 14:53:33 +00:00
|
|
|
GetChars( nc->GetName() ),
|
|
|
|
FmtVal( nc->GetViaDiameter() ),
|
2011-11-24 17:32:51 +00:00
|
|
|
FmtVal( g.m_ViasMinSize )
|
2010-09-15 14:53:33 +00:00
|
|
|
);
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
addMarkerToPcb( newMarker( DRCE_NETCLASS_VIASIZE, msg ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2011-11-24 17:32:51 +00:00
|
|
|
if( nc->GetViaDrill() < g.m_ViasMinDrill )
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "NETCLASS: \"%s\" has Via Drill:%s which is less than global:%s" ),
|
2010-09-15 14:53:33 +00:00
|
|
|
GetChars( nc->GetName() ),
|
|
|
|
FmtVal( nc->GetViaDrill() ),
|
2011-11-24 17:32:51 +00:00
|
|
|
FmtVal( g.m_ViasMinDrill )
|
2010-09-15 14:53:33 +00:00
|
|
|
);
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
addMarkerToPcb( newMarker( DRCE_NETCLASS_VIADRILLSIZE, msg ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2011-11-24 17:32:51 +00:00
|
|
|
if( nc->GetuViaDiameter() < g.m_MicroViasMinSize )
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "NETCLASS: \"%s\" has uVia Dia:%s which is less than global:%s" ),
|
2010-09-15 14:53:33 +00:00
|
|
|
GetChars( nc->GetName() ),
|
|
|
|
FmtVal( nc->GetuViaDiameter() ),
|
2018-08-27 13:50:50 +00:00
|
|
|
FmtVal( g.m_MicroViasMinSize ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
addMarkerToPcb( newMarker( DRCE_NETCLASS_uVIASIZE, msg ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
2011-11-24 17:32:51 +00:00
|
|
|
if( nc->GetuViaDrill() < g.m_MicroViasMinDrill )
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
2017-12-15 11:37:46 +00:00
|
|
|
msg.Printf( _( "NETCLASS: \"%s\" has uVia Drill:%s which is less than global:%s" ),
|
2010-09-15 14:53:33 +00:00
|
|
|
GetChars( nc->GetName() ),
|
|
|
|
FmtVal( nc->GetuViaDrill() ),
|
2018-08-27 13:50:50 +00:00
|
|
|
FmtVal( g.m_MicroViasMinDrill ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
addMarkerToPcb( newMarker( DRCE_NETCLASS_uVIADRILLSIZE, msg ) );
|
2009-09-10 15:22:26 +00:00
|
|
|
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
|
|
|
|
2014-05-13 09:22:51 +00:00
|
|
|
NETCLASSES& netclasses = m_pcb->GetDesignSettings().m_NetClasses;
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
2014-05-20 09:29:37 +00:00
|
|
|
NETCLASSPTR nc = i->second;
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
if( !doNetClass( nc, msg ) )
|
|
|
|
ret = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
void DRC::testPad2Pad()
|
|
|
|
{
|
2008-03-18 04:04:17 +00:00
|
|
|
std::vector<D_PAD*> sortedPads;
|
|
|
|
|
2011-10-31 13:44:13 +00:00
|
|
|
m_pcb->GetSortedPadListByXthenYCoord( sortedPads );
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2018-05-16 07:20:04 +00:00
|
|
|
if( sortedPads.size() == 0 )
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
|
2011-10-31 13:44:13 +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];
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// GetBoundingRadius() is the radius of the minimum sized circle fully containing the pad
|
|
|
|
int radius = pad->GetBoundingRadius();
|
2018-02-10 20:17:11 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( radius > max_size )
|
|
|
|
max_size = radius;
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
|
2018-05-16 07:20:04 +00:00
|
|
|
// Upper limit of pad list (limit not included)
|
|
|
|
D_PAD** listEnd = &sortedPads[0] + sortedPads.size();
|
2008-03-18 04:04:17 +00:00
|
|
|
|
2018-05-16 07:20:04 +00:00
|
|
|
// Test the pads
|
2011-10-31 13:44:13 +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() +
|
2012-02-19 04:02:19 +00:00
|
|
|
pad->GetBoundingRadius() + 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 );
|
2017-03-03 15:04:58 +00:00
|
|
|
addMarkerToPcb ( m_currentMarker );
|
|
|
|
m_currentMarker = nullptr;
|
2007-11-27 01:34:35 +00:00
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
|
|
|
}
|
2007-11-27 01:34:35 +00:00
|
|
|
|
|
|
|
|
2018-04-14 14:58:01 +00:00
|
|
|
void DRC::testDrilledHoles()
|
|
|
|
{
|
2018-04-28 15:22:25 +00:00
|
|
|
int holeToHoleMin = m_pcb->GetDesignSettings().m_HoleToHoleMin;
|
2018-04-14 14:58:01 +00:00
|
|
|
|
|
|
|
if( holeToHoleMin == 0 ) // No min setting turns testing off.
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Test drilled hole clearances to minimize drill bit breakage.
|
|
|
|
//
|
|
|
|
// Notes: slots are milled, so we're only concerned with circular holes
|
|
|
|
// microvias are laser-drilled, so we're only concerned with standard vias
|
|
|
|
|
|
|
|
struct DRILLED_HOLE
|
|
|
|
{
|
|
|
|
wxPoint m_location;
|
|
|
|
int m_drillRadius;
|
|
|
|
BOARD_ITEM* m_owner;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<DRILLED_HOLE> holes;
|
|
|
|
DRILLED_HOLE hole;
|
|
|
|
|
|
|
|
for( MODULE* mod : m_pcb->Modules() )
|
|
|
|
{
|
|
|
|
for( D_PAD* pad : mod->Pads( ) )
|
|
|
|
{
|
|
|
|
if( pad->GetDrillSize().x && pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
|
|
|
|
{
|
|
|
|
hole.m_location = pad->GetPosition();
|
|
|
|
hole.m_drillRadius = pad->GetDrillSize().x / 2;
|
|
|
|
hole.m_owner = pad;
|
|
|
|
holes.push_back( hole );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( TRACK* track : m_pcb->Tracks() )
|
|
|
|
{
|
|
|
|
VIA* via = dynamic_cast<VIA*>( track );
|
|
|
|
if( via && via->GetViaType() == VIA_THROUGH )
|
|
|
|
{
|
|
|
|
hole.m_location = via->GetPosition();
|
|
|
|
hole.m_drillRadius = via->GetDrillValue() / 2;
|
|
|
|
hole.m_owner = via;
|
|
|
|
holes.push_back( hole );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( size_t ii = 0; ii < holes.size(); ++ii )
|
|
|
|
{
|
|
|
|
const DRILLED_HOLE& refHole = holes[ ii ];
|
|
|
|
|
|
|
|
for( size_t jj = ii + 1; jj < holes.size(); ++jj )
|
|
|
|
{
|
|
|
|
const DRILLED_HOLE& checkHole = holes[ jj ];
|
|
|
|
|
|
|
|
// Holes with identical locations are allowable
|
|
|
|
if( checkHole.m_location == refHole.m_location )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( KiROUND( GetLineLength( checkHole.m_location, refHole.m_location ) )
|
|
|
|
< checkHole.m_drillRadius + refHole.m_drillRadius + holeToHoleMin )
|
|
|
|
{
|
2018-06-15 04:49:50 +00:00
|
|
|
addMarkerToPcb( new MARKER_PCB( m_pcbEditorFrame->GetUserUnits(),
|
|
|
|
DRCE_DRILLED_HOLES_TOO_CLOSE, refHole.m_location,
|
2018-04-14 14:58:01 +00:00
|
|
|
refHole.m_owner, refHole.m_location,
|
|
|
|
checkHole.m_owner, checkHole.m_location ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-08 07:33:11 +00:00
|
|
|
void DRC::testTracks( wxWindow *aActiveWindow, bool aShowProgressBar )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
2011-11-10 08:21:11 +00:00
|
|
|
wxProgressDialog * progressDialog = NULL;
|
|
|
|
const int delta = 500; // This is the number of tests between 2 calls to the
|
|
|
|
// progress bar
|
|
|
|
int count = 0;
|
2018-02-10 20:17:11 +00:00
|
|
|
|
2011-11-10 08:21:11 +00:00
|
|
|
for( TRACK* segm = m_pcb->m_Track; segm && segm->Next(); segm = segm->Next() )
|
|
|
|
count++;
|
|
|
|
|
|
|
|
int deltamax = count/delta;
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2011-11-10 08:21:11 +00:00
|
|
|
if( aShowProgressBar && deltamax > 3 )
|
2010-09-20 16:21:47 +00:00
|
|
|
{
|
2018-01-15 16:57:03 +00:00
|
|
|
// Do not use wxPD_APP_MODAL style here: it is not necessary and create issues
|
|
|
|
// on OSX
|
2011-11-10 08:21:11 +00:00
|
|
|
progressDialog = new wxProgressDialog( _( "Track clearances" ), wxEmptyString,
|
2015-07-08 07:33:11 +00:00
|
|
|
deltamax, aActiveWindow,
|
2018-01-15 16:57:03 +00:00
|
|
|
wxPD_AUTO_HIDE | wxPD_CAN_ABORT | wxPD_ELAPSED_TIME );
|
2011-11-10 08:21:11 +00:00
|
|
|
progressDialog->Update( 0, wxEmptyString );
|
|
|
|
}
|
|
|
|
|
|
|
|
int ii = 0;
|
|
|
|
count = 0;
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2016-08-25 01:16:28 +00:00
|
|
|
for( TRACK* segm = m_pcb->m_Track; segm; segm = segm->Next() )
|
2011-11-10 08:21:11 +00:00
|
|
|
{
|
2018-02-10 20:17:11 +00:00
|
|
|
if( ii++ > delta )
|
2011-11-10 08:21:11 +00:00
|
|
|
{
|
|
|
|
ii = 0;
|
|
|
|
count++;
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2011-11-10 08:21:11 +00:00
|
|
|
if( progressDialog )
|
|
|
|
{
|
|
|
|
if( !progressDialog->Update( count, wxEmptyString ) )
|
|
|
|
break; // Aborted by user
|
2015-07-08 07:33:11 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
// Work around a dialog z-order issue on OS X
|
|
|
|
if( count == deltamax )
|
|
|
|
aActiveWindow->Raise();
|
|
|
|
#endif
|
2011-11-10 08:21:11 +00:00
|
|
|
}
|
|
|
|
}
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2010-09-20 16:21:47 +00:00
|
|
|
if( !doTrackDrc( segm, segm->Next(), true ) )
|
|
|
|
{
|
2018-03-20 02:54:16 +00:00
|
|
|
if( m_currentMarker )
|
|
|
|
{
|
|
|
|
addMarkerToPcb ( m_currentMarker );
|
|
|
|
m_currentMarker = nullptr;
|
|
|
|
}
|
2010-09-20 16:21:47 +00:00
|
|
|
}
|
|
|
|
}
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2011-11-10 08:21:11 +00:00
|
|
|
if( progressDialog )
|
|
|
|
progressDialog->Destroy();
|
2010-09-20 16:21:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
void DRC::testUnconnected()
|
|
|
|
{
|
2017-03-22 13:43:10 +00:00
|
|
|
|
|
|
|
auto connectivity = m_pcb->GetConnectivity();
|
|
|
|
|
2017-03-22 15:47:15 +00:00
|
|
|
connectivity->Clear();
|
2018-02-10 20:17:11 +00:00
|
|
|
connectivity->Build( m_pcb ); // just in case. This really needs to be reliable.
|
2017-03-22 15:47:15 +00:00
|
|
|
connectivity->RecalculateRatsnest();
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2017-03-22 15:47:15 +00:00
|
|
|
std::vector<CN_EDGE> edges;
|
|
|
|
connectivity->GetUnconnectedEdges( edges );
|
2013-03-20 14:50:12 +00:00
|
|
|
|
2017-03-22 15:47:15 +00:00
|
|
|
for( const auto& edge : edges )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2017-03-22 15:47:15 +00:00
|
|
|
auto src = edge.GetSourcePos();
|
|
|
|
auto dst = edge.GetTargetPos();
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2018-06-15 04:49:50 +00:00
|
|
|
m_unconnected.emplace_back( new DRC_ITEM( m_pcbEditorFrame->GetUserUnits(),
|
|
|
|
DRCE_UNCONNECTED_ITEMS,
|
|
|
|
edge.GetSourceNode()->Parent(),
|
|
|
|
wxPoint( src.x, src.y ),
|
|
|
|
edge.GetTargetNode()->Parent(),
|
|
|
|
wxPoint( dst.x, dst.y ) ) );
|
2017-03-22 13:43:10 +00:00
|
|
|
|
2017-03-22 15:47:15 +00:00
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
|
2011-11-10 08:21:11 +00:00
|
|
|
void DRC::testZones()
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2011-09-17 01:22:26 +00:00
|
|
|
// Test copper areas for valid netcodes
|
2008-02-09 08:34:45 +00:00
|
|
|
// 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
|
2015-01-22 12:06:34 +00:00
|
|
|
//
|
|
|
|
// In recent Pcbnew versions, the netcode is always >= 0, but an internal net name
|
2018-02-10 20:17:11 +00:00
|
|
|
// is stored, and initialized from the file or the zone properties editor.
|
2015-01-22 12:06:34 +00:00
|
|
|
// if it differs from the net name from net code, there is a DRC issue
|
2008-02-09 08:34:45 +00:00
|
|
|
for( int ii = 0; ii < m_pcb->GetAreaCount(); ii++ )
|
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
ZONE_CONTAINER* zone = m_pcb->GetArea( ii );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
if( !zone->IsOnCopperLayer() )
|
2008-09-26 19:51:36 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
int netcode = zone->GetNetCode();
|
2015-01-22 12:06:34 +00:00
|
|
|
// a netcode < 0 or > 0 and no pad in net is a error or strange
|
|
|
|
// perhaps a "dead" net, which happens when all pads in this net were removed
|
|
|
|
// Remark: a netcode < 0 should not happen (this is more a bug somewhere)
|
2018-08-27 13:50:50 +00:00
|
|
|
int pads_in_net = ( netcode > 0 ) ? m_pcb->GetConnectivity()->GetPadCount( netcode ) : 1;
|
2015-01-22 12:06:34 +00:00
|
|
|
|
|
|
|
if( ( netcode < 0 ) || pads_in_net == 0 )
|
2008-02-09 08:34:45 +00:00
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
wxPoint markerPos = zone->GetPosition();
|
|
|
|
addMarkerToPcb( newMarker( markerPos, zone, DRCE_SUSPICIOUS_NET_FOR_ZONE_OUTLINE ) );
|
2008-02-09 08:34:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test copper areas outlines, and create markers when needed
|
2017-12-08 10:25:13 +00:00
|
|
|
TestZoneToZoneOutline( NULL, true );
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|
2007-08-08 20:51:08 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
void DRC::testKeepoutAreas()
|
|
|
|
{
|
|
|
|
// Test keepout areas for vias, tracks and pads inside keepout areas
|
|
|
|
for( int ii = 0; ii < m_pcb->GetAreaCount(); ii++ )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* area = m_pcb->GetArea( ii );
|
|
|
|
|
|
|
|
if( !area->GetIsKeepout() )
|
2017-11-30 16:22:45 +00:00
|
|
|
{
|
2012-07-13 18:55:29 +00:00
|
|
|
continue;
|
2017-11-30 16:22:45 +00:00
|
|
|
}
|
2012-07-13 18:55:29 +00:00
|
|
|
|
|
|
|
for( TRACK* segm = m_pcb->m_Track; segm != NULL; segm = segm->Next() )
|
|
|
|
{
|
|
|
|
if( segm->Type() == PCB_TRACE_T )
|
|
|
|
{
|
2018-02-10 20:17:11 +00:00
|
|
|
if( !area->GetDoNotAllowTracks() )
|
2012-07-13 18:55:29 +00:00
|
|
|
continue;
|
|
|
|
|
2017-11-30 16:22:45 +00:00
|
|
|
// Ignore if the keepout zone is not on the same layer
|
|
|
|
if( !area->IsOnLayer( segm->GetLayer() ) )
|
2012-07-13 18:55:29 +00:00
|
|
|
continue;
|
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
SEG trackSeg( segm->GetStart(), segm->GetEnd() );
|
|
|
|
|
|
|
|
if( area->Outline()->Distance( trackSeg, segm->GetWidth() ) == 0 )
|
|
|
|
addMarkerToPcb( newMarker( segm, area, DRCE_TRACK_INSIDE_KEEPOUT ) );
|
2012-07-13 18:55:29 +00:00
|
|
|
}
|
|
|
|
else if( segm->Type() == PCB_VIA_T )
|
|
|
|
{
|
|
|
|
if( ! area->GetDoNotAllowVias() )
|
|
|
|
continue;
|
|
|
|
|
2017-11-30 16:22:45 +00:00
|
|
|
auto viaLayers = segm->GetLayerSet();
|
|
|
|
|
|
|
|
if( !area->CommonLayerExists( viaLayers ) )
|
2012-07-13 18:55:29 +00:00
|
|
|
continue;
|
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
if( area->Outline()->Distance( segm->GetPosition() ) < segm->GetWidth()/2 )
|
2018-08-27 13:50:50 +00:00
|
|
|
addMarkerToPcb( newMarker( segm, area, DRCE_VIA_INSIDE_KEEPOUT ) );
|
2012-07-13 18:55:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Test pads: TODO
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-25 09:06:24 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
void DRC::testCopperTextAndGraphics()
|
2014-08-13 15:47:02 +00:00
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
// Test copper items for clearance violations with vias, tracks and pads
|
2014-08-13 15:47:02 +00:00
|
|
|
|
2018-08-23 22:41:57 +00:00
|
|
|
for( BOARD_ITEM* brdItem : m_pcb->Drawings() )
|
2014-08-13 15:47:02 +00:00
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
if( IsCopperLayer( brdItem->GetLayer() ) )
|
|
|
|
{
|
|
|
|
if( brdItem->Type() == PCB_TEXT_T )
|
|
|
|
testCopperTextItem( brdItem );
|
|
|
|
else if( brdItem->Type() == PCB_LINE_T )
|
|
|
|
testCopperDrawItem( static_cast<DRAWSEGMENT*>( brdItem ));
|
|
|
|
}
|
2018-08-23 22:41:57 +00:00
|
|
|
}
|
2014-08-13 15:47:02 +00:00
|
|
|
|
2018-08-23 22:41:57 +00:00
|
|
|
for( MODULE* module : m_pcb->Modules() )
|
|
|
|
{
|
|
|
|
if( IsCopperLayer( module->Reference().GetLayer() ) )
|
2018-08-27 13:50:50 +00:00
|
|
|
testCopperTextItem( &module->Reference());
|
2018-08-23 22:41:57 +00:00
|
|
|
|
|
|
|
if( IsCopperLayer( module->Value().GetLayer() ) )
|
2018-08-27 13:50:50 +00:00
|
|
|
testCopperTextItem( &module->Value());
|
2018-08-23 22:41:57 +00:00
|
|
|
|
|
|
|
for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() )
|
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
if( IsCopperLayer( item->GetLayer() ) )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_MODULE_TEXT_T )
|
|
|
|
testCopperTextItem( item );
|
|
|
|
else if( item->Type() == PCB_MODULE_EDGE_T )
|
|
|
|
testCopperDrawItem( static_cast<DRAWSEGMENT*>( item ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DRC::testCopperDrawItem( DRAWSEGMENT* aItem )
|
|
|
|
{
|
|
|
|
std::vector<SEG> itemShape;
|
|
|
|
int itemWidth = aItem->GetWidth();
|
|
|
|
|
|
|
|
switch( aItem->GetShape() )
|
|
|
|
{
|
|
|
|
case S_ARC:
|
|
|
|
{
|
|
|
|
SHAPE_ARC arc( aItem->GetCenter(), aItem->GetArcStart(), (double) aItem->GetAngle() / 10.0 );
|
|
|
|
|
|
|
|
auto l = arc.ConvertToPolyline();
|
|
|
|
|
|
|
|
for( int i = 0; i < l.SegmentCount(); i++ )
|
|
|
|
itemShape.push_back( l.CSegment(i) );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case S_SEGMENT:
|
|
|
|
itemShape.push_back( SEG( aItem->GetStart(), aItem->GetEnd() ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CIRCLE:
|
|
|
|
{
|
|
|
|
// SHAPE_CIRCLE has no ConvertToPolyline() method, so use a 360.0 SHAPE_ARC
|
|
|
|
SHAPE_ARC circle( aItem->GetCenter(), aItem->GetEnd(), 360.0 );
|
|
|
|
|
|
|
|
auto l = circle.ConvertToPolyline();
|
|
|
|
|
|
|
|
for( int i = 0; i < l.SegmentCount(); i++ )
|
|
|
|
itemShape.push_back( l.CSegment(i) );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case S_CURVE:
|
|
|
|
{
|
|
|
|
aItem->RebuildBezierToSegmentsPointsList( aItem->GetWidth() );
|
|
|
|
wxPoint start_pt = aItem->GetBezierPoints()[0];
|
|
|
|
|
|
|
|
for( unsigned int jj = 1; jj < aItem->GetBezierPoints().size(); jj++ )
|
|
|
|
{
|
|
|
|
wxPoint end_pt = aItem->GetBezierPoints()[jj];
|
|
|
|
itemShape.push_back( SEG( start_pt, end_pt ) );
|
|
|
|
start_pt = end_pt;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test tracks and vias
|
|
|
|
for( TRACK* track = m_pcb->m_Track; track != NULL; track = track->Next() )
|
|
|
|
{
|
|
|
|
if( !track->IsOnLayer( aItem->GetLayer() ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
int minDist = ( track->GetWidth() + itemWidth ) / 2 + track->GetClearance( NULL );
|
|
|
|
SEG trackAsSeg( track->GetStart(), track->GetEnd() );
|
|
|
|
|
|
|
|
for( const auto& itemSeg : itemShape )
|
|
|
|
{
|
|
|
|
if( trackAsSeg.Distance( itemSeg ) < minDist )
|
|
|
|
{
|
|
|
|
if( track->Type() == PCB_VIA_T )
|
|
|
|
addMarkerToPcb( newMarker( track, aItem, itemSeg, DRCE_VIA_NEAR_COPPER ) );
|
|
|
|
else
|
|
|
|
addMarkerToPcb( newMarker( track, aItem, itemSeg, DRCE_TRACK_NEAR_COPPER ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test pads
|
|
|
|
for( auto pad : m_pcb->GetPads() )
|
|
|
|
{
|
|
|
|
if( !pad->IsOnLayer( aItem->GetLayer() ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const int segmentCount = 18;
|
|
|
|
double correctionFactor = GetCircletoPolyCorrectionFactor( segmentCount );
|
|
|
|
SHAPE_POLY_SET padOutline;
|
|
|
|
|
|
|
|
// We incorporate "minDist" into the pad's outline
|
|
|
|
pad->TransformShapeWithClearanceToPolygon( padOutline, pad->GetClearance( NULL ),
|
|
|
|
segmentCount, correctionFactor );
|
|
|
|
|
|
|
|
for( const auto& itemSeg : itemShape )
|
|
|
|
{
|
|
|
|
if( padOutline.Distance( itemSeg, itemWidth ) == 0 )
|
|
|
|
{
|
|
|
|
addMarkerToPcb( newMarker( pad, aItem, DRCE_PAD_NEAR_COPPER ) );
|
|
|
|
break;
|
|
|
|
}
|
2018-08-23 22:41:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-08-13 15:47:02 +00:00
|
|
|
|
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
void DRC::testCopperTextItem( BOARD_ITEM* aTextItem )
|
2018-08-23 22:41:57 +00:00
|
|
|
{
|
|
|
|
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aTextItem );
|
|
|
|
std::vector<wxPoint> textShape; // a buffer to store the text shape (set of segments)
|
2018-08-27 13:50:50 +00:00
|
|
|
int textWidth = text->GetThickness();
|
2018-08-23 22:41:57 +00:00
|
|
|
|
|
|
|
// So far the bounding box makes up the text-area
|
|
|
|
text->TransformTextShapeToSegmentList( textShape );
|
|
|
|
|
|
|
|
if( textShape.size() == 0 ) // Should not happen (empty text?)
|
|
|
|
return;
|
2014-08-13 15:47:02 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
// Test tracks and vias
|
2018-08-23 22:41:57 +00:00
|
|
|
for( TRACK* track = m_pcb->m_Track; track != NULL; track = track->Next() )
|
|
|
|
{
|
|
|
|
if( !track->IsOnLayer( aTextItem->GetLayer() ) )
|
2014-08-13 15:47:02 +00:00
|
|
|
continue;
|
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
int minDist = ( track->GetWidth() + textWidth ) / 2 + track->GetClearance( NULL );
|
|
|
|
SEG trackAsSeg( track->GetStart(), track->GetEnd() );
|
2014-08-13 15:47:02 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
for( unsigned jj = 0; jj < textShape.size(); jj += 2 )
|
2018-08-23 22:41:57 +00:00
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
SEG textSeg( textShape[jj], textShape[jj+1] );
|
2018-08-23 22:41:57 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
if( trackAsSeg.Distance( textSeg ) < minDist )
|
2014-08-13 15:47:02 +00:00
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
if( track->Type() == PCB_VIA_T )
|
|
|
|
addMarkerToPcb( newMarker( track, aTextItem, textSeg, DRCE_VIA_NEAR_COPPER ) );
|
|
|
|
else
|
|
|
|
addMarkerToPcb( newMarker( track, aTextItem, textSeg, DRCE_TRACK_NEAR_COPPER ) );
|
2018-08-23 22:41:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-08-13 15:47:02 +00:00
|
|
|
|
2018-08-23 22:41:57 +00:00
|
|
|
// Test pads
|
2018-08-27 13:50:50 +00:00
|
|
|
for( auto pad : m_pcb->GetPads() )
|
2018-08-23 22:41:57 +00:00
|
|
|
{
|
|
|
|
if( !pad->IsOnLayer( aTextItem->GetLayer() ) )
|
|
|
|
continue;
|
2014-08-13 15:47:02 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
const int segmentCount = 18;
|
|
|
|
double correctionFactor = GetCircletoPolyCorrectionFactor( segmentCount );
|
|
|
|
SHAPE_POLY_SET padOutline;
|
|
|
|
|
|
|
|
// We incorporate "minDist" into the pad's outline
|
|
|
|
pad->TransformShapeWithClearanceToPolygon( padOutline, pad->GetClearance( NULL ),
|
|
|
|
segmentCount, correctionFactor );
|
2014-08-13 15:47:02 +00:00
|
|
|
|
2018-08-23 22:41:57 +00:00
|
|
|
for( unsigned jj = 0; jj < textShape.size(); jj += 2 )
|
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
SEG textSeg( textShape[jj], textShape[jj+1] );
|
2014-08-13 15:47:02 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
if( padOutline.Distance( textSeg, textWidth ) == 0 )
|
2018-08-23 22:41:57 +00:00
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
addMarkerToPcb( newMarker( pad, aTextItem, DRCE_PAD_NEAR_COPPER ) );
|
2018-08-23 22:41:57 +00:00
|
|
|
break;
|
2014-08-13 15:47:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-04 08:23:40 +00:00
|
|
|
void DRC::testDisabledLayers()
|
|
|
|
{
|
|
|
|
BOARD* board = m_pcbEditorFrame->GetBoard();
|
|
|
|
wxCHECK( board, /*void*/ );
|
|
|
|
LSET disabledLayers = board->GetEnabledLayers().flip();
|
|
|
|
|
|
|
|
auto createMarker = [&]( BOARD_ITEM* aItem )
|
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
addMarkerToPcb( newMarker( aItem->GetPosition(), aItem, DRCE_DISABLED_LAYER_ITEM ) );
|
2018-07-04 08:23:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for( auto track : board->Tracks() )
|
|
|
|
{
|
|
|
|
if( disabledLayers.test( track->GetLayer() ) )
|
|
|
|
createMarker( track );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( auto module : board->Modules() )
|
|
|
|
{
|
2018-01-28 09:35:33 +00:00
|
|
|
module->RunOnChildren( [&]( BOARD_ITEM* aItem )
|
|
|
|
{
|
|
|
|
if( disabledLayers.test( aItem->GetLayer() ) )
|
|
|
|
createMarker( aItem );
|
|
|
|
} );
|
2018-07-04 08:23:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( auto zone : board->Zones() )
|
|
|
|
{
|
|
|
|
if( disabledLayers.test( zone->GetLayer() ) )
|
|
|
|
createMarker( zone );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
bool DRC::doTrackKeepoutDrc( TRACK* aRefSeg )
|
|
|
|
{
|
|
|
|
// Test keepout areas for vias, tracks and pads inside keepout areas
|
|
|
|
for( int ii = 0; ii < m_pcb->GetAreaCount(); ii++ )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* area = m_pcb->GetArea( ii );
|
|
|
|
|
|
|
|
if( !area->GetIsKeepout() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if( aRefSeg->Type() == PCB_TRACE_T )
|
|
|
|
{
|
2018-02-10 20:17:11 +00:00
|
|
|
if( !area->GetDoNotAllowTracks() )
|
2012-07-13 18:55:29 +00:00
|
|
|
continue;
|
|
|
|
|
2017-11-30 16:22:45 +00:00
|
|
|
if( !area->IsOnLayer( aRefSeg->GetLayer() ) )
|
2012-07-13 18:55:29 +00:00
|
|
|
continue;
|
|
|
|
|
2017-03-07 12:06:00 +00:00
|
|
|
if( area->Outline()->Distance( SEG( aRefSeg->GetStart(), aRefSeg->GetEnd() ),
|
2013-03-20 14:50:12 +00:00
|
|
|
aRefSeg->GetWidth() ) == 0 )
|
2012-07-13 18:55:29 +00:00
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
m_currentMarker = newMarker( aRefSeg, area, DRCE_TRACK_INSIDE_KEEPOUT );
|
2012-07-13 18:55:29 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( aRefSeg->Type() == PCB_VIA_T )
|
|
|
|
{
|
2018-02-10 20:17:11 +00:00
|
|
|
if( !area->GetDoNotAllowVias() )
|
2012-07-13 18:55:29 +00:00
|
|
|
continue;
|
|
|
|
|
2017-11-30 16:22:45 +00:00
|
|
|
auto viaLayers = aRefSeg->GetLayerSet();
|
|
|
|
|
|
|
|
if( !area->CommonLayerExists( viaLayers ) )
|
2012-07-13 18:55:29 +00:00
|
|
|
continue;
|
|
|
|
|
2013-03-20 14:50:12 +00:00
|
|
|
if( area->Outline()->Distance( aRefSeg->GetPosition() ) < aRefSeg->GetWidth()/2 )
|
2012-07-13 18:55:29 +00:00
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
m_currentMarker = newMarker( aRefSeg, area, DRCE_VIA_INSIDE_KEEPOUT );
|
2012-07-13 18:55:29 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_limit )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
const static LSET all_cu = LSET::AllCuMask();
|
|
|
|
|
|
|
|
LSET layerMask = aRefPad->GetLayerSet() & all_cu;
|
2010-09-18 17:55:08 +00:00
|
|
|
|
2010-10-28 13:02:07 +00:00
|
|
|
/* used to test DRC pad to holes: this dummy pad has the size and shape of the hole
|
|
|
|
* to test pad to pad hole DRC, using the pad to pad DRC test function.
|
|
|
|
* Therefore, this dummy pad is a circle or an oval.
|
|
|
|
* A pad must have a parent because some functions expect a non null parent
|
|
|
|
* to find the parent board, and some other data
|
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
MODULE dummymodule( m_pcb ); // Creates a dummy parent
|
|
|
|
D_PAD dummypad( &dummymodule );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
// Ensure the hole is on all copper layers
|
2014-06-24 16:17:18 +00:00
|
|
|
dummypad.SetLayerSet( all_cu | dummypad.GetLayerSet() );
|
2012-02-19 04:02:19 +00:00
|
|
|
|
|
|
|
// Use the minimal local clearance 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)
|
|
|
|
dummypad.SetLocalClearance( 1 );
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
for( D_PAD** pad_list = aStart; pad_list<aEnd; ++pad_list )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
|
|
|
D_PAD* pad = *pad_list;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
if( pad == aRefPad )
|
|
|
|
continue;
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// We can stop the test when pad->GetPosition().x > x_limit
|
2009-09-10 15:22:26 +00:00
|
|
|
// because the list is sorted by X values
|
2012-02-19 04:02:19 +00:00
|
|
|
if( pad->GetPosition().x > x_limit )
|
2007-12-01 03:42:52 +00:00
|
|
|
break;
|
|
|
|
|
2015-09-30 16:42:28 +00:00
|
|
|
// No problem if pads which are on copper layers are on different copper layers,
|
|
|
|
// (pads can be only on a technical layer, to build complex pads)
|
2011-09-17 01:22:26 +00:00
|
|
|
// but their hole (if any ) can create DRC error because they are on all
|
2009-09-10 15:22:26 +00:00
|
|
|
// copper layers, so we test them
|
2015-09-30 16:42:28 +00:00
|
|
|
if( ( pad->GetLayerSet() & layerMask ) == 0 &&
|
|
|
|
( pad->GetLayerSet() & all_cu ) != 0 &&
|
|
|
|
( aRefPad->GetLayerSet() & all_cu ) != 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()
|
2012-02-19 04:02:19 +00:00
|
|
|
&& pad->GetDrillSize() == aRefPad->GetDrillSize()
|
|
|
|
&& pad->GetDrillShape() == aRefPad->GetDrillShape() )
|
2009-03-23 19:54:15 +00:00
|
|
|
{
|
2015-08-23 19:40:33 +00:00
|
|
|
if( aRefPad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
|
2009-03-23 19:54:15 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-09-17 01:22:26 +00:00
|
|
|
// for oval holes: must also have the same orientation
|
2012-02-19 04:02:19 +00:00
|
|
|
if( pad->GetOrientation() == aRefPad->GetOrientation() )
|
2009-03-23 19:54:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Here, we must test clearance between holes and pads
|
2011-09-17 01:22:26 +00:00
|
|
|
* dummy pad size and shape is adjusted to pad drill size and shape
|
2009-03-23 19:54:15 +00:00
|
|
|
*/
|
2012-02-19 04:02:19 +00:00
|
|
|
if( pad->GetDrillSize().x )
|
2009-03-23 19:54:15 +00:00
|
|
|
{
|
2011-09-17 01:22:26 +00:00
|
|
|
// pad under testing has a hole, test this hole against pad reference
|
2010-09-15 14:53:33 +00:00
|
|
|
dummypad.SetPosition( pad->GetPosition() );
|
2012-02-19 04:02:19 +00:00
|
|
|
dummypad.SetSize( pad->GetDrillSize() );
|
2015-08-23 19:40:33 +00:00
|
|
|
dummypad.SetShape( pad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG ?
|
|
|
|
PAD_SHAPE_OVAL : PAD_SHAPE_CIRCLE );
|
2012-02-19 04:02:19 +00:00
|
|
|
dummypad.SetOrientation( pad->GetOrientation() );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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!
|
2018-08-27 13:50:50 +00:00
|
|
|
m_currentMarker = newMarker( pad, aRefPad, DRCE_HOLE_NEAR_PAD );
|
2009-03-23 19:54:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( aRefPad->GetDrillSize().x ) // pad reference has a hole
|
2009-03-23 19:54:15 +00:00
|
|
|
{
|
2010-09-15 14:53:33 +00:00
|
|
|
dummypad.SetPosition( aRefPad->GetPosition() );
|
2012-02-19 04:02:19 +00:00
|
|
|
dummypad.SetSize( aRefPad->GetDrillSize() );
|
2015-08-23 19:40:33 +00:00
|
|
|
dummypad.SetShape( aRefPad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG ?
|
|
|
|
PAD_SHAPE_OVAL : PAD_SHAPE_CIRCLE );
|
2012-02-19 04:02:19 +00:00
|
|
|
dummypad.SetOrientation( aRefPad->GetOrientation() );
|
2011-09-17 01:22:26 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
if( !checkClearancePadToPad( pad, &dummypad ) )
|
2009-03-23 19:54:15 +00:00
|
|
|
{
|
2011-09-17 01:22:26 +00:00
|
|
|
// here we have a drc error on aRefPad!
|
2018-08-27 13:50:50 +00:00
|
|
|
m_currentMarker = newMarker( aRefPad, pad, DRCE_HOLE_NEAR_PAD );
|
2009-03-23 19:54:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
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
|
|
|
|
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)
|
2014-02-25 10:47:27 +00:00
|
|
|
if( pad->GetNetCode() && ( aRefPad->GetNetCode() == pad->GetNetCode() ) )
|
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.
|
2011-12-16 17:03:25 +00:00
|
|
|
if( pad->PadNameEqual( aRefPad ) )
|
2009-09-10 15:22:26 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-04-15 18:15:22 +00:00
|
|
|
|
2016-01-26 00:33:40 +00:00
|
|
|
// if either pad has no drill and is only on technical layers, not a clearance violation
|
|
|
|
if( ( ( pad->GetLayerSet() & layerMask ) == 0 && !pad->GetDrillSize().x ) ||
|
|
|
|
( ( aRefPad->GetLayerSet() & layerMask ) == 0 && !aRefPad->GetDrillSize().x ) )
|
|
|
|
{
|
|
|
|
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!
|
2018-08-27 13:50:50 +00:00
|
|
|
m_currentMarker = newMarker( aRefPad, pad, DRCE_PAD_NEAR_PAD1 );
|
2007-12-01 03:42:52 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-03-16 17:09:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool DRC::doFootprintOverlappingDrc()
|
|
|
|
{
|
2017-03-19 15:38:30 +00:00
|
|
|
// Detects missing (or malformed) footprint courtyard,
|
|
|
|
// and for footprint with courtyard, courtyards overlap.
|
2017-03-16 17:09:33 +00:00
|
|
|
wxString msg;
|
|
|
|
bool success = true;
|
|
|
|
|
|
|
|
// Update courtyard polygons, and test for missing courtyard definition:
|
|
|
|
for( MODULE* footprint = m_pcb->m_Modules; footprint; footprint = footprint->Next() )
|
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
wxPoint pos = footprint->GetPosition();
|
2017-03-26 06:13:23 +00:00
|
|
|
bool is_ok = footprint->BuildPolyCourtyard();
|
2017-03-16 17:09:33 +00:00
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
if( !is_ok && m_pcb->GetDesignSettings().m_ProhibitOverlappingCourtyards )
|
2017-03-19 15:38:30 +00:00
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
addMarkerToPcb( newMarker( pos, footprint, DRCE_MALFORMED_COURTYARD_IN_FOOTPRINT ) );
|
2017-03-19 15:38:30 +00:00
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
if( !m_pcb->GetDesignSettings().m_RequireCourtyards )
|
2017-03-19 15:38:30 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if( footprint->GetPolyCourtyardFront().OutlineCount() == 0 &&
|
|
|
|
footprint->GetPolyCourtyardBack().OutlineCount() == 0 &&
|
2017-03-26 06:13:23 +00:00
|
|
|
is_ok )
|
2017-03-16 17:09:33 +00:00
|
|
|
{
|
2018-08-27 13:50:50 +00:00
|
|
|
addMarkerToPcb( newMarker( pos, footprint, DRCE_MISSING_COURTYARD_IN_FOOTPRINT ) );
|
2017-03-16 17:09:33 +00:00
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
if( !m_pcb->GetDesignSettings().m_ProhibitOverlappingCourtyards )
|
2017-03-16 17:09:33 +00:00
|
|
|
return success;
|
|
|
|
|
2017-03-19 15:38:30 +00:00
|
|
|
// Now test for overlapping on top layer:
|
|
|
|
SHAPE_POLY_SET courtyard; // temporary storage of the courtyard of current footprint
|
|
|
|
|
|
|
|
for( MODULE* footprint = m_pcb->m_Modules; footprint; footprint = footprint->Next() )
|
|
|
|
{
|
|
|
|
if( footprint->GetPolyCourtyardFront().OutlineCount() == 0 )
|
|
|
|
continue; // No courtyard defined
|
|
|
|
|
|
|
|
for( MODULE* candidate = footprint->Next(); candidate; candidate = candidate->Next() )
|
|
|
|
{
|
|
|
|
if( candidate->GetPolyCourtyardFront().OutlineCount() == 0 )
|
|
|
|
continue; // No courtyard defined
|
|
|
|
|
|
|
|
courtyard.RemoveAllContours();
|
|
|
|
courtyard.Append( footprint->GetPolyCourtyardFront() );
|
|
|
|
|
|
|
|
// Build the common area between footprint and the candidate:
|
2018-02-10 20:17:11 +00:00
|
|
|
courtyard.BooleanIntersection( candidate->GetPolyCourtyardFront(),
|
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2017-03-19 15:38:30 +00:00
|
|
|
|
|
|
|
// If no overlap, courtyard is empty (no common area).
|
|
|
|
// Therefore if a common polygon exists, this is a DRC error
|
|
|
|
if( courtyard.OutlineCount() )
|
|
|
|
{
|
|
|
|
//Overlap between footprint and candidate
|
2017-03-07 12:06:00 +00:00
|
|
|
VECTOR2I& pos = courtyard.Vertex( 0, 0, -1 );
|
2018-08-27 13:50:50 +00:00
|
|
|
addMarkerToPcb( newMarker( wxPoint( pos.x, pos.y ), footprint, candidate,
|
|
|
|
DRCE_OVERLAPPING_FOOTPRINTS ) );
|
2017-03-19 15:38:30 +00:00
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test for overlapping on bottom layer:
|
2017-03-16 17:09:33 +00:00
|
|
|
for( MODULE* footprint = m_pcb->m_Modules; footprint; footprint = footprint->Next() )
|
|
|
|
{
|
2017-03-19 15:38:30 +00:00
|
|
|
if( footprint->GetPolyCourtyardBack().OutlineCount() == 0 )
|
2017-03-16 17:09:33 +00:00
|
|
|
continue; // No courtyard defined
|
|
|
|
|
|
|
|
for( MODULE* candidate = footprint->Next(); candidate; candidate = candidate->Next() )
|
|
|
|
{
|
2017-03-19 15:38:30 +00:00
|
|
|
if( candidate->GetPolyCourtyardBack().OutlineCount() == 0 )
|
2017-03-16 17:09:33 +00:00
|
|
|
continue; // No courtyard defined
|
|
|
|
|
2017-03-19 15:38:30 +00:00
|
|
|
courtyard.RemoveAllContours();
|
|
|
|
courtyard.Append( footprint->GetPolyCourtyardBack() );
|
2017-03-16 17:09:33 +00:00
|
|
|
|
|
|
|
// Build the common area between footprint and the candidate:
|
2018-02-10 20:17:11 +00:00
|
|
|
courtyard.BooleanIntersection( candidate->GetPolyCourtyardBack(),
|
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2017-03-16 17:09:33 +00:00
|
|
|
|
|
|
|
// If no overlap, courtyard is empty (no common area).
|
|
|
|
// Therefore if a common polygon exists, this is a DRC error
|
|
|
|
if( courtyard.OutlineCount() )
|
|
|
|
{
|
|
|
|
//Overlap between footprint and candidate
|
2017-03-07 12:06:00 +00:00
|
|
|
VECTOR2I& pos = courtyard.Vertex( 0, 0, -1 );
|
2018-08-27 13:50:50 +00:00
|
|
|
addMarkerToPcb( newMarker( wxPoint( pos.x, pos.y ), footprint, candidate,
|
|
|
|
DRCE_OVERLAPPING_FOOTPRINTS ) );
|
2017-03-16 17:09:33 +00:00
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|