PD: move handling of changed properties of the Chamfer/Fillet to handleChangedPropertyType
This commit is contained in:
@@ -196,38 +196,20 @@ App::DocumentObjectExecReturn *Chamfer::execute(void)
|
||||
|
||||
void Chamfer::Restore(Base::XMLReader &reader)
|
||||
{
|
||||
reader.readElement("Properties");
|
||||
int Cnt = reader.getAttributeAsInteger("Count");
|
||||
DressUp::Restore(reader);
|
||||
}
|
||||
|
||||
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::PropertyFloatConstraint") == 0 &&
|
||||
strcmp(prop->getTypeId().getName(), "App::PropertyQuantityConstraint") == 0) {
|
||||
App::PropertyFloatConstraint p;
|
||||
p.Restore(reader);
|
||||
static_cast<App::PropertyQuantityConstraint*>(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");
|
||||
void Chamfer::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop)
|
||||
{
|
||||
if (prop && strcmp(TypeName,"App::PropertyFloatConstraint") == 0 &&
|
||||
strcmp(prop->getTypeId().getName(), "App::PropertyQuantityConstraint") == 0) {
|
||||
App::PropertyFloatConstraint p;
|
||||
p.Restore(reader);
|
||||
static_cast<App::PropertyQuantityConstraint*>(prop)->setValue(p.getValue());
|
||||
}
|
||||
else {
|
||||
DressUp::handleChangedPropertyType(reader, TypeName, prop);
|
||||
}
|
||||
reader.readEndElement("Properties");
|
||||
}
|
||||
|
||||
void Chamfer::onChanged(const App::Property* prop)
|
||||
|
||||
@@ -62,6 +62,7 @@ public:
|
||||
|
||||
protected:
|
||||
void Restore(Base::XMLReader &reader) override;
|
||||
void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop) override;
|
||||
static const App::PropertyQuantityConstraint::Constraints floatSize;
|
||||
static const App::PropertyAngle::Constraints floatAngle;
|
||||
};
|
||||
|
||||
@@ -134,36 +134,18 @@ App::DocumentObjectExecReturn *Fillet::execute(void)
|
||||
|
||||
void Fillet::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::PropertyFloatConstraint") == 0 &&
|
||||
strcmp(prop->getTypeId().getName(), "App::PropertyQuantityConstraint") == 0) {
|
||||
App::PropertyFloatConstraint p;
|
||||
p.Restore(reader);
|
||||
static_cast<App::PropertyQuantityConstraint*>(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");
|
||||
DressUp::Restore(reader);
|
||||
}
|
||||
|
||||
void Fillet::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop)
|
||||
{
|
||||
if (prop && strcmp(TypeName,"App::PropertyFloatConstraint") == 0 &&
|
||||
strcmp(prop->getTypeId().getName(), "App::PropertyQuantityConstraint") == 0) {
|
||||
App::PropertyFloatConstraint p;
|
||||
p.Restore(reader);
|
||||
static_cast<App::PropertyQuantityConstraint*>(prop)->setValue(p.getValue());
|
||||
}
|
||||
else {
|
||||
DressUp::handleChangedPropertyType(reader, TypeName, prop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
|
||||
protected:
|
||||
void Restore(Base::XMLReader &reader);
|
||||
|
||||
void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop);
|
||||
};
|
||||
|
||||
} //namespace Part
|
||||
|
||||
Reference in New Issue
Block a user