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/SketcherSettings.cpp b/src/Mod/Sketcher/Gui/SketcherSettings.cpp index 66e60e91f6..8b5c2a29dd 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 04f0c5782a..81328f727a 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -3312,19 +3312,32 @@ void ViewProviderSketch::unsetEdit(int ModNum) if (sketchHandler) deactivateHandler(); + // Resets the override draw style mode when leaving the sketch edit mode. + 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(OverrideMode); + viewer->setOverrideMode(OverrideMode); + } + } + 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 @@ -3395,13 +3408,23 @@ void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int Mo } } - ParameterGrp::handle hGrpView = App::GetApplication().GetParameterGroupByPath( - "User parameter:BaseApp/Preferences/View"); + // Sets the view mode to no shading to prevent visibility issues against parallel surfaces with shininess when entering the sketch mode. + 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 headlightIntensityExisting = hGrpView->GetInt("HeadlightIntensity", 100); - auto headlightIntensityTemp = 50; - hGrpView->SetInt("HeadlightIntensity", headlightIntensityTemp); - hGrpView->SetInt("HeadlightIntensityExisting", headlightIntensityExisting); auto editDoc = Gui::Application::Instance->editDocument(); editDocName.clear();