Allow rules to operate on hole when hole-to-track testing.

This commit is contained in:
Jeff Young 2020-06-03 12:11:50 +01:00
parent 3bd4c0c5dc
commit d2cd4de280
3 changed files with 26 additions and 8 deletions

View File

@ -170,7 +170,7 @@ bool BOARD_CONNECTED_ITEM::GetRuleClearance( BOARD_ITEM* aItem, int* aClearance,
if( rule )
{
if( aSource )
*aSource = wxString::Format( _( "'%s' rule clearance" ), rule->m_Name );
*aSource = wxString::Format( _( "'%s' rule" ), rule->m_Name );
*aClearance = rule->m_Clearance.Min;
return true;

View File

@ -1217,12 +1217,9 @@ bool DRC::doPadToPadsDrc( BOARD_COMMIT& aCommit, D_PAD* aRefPad, D_PAD** aStart,
LSET layerMask = aRefPad->GetLayerSet() & all_cu;
/* 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
*/
// For hole testing we use a dummy pad which is given the shape of the hole. Note that
// this pad must have a parent because some functions expect a non-null parent to find
// the pad's board.
MODULE dummymodule( m_pcb ); // Creates a dummy parent
D_PAD dummypad( &dummymodule );

View File

@ -381,7 +381,28 @@ void DRC::doTrackDrc( BOARD_COMMIT& aCommit, TRACK* aRefSeg, TRACKS::iterator aS
if( pad->GetDrillSize().x > 0 )
{
int minClearance = aRefSeg->GetClearance( nullptr, &m_clearanceSource );
// For hole testing we use a dummy pad which is a copy of the current pad
// shrunk down to nothing but its hole.
D_PAD dummypad( *pad );
dummypad.SetSize( pad->GetDrillSize() );
dummypad.SetShape( pad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG ?
PAD_SHAPE_OVAL : PAD_SHAPE_CIRCLE );
// Ensure the hole is on all copper layers
const static LSET all_cu = LSET::AllCuMask();
dummypad.SetLayerSet( all_cu | dummypad.GetLayerSet() );
int minClearance;
DRC_RULE* rule = GetRule( aRefSeg, &dummypad, CLEARANCE_CONSTRAINT );
if( rule )
{
m_clearanceSource = wxString::Format( _( "'%s' rule" ), rule->m_Name );
minClearance = rule->m_Clearance.Min;
}
else
{
minClearance = aRefSeg->GetClearance( nullptr, &m_clearanceSource );
}
/* Treat an oval hole as a line segment along the hole's major axis,
* shortened by half its minor axis.