From 74fc8f6db02e86bb4e6a6ba5484b574f4ae077f3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 31 Jul 2023 18:35:38 +0200 Subject: [PATCH] APPEARANCE_CONTROLS, preset layers: re-allow storing object visibility in a User preset, and use the last defined object visibility when switching to a builtin preset From master branch Fixes #15282 https://gitlab.com/kicad/code/kicad/-/issues/15282 --- pcbnew/widgets/appearance_controls.cpp | 19 ++++++++++++++++++- pcbnew/widgets/appearance_controls.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index 38e1a679ab..12bde59a31 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -394,6 +394,10 @@ LAYER_PRESET APPEARANCE_CONTROLS::presetBack( _HKI( "Back Layers" ), LAYER_PRESET APPEARANCE_CONTROLS::presetBackAssembly( _HKI( "Back Assembly View" ), LSET::BackAssembly().set( Edge_Cuts ), GAL_SET::DefaultVisible(), B_SilkS ); +// this one is only used to store the object visibility settings of the last used +// built-in layer preset +LAYER_PRESET APPEARANCE_CONTROLS::m_lastBuiltinPreset; + APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwner, bool aFpEditorMode ) : @@ -2693,6 +2697,14 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent ) return; } + // Store the objects visibility settings if the presedt is not a user preset, + // to be reused when selecting a new built-in layer preset, even if a previous + // user preset has changed the object visibility + if( !m_currentPreset || m_currentPreset->readOnly ) + { + m_lastBuiltinPreset.renderLayers = getVisibleObjects(); + } + LAYER_PRESET* preset = static_cast( m_cbLayerPresets->GetClientData( index ) ); m_currentPreset = preset; @@ -2702,7 +2714,12 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent ) { // Change board layers visibility, but do not change objects visibility LAYER_PRESET curr_layers_choice = *preset; - curr_layers_choice.renderLayers = getVisibleObjects(); + + // For predefined presets that do not manage objects visibility, use + // the objects visibility settings of the last used predefined preset. + if( curr_layers_choice.readOnly ) + curr_layers_choice.renderLayers = m_lastBuiltinPreset.renderLayers; + doApplyLayerPreset( curr_layers_choice ); } diff --git a/pcbnew/widgets/appearance_controls.h b/pcbnew/widgets/appearance_controls.h index eef0987d4c..37d5ba176a 100644 --- a/pcbnew/widgets/appearance_controls.h +++ b/pcbnew/widgets/appearance_controls.h @@ -430,6 +430,9 @@ private: static LAYER_PRESET presetFrontAssembly; static LAYER_PRESET presetBack; static LAYER_PRESET presetBackAssembly; + // a LAYER_PRESET used only to store the objects visibility of the + // last selected built-in LAYER_PRESET preset + static LAYER_PRESET m_lastBuiltinPreset; int m_pointSize;