[PD] Add a Suppressed property to disable a feature

This commit is contained in:
Florian Foinant-Willig
2024-01-24 22:49:46 +01:00
committed by Adrián Insaurralde Avalos
parent ffb3fabd21
commit f4763109c3
2 changed files with 22 additions and 0 deletions

View File

@@ -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

View File

@@ -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