PartDesign: support transformed pattern in FeatureDressUp

Fixes #1650
This commit is contained in:
Zheng, Lei
2020-02-13 10:48:37 +08:00
committed by wwmayer
parent 60d9607112
commit 379e07ef30
3 changed files with 39 additions and 4 deletions

View File

@@ -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();

View File

@@ -33,6 +33,7 @@
#include "FeatureDressUp.h"
#include <App/Document.h>
#include <Base/Exception.h>
@@ -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<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);

View File

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