+ support loading projects with old pad features, fix critical bug where the unit gets replaced

This commit is contained in:
wmayer
2014-02-12 15:14:02 +01:00
parent cfe77ee175
commit e8eb0bd828
5 changed files with 65 additions and 32 deletions

View File

@@ -38,7 +38,7 @@ PROPERTY_SOURCE(Fem::FemResultObject, App::DocumentObject)
FemResultObject::FemResultObject()
{
ADD_PROPERTY_TYPE(DataType,(""), "General",Prop_None,"Type identifier of the result data");
ADD_PROPERTY_TYPE(Unit,(Base::Quantity()), "General",Prop_None,"Unit of the data");
ADD_PROPERTY_TYPE(Unit,(0), "General",Prop_None,"Unit of the data");
ADD_PROPERTY_TYPE(ElementNumbers,(0), "Data",Prop_None,"Numbers of the result elements");
ADD_PROPERTY_TYPE(Mesh,(0), "General",Prop_None,"Link to the corosbonding mesh");
}

View File

@@ -42,6 +42,8 @@
#include <Base/Exception.h>
#include <Base/Placement.h>
#include <Base/Console.h>
#include <Base/Reader.h>
#include <App/Document.h>
#include "FeaturePad.h"
@@ -75,6 +77,42 @@ 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

@@ -66,6 +66,10 @@ public:
return "PartDesignGui::ViewProviderPad";
}
//@}
protected:
void Restore(Base::XMLReader &reader);
private:
static const char* TypeEnums[];
//static const char* SideEnums[];