diff --git a/3d-viewer/3d_cache/dialogs/panel_preview_3d_model.cpp b/3d-viewer/3d_cache/dialogs/panel_preview_3d_model.cpp index 5bbbcf84f9..a1b7488f05 100644 --- a/3d-viewer/3d_cache/dialogs/panel_preview_3d_model.cpp +++ b/3d-viewer/3d_cache/dialogs/panel_preview_3d_model.cpp @@ -37,8 +37,9 @@ #include #include #include +#include #include - +#include PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAME* aFrame, FOOTPRINT* aFootprint, @@ -95,7 +96,7 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM m_dummyBoard, m_boardAdapter, m_currentCamera, aFrame->Prj().Get3DCacheManager() ); - loadCommonSettings(); + loadSettings(); m_boardAdapter.SetFlag( FL_USE_SELECTION, false ); m_boardAdapter.SetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM, false ); @@ -161,7 +162,7 @@ void PANEL_PREVIEW_3D_MODEL::OnMenuEvent( wxMenuEvent& aEvent ) } -void PANEL_PREVIEW_3D_MODEL::loadCommonSettings() +void PANEL_PREVIEW_3D_MODEL::loadSettings() { wxCHECK_RET( m_previewPane, "Cannot load settings to null canvas" ); @@ -172,6 +173,43 @@ void PANEL_PREVIEW_3D_MODEL::loadCommonSettings() // TODO(JE) use all control options m_boardAdapter.SetFlag( FL_MOUSEWHEEL_PANNING, settings->m_Input.scroll_modifier_zoom != 0 ); + + COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings(); + + if( colors ) + { + auto set = + [] ( const COLOR4D& aColor, SFVEC4F& aTarget ) + { + aTarget.r = aColor.r; + aTarget.g = aColor.g; + aTarget.b = aColor.b; + aTarget.a = aColor.a; + }; + + set( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ), m_boardAdapter.m_BgColorBot ); + set( colors->GetColor( LAYER_3D_BACKGROUND_TOP ), m_boardAdapter.m_BgColorTop ); + set( colors->GetColor( LAYER_3D_BOARD ), m_boardAdapter.m_BoardBodyColor ); + set( colors->GetColor( LAYER_3D_COPPER ), m_boardAdapter.m_CopperColor ); + set( colors->GetColor( LAYER_3D_SILKSCREEN_BOTTOM ), m_boardAdapter.m_SilkScreenColorBot ); + set( colors->GetColor( LAYER_3D_SILKSCREEN_TOP ), m_boardAdapter.m_SilkScreenColorTop ); + set( colors->GetColor( LAYER_3D_SOLDERMASK ), m_boardAdapter.m_SolderMaskColorBot ); + set( colors->GetColor( LAYER_3D_SOLDERMASK ), m_boardAdapter.m_SolderMaskColorTop ); + set( colors->GetColor( LAYER_3D_SOLDERPASTE ), m_boardAdapter.m_SolderPasteColor ); + } + + EDA_3D_VIEWER_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); + + if( cfg ) + { + m_boardAdapter.SetRenderEngine( RENDER_ENGINE::OPENGL_LEGACY ); + m_boardAdapter.SetFlag( FL_USE_REALISTIC_MODE, cfg->m_Render.realistic ); + m_boardAdapter.SetMaterialMode( static_cast( cfg->m_Render.material_mode ) ); + + 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 ); + } } diff --git a/3d-viewer/3d_cache/dialogs/panel_preview_3d_model.h b/3d-viewer/3d_cache/dialogs/panel_preview_3d_model.h index 506367f5a4..a635fb3b6f 100644 --- a/3d-viewer/3d_cache/dialogs/panel_preview_3d_model.h +++ b/3d-viewer/3d_cache/dialogs/panel_preview_3d_model.h @@ -106,7 +106,7 @@ private: /** * Load 3D relevant settings from the user configuration */ - void loadCommonSettings(); + void loadSettings(); /** * It will receive the events from editing the fields. diff --git a/3d-viewer/3d_viewer/dialogs/panel_3D_colors.cpp b/3d-viewer/3d_viewer/dialogs/panel_3D_colors.cpp index 852c07f4cd..561a7c57ef 100644 --- a/3d-viewer/3d_viewer/dialogs/panel_3D_colors.cpp +++ b/3d-viewer/3d_viewer/dialogs/panel_3D_colors.cpp @@ -25,13 +25,18 @@ #include #include <3d_canvas/board_adapter.h> #include <3d_viewer/eda_3d_viewer.h> +#include +#include #include #include #include +#include + PANEL_3D_COLORS::PANEL_3D_COLORS( EDA_3D_VIEWER_FRAME* aFrame, wxWindow* aParent ) : PANEL_3D_COLORS_BASE( aParent ), - m_settings( aFrame->GetAdapter() ) + m_frame( aFrame ), + m_boardAdapter( aFrame->GetAdapter() ) { #define ADD_COLOR( list, r, g, b, a, name ) \ list.push_back( CUSTOM_COLOR_ITEM( r/255.0, g/255.0, b/255.0, a, name ) ) @@ -109,15 +114,15 @@ bool PANEL_3D_COLORS::TransferDataToWindow() return COLOR4D( src.r, src.g, src.b, src.a ); }; - m_backgroundTop->SetSwatchColor( to_COLOR4D( m_settings.m_BgColorTop ), false ); - m_backgroundBottom->SetSwatchColor( to_COLOR4D( m_settings.m_BgColorBot ), false ); - m_silkscreenTop->SetSwatchColor( to_COLOR4D( m_settings.m_SilkScreenColorTop ), false ); - m_silkscreenBottom->SetSwatchColor( to_COLOR4D( m_settings.m_SilkScreenColorBot ), false ); - m_solderMaskTop->SetSwatchColor( to_COLOR4D( m_settings.m_SolderMaskColorTop ), false ); - m_solderMaskBottom->SetSwatchColor( to_COLOR4D( m_settings.m_SolderMaskColorBot ), false ); - m_solderPaste->SetSwatchColor( to_COLOR4D( m_settings.m_SolderPasteColor ), false ); - m_surfaceFinish->SetSwatchColor( to_COLOR4D( m_settings.m_CopperColor ), false ); - m_boardBody->SetSwatchColor( to_COLOR4D( m_settings.m_BoardBodyColor ), false ); + m_backgroundTop->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_BgColorTop ), false ); + m_backgroundBottom->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_BgColorBot ), false ); + m_silkscreenTop->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_SilkScreenColorTop ), false ); + m_silkscreenBottom->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_SilkScreenColorBot ), false ); + m_solderMaskTop->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_SolderMaskColorTop ), false ); + m_solderMaskBottom->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_SolderMaskColorBot ), false ); + m_solderPaste->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_SolderPasteColor ), false ); + m_surfaceFinish->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_CopperColor ), false ); + m_boardBody->SetSwatchColor( to_COLOR4D( m_boardAdapter.m_BoardBodyColor ), false ); return true; } @@ -130,15 +135,20 @@ bool PANEL_3D_COLORS::TransferDataFromWindow() return SFVEC4F( src.r, src.g, src.b, src.a ); }; - m_settings.m_BgColorTop = to_SFVEC4F( m_backgroundTop->GetSwatchColor() ); - m_settings.m_BgColorBot = to_SFVEC4F( m_backgroundBottom->GetSwatchColor() ); - m_settings.m_SilkScreenColorTop = to_SFVEC4F( m_silkscreenTop->GetSwatchColor() ); - m_settings.m_SilkScreenColorBot = to_SFVEC4F( m_silkscreenBottom->GetSwatchColor() ); - m_settings.m_SolderMaskColorTop = to_SFVEC4F( m_solderMaskTop->GetSwatchColor() ); - m_settings.m_SolderMaskColorBot = to_SFVEC4F( m_solderMaskBottom->GetSwatchColor() ); - m_settings.m_SolderPasteColor = to_SFVEC4F( m_solderPaste->GetSwatchColor() ); - m_settings.m_CopperColor = to_SFVEC4F( m_surfaceFinish->GetSwatchColor() ); - m_settings.m_BoardBodyColor = to_SFVEC4F( m_boardBody->GetSwatchColor() ); + m_boardAdapter.m_BgColorTop = to_SFVEC4F( m_backgroundTop->GetSwatchColor() ); + m_boardAdapter.m_BgColorBot = to_SFVEC4F( m_backgroundBottom->GetSwatchColor() ); + m_boardAdapter.m_SilkScreenColorTop = to_SFVEC4F( m_silkscreenTop->GetSwatchColor() ); + m_boardAdapter.m_SilkScreenColorBot = to_SFVEC4F( m_silkscreenBottom->GetSwatchColor() ); + m_boardAdapter.m_SolderMaskColorTop = to_SFVEC4F( m_solderMaskTop->GetSwatchColor() ); + m_boardAdapter.m_SolderMaskColorBot = to_SFVEC4F( m_solderMaskBottom->GetSwatchColor() ); + m_boardAdapter.m_SolderPasteColor = to_SFVEC4F( m_solderPaste->GetSwatchColor() ); + m_boardAdapter.m_CopperColor = to_SFVEC4F( m_surfaceFinish->GetSwatchColor() ); + m_boardAdapter.m_BoardBodyColor = to_SFVEC4F( m_boardBody->GetSwatchColor() ); + + auto cfg = Pgm().GetSettingsManager().GetAppSettings(); + + if( cfg ) + m_frame->SaveSettings( cfg ); return true; } @@ -146,7 +156,7 @@ bool PANEL_3D_COLORS::TransferDataFromWindow() void PANEL_3D_COLORS::OnLoadColorsFromBoardStackup( wxCommandEvent& event ) { - const BOARD* brd = m_settings.GetBoard(); + const BOARD* brd = m_boardAdapter.GetBoard(); const FAB_LAYER_COLOR* stdColors = GetColorStandardList(); wxColour color; @@ -179,26 +189,26 @@ void PANEL_3D_COLORS::OnLoadColorsFromBoardStackup( wxCommandEvent& event ) switch( stckpItem->GetBrdLayerId() ) { case F_SilkS: - m_settings.m_SilkScreenColorTop.r = color.Red() / 255.0; - m_settings.m_SilkScreenColorTop.g = color.Green() / 255.0; - m_settings.m_SilkScreenColorTop.b = color.Blue() / 255.0; + m_boardAdapter.m_SilkScreenColorTop.r = color.Red() / 255.0; + m_boardAdapter.m_SilkScreenColorTop.g = color.Green() / 255.0; + m_boardAdapter.m_SilkScreenColorTop.b = color.Blue() / 255.0; break; case B_SilkS: - m_settings.m_SilkScreenColorBot.r = color.Red() / 255.0; - m_settings.m_SilkScreenColorBot.g = color.Green() / 255.0; - m_settings.m_SilkScreenColorBot.b = color.Blue() / 255.0; + m_boardAdapter.m_SilkScreenColorBot.r = color.Red() / 255.0; + m_boardAdapter.m_SilkScreenColorBot.g = color.Green() / 255.0; + m_boardAdapter.m_SilkScreenColorBot.b = color.Blue() / 255.0; break; case F_Mask: - m_settings.m_SolderMaskColorTop.r = color.Red() / 255.0; - m_settings.m_SolderMaskColorTop.g = color.Green() / 255.0; - m_settings.m_SolderMaskColorTop.b = color.Blue() / 255.0; + m_boardAdapter.m_SolderMaskColorTop.r = color.Red() / 255.0; + m_boardAdapter.m_SolderMaskColorTop.g = color.Green() / 255.0; + m_boardAdapter.m_SolderMaskColorTop.b = color.Blue() / 255.0; // Keep the previous alpha value //m_boardAdapter.m_SolderMaskColorTop.a = color.Alpha() / 255.0; break; case B_Mask: - m_settings.m_SolderMaskColorBot.r = color.Red() / 255.0; - m_settings.m_SolderMaskColorBot.g = color.Green() / 255.0; - m_settings.m_SolderMaskColorBot.b = color.Blue() / 255.0; + m_boardAdapter.m_SolderMaskColorBot.r = color.Red() / 255.0; + m_boardAdapter.m_SolderMaskColorBot.g = color.Green() / 255.0; + m_boardAdapter.m_SolderMaskColorBot.b = color.Blue() / 255.0; // Keep the previous alpha value //m_boardAdapter.m_SolderMaskColorBot.a = color.Alpha() / 255.0; break; diff --git a/3d-viewer/3d_viewer/dialogs/panel_3D_colors.h b/3d-viewer/3d_viewer/dialogs/panel_3D_colors.h index 9d804dd21a..6d376eff79 100644 --- a/3d-viewer/3d_viewer/dialogs/panel_3D_colors.h +++ b/3d-viewer/3d_viewer/dialogs/panel_3D_colors.h @@ -41,13 +41,14 @@ public: void OnLoadColorsFromBoardStackup( wxCommandEvent& event ) override; private: - BOARD_ADAPTER& m_settings; + EDA_3D_VIEWER_FRAME* m_frame; + BOARD_ADAPTER& m_boardAdapter; - CUSTOM_COLORS_LIST m_silkscreenColors; - CUSTOM_COLORS_LIST m_maskColors; - CUSTOM_COLORS_LIST m_pasteColors; - CUSTOM_COLORS_LIST m_finishColors; - CUSTOM_COLORS_LIST m_boardColors; + CUSTOM_COLORS_LIST m_silkscreenColors; + CUSTOM_COLORS_LIST m_maskColors; + CUSTOM_COLORS_LIST m_pasteColors; + CUSTOM_COLORS_LIST m_finishColors; + CUSTOM_COLORS_LIST m_boardColors; }; diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.h b/3d-viewer/3d_viewer/eda_3d_viewer.h index 980c62eb5f..7a0d6d8f6f 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer.h +++ b/3d-viewer/3d_viewer/eda_3d_viewer.h @@ -106,6 +106,9 @@ public: EDA_3D_CANVAS* GetCanvas() { return m_canvas; } + void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; + void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; + /** * Notification that common settings are updated. * @@ -137,10 +140,6 @@ private: void CreateMenuBar(); void ReCreateMainToolbar(); - void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; - - void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; - /** * Create a Screenshot of the current 3D view. * Output file format is png or jpeg, or image is copied to the clipboard diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index 0fa49a8547..2d61c136df 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -262,7 +262,7 @@ bool PGM_BASE::InitPgm( bool aHeadless ) // Load common settings from disk after setting up env vars GetSettingsManager().Load( GetCommonSettings() ); - // Init user language *before* calling loadCommonSettings, because + // Init user language *before* calling loadSettings, because // env vars could be incorrectly initialized on Linux // (if the value contains some non ASCII7 chars, the env var is not initialized) SetLanguage( tmp, true ); @@ -343,7 +343,7 @@ void PGM_BASE::loadCommonSettings() for( const std::pair it : GetCommonSettings()->m_Env.vars ) { - wxLogTrace( traceEnvVars, "PGM_BASE::loadCommonSettings: Found entry %s = %s", + wxLogTrace( traceEnvVars, "PGM_BASE::loadSettings: Found entry %s = %s", it.first, it.second.GetValue() ); // Do not store the env var PROJECT_VAR_NAME ("KIPRJMOD") definition if for some reason diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index e9bd1401d9..f7a83daee4 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -428,7 +428,7 @@ void WX_VIEW_CONTROLS::onButton( wxMouseEvent& aEvent ) { m_state = IDLE; #if defined USE_MOUSE_CAPTURE - if( !m_settings.m_cursorCaptured && m_parentPanel->HasCapture() ) + if( !m_boardAdapter.m_cursorCaptured && m_parentPanel->HasCapture() ) m_parentPanel->ReleaseMouse(); #endif } @@ -629,7 +629,7 @@ void WX_VIEW_CONTROLS::CancelDrag() { m_state = IDLE; #if defined USE_MOUSE_CAPTURE - if( !m_settings.m_cursorCaptured && m_parentPanel->HasCapture() ) + if( !m_boardAdapter.m_cursorCaptured && m_parentPanel->HasCapture() ) m_parentPanel->ReleaseMouse(); #endif } diff --git a/eeschema/sim/sim_plot_frame_base.fbp b/eeschema/sim/sim_plot_frame_base.fbp index 1c19e291cf..c4ea75699b 100644 --- a/eeschema/sim/sim_plot_frame_base.fbp +++ b/eeschema/sim/sim_plot_frame_base.fbp @@ -280,7 +280,7 @@ ID_MENU_SET_SIMUL wxITEM_NORMAL Settings... - m_settings + m_boardAdapter protected diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index d79353952c..47cc59148b 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -261,7 +261,7 @@ SYMBOL_EDIT_FRAME::~SYMBOL_EDIT_FRAME() void SYMBOL_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) { - wxCHECK_RET( m_settings, "Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_settings" ); + wxCHECK_RET( m_settings, "Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_boardAdapter" ); SCH_BASE_FRAME::LoadSettings( GetSettings() ); @@ -276,7 +276,7 @@ void SYMBOL_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) void SYMBOL_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { - wxCHECK_RET( m_settings, "Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_settings" ); + wxCHECK_RET( m_settings, "Call to SYMBOL_EDIT_FRAME::LoadSettings with null m_boardAdapter" ); GetGalDisplayOptions().m_axesEnabled = true;