[Sketcher] Visibility automation : add option to force orthographic view when entering edit mode

This commit is contained in:
0penBrain
2021-05-06 18:32:13 +02:00
committed by wwmayer
parent 30d277b27a
commit bb434d3ff2
4 changed files with 40 additions and 2 deletions

View File

@@ -156,6 +156,7 @@ void SketcherSettingsDisplay::saveSettings()
ui->checkBoxTVShowLinks->onSave();
ui->checkBoxTVShowSupport->onSave();
ui->checkBoxTVRestoreCamera->onSave();
ui->checkBoxTVForceOrtho->onSave();
ui->checkBoxTVSectionView->onSave();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part");
@@ -178,6 +179,8 @@ void SketcherSettingsDisplay::loadSettings()
ui->checkBoxTVShowLinks->onRestore();
ui->checkBoxTVShowSupport->onRestore();
ui->checkBoxTVRestoreCamera->onRestore();
ui->checkBoxTVForceOrtho->onRestore();
this->ui->checkBoxTVForceOrtho->setEnabled(this->ui->checkBoxTVRestoreCamera->isChecked());
ui->checkBoxTVSectionView->onRestore();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part");
@@ -211,12 +214,14 @@ void SketcherSettingsDisplay::onBtnTVApplyClicked(bool)
" sketch.ViewObject.ShowLinks = %s\n"
" sketch.ViewObject.ShowSupport = %s\n"
" sketch.ViewObject.RestoreCamera = %s\n"
" sketch.ViewObject.ForceOrtho = %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->checkBoxTVSectionView->isChecked() ? "True": "False");
this->ui->checkBoxTVForceOrtho->isChecked() ? "True": "False",
this->ui->checkBoxTVSectionView->isChecked() ? "True": "False");
} catch (Base::PyException &e){
Base::Console().Error("SketcherSettings::onBtnTVApplyClicked:\n");
e.ReportException();

View File

@@ -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="checkBoxTVForceOrtho">
<property name="toolTip">
<string>When entering edit mode, force orthographic view of camera. Operates only with camera restoration enabled.</string>
</property>
<property name="text">
<string>Force orthographic camera when entering edit</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ForceOrtho</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher/General</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxTVSectionView">
<property name="toolTip">
@@ -445,8 +464,17 @@ Supports all unit systems except 'US customary' and 'Building US/Euro'.</string>
<tabstop>checkBoxTVShowLinks</tabstop>
<tabstop>checkBoxTVShowSupport</tabstop>
<tabstop>checkBoxTVRestoreCamera</tabstop>
<tabstop>checkBoxTVForceOrtho</tabstop>
<tabstop>checkBoxTVSectionView</tabstop>
<tabstop>btnTVApply</tabstop>
</tabstops>
<resources/>
<connections/>
<connections>
<connection>
<sender>checkBoxTVRestoreCamera</sender>
<signal>toggled(bool)</signal>
<receiver>checkBoxTVForceOrtho</receiver>
<slot>setEnabled(bool)</slot>
</connection>
</connections>
</ui>

View File

@@ -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(ForceOrtho,(false),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, camera type will be forced to orthographic view when entering editing mode.");
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.");
@@ -344,6 +345,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->ForceOrtho.setValue(hGrp->GetBool("ForceOrtho", false));
this->SectionView.setValue(hGrp->GetBool("SectionView", false));
// well it is not visibility automation but a good place nevertheless
@@ -6889,6 +6891,8 @@ void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int Mo
"ActiveSketch = App.getDocument('%1').getObject('%2')\n"
"if ActiveSketch.ViewObject.RestoreCamera:\n"
" ActiveSketch.ViewObject.TempoVis.saveCamera()\n"
" if ActiveSketch.ViewObject.ForceOrtho:\n"
" ActiveSketch.ViewObject.Document.ActiveView.setCameraType('Orthographic')\n"
).arg(QString::fromLatin1(getDocument()->getDocument()->getName())).arg(
QString::fromLatin1(getSketchObject()->getNameInDocument()));
QByteArray cmdstr_bytearray = cmdstr.toLatin1();

View File

@@ -114,6 +114,7 @@ public:
App::PropertyBool ShowLinks;
App::PropertyBool ShowSupport;
App::PropertyBool RestoreCamera;
App::PropertyBool ForceOrtho;
App::PropertyBool SectionView;
App::PropertyString EditingWorkbench;