Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
PartDesign: support transformed pattern in FeatureDressUp
Fixes #1650
  • Loading branch information
realthunder authored and wwmayer committed Feb 14, 2020
1 parent 88a60f9 commit 469614e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Mod/PartDesign/App/AppPartDesign.cpp
Expand Up @@ -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();
Expand Down
34 changes: 33 additions & 1 deletion src/Mod/PartDesign/App/FeatureDressUp.cpp
Expand Up @@ -33,6 +33,7 @@


#include "FeatureDressUp.h"
#include <App/Document.h>
#include <Base/Exception.h>


Expand All @@ -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
Expand Down Expand Up @@ -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<FeatureAddSub>(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);
Expand Down
7 changes: 5 additions & 2 deletions src/Mod/PartDesign/App/FeatureDressUp.h
Expand Up @@ -25,12 +25,12 @@
#define PARTDESIGN_DressUp_H

#include <App/PropertyStandard.h>
#include "Feature.h"
#include "FeatureAddSub.h"

namespace PartDesign
{

class PartDesignExport DressUp : public PartDesign::Feature
class PartDesignExport DressUp : public PartDesign::FeatureAddSub
{
PROPERTY_HEADER(PartDesign::DressUp);

Expand All @@ -43,6 +43,9 @@ class PartDesignExport DressUp : public PartDesign::Feature
* 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
Expand Down

0 comments on commit 469614e

Please sign in to comment.