Skip to content

Commit

Permalink
+ PropertyLength inherits PropertyQuantity
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Feb 13, 2014
1 parent 37f283e commit 893a5d3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 46 deletions.
7 changes: 6 additions & 1 deletion src/App/PropertyUnits.cpp
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions src/App/PropertyUnits.h
Expand Up @@ -87,11 +87,11 @@ class AppExport PropertyDistance: public App::PropertyFloat
* 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;

Expand Down
38 changes: 0 additions & 38 deletions src/Mod/PartDesign/App/FeaturePad.cpp
Expand Up @@ -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");
}

Expand All @@ -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 ;i<Cnt ;i++) {
reader.readElement("Property");
const char* PropName = reader.getAttribute("name");
const char* TypeName = reader.getAttribute("type");
App::Property* prop = getPropertyByName(PropName);

try {
if (prop && strcmp(prop->getTypeId().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<App::PropertyQuantity*>(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
Expand Down
7 changes: 2 additions & 5 deletions src/Mod/PartDesign/App/FeaturePad.h
Expand Up @@ -40,8 +40,8 @@ class PartDesignExport Pad : public Additive
Pad();

App::PropertyEnumeration Type;
App::PropertyQuantity Length;
App::PropertyQuantity Length2;
App::PropertyLength Length;
App::PropertyLength Length2;
App::PropertyLinkSub UpToFace;

/** @name methods override feature */
Expand All @@ -67,9 +67,6 @@ class PartDesignExport Pad : public Additive
}
//@}

protected:
void Restore(Base::XMLReader &reader);

private:
static const char* TypeEnums[];
//static const char* SideEnums[];
Expand Down

0 comments on commit 893a5d3

Please sign in to comment.