7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-04 23:05:30 +00:00

Don't bleed settings between 3D viewer and 3D footprint preview.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17353
This commit is contained in:
Jeff Young 2025-03-16 10:49:57 +00:00
parent 676dd4ceec
commit 533551f014
8 changed files with 75 additions and 38 deletions

View File

@ -805,6 +805,46 @@ std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetVisibleLayers() const
{
std::bitset<LAYER_3D_END> ret;
if( m_board->IsFootprintHolder() )
{
if( m_Cfg->m_Render.preview_show_board_body )
{
ret.set( LAYER_3D_BOARD, m_Cfg->m_Render.show_board_body );
ret.set( LAYER_3D_SOLDERMASK_TOP, m_Cfg->m_Render.show_soldermask_top );
ret.set( LAYER_3D_SOLDERMASK_BOTTOM, m_Cfg->m_Render.show_soldermask_bottom );
ret.set( LAYER_3D_SOLDERPASTE, m_Cfg->m_Render.show_solderpaste );
ret.set( LAYER_3D_ADHESIVE, m_Cfg->m_Render.show_adhesive );
}
ret.set( LAYER_3D_COPPER_TOP, true );
ret.set( LAYER_3D_COPPER_BOTTOM, true );
ret.set( LAYER_3D_SILKSCREEN_TOP, true );
ret.set( LAYER_3D_SILKSCREEN_BOTTOM, true );
ret.set( LAYER_3D_USER_COMMENTS, true );
ret.set( LAYER_3D_USER_DRAWINGS, true );
ret.set( LAYER_3D_USER_ECO1, true );
ret.set( LAYER_3D_USER_ECO2, true );
for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
ret.set( layer, true );
ret.set( LAYER_FP_REFERENCES, true );
ret.set( LAYER_FP_VALUES, true );
ret.set( LAYER_FP_TEXT, true );
ret.set( LAYER_3D_TH_MODELS, true );
ret.set( LAYER_3D_SMD_MODELS, true );
ret.set( LAYER_3D_VIRTUAL_MODELS, true );
ret.set( LAYER_3D_MODELS_NOT_IN_POS, true );
ret.set( LAYER_3D_MODELS_MARKED_DNP, true );
ret.set( LAYER_3D_BOUNDING_BOXES, m_Cfg->m_Render.show_model_bbox );
ret.set( LAYER_3D_OFF_BOARD_SILK, m_Cfg->m_Render.show_off_board_silk );
ret.set( LAYER_3D_AXES, m_Cfg->m_Render.show_axis );
return ret;
}
ret.set( LAYER_3D_BOARD, m_Cfg->m_Render.show_board_body );
ret.set( LAYER_3D_COPPER_TOP, m_Cfg->m_Render.show_copper_top );
ret.set( LAYER_3D_COPPER_BOTTOM, m_Cfg->m_Render.show_copper_bottom );
@ -938,6 +978,12 @@ std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetDefaultVisibleLayers() const
}
bool BOARD_ADAPTER::GetUseBoardEditorCopperLayerColors() const
{
return m_Cfg->m_Render.use_board_editor_copper_colors && !m_board->IsFootprintHolder();
}
bool BOARD_ADAPTER::createBoardPolygon( wxString* aErrorMsg )
{
m_board_poly.RemoveAllContours();

View File

@ -119,6 +119,8 @@ public:
std::bitset<LAYER_3D_END> GetDefaultVisibleLayers() const;
void SetVisibleLayers( const std::bitset<LAYER_3D_END>& aLayers );
bool GetUseBoardEditorCopperLayerColors() const;
/**
* Function to be called by the render when it need to reload the settings for the board.
*

View File

@ -271,9 +271,7 @@ void RENDER_3D_OPENGL::setupMaterials()
void RENDER_3D_OPENGL::setLayerMaterial( PCB_LAYER_ID aLayerID )
{
EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS& cfg = m_boardAdapter.m_Cfg->m_Render;
if( cfg.use_board_editor_copper_colors && IsCopperLayer( aLayerID ) )
if( m_boardAdapter.GetUseBoardEditorCopperLayerColors() && IsCopperLayer( aLayerID ) )
{
COLOR4D copper_color = m_boardAdapter.m_BoardEditorColors[aLayerID];
m_materials.m_Copper.m_Diffuse = SFVEC3F( copper_color.r, copper_color.g,

View File

@ -401,6 +401,8 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() :
&m_Render.differentiate_plated_copper, false ) );
m_params.emplace_back( new PARAM<bool>( "render.use_board_editor_copper_colors",
&m_Render.use_board_editor_copper_colors, false ) );
m_params.emplace_back( new PARAM<bool>( "render.preview_show_board_body",
&m_Render.preview_show_board_body, true ) );
m_params.emplace_back( new PARAM<bool>( "camera.animation_enabled",
&m_Camera.animation_enabled, true ) );
m_params.emplace_back( new PARAM<int>( "camera.moving_speed_multiplier",

View File

@ -152,21 +152,19 @@ public:
bool subtract_mask_from_silk;
bool clip_silk_on_via_annuli;
bool differentiate_plated_copper;
// Board editor copper colors are used only in OpenGL mode if
// use_board_editor_copper_colors is true
bool use_board_editor_copper_colors;
bool use_board_editor_copper_colors; // OpenGL only
bool preview_show_board_body;
/**
* return true if platted copper aeras and non platted copper areas must be drawn
* using a different color
* in OPENGL mode, if use_board_editor_copper_colors, always false
* in RAYTRACING mode, use_board_editor_copper_colors is ignored (board editor copper
* colors are ignored)
*/
bool DifferentiatePlatedCopper()
{
return engine == RENDER_ENGINE::RAYTRACING ? differentiate_plated_copper
: differentiate_plated_copper && !use_board_editor_copper_colors;
if( engine == RENDER_ENGINE::OPENGL && use_board_editor_copper_colors )
return false;
return differentiate_plated_copper;
}
};

View File

@ -177,7 +177,6 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent,
cfg->m_UseStackupColors = aEvent.IsChecked();
UpdateLayerCtls();
syncLayerPresetSelection();
m_frame->NewDisplay( true );
} );
@ -194,7 +193,6 @@ APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D( EDA_3D_VIEWER_FRAME* aParent,
cfg->m_Render.use_board_editor_copper_colors = aEvent.IsChecked();
UpdateLayerCtls();
syncLayerPresetSelection();
m_frame->NewDisplay( true );
} );
@ -314,7 +312,13 @@ void APPEARANCE_CONTROLS_3D::CommonSettingsChanged()
rebuildControls();
UpdateLayerCtls();
syncLayerPresetSelection();
const wxString& currentPreset = m_frame->GetAdapter().m_Cfg->m_CurrentPreset;
if( currentPreset == FOLLOW_PCB || currentPreset == FOLLOW_PLOT_SETTINGS )
updateLayerPresetWidget( currentPreset );
else
syncLayerPresetSelection();
}
@ -502,7 +506,12 @@ void APPEARANCE_CONTROLS_3D::onColorSwatchChanged( COLOR_SWATCH* aSwatch )
m_frame->GetAdapter().SetLayerColors( colors );
syncLayerPresetSelection();
const wxString& currentPreset = m_frame->GetAdapter().m_Cfg->m_CurrentPreset;
if( currentPreset == FOLLOW_PCB || currentPreset == FOLLOW_PLOT_SETTINGS )
updateLayerPresetWidget( currentPreset );
else
syncLayerPresetSelection();
m_frame->NewDisplay( true );
}

View File

@ -68,8 +68,6 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
// This board will only be used to hold a footprint for viewing
m_dummyBoard->SetBoardUse( BOARD_USE::FPHOLDER );
m_bodyStyleShowAll = true;
BOARD_DESIGN_SETTINGS parent_bds = aFrame->GetDesignSettings();
BOARD_DESIGN_SETTINGS& dummy_bds = m_dummyBoard->GetDesignSettings();
dummy_bds.SetBoardThickness( parent_bds.GetBoardThickness() );
@ -225,16 +223,6 @@ void PANEL_PREVIEW_3D_MODEL::loadSettings()
m_previewPane->SetAnimationEnabled( cfg->m_Camera.animation_enabled );
m_previewPane->SetMovingSpeedMultiplier( cfg->m_Camera.moving_speed_multiplier );
m_previewPane->SetProjectionMode( cfg->m_Camera.projection_mode );
// Ensure the board body is always shown, and do not use the settings of the 3D viewer
cfg->m_Render.show_copper_top = m_bodyStyleShowAll;
cfg->m_Render.show_copper_bottom = m_bodyStyleShowAll;
cfg->m_Render.show_soldermask_top = m_bodyStyleShowAll;
cfg->m_Render.show_soldermask_bottom = m_bodyStyleShowAll;
cfg->m_Render.show_solderpaste = m_bodyStyleShowAll;
cfg->m_Render.show_zones = m_bodyStyleShowAll;
cfg->m_Render.show_board_body = m_bodyStyleShowAll;
cfg->m_Render.use_board_editor_copper_colors = false;
}
}
@ -405,13 +393,7 @@ void PANEL_PREVIEW_3D_MODEL::setBodyStyleView( wxCommandEvent& event )
if( !cfg )
return;
m_bodyStyleShowAll = !m_bodyStyleShowAll;
cfg->m_Render.show_soldermask_top = m_bodyStyleShowAll;
cfg->m_Render.show_soldermask_bottom = m_bodyStyleShowAll;
cfg->m_Render.show_solderpaste = m_bodyStyleShowAll;
cfg->m_Render.show_zones = m_bodyStyleShowAll;
cfg->m_Render.show_board_body = m_bodyStyleShowAll;
cfg->m_Render.preview_show_board_body = !cfg->m_Render.preview_show_board_body;
m_previewPane->ReloadRequest();
m_previewPane->Refresh();

View File

@ -222,11 +222,11 @@ private:
int m_selected; /// Index into m_parentInfoList
EDA_UNITS m_userUnits;
bool m_bodyStyleShowAll; /// true if the board body is show
/// The 3d viewer Render initial settings (must be saved and restored)
EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS m_initialRender;
std::unique_ptr<NL_FOOTPRINT_PROPERTIES_PLUGIN> m_spaceMouse;
/// The 3d viewer Render initial settings (must be saved and restored)
EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS m_initialRender;
std::unique_ptr<NL_FOOTPRINT_PROPERTIES_PLUGIN> m_spaceMouse;
};
#endif // PANEL_PREVIEW_3D_MODEL_H