add method restoreFinished and reimplement it in SketchObject

This commit is contained in:
wmayer
2018-12-29 15:27:32 +01:00
parent 3294fbfe94
commit 65c06fce5c
4 changed files with 25 additions and 0 deletions

View File

@@ -129,4 +129,5 @@ void Persistence::restoreFromStream(std::istream& stream)
reader.readElement("Content");
Restore(reader);
reader.readFiles(zipstream);
restoreFinished();
}

View File

@@ -154,6 +154,14 @@ public:
//restore the binary persistence data from a stream. Must have the format used by dumpToStream
void restoreFromStream(std::istream& stream);
private:
/** This method is used at the end of restoreFromStream()
* after all data files have been read in.
* A subclass can set up some internals. The default
* implementation does nothing.
*/
virtual void restoreFinished() {}
};
} //namespace Base

View File

@@ -6614,6 +6614,21 @@ void SketchObject::onDocumentRestored()
}
}
void SketchObject::restoreFinished()
{
try {
Constraints.acceptGeometry(getCompleteGeometry());
// this may happen when saving a sketch directly in edit mode
// but never performed a recompute before
if (Shape.getValue().IsNull() && hasConflicts() == 0) {
if (this->solve(true) == 0)
Shape.setValue(solvedSketch.toShape());
}
}
catch (...) {
}
}
void SketchObject::getGeoVertexIndex(int VertexId, int &GeoId, PointPos &PosId) const
{
if (VertexId < 0 || VertexId >= int(VertexId2GeoId.size())) {

View File

@@ -403,6 +403,7 @@ protected:
/// get called by the container when a property has changed
virtual void onChanged(const App::Property* /*prop*/);
virtual void onDocumentRestored();
virtual void restoreFinished();
virtual void setExpression(const App::ObjectIdentifier &path, boost::shared_ptr<App::Expression> expr, const char * comment = 0);