DRC checks for keepout zones work on all layers

This commit is contained in:
Oliver Walters 2017-09-23 14:53:34 +10:00 committed by jean-pierre charras
parent 2895030cfa
commit 7e0fa329d0
4 changed files with 38 additions and 8 deletions

View File

@ -195,6 +195,14 @@ bool ZONE_CONTAINER::IsOnCopperLayer() const
}
bool ZONE_CONTAINER::CommonLayerExists( const LSET aLayerSet ) const
{
auto common = GetLayerSet() & aLayerSet;
return common.size() > 0;
}
void ZONE_CONTAINER::SetLayer( PCB_LAYER_ID aLayer )
{
SetLayerSet( LSET( aLayer ) );

View File

@ -182,6 +182,12 @@ public:
*/
bool IsOnCopperLayer() const;
/**
* Function CommonLayerExist
* Test if this zone shares a common layer with the given layer set
*/
bool CommonLayerExists( const LSET aLayerSet ) const;
virtual void SetLayer( PCB_LAYER_ID aLayer ) override;
virtual PCB_LAYER_ID GetLayer() const override;

View File

@ -621,7 +621,9 @@ void DRC::testKeepoutAreas()
ZONE_CONTAINER* area = m_pcb->GetArea( ii );
if( !area->GetIsKeepout() )
{
continue;
}
for( TRACK* segm = m_pcb->m_Track; segm != NULL; segm = segm->Next() )
{
@ -630,7 +632,8 @@ void DRC::testKeepoutAreas()
if( ! area->GetDoNotAllowTracks() )
continue;
if( segm->GetLayer() != area->GetLayer() )
// Ignore if the keepout zone is not on the same layer
if( !area->IsOnLayer( segm->GetLayer() ) )
continue;
if( area->Outline()->Distance( SEG( segm->GetStart(), segm->GetEnd() ),
@ -646,7 +649,9 @@ void DRC::testKeepoutAreas()
if( ! area->GetDoNotAllowVias() )
continue;
if( ! ((VIA*)segm)->IsOnLayer( area->GetLayer() ) )
auto viaLayers = segm->GetLayerSet();
if( !area->CommonLayerExists( viaLayers ) )
continue;
if( area->Outline()->Distance( segm->GetPosition() ) < segm->GetWidth()/2 )
@ -801,7 +806,7 @@ bool DRC::doTrackKeepoutDrc( TRACK* aRefSeg )
if( ! area->GetDoNotAllowTracks() )
continue;
if( aRefSeg->GetLayer() != area->GetLayer() )
if( !area->IsOnLayer( aRefSeg->GetLayer() ) )
continue;
if( area->Outline()->Distance( SEG( aRefSeg->GetStart(), aRefSeg->GetEnd() ),
@ -817,7 +822,9 @@ bool DRC::doTrackKeepoutDrc( TRACK* aRefSeg )
if( ! area->GetDoNotAllowVias() )
continue;
if( ! ((VIA*)aRefSeg)->IsOnLayer( area->GetLayer() ) )
auto viaLayers = aRefSeg->GetLayerSet();
if( !area->CommonLayerExists( viaLayers ) )
continue;
if( area->Outline()->Distance( aRefSeg->GetPosition() ) < aRefSeg->GetWidth()/2 )

View File

@ -127,12 +127,21 @@ void PCB_EDIT_FRAME::duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone )
// If the new zone is on the same layer as the the initial zone,
// do nothing
if( success && ( aZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
if( success )
{
DisplayErrorMessage( this,
_( "The duplicated zone cannot be on the same layer as the original zone." ) );
if( aZone->GetIsKeepout() && ( aZone->GetLayerSet() == zoneSettings.m_Layers ) )
{
DisplayErrorMessage(
this, _( "The duplicated zone cannot be on the same layers as the original zone." ) );
success = false;
}
else if( !aZone->GetIsKeepout() && ( aZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) )
{
DisplayErrorMessage(
this, _( "The duplicated zone cannot be on the same layer as the original zone." ) );
success = false;
}
}
if( success )
{