Skip to content

Commit

Permalink
[Sketcher] Visibility automation : add ability to open sketch in Sect…
Browse files Browse the repository at this point in the history
…ion View mode
  • Loading branch information
0penBrain authored and abdullahtahiriyo committed Apr 24, 2021
1 parent 18e7515 commit 043dd45
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Mod/Sketcher/Gui/SketcherSettings.cpp
Expand Up @@ -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());
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
19 changes: 19 additions & 0 deletions src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui
Expand Up @@ -230,6 +230,25 @@ Supports all unit systems except 'US customary' and 'Building US/Euro'.</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxTVSectionView">
<property name="toolTip">
<string>By default, open a sketch in Section View mode -- objects are only visible behind sketch plane</string>
</property>
<property name="text">
<string>Open sketch in Section View mode</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>SectionView</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher/General</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
Expand Down
3 changes: 3 additions & 0 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
Expand Up @@ -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
Expand All @@ -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));
Expand Down Expand Up @@ -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()),
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.h
Expand Up @@ -114,6 +114,7 @@ class SketcherGuiExport ViewProviderSketch : public PartGui::ViewProvider2DObjec
App::PropertyBool ShowLinks;
App::PropertyBool ShowSupport;
App::PropertyBool RestoreCamera;
App::PropertyBool SectionView;
App::PropertyString EditingWorkbench;

/// Draw all constraint icons
Expand Down

0 comments on commit 043dd45

Please sign in to comment.