From 5c7d287f6b3331a8cd0e0750ade0dc8edc553724 Mon Sep 17 00:00:00 2001 From: Max Wilfinger Date: Thu, 30 May 2024 11:17:35 +0200 Subject: [PATCH] Changes override draw style when entering sketch edit mode. --- src/Gui/View3DSettings.cpp | 8 ------ src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 31 +++++++++++---------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/Gui/View3DSettings.cpp b/src/Gui/View3DSettings.cpp index 86a96690da..5caa1b3d57 100644 --- a/src/Gui/View3DSettings.cpp +++ b/src/Gui/View3DSettings.cpp @@ -69,14 +69,6 @@ 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 c418e5c24c..11fd7020b2 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -3225,19 +3225,22 @@ void ViewProviderSketch::unsetEdit(int ModNum) if (sketchHandler) deactivateHandler(); + // Resets the override draw style mode when leaving the sketch edit mode. + // TODO: This could maybe also be a preference (enable auto switch of draw style). Additionally the previous override draw style could be saved and applied when leaving the edit mode. + Gui::MDIView* mdi = Gui::Application::Instance->editViewOfNode(editCoinManager->getRootEditNode()); + Gui::View3DInventorViewer* viewer = static_cast(mdi)->getViewer(); + if (viewer) + { + viewer->updateOverrideMode("As Is"); + viewer->setOverrideMode("As Is"); + } + editCoinManager = nullptr; snapManager = nullptr; preselection.reset(); 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 @@ -3308,13 +3311,13 @@ 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); + // Sets the view mode to no shading to prevent visibility issues against parallel surfaces with shininess when entering the sketch mode. + // TODO: This could maybe also be a preference (enable auto switch of draw style) and further improved if the user has already an override draw style enabled which has no shading (e.g. wireframe). Additionally the current override draw style could be saved and applied when leaving the edit mode. + if (viewer) + { + viewer->updateOverrideMode("No Shading"); + viewer->setOverrideMode("No Shading"); + } auto editDoc = Gui::Application::Instance->editDocument(); editDocName.clear();