From d4e9ddc14c9c0db279233db480545e24a2cf3208 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 31 Jul 2019 09:19:44 +0200 Subject: [PATCH] 3D viewer: fix check state of some menuitems not correctly updated. Fixes: lp:1837950 https://bugs.launchpad.net/kicad/+bug/1837950 --- 3d-viewer/3d_viewer/eda_3d_viewer.cpp | 34 +++++++++++++++++++++++++++ 3d-viewer/3d_viewer/eda_3d_viewer.h | 3 +++ 2 files changed, 37 insertions(+) diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.cpp b/3d-viewer/3d_viewer/eda_3d_viewer.cpp index 9c0246934e..616de6fe78 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer.cpp @@ -128,6 +128,11 @@ BEGIN_EVENT_TABLE( EDA_3D_VIEWER, EDA_BASE_FRAME ) EVT_MENU_RANGE( ID_MENU3D_GRID, ID_MENU3D_GRID_END, EDA_3D_VIEWER::On3DGridSelection ) + EVT_UPDATE_UI( ID_RENDER_CURRENT_VIEW, EDA_3D_VIEWER::OnUpdateUIEngine ) + EVT_UPDATE_UI_RANGE( ID_MENU3D_FL_RENDER_MATERIAL_MODE_NORMAL, + ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE, + EDA_3D_VIEWER::OnUpdateUIMaterial ) + EVT_CLOSE( EDA_3D_VIEWER::OnCloseWindow ) END_EVENT_TABLE() @@ -1114,6 +1119,35 @@ bool EDA_3D_VIEWER::Set3DSolderPasteColorFromUser() } +void EDA_3D_VIEWER::OnUpdateUIEngine( wxUpdateUIEvent& aEvent ) +{ + aEvent.Check( m_settings.RenderEngineGet() != RENDER_ENGINE_OPENGL_LEGACY ); +} + + +void EDA_3D_VIEWER::OnUpdateUIMaterial( wxUpdateUIEvent& aEvent ) +{ + // Set the state of toggle menus according to the current display options + switch( aEvent.GetId() ) + { + case ID_MENU3D_FL_RENDER_MATERIAL_MODE_NORMAL: + aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE_NORMAL ); + break; + + case ID_MENU3D_FL_RENDER_MATERIAL_MODE_DIFFUSE_ONLY: + aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE_DIFFUSE_ONLY ); + break; + + case ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE: + aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE_CAD_MODE ); + break; + + default: + wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::OnUpdateUIMaterial()" ); + } +} + + void EDA_3D_VIEWER::loadCommonSettings() { wxCHECK_RET( m_canvas, "Cannot load settings to null canvas" ); diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.h b/3d-viewer/3d_viewer/eda_3d_viewer.h index faeabbc317..7b941f6797 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer.h +++ b/3d-viewer/3d_viewer/eda_3d_viewer.h @@ -172,6 +172,9 @@ class EDA_3D_VIEWER : public KIWAY_PLAYER void Install3DViewOptionDialog( wxCommandEvent &event ); + void OnUpdateUIEngine( wxUpdateUIEvent& aEvent ); + void OnUpdateUIMaterial( wxUpdateUIEvent& aEvent ); + void CreateMenuBar(); /**