From 93665fa95a29195a6893cb40c39d01398e0b9fda Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 28 Dec 2011 13:19:26 +0000 Subject: [PATCH] + restore external constraints after project load git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5352 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/App/Document.cpp | 4 +++- src/App/DocumentObject.h | 2 ++ src/Mod/Sketcher/App/SketchObject.cpp | 11 ++++++++++- src/Mod/Sketcher/App/SketchObject.h | 1 + src/Mod/Sketcher/App/SketchObjectSF.cpp | 2 +- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 9c9399ccb..d70734bfa 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -987,8 +987,10 @@ void Document::restore (void) reader.readFiles(zipstream); // reset all touched - for (std::map::iterator It= d->objectMap.begin();It!=d->objectMap.end();++It) + for (std::map::iterator It= d->objectMap.begin();It!=d->objectMap.end();++It) { + It->second->onDocumentRestored(); It->second->purgeTouched(); + } GetApplication().signalRestoreDocument(*this); } diff --git a/src/App/DocumentObject.h b/src/App/DocumentObject.h index 9658d6527..48c3f6751 100644 --- a/src/App/DocumentObject.h +++ b/src/App/DocumentObject.h @@ -179,6 +179,8 @@ protected: virtual void onBeforeChange(const Property* prop); /// get called by the container when a property was changed virtual void onChanged(const Property* prop); + /// get called after a document has been fully restored + virtual void onDocumentRestored() {} /// python object of this class and all descendend protected: // attributes diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 4d7dce5af..0fc4f76bd 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1300,7 +1300,6 @@ void SketchObject::Restore(XMLReader &reader) { // read the father classes Part::Part2DObject::Restore(reader); - rebuildExternalGeometry(); Constraints.acceptGeometry(getCompleteGeometry()); rebuildVertexIndex(); } @@ -1312,6 +1311,16 @@ void SketchObject::onChanged(const App::Property* prop) Part::Part2DObject::onChanged(prop); } +void SketchObject::onDocumentRestored() +{ + try { + rebuildExternalGeometry(); + Constraints.acceptGeometry(getCompleteGeometry()); + } + catch (...) { + } +} + void SketchObject::getGeoVertexIndex(int VertexId, int &GeoId, PointPos &PosId) { if (VertexId < 0 || VertexId >= (int)VertexId2GeoId.size()) { diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index e3ae6b800..84f2dd0c7 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -148,6 +148,7 @@ public: protected: /// get called by the container when a property has changed virtual void onChanged(const App::Property* /*prop*/); + virtual void onDocumentRestored(); private: std::vector ExternalGeo; diff --git a/src/Mod/Sketcher/App/SketchObjectSF.cpp b/src/Mod/Sketcher/App/SketchObjectSF.cpp index 2f82b4cc3..a0adf0bc1 100644 --- a/src/Mod/Sketcher/App/SketchObjectSF.cpp +++ b/src/Mod/Sketcher/App/SketchObjectSF.cpp @@ -52,7 +52,7 @@ short SketchObjectSF::mustExecute() const App::DocumentObjectExecReturn *SketchObjectSF::execute(void) { - Base::Console().Warning("%s: This feature is deprecated and will not longer supported in future version of FreeCAD \n",this->getNameInDocument()); + Base::Console().Warning("%s: This feature is deprecated and won't be longer supported in future FreeCAD versions\n",this->getNameInDocument()); // do nothing return App::DocumentObject::StdReturn; }