PartDesign: Allow customization of Helix preview modes

This commit is contained in:
David Osterberg
2021-02-18 09:16:35 +01:00
committed by wmayer
parent ba5c438ec2
commit 34a44073c1
3 changed files with 23 additions and 10 deletions

View File

@@ -479,28 +479,41 @@ void TaskHelixParameters::getReferenceAxis(App::DocumentObject*& obj, std::vecto
}
}
bool TaskHelixParameters::showPreview(PartDesign::Helix* helix)
{
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/PartDesign");
if ((hGrp->GetBool("SubractiveHelixPreview", true) && helix->getAddSubType() == PartDesign::FeatureAddSub::Subtractive) ||
(hGrp->GetBool("AdditiveHelixPreview", false) && helix->getAddSubType() == PartDesign::FeatureAddSub::Additive)) {
return true;
}
return false;
}
void TaskHelixParameters::startReferenceSelection(App::DocumentObject* profile, App::DocumentObject* base)
{
PartDesign::ProfileBased* pcHelix = dynamic_cast<PartDesign::Helix*>(vp->getObject());
if (pcHelix->getAddSubType() == PartDesign::FeatureAddSub::Subtractive) {
PartDesign::Helix* pcHelix = dynamic_cast<PartDesign::Helix*>(vp->getObject());
if (pcHelix && showPreview(pcHelix)) {
Gui::Document* doc = vp->getDocument();
if (doc) {
doc->setHide(profile->getNameInDocument());
}
} else {
}
else {
TaskSketchBasedParameters::startReferenceSelection(profile, base);
}
}
void TaskHelixParameters::finishReferenceSelection(App::DocumentObject* profile, App::DocumentObject* base)
{
PartDesign::ProfileBased* pcHelix = dynamic_cast<PartDesign::Helix*>(vp->getObject());
if (pcHelix->getAddSubType() == PartDesign::FeatureAddSub::Subtractive) {
PartDesign::Helix* pcHelix = dynamic_cast<PartDesign::Helix*>(vp->getObject());
if (pcHelix && showPreview(pcHelix)) {
Gui::Document* doc = vp->getDocument();
if (doc) {
doc->setShow(profile->getNameInDocument());
}
} else {
}
else {
TaskSketchBasedParameters::finishReferenceSelection(profile, base);
}
}

View File

@@ -31,8 +31,6 @@
#include "TaskSketchBasedParameters.h"
#include "ViewProviderHelix.h"
class Ui_TaskHelixParameters;
namespace App {
class Property;
}
@@ -42,6 +40,7 @@ class ViewProvider;
}
namespace PartDesignGui {
class Ui_TaskHelixParameters;
@@ -55,6 +54,8 @@ public:
virtual void apply() override;
static bool showPreview(PartDesign::Helix*);
/**
* @brief fillAxisCombo fills the combo and selects the item according to
* current value of revolution object's axis reference.

View File

@@ -78,10 +78,9 @@ QIcon ViewProviderHelix::getIcon(void) const {
bool ViewProviderHelix::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default ) {
auto* prim = static_cast<PartDesign::Helix*>(getObject());
setPreviewDisplayMode(prim->getAddSubType() == PartDesign::FeatureAddSub::Subtractive);
setPreviewDisplayMode(TaskHelixParameters::showPreview(prim));
}
return ViewProviderAddSub::setEdit(ModNum);
}