Automatically adjust datum line/plane size to Body bounding box

This commit is contained in:
jrheinlaender 2013-05-06 12:14:12 +04:30 committed by Stefan Tröger
parent a6431ee5cf
commit 2aea9bbf96
2 changed files with 21 additions and 0 deletions

View File

@ -292,6 +292,7 @@ void Body::removeFeature(App::DocumentObject* feature)
App::DocumentObjectExecReturn *Body::execute(void)
{
/*
Base::Console().Error("Body '%s':\n", getNameInDocument());
App::DocumentObject* tip = Tip.getValue();
Base::Console().Error(" Tip: %s\n", (tip == NULL) ? "None" : tip->getNameInDocument());
@ -307,6 +308,7 @@ App::DocumentObjectExecReturn *Body::execute(void)
Base::Console().Error("\n");
}
}
*/
const Part::TopoShape& TipShape = getTipShape();

View File

@ -34,6 +34,8 @@
#include <Gui/Application.h>
#include <Mod/PartDesign/App/Body.h>
#include <Mod/PartDesign/App/FeatureSketchBased.h>
#include <Mod/PartDesign/App/DatumLine.h>
#include <Mod/PartDesign/App/DatumPlane.h>
#include <algorithm>
#include "Base/Console.h"
@ -179,5 +181,22 @@ void ViewProviderBody::updateData(const App::Property* prop)
}
// Note: The Model property only changes by itself (without the Tip also changing) if a feature is deleted somewhere
// Update the visual size of datum lines and planes
PartDesign::Body* body = static_cast<PartDesign::Body*>(getObject());
std::vector<App::DocumentObject*> features = body->Model.getValues();
for (std::vector<App::DocumentObject*>::const_iterator f = features.begin(); f != features.end(); f++) {
App::PropertyVector* baseProp = NULL;
if ((*f)->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId()))
baseProp = &(static_cast<PartDesign::Line*>(*f)->_Base);
else if ((*f)->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId()))
baseProp = &(static_cast<PartDesign::Plane*>(*f)->_Base);
if (baseProp != NULL) {
Gui::ViewProviderDocumentObject* vp = dynamic_cast<Gui::ViewProviderDocumentObject*>(Gui::Application::Instance->getViewProvider(*f));
if (vp != NULL)
vp->updateData(baseProp);
}
}
PartGui::ViewProviderPart::updateData(prop);
}