diff --git a/src/Mod/PartDesign/App/AppPartDesign.cpp b/src/Mod/PartDesign/App/AppPartDesign.cpp index 26abc6f76b..3cae7878dd 100644 --- a/src/Mod/PartDesign/App/AppPartDesign.cpp +++ b/src/Mod/PartDesign/App/AppPartDesign.cpp @@ -88,11 +88,11 @@ PyMOD_INIT_FUNC(_PartDesign) PartDesign::Feature ::init(); PartDesign::FeaturePython ::init(); PartDesign::Solid ::init(); - PartDesign::DressUp ::init(); PartDesign::FeatureAddSub ::init(); PartDesign::FeatureAddSubPython ::init(); PartDesign::FeatureAdditivePython ::init(); PartDesign::FeatureSubtractivePython ::init(); + PartDesign::DressUp ::init(); PartDesign::ProfileBased ::init(); PartDesign::Transformed ::init(); PartDesign::Mirrored ::init(); diff --git a/src/Mod/PartDesign/App/FeatureDressUp.cpp b/src/Mod/PartDesign/App/FeatureDressUp.cpp index b658318d27..3f697733b0 100644 --- a/src/Mod/PartDesign/App/FeatureDressUp.cpp +++ b/src/Mod/PartDesign/App/FeatureDressUp.cpp @@ -33,6 +33,7 @@ #include "FeatureDressUp.h" +#include #include @@ -42,12 +43,22 @@ using namespace PartDesign; namespace PartDesign { -PROPERTY_SOURCE(PartDesign::DressUp, PartDesign::Feature) +PROPERTY_SOURCE(PartDesign::DressUp, PartDesign::FeatureAddSub) DressUp::DressUp() { ADD_PROPERTY(Base,(0)); Placement.setStatus(App::Property::ReadOnly, true); + + ADD_PROPERTY_TYPE(SupportTransform,(false),"Base", App::Prop_None, + "Enable support for transform patterns"); + + addSubType = Additive; +} + +void DressUp::setupObject() { + SupportTransform.setValue(true); + FeatureAddSub::setupObject(); } short DressUp::mustExecute() const @@ -170,6 +181,27 @@ void DressUp::onChanged(const App::Property* prop) if (BaseFeature.getValue() && Base.getValue() != BaseFeature.getValue()) { BaseFeature.setValue (Base.getValue()); } + } else if (prop == &Shape || prop == &SupportTransform) { + if (!isRestoring() && !getDocument()->isPerformingTransaction()) { + Part::TopoShape s; + auto base = Base::freecad_dynamic_cast(getBaseObject(true)); + if(!base) { + addSubType = Additive; + if(!SupportTransform.getValue()) + s = getBaseShape(); + else + s = Shape.getShape(); + } else { + addSubType = base->getAddSubType(); + if(!SupportTransform.getValue()) + s = base->AddSubShape.getShape(); + else if(addSubType == Additive) + s = Shape.getShape().cut(base->getBaseShape()); + else + s = TopoShape(base->getBaseShape()).cut(Shape.getValue()); + } + AddSubShape.setValue(s); + } } Feature::onChanged(prop); diff --git a/src/Mod/PartDesign/App/FeatureDressUp.h b/src/Mod/PartDesign/App/FeatureDressUp.h index 520dc24a71..039b66cc12 100644 --- a/src/Mod/PartDesign/App/FeatureDressUp.h +++ b/src/Mod/PartDesign/App/FeatureDressUp.h @@ -25,12 +25,12 @@ #define PARTDESIGN_DressUp_H #include -#include "Feature.h" +#include "FeatureAddSub.h" namespace PartDesign { -class PartDesignExport DressUp : public PartDesign::Feature +class PartDesignExport DressUp : public PartDesign::FeatureAddSub { PROPERTY_HEADER(PartDesign::DressUp); @@ -43,6 +43,9 @@ public: * But for consistency if BaseFeature is nonzero this links to the same body as it. */ App::PropertyLinkSub Base; + App::PropertyBool SupportTransform; + + virtual void setupObject(); short mustExecute() const; /// updates the Placement property from the Placement of the BaseFeature