diff --git a/pcbnew/board_stackup_manager/panel_board_stackup.cpp b/pcbnew/board_stackup_manager/panel_board_stackup.cpp
index 619fb49916..4700f71610 100644
--- a/pcbnew/board_stackup_manager/panel_board_stackup.cpp
+++ b/pcbnew/board_stackup_manager/panel_board_stackup.cpp
@@ -80,6 +80,8 @@ PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( PAGED_DIALOG* aParent, PCB
m_brdSettings = &m_board->GetDesignSettings();
m_units = aFrame->GetUserUnits();
+ m_panelLayers->SetPhysicalStackupPanel( this );
+
m_enabledLayers = m_board->GetEnabledLayers() & BOARD_STACKUP::StackupAllowedBrdLayers();
// Calculates a good size for color swatches (icons) in this dialog
@@ -112,6 +114,14 @@ PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( PAGED_DIALOG* aParent, PCB
buildLayerStackPanel( true );
synchronizeWithBoard( true );
+
+ m_choiceCopperLayers->Bind( wxEVT_CHOICE,
+ [&]( wxCommandEvent )
+ {
+ updateCopperLayerCount();
+ showOnlyActiveLayers();
+ Layout();
+ } );
}
@@ -329,12 +339,34 @@ void PANEL_SETUP_BOARD_STACKUP::onUpdateThicknessValue( wxUpdateUIEvent& event )
}
+int PANEL_SETUP_BOARD_STACKUP::GetCopperLayerCount() const
+{
+ return ( m_choiceCopperLayers->GetSelection() + 1 ) * 2;
+}
+
+
+void PANEL_SETUP_BOARD_STACKUP::updateCopperLayerCount()
+{
+ int copperCount = GetCopperLayerCount();
+
+ wxASSERT( copperCount >= 2 );
+
+ m_enabledLayers |= LSET::ExternalCuMask();
+ m_enabledLayers &= ~LSET::InternalCuMask();
+
+ for( int i = 1; i < copperCount - 1; i++ )
+ m_enabledLayers.set( F_Cu + i );
+}
+
+
void PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard( bool aFullSync )
{
const BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
if( aFullSync )
{
+ m_choiceCopperLayers->SetSelection( ( m_board->GetCopperLayerCount() / 2 ) - 1 );
+
m_rbDielectricConstraint->SetSelection( brd_stackup.m_HasDielectricConstrains ? 1 : 0 );
m_choiceEdgeConn->SetSelection( brd_stackup.m_EdgeConnectorConstraints );
m_cbCastellatedPads->SetValue( brd_stackup.m_CastellatedPads );
@@ -1041,6 +1073,10 @@ bool PANEL_SETUP_BOARD_STACKUP::TransferDataFromWindow()
if( !transferDataFromUIToStackup() )
return false;
+ // NOTE: Copper layer count is transferred via PANEL_SETUP_LAYERS even though it is configured
+ // on this page, because the logic for confirming deletion of board items on deleted layers is
+ // on that panel and it doesn't make sense to split it up.
+
BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
STRING_FORMATTER old_stackup;
diff --git a/pcbnew/board_stackup_manager/panel_board_stackup.h b/pcbnew/board_stackup_manager/panel_board_stackup.h
index 79bba5ee7d..24a603d918 100644
--- a/pcbnew/board_stackup_manager/panel_board_stackup.h
+++ b/pcbnew/board_stackup_manager/panel_board_stackup.h
@@ -93,6 +93,9 @@ public:
*/
void OnLayersOptionsChanged( LSET aNewLayerSet );
+ /// @return the number of copper layers configured for the board stackup
+ int GetCopperLayerCount() const;
+
/// @return the BOARD_STACKUP_ITEM managed by the row aRow
BOARD_STACKUP_ITEM* GetStackupItem( int aRow );
/// @return the BOARD_STACKUP_ITEM sublayermanaged by the row aRow
@@ -170,6 +173,11 @@ private:
*/
bool transferDataFromUIToStackup();
+ /**
+ * Updates the enabled copper layers when the dropdown is changed
+ */
+ void updateCopperLayerCount();
+
void onUpdateThicknessValue( wxUpdateUIEvent& event ) override;
void onColorSelected( wxCommandEvent& event );
void onMaterialChange( wxCommandEvent& event );
diff --git a/pcbnew/board_stackup_manager/panel_board_stackup_base.cpp b/pcbnew/board_stackup_manager/panel_board_stackup_base.cpp
index 504138132e..bb2e88ca35 100644
--- a/pcbnew/board_stackup_manager/panel_board_stackup_base.cpp
+++ b/pcbnew/board_stackup_manager/panel_board_stackup_base.cpp
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version 3.9.0 Dec 30 2020)
+// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@@ -156,6 +156,23 @@ PANEL_SETUP_BOARD_STACKUP_BASE::PANEL_SETUP_BOARD_STACKUP_BASE( wxWindow* parent
wxBoxSizer* bSizerBrdThickness;
bSizerBrdThickness = new wxBoxSizer( wxHORIZONTAL );
+ m_lblCopperLayers = new wxStaticText( this, wxID_ANY, _("Copper layers:"), wxDefaultPosition, wxDefaultSize, 0 );
+ m_lblCopperLayers->Wrap( -1 );
+ m_lblCopperLayers->SetToolTip( _("Select the number of copper layers in the stackup") );
+
+ bSizerBrdThickness->Add( m_lblCopperLayers, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+
+ wxString m_choiceCopperLayersChoices[] = { _("2"), _("4"), _("6"), _("8"), _("10"), _("12"), _("14"), _("16"), _("18"), _("20"), _("22"), _("24"), _("26"), _("28"), _("30"), _("32") };
+ int m_choiceCopperLayersNChoices = sizeof( m_choiceCopperLayersChoices ) / sizeof( wxString );
+ m_choiceCopperLayers = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceCopperLayersNChoices, m_choiceCopperLayersChoices, 0 );
+ m_choiceCopperLayers->SetSelection( 0 );
+ m_choiceCopperLayers->SetToolTip( _("Select the number of copper layers in the stackup") );
+
+ bSizerBrdThickness->Add( m_choiceCopperLayers, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
+
+
+ bSizerBrdThickness->Add( 0, 0, 1, wxEXPAND, 5 );
+
m_staticTextCT = new wxStaticText( this, wxID_ANY, _("Board thickness from stackup:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT );
m_staticTextCT->Wrap( -1 );
bSizerBrdThickness->Add( m_staticTextCT, 2, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
diff --git a/pcbnew/board_stackup_manager/panel_board_stackup_base.fbp b/pcbnew/board_stackup_manager/panel_board_stackup_base.fbp
index c0f856bea0..03c2606dee 100644
--- a/pcbnew/board_stackup_manager/panel_board_stackup_base.fbp
+++ b/pcbnew/board_stackup_manager/panel_board_stackup_base.fbp
@@ -14,7 +14,6 @@
panel_board_stackup_base
1000
none
-
1
PANEL_BOARD_SETUP_BASE
@@ -26,7 +25,6 @@
1
1
UI
- 0
0
0