Ensure correct sketch placement calculation

As bodies are movable now they need to be taken into account for calculating the sketch placement.
This commit is contained in:
Stefan Tröger 2015-11-08 16:31:16 +01:00
parent ef2437bb5c
commit 4ed0302404
2 changed files with 10 additions and 14 deletions

View File

@ -4157,18 +4157,10 @@ void ViewProviderSketch::setupContextMenu(QMenu *menu, QObject *receiver, const
bool ViewProviderSketch::setEdit(int ModNum)
{
//find the Part object the feature belongs to, TODO: use GRAPH methods
App::DocumentObject* search = getSketchObject();
for(Part::BodyBase* b : getSketchObject()->getDocument()->getObjectsOfType<Part::BodyBase>()) {
if(b->hasFeature(getSketchObject())) {
search = b;
}
}
for(App::Part* p : getSketchObject()->getDocument()->getObjectsOfType<App::Part>()) {
if(p->hasObject(search)) {
parentPart = p;
}
}
//find the Part and body object the feature belongs to for placement calculations
//TODO: this needs to be replaced with GRAPH methods to get the real stacked placement
parentPart = App::Part::getPartOfObject(getSketchObject());
parentBody = Part::BodyBase::findBodyOf(getSketchObject());
// always change to sketcher WB, remember where we come from
oldWb = Gui::Command::assureWorkbench("SketcherWorkbench");
@ -4896,8 +4888,10 @@ Base::Placement ViewProviderSketch::getPlacement() {
//TODO: use GRAPH placement handling, as this function right now only works with one parent
//part object
Base::Placement Plz = getSketchObject()->Placement.getValue();
if(parentBody)
Plz = parentBody->Placement.getValue()*Plz;
if(parentPart)
return parentPart->Placement.getValue()*Plz;
Plz = parentPart->Placement.getValue()*Plz;
return Plz;
}

View File

@ -25,6 +25,7 @@
#define SKETCHERGUI_VIEWPROVIDERSKETCH_H
#include <Mod/Part/Gui/ViewProvider2DObject.h>
#include <Mod/Part/App/BodyBase.h>
#include <Inventor/SbImage.h>
#include <Inventor/SbColor.h>
#include <Base/Tools2D.h>
@ -390,7 +391,8 @@ protected:
int antiAliasing;
Gui::Rubberband* rubberband;
App::Part* parentPart = nullptr;
App::Part* parentPart = nullptr;
Part::BodyBase* parentBody = nullptr;
};
} // namespace PartGui