From 7978c8c2911ce3b02780a5f7e6163568dd2b36d2 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 17 Feb 2022 23:54:15 +0000 Subject: [PATCH] Allow Rule Areas on all physical layers. Required to do things like modify silk_clearance rules. (cherry picked from commit 8f670552a66046b3cd3d8ece22ba66ac07151612) --- pcbnew/dialogs/dialog_copper_zones.cpp | 4 ++- .../dialog_non_copper_zones_properties.cpp | 5 ++- .../dialogs/dialog_rule_area_properties.cpp | 11 ++++--- pcbnew/pcb_expr_evaluator.cpp | 7 ++-- pcbnew/zone.cpp | 32 ------------------- pcbnew/zone_settings.cpp | 8 ++--- pcbnew/zone_settings.h | 20 +++--------- 7 files changed, 25 insertions(+), 62 deletions(-) diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index 553e1609fb..83b811e11e 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -183,7 +183,9 @@ DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* m_ptr = aSettings; m_settings = *aSettings; - m_settings.SetupLayersList( m_layers, m_Parent, true ); + m_settings.SetupLayersList( m_layers, m_Parent, + LSET::AllCuMask( aParent->GetBoard()->GetCopperLayerCount() ), + false ); m_settingsExported = false; m_currentlySelectedNetcode = INVALID_NET_CODE; diff --git a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp index ccf0e2fd5e..951b43dc28 100644 --- a/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp +++ b/pcbnew/dialogs/dialog_non_copper_zones_properties.cpp @@ -81,7 +81,10 @@ DIALOG_NON_COPPER_ZONES_EDITOR::DIALOG_NON_COPPER_ZONES_EDITOR( PCB_BASE_FRAME* m_ptr = aSettings; m_settings = *aSettings; - m_settings.SetupLayersList( m_layers, m_parent, false ); + + bool fpEditorMode = m_parent->IsType( FRAME_FOOTPRINT_EDITOR ); + + m_settings.SetupLayersList( m_layers, m_parent, LSET::AllNonCuMask(), fpEditorMode ); m_sdbSizerButtonsOK->SetDefault(); diff --git a/pcbnew/dialogs/dialog_rule_area_properties.cpp b/pcbnew/dialogs/dialog_rule_area_properties.cpp index a785c3f465..e641cb136d 100644 --- a/pcbnew/dialogs/dialog_rule_area_properties.cpp +++ b/pcbnew/dialogs/dialog_rule_area_properties.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.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 @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -73,10 +72,12 @@ DIALOG_RULE_AREA_PROPERTIES::DIALOG_RULE_AREA_PROPERTIES( PCB_BASE_FRAME* aParen m_ptr = aSettings; m_zonesettings = *aSettings; - m_isFpEditor = dynamic_cast( aParent ) != nullptr; + m_isFpEditor = m_parent->IsType( FRAME_FOOTPRINT_EDITOR ); - bool fpEditorMode = m_parent->IsType( FRAME_FOOTPRINT_EDITOR ); - m_zonesettings.SetupLayersList( m_layers, m_parent, true, fpEditorMode ); + BOARD* board = m_parent->GetBoard(); + LSET layers = LSET::AllBoardTechMask() | LSET::AllCuMask( board->GetCopperLayerCount() ); + + m_zonesettings.SetupLayersList( m_layers, m_parent, layers, m_isFpEditor ); m_sdbSizerButtonsOK->SetDefault(); diff --git a/pcbnew/pcb_expr_evaluator.cpp b/pcbnew/pcb_expr_evaluator.cpp index 91559ef58d..15764bccb1 100644 --- a/pcbnew/pcb_expr_evaluator.cpp +++ b/pcbnew/pcb_expr_evaluator.cpp @@ -565,12 +565,13 @@ bool calcIsInsideArea( BOARD_ITEM* aItem, const EDA_RECT& aItemBBox, PCB_EXPR_CO } else { - if( aCtx->GetLayer() != UNDEFINED_LAYER - && !( aArea->GetLayerSet().Contains( aCtx->GetLayer() ) ) ) + PCB_LAYER_ID layer = aCtx->GetLayer(); + + if( layer != UNDEFINED_LAYER && !( aArea->GetLayerSet().Contains( layer ) ) ) return false; if( !shape ) - shape = aItem->GetEffectiveShape( aCtx->GetLayer() ); + shape = aItem->GetEffectiveShape( layer ); return areaOutline.Collide( shape.get() ); } diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 181a2a4d64..450d6dc0a7 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -249,12 +249,6 @@ void ZONE::SetLayer( PCB_LAYER_ID aLayer ) void ZONE::SetLayerSet( LSET aLayerSet ) { - if( GetIsRuleArea() ) - { - // Rule areas can only exist on copper layers - aLayerSet &= LSET::AllCuMask(); - } - if( aLayerSet.count() == 0 ) return; @@ -653,32 +647,6 @@ void ZONE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& // and filled polygons can explain the display and DRC calculation time: msg.Printf( wxT( "%d" ), (int) m_borderHatchLines.size() ); aList.emplace_back( MSG_PANEL_ITEM( _( "HatchBorder Lines" ), msg ) ); - - PCB_LAYER_ID layer = m_layer; - - // NOTE: This brings in dependence on PCB_EDIT_FRAME to the qa tests, which isn't ideal. - // TODO: Figure out a way for items to know the active layer without the whole edit frame? -#if 0 - if( PCB_EDIT_FRAME* pcbframe = dynamic_cast( aFrame ) ) - { - if( m_FilledPolysList.count( pcbframe->GetActiveLayer() ) ) - layer = pcbframe->GetActiveLayer(); - } -#endif - - if( !GetIsRuleArea() ) - { - auto layer_it = m_FilledPolysList.find( layer ); - - if( layer_it == m_FilledPolysList.end() ) - layer_it = m_FilledPolysList.begin(); - - if( layer_it != m_FilledPolysList.end() ) - { - msg.Printf( wxT( "%d" ), layer_it->second.TotalVertices() ); - aList.emplace_back( MSG_PANEL_ITEM( _( "Corner Count" ), msg ) ); - } - } } diff --git a/pcbnew/zone_settings.cpp b/pcbnew/zone_settings.cpp index c0ac120cfa..ccaa55a278 100644 --- a/pcbnew/zone_settings.cpp +++ b/pcbnew/zone_settings.cpp @@ -192,16 +192,14 @@ const static wxSize CHECKERBOARD_SIZE( 8, 8 ); // A helper for setting up a dialog list for specifying zone layers. Used by all three // zone settings dialogs. void ZONE_SETTINGS::SetupLayersList( wxDataViewListCtrl* aList, PCB_BASE_FRAME* aFrame, - bool aShowCopper, bool aFpEditorMode ) + LSET aLayers, bool aFpEditorMode ) { BOARD* board = aFrame->GetBoard(); COLOR4D backgroundColor = aFrame->GetColorSettings()->GetColor( LAYER_PCB_BACKGROUND ); - LSET layers = aShowCopper ? LSET::AllCuMask( board->GetCopperLayerCount() ) - : LSET::AllNonCuMask(); // In the Footprint Editor In1_Cu is used as a proxy for "all inner layers" if( aFpEditorMode ) - layers.set( In1_Cu ); + aLayers.set( In1_Cu ); wxDataViewColumn* checkColumn = aList->AppendToggleColumn( wxEmptyString ); wxDataViewColumn* layerColumn = aList->AppendIconTextColumn( wxEmptyString ); @@ -210,7 +208,7 @@ void ZONE_SETTINGS::SetupLayersList( wxDataViewListCtrl* aList, PCB_BASE_FRAME* int textWidth = 0; - for( LSEQ layer = layers.UIOrder(); layer; ++layer ) + for( LSEQ layer = aLayers.UIOrder(); layer; ++layer ) { PCB_LAYER_ID layerID = *layer; wxString layerName = board->GetLayerName( layerID ); diff --git a/pcbnew/zone_settings.h b/pcbnew/zone_settings.h index 671b8ed7b1..c80f7c53f2 100644 --- a/pcbnew/zone_settings.h +++ b/pcbnew/zone_settings.h @@ -140,11 +140,10 @@ public: * A helper routine for the various zone dialogs (copper, non-copper, keepout). * @param aList the wxDataViewListCtrl to populate * @param aFrame the parent editor frame - * @param aShowCopper indicates whether copper or technical layers should be shown - * @param aFpEditorMode true to show (when aShowCopper = true) the option: all inner layers + * @param aFpEditorMode true to show a single "Inner Layers" item for all inner copper layers */ - void SetupLayersList( wxDataViewListCtrl* aList, PCB_BASE_FRAME* aFrame, - bool aShowCopper, bool aFpEditorMode = false ); + void SetupLayersList( wxDataViewListCtrl* aList, PCB_BASE_FRAME* aFrame, LSET aLayers, + bool aFpEditorMode ); /** * Function ExportSetting @@ -158,22 +157,13 @@ public: void ExportSetting( ZONE& aTarget, bool aFullExport = true ) const; void SetCornerSmoothingType( int aType) { m_cornerSmoothingType = aType; } - int GetCornerSmoothingType() const { return m_cornerSmoothingType; } void SetCornerRadius( int aRadius ); - unsigned int GetCornerRadius() const { return m_cornerRadius; } - ZONE_CONNECTION GetPadConnection() const - { - return m_padConnection; - } - - void SetPadConnection( ZONE_CONNECTION aPadConnection ) - { - m_padConnection = aPadConnection; - } + ZONE_CONNECTION GetPadConnection() const { return m_padConnection; } + void SetPadConnection( ZONE_CONNECTION aPadConnection ) { m_padConnection = aPadConnection; } /** * Accessors to parameters used in Rule Area zones: