From acd0f6a79e7e7fadf82a3ee42ee94bca7df8d7d5 Mon Sep 17 00:00:00 2001 From: Eivind Kvedalen Date: Sun, 25 Oct 2015 21:48:39 +0100 Subject: [PATCH] PartDesign: Fixed issue #2302 with unit handling when using an expression for the fillet radius. --- src/Mod/PartDesign/App/FeatureFillet.cpp | 41 +++++++++++++++++++++++- src/Mod/PartDesign/App/FeatureFillet.h | 7 +++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureFillet.cpp b/src/Mod/PartDesign/App/FeatureFillet.cpp index 7d6c1f2bb..21312e212 100644 --- a/src/Mod/PartDesign/App/FeatureFillet.cpp +++ b/src/Mod/PartDesign/App/FeatureFillet.cpp @@ -29,6 +29,8 @@ # include #endif +#include +#include #include #include "FeatureFillet.h" @@ -39,11 +41,12 @@ using namespace PartDesign; PROPERTY_SOURCE(PartDesign::Fillet, PartDesign::DressUp) -const App::PropertyFloatConstraint::Constraints floatRadius = {0.0,FLT_MAX,0.1}; +const App::PropertyQuantityConstraint::Constraints floatRadius = {0.0,FLT_MAX,0.1}; Fillet::Fillet() { ADD_PROPERTY(Radius,(1.0)); + Radius.setUnit(Base::Unit::Length); Radius.setConstraints(&floatRadius); } @@ -100,3 +103,39 @@ App::DocumentObjectExecReturn *Fillet::execute(void) return new App::DocumentObjectExecReturn(e->GetMessageString()); } } + +void Fillet::Restore(Base::XMLReader &reader) +{ + reader.readElement("Properties"); + int Cnt = reader.getAttributeAsInteger("Count"); + + for (int i=0 ;igetTypeId().getName(), TypeName) == 0) { + prop->Restore(reader); + } + else if (prop && strcmp(TypeName,"App::PropertyFloatConstraint") == 0 && + strcmp(prop->getTypeId().getName(), "App::PropertyQuantityConstraint") == 0) { + App::PropertyFloatConstraint p; + p.Restore(reader); + static_cast(prop)->setValue(p.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()); + } + reader.readEndElement("Property"); + } + reader.readEndElement("Properties"); +} diff --git a/src/Mod/PartDesign/App/FeatureFillet.h b/src/Mod/PartDesign/App/FeatureFillet.h index 57bdd9fae..663704004 100644 --- a/src/Mod/PartDesign/App/FeatureFillet.h +++ b/src/Mod/PartDesign/App/FeatureFillet.h @@ -25,6 +25,7 @@ #define PARTDESIGN_FEATUREFILLET_H #include +#include #include #include "FeatureDressUp.h" @@ -38,7 +39,7 @@ class PartDesignExport Fillet : public DressUp public: Fillet(); - App::PropertyFloatConstraint Radius; + App::PropertyQuantityConstraint Radius; /** @name methods override feature */ //@{ @@ -50,6 +51,10 @@ public: return "PartDesignGui::ViewProviderFillet"; } //@} + +protected: + void Restore(Base::XMLReader &reader); + }; } //namespace Part