From 2af9c5038e899d543f7570d5abf64dc9298af9ae Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 15 Sep 2021 15:20:40 +0200 Subject: [PATCH] PD: move handling of changed properties of Transformed to handleChangedPropertyType --- src/Mod/PartDesign/App/FeatureTransformed.cpp | 63 +++++-------------- src/Mod/PartDesign/App/FeatureTransformed.h | 1 + 2 files changed, 18 insertions(+), 46 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index f52d1dfca8..bcde049a73 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -146,54 +146,25 @@ App::DocumentObject* Transformed::getSketchObject() const void Transformed::Restore(Base::XMLReader &reader) { - reader.readElement("Properties"); - int Cnt = reader.getAttributeAsInteger("Count"); + PartDesign::Feature::Restore(reader); +} - for (int i=0 ;igetTypeId().getName(), TypeName) == 0) { - prop->Restore(reader); - } - else if (prop) { - Base::Type inputType = Base::Type::fromName(TypeName); - if (prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId()) && - inputType.isDerivedFrom(App::PropertyFloat::getClassTypeId())) { - // Do not directly call the property's Restore method in case the implementation - // has changed. So, create a temporary PropertyFloat object and assign the value. - App::PropertyFloat floatProp; - floatProp.Restore(reader); - static_cast(prop)->setValue(floatProp.getValue()); - } - } - } - catch (const Base::XMLParseException&) { - throw; // re-throw - } - catch (const Base::Exception &e) { - Base::Console().Error("%s\n", e.what()); - } - catch (const std::exception &e) { - Base::Console().Error("%s\n", e.what()); - } - catch (const char* e) { - Base::Console().Error("%s\n", e); - } -#ifndef FC_DEBUG - catch (...) { - Base::Console().Error("Primitive::Restore: Unknown C++ exception thrown\n"); - } -#endif - - reader.readEndElement("Property"); +void Transformed::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop) +{ + // The property 'Angle' of PolarPattern has changed from PropertyFloat + // to PropertyAngle and the property 'Length' has changed to PropertyLength. + Base::Type inputType = Base::Type::fromName(TypeName); + if (prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId()) && + inputType.isDerivedFrom(App::PropertyFloat::getClassTypeId())) { + // Do not directly call the property's Restore method in case the implementation + // has changed. So, create a temporary PropertyFloat object and assign the value. + App::PropertyFloat floatProp; + floatProp.Restore(reader); + static_cast(prop)->setValue(floatProp.getValue()); + } + else { + PartDesign::Feature::handleChangedPropertyType(reader, TypeName, prop); } - reader.readEndElement("Properties"); } short Transformed::mustExecute() const diff --git a/src/Mod/PartDesign/App/FeatureTransformed.h b/src/Mod/PartDesign/App/FeatureTransformed.h index e306871497..6907288c98 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.h +++ b/src/Mod/PartDesign/App/FeatureTransformed.h @@ -90,6 +90,7 @@ public: protected: void Restore(Base::XMLReader &reader); + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); virtual void positionBySupport(void); TopoDS_Shape refineShapeIfActive(const TopoDS_Shape&) const; void divideTools(const std::vector &toolsIn, std::vector &individualsOut,