From 043dd45da0dd27bb7617902b8785e4993bd5ac6b Mon Sep 17 00:00:00 2001
From: 0penBrain <48731257+0penBrain@users.noreply.github.com>
Date: Sun, 18 Apr 2021 19:49:43 +0200
Subject: [PATCH] [Sketcher] Visibility automation : add ability to open sketch
in Section View mode
---
src/Mod/Sketcher/Gui/SketcherSettings.cpp | 8 ++++++--
.../Sketcher/Gui/SketcherSettingsDisplay.ui | 19 +++++++++++++++++++
src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 3 +++
src/Mod/Sketcher/Gui/ViewProviderSketch.h | 1 +
4 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.cpp b/src/Mod/Sketcher/Gui/SketcherSettings.cpp
index d31d1e6fd5..9734c597af 100644
--- a/src/Mod/Sketcher/Gui/SketcherSettings.cpp
+++ b/src/Mod/Sketcher/Gui/SketcherSettings.cpp
@@ -156,6 +156,7 @@ void SketcherSettingsDisplay::saveSettings()
ui->checkBoxTVShowLinks->onSave();
ui->checkBoxTVShowSupport->onSave();
ui->checkBoxTVRestoreCamera->onSave();
+ ui->checkBoxTVSectionView->onSave();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part");
QVariant data = ui->comboBox->itemData(ui->comboBox->currentIndex());
@@ -177,6 +178,7 @@ void SketcherSettingsDisplay::loadSettings()
ui->checkBoxTVShowLinks->onRestore();
ui->checkBoxTVShowSupport->onRestore();
ui->checkBoxTVRestoreCamera->onRestore();
+ ui->checkBoxTVSectionView->onRestore();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part");
int pattern = hGrp->GetInt("GridLinePattern", 0x0f0f);
@@ -208,11 +210,13 @@ void SketcherSettingsDisplay::onBtnTVApplyClicked(bool)
" sketch.ViewObject.HideDependent = %s\n"
" sketch.ViewObject.ShowLinks = %s\n"
" sketch.ViewObject.ShowSupport = %s\n"
- " sketch.ViewObject.RestoreCamera = %s\n",
+ " sketch.ViewObject.RestoreCamera = %s\n"
+ " sketch.ViewObject.SectionView = %s\n",
this->ui->checkBoxTVHideDependent->isChecked() ? "True": "False",
this->ui->checkBoxTVShowLinks->isChecked() ? "True": "False",
this->ui->checkBoxTVShowSupport->isChecked() ? "True": "False",
- this->ui->checkBoxTVRestoreCamera->isChecked() ? "True": "False");
+ this->ui->checkBoxTVRestoreCamera->isChecked() ? "True": "False",
+ this->ui->checkBoxTVSectionView->isChecked() ? "True": "False");
} catch (Base::PyException &e){
Base::Console().Error("SketcherSettings::onBtnTVApplyClicked:\n");
e.ReportException();
diff --git a/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui b/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui
index 028009982f..46ce790e35 100644
--- a/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui
+++ b/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui
@@ -230,6 +230,25 @@ Supports all unit systems except 'US customary' and 'Building US/Euro'.
+ -
+
+
+ By default, open a sketch in Section View mode -- objects are only visible behind sketch plane
+
+
+ Open sketch in Section View mode
+
+
+ false
+
+
+ SectionView
+
+
+ Mod/Sketcher/General
+
+
+
-
diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
index 34798294e2..241e4467b7 100644
--- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
+++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
@@ -335,6 +335,7 @@ ViewProviderSketch::ViewProviderSketch()
ADD_PROPERTY_TYPE(ShowLinks,(true),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, all objects used in links to external geometry are shown when opening sketch.");
ADD_PROPERTY_TYPE(ShowSupport,(true),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, all objects this sketch is attached to are shown when opening sketch.");
ADD_PROPERTY_TYPE(RestoreCamera,(true),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, camera position before entering sketch is remembered, and restored after closing it.");
+ ADD_PROPERTY_TYPE(SectionView,(false),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, only objects (or part of) located behind the sketch plane are visible.");
ADD_PROPERTY_TYPE(EditingWorkbench,("SketcherWorkbench"),"Visibility automation",(App::PropertyType)(App::Prop_None),"Name of the workbench to activate when editing this sketch.");
{//visibility automation: update defaults to follow preferences
@@ -343,6 +344,7 @@ ViewProviderSketch::ViewProviderSketch()
this->ShowLinks.setValue(hGrp->GetBool("ShowLinks", true));
this->ShowSupport.setValue(hGrp->GetBool("ShowSupport", true));
this->RestoreCamera.setValue(hGrp->GetBool("RestoreCamera", true));
+ this->SectionView.setValue(hGrp->GetBool("SectionView", false));
// well it is not visibility automation but a good place nevertheless
this->ShowGrid.setValue(hGrp->GetBool("ShowGrid", false));
@@ -6326,6 +6328,7 @@ bool ViewProviderSketch::setEdit(int ModNum)
" tv.show([ref[0] for ref in ActiveSketch.Support if not ref[0].isDerivedFrom(\"PartDesign::Plane\")])\n"
"if ActiveSketch.ViewObject.ShowLinks:\n"
" tv.show([ref[0] for ref in ActiveSketch.ExternalGeometry])\n"
+ " tv.sketchClipPlane(ActiveSketch, ActiveSketch.ViewObject.SectionView)\n"
"tv.hide(ActiveSketch)\n"
"del(tv)\n"
).arg(QString::fromLatin1(getDocument()->getDocument()->getName()),
diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.h b/src/Mod/Sketcher/Gui/ViewProviderSketch.h
index 6f66d6507f..5d2bfb147d 100644
--- a/src/Mod/Sketcher/Gui/ViewProviderSketch.h
+++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.h
@@ -114,6 +114,7 @@ public:
App::PropertyBool ShowLinks;
App::PropertyBool ShowSupport;
App::PropertyBool RestoreCamera;
+ App::PropertyBool SectionView;
App::PropertyString EditingWorkbench;
/// Draw all constraint icons