From 5c7d287f6b3331a8cd0e0750ade0dc8edc553724 Mon Sep 17 00:00:00 2001 From: Max Wilfinger Date: Thu, 30 May 2024 11:17:35 +0200 Subject: [PATCH 1/2] 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(); From 4e8f3f03817d433692a823d981cb5ab96c0290d3 Mon Sep 17 00:00:00 2001 From: Max Wilfinger Date: Thu, 30 May 2024 21:05:42 +0200 Subject: [PATCH 2/2] Added preference for disabling shaded override draw style when entering sketch edit mode. Storing previous override draw style and applying it when leaving the sketch. --- src/Mod/Sketcher/Gui/SketcherSettings.cpp | 2 + src/Mod/Sketcher/Gui/SketcherSettings.ui | 19 ++++++++++ src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 42 +++++++++++++++------ 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.cpp b/src/Mod/Sketcher/Gui/SketcherSettings.cpp index ca7b908ab3..dcf575fb15 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.cpp +++ b/src/Mod/Sketcher/Gui/SketcherSettings.cpp @@ -107,6 +107,7 @@ void SketcherSettings::saveSettings() ui->checkBoxAdvancedSolverTaskBox->onSave(); ui->checkBoxRecalculateInitialSolutionWhileDragging->onSave(); ui->checkBoxEnableEscape->onSave(); + ui->checkBoxDisableShading->onSave(); ui->checkBoxNotifyConstraintSubstitutions->onSave(); ui->checkBoxAutoRemoveRedundants->onSave(); ui->checkBoxUnifiedCoincident->onSave(); @@ -178,6 +179,7 @@ void SketcherSettings::loadSettings() ui->checkBoxAdvancedSolverTaskBox->onRestore(); ui->checkBoxRecalculateInitialSolutionWhileDragging->onRestore(); ui->checkBoxEnableEscape->onRestore(); + ui->checkBoxDisableShading->onRestore(); ui->checkBoxNotifyConstraintSubstitutions->onRestore(); ui->checkBoxAutoRemoveRedundants->onRestore(); ui->checkBoxUnifiedCoincident->onRestore(); diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.ui b/src/Mod/Sketcher/Gui/SketcherSettings.ui index d08221dd96..134703a284 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.ui +++ b/src/Mod/Sketcher/Gui/SketcherSettings.ui @@ -140,6 +140,25 @@ Requires to re-enter edit mode to take effect. + + + + Disables the shaded view when entering the sketch edit mode. + + + Disable shading in edit mode + + + true + + + DisableShadedView + + + Mod/Sketcher/General + + + diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 11fd7020b2..bf678d4422 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -3226,14 +3226,24 @@ void ViewProviderSketch::unsetEdit(int ModNum) 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) + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Sketcher/General"); + auto disableShadedView = hGrp->GetBool("DisableShadedView", true); + if (disableShadedView) { + Gui::Document* doc = Gui::Application::Instance->activeDocument(); + Gui::MDIView* mdi = doc->getActiveView(); + Gui::View3DInventorViewer* viewer = static_cast(mdi)->getViewer(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Sketcher/General"); + auto OverrideMode = hGrp->GetASCII("OverrideMode", "As Is"); + + if (viewer) { - viewer->updateOverrideMode("As Is"); - viewer->setOverrideMode("As Is"); + viewer->updateOverrideMode(OverrideMode); + viewer->setOverrideMode(OverrideMode); } + } editCoinManager = nullptr; snapManager = nullptr; @@ -3312,13 +3322,23 @@ void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int Mo } // 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"); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Sketcher/General"); + auto disableShadedView = hGrp->GetBool("DisableShadedView", true); + + hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Sketcher/General"); + hGrp->SetASCII("OverrideMode", viewer->getOverrideMode()); + + if (disableShadedView) { + + + viewer->updateOverrideMode("No Shading"); + viewer->setOverrideMode("No Shading"); + } + auto editDoc = Gui::Application::Instance->editDocument(); editDocName.clear(); if (editDoc) {