From f4763109c34cd5d25913c045280e56aef0b1f663 Mon Sep 17 00:00:00 2001 From: Florian Foinant-Willig Date: Wed, 24 Jan 2024 22:49:46 +0100 Subject: [PATCH] [PD] Add a Suppressed property to disable a feature --- src/Mod/PartDesign/App/Feature.cpp | 18 ++++++++++++++++++ src/Mod/PartDesign/App/Feature.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp index 681da9f60f..f33d32d6f1 100644 --- a/src/Mod/PartDesign/App/Feature.cpp +++ b/src/Mod/PartDesign/App/Feature.cpp @@ -54,10 +54,28 @@ PROPERTY_SOURCE(PartDesign::Feature,Part::Feature) Feature::Feature() { ADD_PROPERTY(BaseFeature,(nullptr)); + ADD_PROPERTY(Suppressed,(false)); ADD_PROPERTY_TYPE(_Body,(nullptr),"Base",(App::PropertyType)( App::Prop_ReadOnly|App::Prop_Hidden|App::Prop_Output|App::Prop_Transient),0); Placement.setStatus(App::Property::Hidden, true); BaseFeature.setStatus(App::Property::Hidden, true); + Suppressed.setStatus(App::Property::Hidden, true); +} + +App::DocumentObjectExecReturn* Feature::recompute() +{ + try { + auto baseShape = getBaseShape(); + if (Suppressed.getValue()) { + this->Shape.setValue(baseShape); + return StdReturn; + } + } + catch (Base::Exception& e) { + //invalid BaseShape, do nothing here but recompute below + } + + return DocumentObject::recompute(); } short Feature::mustExecute() const diff --git a/src/Mod/PartDesign/App/Feature.h b/src/Mod/PartDesign/App/Feature.h index 7e671a8142..2c471992a5 100644 --- a/src/Mod/PartDesign/App/Feature.h +++ b/src/Mod/PartDesign/App/Feature.h @@ -55,6 +55,10 @@ public: App::PropertyLink BaseFeature; App::PropertyLinkHidden _Body; + App::PropertyBool Suppressed; + + App::DocumentObjectExecReturn* recompute() override; + short mustExecute() const override; /// Check whether the given feature is a datum feature