Better safety around layersets.

This commit is contained in:
Jeff Young 2022-03-21 18:18:39 +00:00
parent 40e0c8257d
commit cf611f1742
5 changed files with 22 additions and 11 deletions

View File

@ -177,10 +177,13 @@ void DIALOG_FOOTPRINT_CHECKER::OnSelectItem( wxDataViewEvent& aEvent )
if( node && item )
{
PCB_LAYER_ID principalLayer = item->GetLayerSet().Seq()[0];
PCB_LAYER_ID principalLayer = UNDEFINED_LAYER;
LSET violationLayers;
std::shared_ptr<RC_ITEM> rc_item = node->m_RcItem;
if( item->GetLayerSet().count() > 0 )
principalLayer = item->GetLayerSet().Seq().front();
if( rc_item->GetErrorCode() == DRCE_MALFORMED_COURTYARD )
{
BOARD_ITEM* a = board->GetItem( rc_item->GetMainItemID() );

View File

@ -201,21 +201,25 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run()
auto checkDisallow =
[&]( BOARD_ITEM* item )
{
auto constraint = m_drcEngine->EvalRules( DISALLOW_CONSTRAINT, item, nullptr,
UNDEFINED_LAYER );
DRC_CONSTRAINT constraint = m_drcEngine->EvalRules( DISALLOW_CONSTRAINT, item,
nullptr, UNDEFINED_LAYER );
if( constraint.m_DisallowFlags && constraint.GetSeverity() != RPT_SEVERITY_IGNORE )
{
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_ALLOWED_ITEMS );
m_msg.Printf( drcItem->GetErrorText() + wxS( " (%s)" ),
constraint.GetName() );
m_msg.Printf( drcItem->GetErrorText() + wxS( " (%s)" ), constraint.GetName() );
drcItem->SetErrorMessage( m_msg );
drcItem->SetItems( item );
drcItem->SetViolatingRule( constraint.GetParentRule() );
reportViolation( drcItem, item->GetPosition(), item->GetLayerSet().Seq()[0] );
PCB_LAYER_ID layer = UNDEFINED_LAYER;
if( item->GetLayerSet().count() )
layer = item->GetLayerSet().Seq().front();
reportViolation( drcItem, item->GetPosition(), layer );
}
};

View File

@ -421,11 +421,13 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
if( IsPcbLayer( aLayer ) && parentFP->GetPrivateLayers().test( aLayer ) )
return false;
}
else
else if( item->GetLayerSet().count() == 1 )
{
// For single-layer objects, exclude all layers including ancillary layers
// such as holes, netnames, etc.
if( parentFP->GetPrivateLayers().test( item->GetLayerSet().Seq()[0] ) )
PCB_LAYER_ID singleLayer = item->GetLayerSet().Seq()[0];
if( parentFP->GetPrivateLayers().test( singleLayer ) )
return false;
}
}

View File

@ -388,9 +388,11 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent )
if( copperIntersection.any() && zone && pad && zone->GetNetCode() == pad->GetNetCode() )
{
PCB_LAYER_ID layer = active;
PCB_LAYER_ID layer = UNDEFINED_LAYER;
if( !zone->IsOnLayer( active ) )
if( zone->IsOnLayer( active ) )
layer = active;
else if( zone->GetLayerSet().count() > 0 )
layer = zone->GetLayerSet().Seq().front();
r = m_inspectClearanceDialog->AddPage( _( "Zone" ) );

View File

@ -884,7 +884,7 @@ void ZONE::HatchBorder()
int hatch_line_len = m_borderHatchPitch;
// To have a better look, give a slope depending on the layer
int layer = GetLayerSet().Seq()[0];
int layer = GetFirstLayer();
int slope_flag = (layer & 1) ? 1 : -1; // 1 or -1
double slope = 0.707106 * slope_flag; // 45 degrees slope
int max_a, min_a;