From e7c11a01bec028acc2aba119a1ba381a42f9bdb8 Mon Sep 17 00:00:00 2001 From: Syres916 <46537884+Syres916@users.noreply.github.com> Date: Mon, 27 May 2024 17:27:11 +0100 Subject: [PATCH] [Sketcher] Change HeadlightIntensity entering and exiting Edit Mode (#14013) * [Sketcher] Change HeadlightIntensity entering and exiting Edit Mode * [Gui] Fix Lint Warning * [Sketcher] Fix Lint Warning * [Sketcher] Remove duplicate parameter check * [Gui] Add const --- src/Gui/View3DSettings.cpp | 8 ++++++++ src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/Gui/View3DSettings.cpp b/src/Gui/View3DSettings.cpp index 5caa1b3d57..86a96690da 100644 --- a/src/Gui/View3DSettings.cpp +++ b/src/Gui/View3DSettings.cpp @@ -69,6 +69,14 @@ int View3DSettings::stopAnimatingIfDeactivated() const void View3DSettings::applySettings() { + // Check if Sketcher Edit Mode exited cleanly + const int overMaxHeadlightIntensity = 101; + int sketcherEditLastExit = hGrp->GetInt("HeadlightIntensityExisting", overMaxHeadlightIntensity); + if (sketcherEditLastExit != overMaxHeadlightIntensity) { + // must mean a seg fault or abnormal exit last time + hGrp->SetInt("HeadlightIntensity", sketcherEditLastExit); + hGrp->RemoveInt("HeadlightIntensityExisting"); + } // apply the user settings OnChange(*hGrp,"EyeDistance"); OnChange(*hGrp,"CornerCoordSystem"); diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 40d31aeb88..c418e5c24c 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -3231,6 +3231,13 @@ void ViewProviderSketch::unsetEdit(int ModNum) selection.reset(); this->detachSelection(); + ParameterGrp::handle hGrpView = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/View"); + + auto headlightIntensityExisting = hGrpView->GetInt("HeadlightIntensityExisting", 100); + hGrpView->SetInt("HeadlightIntensity", headlightIntensityExisting); + hGrpView->RemoveInt("HeadlightIntensityExisting"); + App::AutoTransaction trans("Sketch recompute"); try { // and update the sketch @@ -3301,6 +3308,14 @@ void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int Mo } } + ParameterGrp::handle hGrpView = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/View"); + + auto headlightIntensityExisting = hGrpView->GetInt("HeadlightIntensity", 100); + auto headlightIntensityTemp = 50; + hGrpView->SetInt("HeadlightIntensity", headlightIntensityTemp); + hGrpView->SetInt("HeadlightIntensityExisting", headlightIntensityExisting); + auto editDoc = Gui::Application::Instance->editDocument(); editDocName.clear(); if (editDoc) {