From afb335519329a67f8ad5b7d5d906128e77543273 Mon Sep 17 00:00:00 2001 From: logari81 Date: Sun, 6 Jan 2013 23:33:00 +0100 Subject: [PATCH] Make Multitransform children inherit its Placement --- .../PartDesign/App/FeatureMultiTransform.cpp | 17 +++++++++++++++-- src/Mod/PartDesign/App/FeatureMultiTransform.h | 3 +++ src/Mod/PartDesign/App/FeatureTransformed.cpp | 11 +---------- src/Mod/PartDesign/App/FeatureTransformed.h | 5 +---- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureMultiTransform.cpp b/src/Mod/PartDesign/App/FeatureMultiTransform.cpp index 6fd4af46b..fcb10733c 100644 --- a/src/Mod/PartDesign/App/FeatureMultiTransform.cpp +++ b/src/Mod/PartDesign/App/FeatureMultiTransform.cpp @@ -49,6 +49,19 @@ MultiTransform::MultiTransform() Transformations.setSize(0); } +void MultiTransform::positionBySupport(void) +{ + PartDesign::Transformed::positionBySupport(); + std::vector transFeatures = Transformations.getValues(); + for (std::vector::const_iterator f = transFeatures.begin(); + f != transFeatures.end(); f++) { + if (!((*f)->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()))) + throw Base::Exception("Transformation features must be subclasses of Transformed"); + PartDesign::Transformed* transFeature = static_cast(*f); + transFeature->Placement.setValue(this->Placement.getValue()); + } +} + short MultiTransform::mustExecute() const { if (Transformations.isTouched()) @@ -58,7 +71,7 @@ short MultiTransform::mustExecute() const const std::list MultiTransform::getTransformations(const std::vector originals) { - std::vector transformationFeatures = Transformations.getValues(); + std::vector transFeatures = Transformations.getValues(); // Find centre of gravity of first original // FIXME: This method will NOT give the expected result for more than one original! @@ -81,7 +94,7 @@ const std::list MultiTransform::getTransformations(const std::vector cogs; std::vector::const_iterator f; - for (f = transformationFeatures.begin(); f != transformationFeatures.end(); f++) { + for (f = transFeatures.begin(); f != transFeatures.end(); f++) { if (!((*f)->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()))) throw Base::Exception("Transformation features must be subclasses of Transformed"); PartDesign::Transformed* transFeature = static_cast(*f); diff --git a/src/Mod/PartDesign/App/FeatureMultiTransform.h b/src/Mod/PartDesign/App/FeatureMultiTransform.h index 775624f59..d35f9089b 100644 --- a/src/Mod/PartDesign/App/FeatureMultiTransform.h +++ b/src/Mod/PartDesign/App/FeatureMultiTransform.h @@ -58,6 +58,9 @@ public: * Scaled. */ const std::list getTransformations(const std::vector originals); + +protected: + virtual void positionBySupport(void); }; } //namespace PartDesign diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index 8e55f17d0..6d5146333 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -53,16 +53,7 @@ Transformed::Transformed() : rejected(0) { ADD_PROPERTY(Originals,(0)); Originals.setSize(0); -} - -void Transformed::onChanged(const App::Property* prop) -{ - if (prop == &Originals) { - // if attached then mark it as read-only - this->Placement.StatusBits.set(2, Originals.getSize() != 0); - } - - PartDesign::Feature::onChanged(prop); + Placement.StatusBits.set(2, true); } void Transformed::positionBySupport(void) diff --git a/src/Mod/PartDesign/App/FeatureTransformed.h b/src/Mod/PartDesign/App/FeatureTransformed.h index ab2b29f6a..ab9b9ae43 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.h +++ b/src/Mod/PartDesign/App/FeatureTransformed.h @@ -71,17 +71,14 @@ public: short mustExecute() const; //@} - void positionBySupport(void); - /** returns a list of the transformations that where rejected during the last execute * because they did not ovelap with the support */ const std::list getRejectedTransformations(void) { return rejected; } protected: - void onChanged(const App::Property* prop); + virtual void positionBySupport(void); -protected: std::list rejected; };