From 893a5d3a869cf0e71c0a2a7e06a6aae0dfb3e90c Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 13 Feb 2014 17:03:48 +0100 Subject: [PATCH] + PropertyLength inherits PropertyQuantity --- src/App/PropertyUnits.cpp | 7 ++++- src/App/PropertyUnits.h | 4 +-- src/Mod/PartDesign/App/FeaturePad.cpp | 38 --------------------------- src/Mod/PartDesign/App/FeaturePad.h | 7 ++--- 4 files changed, 10 insertions(+), 46 deletions(-) diff --git a/src/App/PropertyUnits.cpp b/src/App/PropertyUnits.cpp index 252416c42..351708b12 100644 --- a/src/App/PropertyUnits.cpp +++ b/src/App/PropertyUnits.cpp @@ -125,7 +125,12 @@ TYPESYSTEM_SOURCE(App::PropertyAcceleration, App::PropertyFloat); // PropertyLength //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -TYPESYSTEM_SOURCE(App::PropertyLength, App::PropertyFloat); +TYPESYSTEM_SOURCE(App::PropertyLength, App::PropertyQuantity); + +PropertyLength::PropertyLength() +{ + setUnit(Base::Unit::Length); +} const char* PropertyLength::getEditorName(void) const { diff --git a/src/App/PropertyUnits.h b/src/App/PropertyUnits.h index 1db865cd7..e2a6bf632 100644 --- a/src/App/PropertyUnits.h +++ b/src/App/PropertyUnits.h @@ -87,11 +87,11 @@ public: * This is a property for representing lengths. It is basically a float * property which must not be negative. On the Gui it has a quantity like m or mm. */ -class AppExport PropertyLength : public PropertyFloat +class AppExport PropertyLength : public PropertyQuantity { TYPESYSTEM_HEADER(); public: - PropertyLength(void){} + PropertyLength(void); virtual ~PropertyLength(){} virtual const char* getEditorName(void) const; diff --git a/src/Mod/PartDesign/App/FeaturePad.cpp b/src/Mod/PartDesign/App/FeaturePad.cpp index 7dbff3c79..736252afc 100644 --- a/src/Mod/PartDesign/App/FeaturePad.cpp +++ b/src/Mod/PartDesign/App/FeaturePad.cpp @@ -60,9 +60,7 @@ Pad::Pad() ADD_PROPERTY(Type,((long)0)); Type.setEnums(TypeEnums); ADD_PROPERTY(Length,(100.0)); - Length.setUnit(Base::Unit::Length); ADD_PROPERTY(Length2,(100.0)); - Length2.setUnit(Base::Unit::Length); ADD_PROPERTY_TYPE(UpToFace,(0),"Pad",(App::PropertyType)(App::Prop_None),"Face where feature will end"); } @@ -77,42 +75,6 @@ short Pad::mustExecute() const return Additive::mustExecute(); } -void Pad::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::PropertyLength") == 0 && - strcmp(prop->getTypeId().getName(), "App::PropertyQuantity") == 0) { - App::PropertyLength 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"); -} - App::DocumentObjectExecReturn *Pad::execute(void) { // Validate parameters diff --git a/src/Mod/PartDesign/App/FeaturePad.h b/src/Mod/PartDesign/App/FeaturePad.h index a8a7b1a85..a3a7cebdf 100644 --- a/src/Mod/PartDesign/App/FeaturePad.h +++ b/src/Mod/PartDesign/App/FeaturePad.h @@ -40,8 +40,8 @@ public: Pad(); App::PropertyEnumeration Type; - App::PropertyQuantity Length; - App::PropertyQuantity Length2; + App::PropertyLength Length; + App::PropertyLength Length2; App::PropertyLinkSub UpToFace; /** @name methods override feature */ @@ -67,9 +67,6 @@ public: } //@} -protected: - void Restore(Base::XMLReader &reader); - private: static const char* TypeEnums[]; //static const char* SideEnums[];