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.
This commit is contained in:
DeepSOIC
2018-04-03 23:44:04 +03:00
committed by wmayer
parent 839cef928b
commit d2ee3d2ac0
2 changed files with 32 additions and 7 deletions

View File

@@ -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()

View File

@@ -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