[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
This commit is contained in:
Syres916
2024-05-27 17:27:11 +01:00
committed by GitHub
parent 904d689218
commit e7c11a01be
2 changed files with 23 additions and 0 deletions

View File

@@ -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");

View File

@@ -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) {