3d viewer: save color settings.

The call to SaveColorSettings() was not at the right place, and the new
color settings never saved.

Fixes #5529
https://gitlab.com/kicad/code/kicad/issues/5529
This commit is contained in:
jean-pierre charras 2020-09-17 17:15:25 +02:00
parent e8d09cd998
commit 6ec6baf401
1 changed files with 17 additions and 4 deletions

View File

@ -291,9 +291,6 @@ void EDA_3D_VIEWER::OnCloseWindow( wxCloseEvent &event )
//delete m_canvas;
//m_canvas = nullptr;
COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
Pgm().GetSettingsManager().SaveColorSettings( colors, "3d_viewer" );
Destroy();
event.Skip( true );
}
@ -581,6 +578,20 @@ void EDA_3D_VIEWER::SaveSettings( APP_SETTINGS_BASE *aCfg )
auto save_color =
[colors] ( SFVEC4F& aSource, LAYER_3D_ID aTarget )
{
// You could think just copy the new color in config is enough.
// unfortunately, SFVEC4F uses floats, and COLOR4D uses doubles,
// and the conversion SFVEC4F from/to COLOR4D creates small diffs.
//
// This has no matter to draw colors, but creates slight differences
// in config file, that appears always modified.
// So we must compare the SFVEC4F old and new values and update only
// actual changes.
SFVEC4F newSFVEC4Fcolor( float(colors->GetColor( aTarget ).r),
float(colors->GetColor( aTarget ).g),
float(colors->GetColor( aTarget ).b),
float(colors->GetColor( aTarget ).a) );
if( aSource != newSFVEC4Fcolor )
colors->SetColor( aTarget, COLOR4D( aSource.r, aSource.g, aSource.b, aSource.a ) );
};
@ -593,6 +604,8 @@ void EDA_3D_VIEWER::SaveSettings( APP_SETTINGS_BASE *aCfg )
save_color( m_boardAdapter.m_SolderMaskColorTop, LAYER_3D_SOLDERMASK );
save_color( m_boardAdapter.m_SolderPasteColor, LAYER_3D_SOLDERPASTE );
Pgm().GetSettingsManager().SaveColorSettings( colors, "3d_viewer" );
wxLogTrace( m_logTrace, m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ?
"EDA_3D_VIEWER::SaveSettings render setting Ray Trace" :
"EDA_3D_VIEWER::SaveSettings render setting OpenGL" );