PartDesign/Gui: add origin sizing and rework datums sizing

This commit is contained in:
Alexander Golubev
2015-09-08 10:45:22 +03:00
committed by Stefan Tröger
parent a3e3c78388
commit 68c78de00d
21 changed files with 308 additions and 195 deletions

View File

@@ -410,42 +410,6 @@ App::DocumentObjectExecReturn *Body::execute(void)
}
Base::BoundBox3d Body::getBoundBox()
{
// TODO review the function (2015-08-31, Fat-Zer)
Base::BoundBox3d result;
Part::Feature* tipSolid = static_cast<Part::Feature*>(Tip.getValue());
if (tipSolid && tipSolid->Shape.getValue().IsNull()) {
// This can happen when a new feature is added without having its Shape property set yet
tipSolid = static_cast<Part::Feature*>(getPrevSolidFeature());
}
if (!tipSolid || tipSolid->Shape.getValue().IsNull()) {
// TODO check that all callers are correctly handle if bounding box is null (2015-08-31, Fat-Zer)
result = Base::BoundBox3d ();
} else {
result = tipSolid->Shape.getShape().getBoundBox();
}
std::vector<App::DocumentObject*> model = Model.getValues();
// TODO: In DatumLine and DatumPlane, recalculate the Base point to be as near as possible to the origin (0,0,0)
for (std::vector<App::DocumentObject*>::const_iterator m = model.begin(); m != model.end(); m++) {
if ((*m)->getTypeId().isDerivedFrom(PartDesign::Point::getClassTypeId())) {
PartDesign::Point* point = static_cast<PartDesign::Point*>(*m);
result.Add(point->getPoint());
} else if ((*m)->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) {
PartDesign::Line* line = static_cast<PartDesign::Line*>(*m);
result.Add(line->getBasePoint());
} else if ((*m)->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
PartDesign::Plane* plane = static_cast<PartDesign::Plane*>(*m);
result.Add(plane->getBasePoint());
}
}
return result;
}
void Body::onSettingDocument() {
if(connection.connected())

View File

@@ -117,9 +117,6 @@ public:
*/
static Body *findBodyOf(const App::DocumentObject* feature);
/// Return the bounding box of the Tip Shape, taking into account datum features
Base::BoundBox3d getBoundBox();
/// Returns the origin link or throws an exception
App::Origin *getOrigin () const;

View File

@@ -100,11 +100,6 @@ void Line::onChanged(const App::Property *prop)
Part::Datum::onChanged(prop);
}
Base::Vector3d Line::getBasePoint() const
{
return Placement.getValue().getPosition();
}
Base::Vector3d Line::getDirection() const
{
Base::Rotation rot = Placement.getValue().getRotation();

View File

@@ -45,7 +45,6 @@ public:
return "PartDesignGui::ViewProviderDatumLine";
}
Base::Vector3d getBasePoint() const;
Base::Vector3d getDirection() const;
protected:

View File

@@ -98,11 +98,6 @@ void Plane::onChanged(const App::Property *prop)
Part::Datum::onChanged(prop);
}
Base::Vector3d Plane::getBasePoint()
{
return Placement.getValue().getPosition();
}
Base::Vector3d Plane::getNormal()
{
Base::Rotation rot = Placement.getValue().getRotation();

View File

@@ -43,7 +43,6 @@ public:
return "PartDesignGui::ViewProviderDatumPlane";
}
Base::Vector3d getBasePoint();
Base::Vector3d getNormal();
protected: