From d2ee3d2ac09bf1c1f32f42e8a971d27c601d9e4a Mon Sep 17 00:00:00 2001 From: DeepSOIC Date: Tue, 3 Apr 2018 23:44:04 +0300 Subject: [PATCH] PartDesign: fix #0002758 Datum point moves to (0,0,0) when reopening the file OCC has a peculiarity, that when saving single vertexes, it burns in placement into vertex coordinates. In loaded shape, Placement is zero. This caused datum point placement reset to zero, and its shape had nonzero coordinates. This fix keeps placement property from resetting, and reconstructs a new vertex upon load. --- src/Mod/PartDesign/App/DatumPoint.cpp | 34 +++++++++++++++++++++------ src/Mod/PartDesign/App/DatumPoint.h | 5 ++++ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/Mod/PartDesign/App/DatumPoint.cpp b/src/Mod/PartDesign/App/DatumPoint.cpp index 4615ad2e4d..297d562769 100644 --- a/src/Mod/PartDesign/App/DatumPoint.cpp +++ b/src/Mod/PartDesign/App/DatumPoint.cpp @@ -80,12 +80,7 @@ PROPERTY_SOURCE(PartDesign::Point, Part::Datum) Point::Point() { this->setAttacher(new AttachEnginePoint); - // Create a shape, which will be used by the Sketcher. Them main function is to avoid a dependency of - // Sketcher on the PartDesign module - BRepBuilderAPI_MakeVertex builder(gp_Pnt(0,0,0)); - if (!builder.IsDone()) - return; - Shape.setValue(builder.Shape()); + this->makeShape(); } Point::~Point() @@ -94,7 +89,32 @@ Point::~Point() void Point::onChanged(const App::Property* prop) { - Part::Datum::onChanged(prop); + if(prop == &(this->Shape)){ + //fix for #0002758 Datum point moves to (0,0,0) when reopening the file. + //bypass Part::Feature's onChanged, which may alter Placement property to match shape's placement. + //This is to prevent loss of correct Placement when restoring Shape from file. + App::GeoFeature::onChanged(prop); + return; + } + Superclass::onChanged(prop); +} + +void Point::Restore(Base::XMLReader& r) +{ + Superclass::Restore(r); + //fix for #0002758 Datum point moves to (0,0,0) when reopening the file. + //recreate shape, as the restored one has old Placement burned into it. + this->makeShape(); +} + +void Point::makeShape() +{ + // Create a shape, which will be used by Sketcher, attachables, and whatever. Them main function is to avoid a dependency of + // Sketcher on the PartDesign module + BRepBuilderAPI_MakeVertex builder(gp_Pnt(0,0,0)); + if (!builder.IsDone()) + return; + Shape.setValue(builder.Shape()); } Base::Vector3d Point::getPoint() diff --git a/src/Mod/PartDesign/App/DatumPoint.h b/src/Mod/PartDesign/App/DatumPoint.h index 9227bbe43e..19dfdbeb41 100644 --- a/src/Mod/PartDesign/App/DatumPoint.h +++ b/src/Mod/PartDesign/App/DatumPoint.h @@ -46,8 +46,13 @@ public: Base::Vector3d getPoint(); + typedef Part::Datum Superclass; + protected: virtual void onChanged(const App::Property* prop); + virtual void Restore(Base::XMLReader& r); +private: + void makeShape(); }; } //namespace PartDesign