+ PropertyLength inherits PropertyQuantity
This commit is contained in:
parent
37f283e7d7
commit
893a5d3a86
|
@ -125,7 +125,12 @@ TYPESYSTEM_SOURCE(App::PropertyAcceleration, App::PropertyFloat);
|
||||||
// PropertyLength
|
// 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
|
const char* PropertyLength::getEditorName(void) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,11 +87,11 @@ public:
|
||||||
* This is a property for representing lengths. It is basically a float
|
* 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.
|
* 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();
|
TYPESYSTEM_HEADER();
|
||||||
public:
|
public:
|
||||||
PropertyLength(void){}
|
PropertyLength(void);
|
||||||
virtual ~PropertyLength(){}
|
virtual ~PropertyLength(){}
|
||||||
virtual const char* getEditorName(void) const;
|
virtual const char* getEditorName(void) const;
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,7 @@ Pad::Pad()
|
||||||
ADD_PROPERTY(Type,((long)0));
|
ADD_PROPERTY(Type,((long)0));
|
||||||
Type.setEnums(TypeEnums);
|
Type.setEnums(TypeEnums);
|
||||||
ADD_PROPERTY(Length,(100.0));
|
ADD_PROPERTY(Length,(100.0));
|
||||||
Length.setUnit(Base::Unit::Length);
|
|
||||||
ADD_PROPERTY(Length2,(100.0));
|
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");
|
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();
|
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)
|
App::DocumentObjectExecReturn *Pad::execute(void)
|
||||||
{
|
{
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
|
|
|
@ -40,8 +40,8 @@ public:
|
||||||
Pad();
|
Pad();
|
||||||
|
|
||||||
App::PropertyEnumeration Type;
|
App::PropertyEnumeration Type;
|
||||||
App::PropertyQuantity Length;
|
App::PropertyLength Length;
|
||||||
App::PropertyQuantity Length2;
|
App::PropertyLength Length2;
|
||||||
App::PropertyLinkSub UpToFace;
|
App::PropertyLinkSub UpToFace;
|
||||||
|
|
||||||
/** @name methods override feature */
|
/** @name methods override feature */
|
||||||
|
@ -67,9 +67,6 @@ public:
|
||||||
}
|
}
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
protected:
|
|
||||||
void Restore(Base::XMLReader &reader);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char* TypeEnums[];
|
static const char* TypeEnums[];
|
||||||
//static const char* SideEnums[];
|
//static const char* SideEnums[];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user