diff --git a/src/Mod/Part/Gui/ViewProvider2DObject.cpp b/src/Mod/Part/Gui/ViewProvider2DObject.cpp
index 910f9c61e..5e9337126 100644
--- a/src/Mod/Part/Gui/ViewProvider2DObject.cpp
+++ b/src/Mod/Part/Gui/ViewProvider2DObject.cpp
@@ -36,7 +36,9 @@
#endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
+#include
#include
+#include
#include
#include
#include
@@ -232,6 +234,56 @@ void ViewProvider2DObject::onChanged(const App::Property* prop)
}
}
+void ViewProvider2DObject::Restore(Base::XMLReader &reader)
+{
+ reader.readElement("Properties");
+ int Cnt = reader.getAttributeAsInteger("Count");
+
+ for (int i=0 ;igetTypeId().getName(), TypeName) == 0) {
+ prop->Restore(reader);
+ }
+ else if (prop) {
+ Base::Type inputType = Base::Type::fromName(TypeName);
+ if (prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId()) &&
+ inputType.isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
+ // Do not directly call the property's Restore method in case the implmentation
+ // has changed. So, create a temporary PropertyFloat object and assign the value.
+ App::PropertyFloat floatProp;
+ floatProp.Restore(reader);
+ static_cast(prop)->setValue(floatProp.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());
+ }
+ catch (const char* e) {
+ Base::Console().Error("%s\n", e);
+ }
+#ifndef FC_DEBUG
+ catch (...) {
+ Base::Console().Error("Primitive::Restore: Unknown C++ exception thrown");
+ }
+#endif
+
+ reader.readEndElement("Property");
+ }
+ reader.readEndElement("Properties");
+}
+
void ViewProvider2DObject::attach(App::DocumentObject *pcFeat)
{
ViewProviderPart::attach(pcFeat);
diff --git a/src/Mod/Part/Gui/ViewProvider2DObject.h b/src/Mod/Part/Gui/ViewProvider2DObject.h
index 4811be35d..a68ffaf9e 100644
--- a/src/Mod/Part/Gui/ViewProvider2DObject.h
+++ b/src/Mod/Part/Gui/ViewProvider2DObject.h
@@ -39,43 +39,44 @@ namespace PartGui {
class PartGuiExport ViewProvider2DObject: public PartGui::ViewProviderPart
{
- PROPERTY_HEADER(PartGui::ViewProvider2DObject);
+ PROPERTY_HEADER(PartGui::ViewProvider2DObject);
public:
- /// constructor
- ViewProvider2DObject();
- /// destructor
- virtual ~ViewProvider2DObject();
+ /// constructor
+ ViewProvider2DObject();
+ /// destructor
+ virtual ~ViewProvider2DObject();
- /// Property to switch the grid on and off
- App::PropertyBool ShowGrid;
- App::PropertyLength GridSize;
- App::PropertyEnumeration GridStyle;
- App::PropertyBool TightGrid;
- App::PropertyBool GridSnap;
+ /// Property to switch the grid on and off
+ App::PropertyBool ShowGrid;
+ App::PropertyLength GridSize;
+ App::PropertyEnumeration GridStyle;
+ App::PropertyBool TightGrid;
+ App::PropertyBool GridSnap;
- virtual void attach(App::DocumentObject *);
- virtual void updateData(const App::Property*);
- virtual std::vector getDisplayModes(void) const;
- virtual const char* getDefaultDisplayMode() const;
+ virtual void attach(App::DocumentObject *);
+ virtual void updateData(const App::Property*);
+ virtual std::vector getDisplayModes(void) const;
+ virtual const char* getDefaultDisplayMode() const;
- /// creates the grid
- SoSeparator* createGrid(void);
+ /// creates the grid
+ SoSeparator* createGrid(void);
protected:
- virtual bool setEdit(int ModNum);
- virtual void unsetEdit(int ModNum);
- /// get called by the container whenever a property has been changed
- virtual void onChanged(const App::Property* prop);
+ virtual bool setEdit(int ModNum);
+ virtual void unsetEdit(int ModNum);
+ /// get called by the container whenever a property has been changed
+ virtual void onChanged(const App::Property* prop);
+ virtual void Restore(Base::XMLReader &reader);
- SoSeparator *GridRoot;
+ SoSeparator *GridRoot;
- float MinX;
- float MaxX;
- float MinY;
- float MaxY;
- static const char* GridStyleEnums[];
- static App::PropertyQuantityConstraint::Constraints GridSizeRange;
+ float MinX;
+ float MaxX;
+ float MinY;
+ float MaxY;
+ static const char* GridStyleEnums[];
+ static App::PropertyQuantityConstraint::Constraints GridSizeRange;
};
typedef Gui::ViewProviderPythonFeatureT ViewProvider2DObjectPython;