PANEL_BOARD_STACKUP: Ensure UI is re-linked to storage when importing

Fixes https://gitlab.com/kicad/code/kicad/-/issues/13835
This commit is contained in:
Jon Evans 2023-02-10 12:58:04 -05:00
parent 79d246b8fe
commit e2353a2849
2 changed files with 21 additions and 14 deletions

View File

@ -961,7 +961,7 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow,
}
void PANEL_SETUP_BOARD_STACKUP::rebuildLayerStackPanel()
void PANEL_SETUP_BOARD_STACKUP::rebuildLayerStackPanel( bool aRelinkItems )
{
wxWindowUpdateLocker locker( m_scGridWin );
m_scGridWin->Hide();
@ -974,7 +974,7 @@ void PANEL_SETUP_BOARD_STACKUP::rebuildLayerStackPanel()
m_controlItemsList.clear();
// Delete widgets (handled by the wxPanel parent)
for( BOARD_STACKUP_ROW_UI_ITEM ui_item: m_rowUiItemsList )
for( BOARD_STACKUP_ROW_UI_ITEM& ui_item: m_rowUiItemsList )
{
// This remove and delete the current ui_item.m_MaterialCtrl sizer
ui_item.m_MaterialCtrl->SetSizer( nullptr );
@ -1019,7 +1019,7 @@ void PANEL_SETUP_BOARD_STACKUP::rebuildLayerStackPanel()
// Now, rebuild the widget list from the new m_stackup items:
buildLayerStackPanel( false );
buildLayerStackPanel( false, aRelinkItems );
// Now enable/disable stackup items, according to the m_enabledLayers config
showOnlyActiveLayers();
@ -1029,17 +1029,22 @@ void PANEL_SETUP_BOARD_STACKUP::rebuildLayerStackPanel()
}
void PANEL_SETUP_BOARD_STACKUP::buildLayerStackPanel( bool aCreatedInitialStackup )
void PANEL_SETUP_BOARD_STACKUP::buildLayerStackPanel( bool aCreateInitialStackup,
bool aRelinkStackup )
{
// Build a full stackup for the dialog, with a active copper layer count
// = current board layer count to calculate a reasonable default stackup:
if( aCreatedInitialStackup )
if( aCreateInitialStackup || aRelinkStackup )
{
// Creates a full BOARD_STACKUP with 32 copper layers.
// extra layers will be hidden later.
// but if the number of layer is changed in the dialog, the corresponding
// widgets will be available with their previous values.
m_stackup.BuildDefaultStackupList( nullptr, m_brdSettings->GetCopperLayerCount() );
if( aCreateInitialStackup )
{
// Creates a full BOARD_STACKUP with 32 copper layers.
// extra layers will be hidden later.
// but if the number of layer is changed in the dialog, the corresponding
// widgets will be available with their previous values.
m_stackup.BuildDefaultStackupList( nullptr, m_brdSettings->GetCopperLayerCount() );
}
const BOARD_STACKUP& brd_stackup = m_brdSettings->GetStackupDescriptor();
// Now initialize all stackup items to the board values, when exist
@ -1304,7 +1309,7 @@ void PANEL_SETUP_BOARD_STACKUP::ImportSettingsFrom( BOARD* aBoard )
m_enabledLayers = m_board->GetEnabledLayers() & BOARD_STACKUP::StackupAllowedBrdLayers();
rebuildLayerStackPanel();
rebuildLayerStackPanel( true );
synchronizeWithBoard( true );
computeBoardThickness();

View File

@ -148,10 +148,11 @@ private:
* all copper layers and all tech layers that are supported by the stackup
* items not in the current board stackup will be not shown, but they are
* existing in list
* @param aCreatedInitialStackup = true to create a initial stackup list for the dialog
* @param aCreateInitialStackup = true to create a initial stackup list for the dialog
* @param aRelinkStackup = true to re-link m_stackup to m_brdSettings
* false to build the stackup panel from the existing stackup list.
*/
void buildLayerStackPanel( bool aCreatedInitialStackup );
void buildLayerStackPanel( bool aCreateInitialStackup = false, bool aRelinkStackup = false );
/** Synchronize the full stackup shown in m_fgGridSizer according to the stackup of the
* current board and optionally update the stackup params (thickness, color ... )
@ -171,8 +172,9 @@ private:
* If previous items are in list, remove old items
* New prms are added
* must be called after adding or deleting a dielectric parameter set
* @param aRelinkItems will recreate the links between m_stackup and m_brdSettings
*/
void rebuildLayerStackPanel();
void rebuildLayerStackPanel( bool aRelinkItems = false );
/** Transfer current UI settings to m_stackup but not to the board
*/