+ PropertyLength inherits PropertyQuantity

This commit is contained in:
wmayer 2014-02-13 17:03:48 +01:00
parent 37f283e7d7
commit 893a5d3a86
4 changed files with 10 additions and 46 deletions

View File

@ -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
{

View File

@ -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;

View File

@ -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 ;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

View File

@ -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[];