diff --git a/src/Mod/Mesh/App/FeatureMeshSolid.cpp b/src/Mod/Mesh/App/FeatureMeshSolid.cpp index 3d320c3992..d44549f127 100644 --- a/src/Mod/Mesh/App/FeatureMeshSolid.cpp +++ b/src/Mod/Mesh/App/FeatureMeshSolid.cpp @@ -35,8 +35,8 @@ namespace Mesh { - const App::PropertyIntegerConstraint::Constraints intSampling = {0,1000,1}; - const App::PropertyFloatConstraint::Constraints floatRange = {0.0,1000.0,1.0}; + const App::PropertyIntegerConstraint::Constraints intSampling = {0,INT_MAX,1}; + const App::PropertyLength::Constraints floatRange = {0.0,FLT_MAX,1.0}; } using namespace Mesh; @@ -72,6 +72,18 @@ App::DocumentObjectExecReturn *Sphere::execute(void) } } +void Sphere::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + if (prop == &Radius && strcmp(TypeName, "App::PropertyFloatConstraint") == 0) { + App::PropertyFloatConstraint r; + r.Restore(reader); + Radius.setValue(r.getValue()); + } + else { + Mesh::Feature::handleChangedPropertyType(reader, TypeName, prop); + } +} + // ------------------------------------------------------------- PROPERTY_SOURCE(Mesh::Ellipsoid, Mesh::Feature) @@ -108,6 +120,19 @@ App::DocumentObjectExecReturn *Ellipsoid::execute(void) } } +void Ellipsoid::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + if ((prop == &Radius1 || prop == &Radius2) && + strcmp(TypeName, "App::PropertyFloatConstraint") == 0) { + App::PropertyFloatConstraint r; + r.Restore(reader); + static_cast(prop)->setValue(r.getValue()); + } + else { + Mesh::Feature::handleChangedPropertyType(reader, TypeName, prop); + } +} + // ------------------------------------------------------------- PROPERTY_SOURCE(Mesh::Cylinder, Mesh::Feature) @@ -150,6 +175,19 @@ App::DocumentObjectExecReturn *Cylinder::execute(void) } } +void Cylinder::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + if ((prop == &Radius || prop == &Length || prop == &EdgeLength) && + strcmp(TypeName, "App::PropertyFloatConstraint") == 0) { + App::PropertyFloatConstraint r; + r.Restore(reader); + static_cast(prop)->setValue(r.getValue()); + } + else { + Mesh::Feature::handleChangedPropertyType(reader, TypeName, prop); + } +} + // ------------------------------------------------------------- PROPERTY_SOURCE(Mesh::Cone, Mesh::Feature) @@ -195,6 +233,19 @@ App::DocumentObjectExecReturn *Cone::execute(void) } } +void Cone::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + if ((prop == &Radius1 || prop == &Radius2 || prop == &Length || prop == &EdgeLength) && + strcmp(TypeName, "App::PropertyFloatConstraint") == 0) { + App::PropertyFloatConstraint r; + r.Restore(reader); + static_cast(prop)->setValue(r.getValue()); + } + else { + Mesh::Feature::handleChangedPropertyType(reader, TypeName, prop); + } +} + // ------------------------------------------------------------- PROPERTY_SOURCE(Mesh::Torus, Mesh::Feature) @@ -231,6 +282,19 @@ App::DocumentObjectExecReturn *Torus::execute(void) } } +void Torus::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + if ((prop == &Radius1 || prop == &Radius2) && + strcmp(TypeName, "App::PropertyFloatConstraint") == 0) { + App::PropertyFloatConstraint r; + r.Restore(reader); + static_cast(prop)->setValue(r.getValue()); + } + else { + Mesh::Feature::handleChangedPropertyType(reader, TypeName, prop); + } +} + // ------------------------------------------------------------- PROPERTY_SOURCE(Mesh::Cube, Mesh::Feature) @@ -266,3 +330,16 @@ App::DocumentObjectExecReturn *Cube::execute(void) return new App::DocumentObjectExecReturn("Cannot create cube", this); } } + +void Cube::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + if ((prop == &Length || prop == &Width || prop == &Height) && + strcmp(TypeName, "App::PropertyFloatConstraint") == 0) { + App::PropertyFloatConstraint r; + r.Restore(reader); + static_cast(prop)->setValue(r.getValue()); + } + else { + Mesh::Feature::handleChangedPropertyType(reader, TypeName, prop); + } +} diff --git a/src/Mod/Mesh/App/FeatureMeshSolid.h b/src/Mod/Mesh/App/FeatureMeshSolid.h index 1eb3ad5024..60bea888c9 100644 --- a/src/Mod/Mesh/App/FeatureMeshSolid.h +++ b/src/Mod/Mesh/App/FeatureMeshSolid.h @@ -26,7 +26,7 @@ #include "MeshFeature.h" -#include +#include #include namespace Mesh @@ -42,7 +42,7 @@ class Sphere : public Mesh::Feature public: Sphere(); - App::PropertyFloatConstraint Radius; + App::PropertyLength Radius; App::PropertyIntegerConstraint Sampling; /** @name methods override Feature */ @@ -50,6 +50,7 @@ public: /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); //@} }; @@ -62,8 +63,8 @@ class Ellipsoid : public Mesh::Feature public: Ellipsoid(); - App::PropertyFloatConstraint Radius1; - App::PropertyFloatConstraint Radius2; + App::PropertyLength Radius1; + App::PropertyLength Radius2; App::PropertyIntegerConstraint Sampling; /** @name methods override Feature */ @@ -71,6 +72,7 @@ public: /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); //@} }; @@ -83,9 +85,9 @@ class Cylinder : public Mesh::Feature public: Cylinder(); - App::PropertyFloatConstraint Radius; - App::PropertyFloatConstraint Length; - App::PropertyFloatConstraint EdgeLength; + App::PropertyLength Radius; + App::PropertyLength Length; + App::PropertyLength EdgeLength; App::PropertyBool Closed; App::PropertyIntegerConstraint Sampling; @@ -94,6 +96,7 @@ public: /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); //@} }; @@ -106,10 +109,10 @@ class Cone : public Mesh::Feature public: Cone(); - App::PropertyFloatConstraint Radius1; - App::PropertyFloatConstraint Radius2; - App::PropertyFloatConstraint Length; - App::PropertyFloatConstraint EdgeLength; + App::PropertyLength Radius1; + App::PropertyLength Radius2; + App::PropertyLength Length; + App::PropertyLength EdgeLength; App::PropertyBool Closed; App::PropertyIntegerConstraint Sampling; @@ -118,6 +121,7 @@ public: /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); //@} }; @@ -130,8 +134,8 @@ class Torus : public Mesh::Feature public: Torus(); - App::PropertyFloatConstraint Radius1; - App::PropertyFloatConstraint Radius2; + App::PropertyLength Radius1; + App::PropertyLength Radius2; App::PropertyIntegerConstraint Sampling; /** @name methods override Feature */ @@ -139,6 +143,7 @@ public: /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); //@} }; @@ -151,15 +156,16 @@ class Cube : public Mesh::Feature public: Cube(); - App::PropertyFloatConstraint Length; - App::PropertyFloatConstraint Width; - App::PropertyFloatConstraint Height; + App::PropertyLength Length; + App::PropertyLength Width; + App::PropertyLength Height; /** @name methods override Feature */ //@{ /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); //@} };