fix sketch editing within transformed parts
This commit is contained in:
@@ -99,6 +99,7 @@
|
||||
#include <Gui/Inventor/MarkerBitmaps.h>
|
||||
|
||||
#include <Mod/Part/App/Geometry.h>
|
||||
#include <Mod/Part/App/BodyBase.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
#include <Mod/Sketcher/App/Sketch.h>
|
||||
|
||||
@@ -492,7 +493,7 @@ void ViewProviderSketch::getCoordsOnSketchPlane(double &u, double &v,const SbVec
|
||||
Base::Vector3d R0(0,0,0),RN(0,0,1),RX(1,0,0),RY(0,1,0);
|
||||
|
||||
// move to position of Sketch
|
||||
Base::Placement Plz = getSketchObject()->Placement.getValue();
|
||||
Base::Placement Plz = getPlacement();
|
||||
R0 = Plz.getPosition() ;
|
||||
Base::Rotation tmp(Plz.getRotation());
|
||||
tmp.multVec(RN,RN);
|
||||
@@ -1869,7 +1870,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
||||
Sketcher::SketchObject *sketchObject = getSketchObject();
|
||||
App::Document *doc = sketchObject->getDocument();
|
||||
|
||||
Base::Placement Plm = sketchObject->Placement.getValue();
|
||||
Base::Placement Plm = getPlacement();
|
||||
|
||||
int intGeoCount = sketchObject->getHighestCurveIndex() + 1;
|
||||
int extGeoCount = sketchObject->getExternalGeometryCount();
|
||||
@@ -3950,7 +3951,7 @@ void ViewProviderSketch::rebuildConstraintsVisual(void)
|
||||
Base::Vector3d RN(0,0,1);
|
||||
|
||||
// move to position of Sketch
|
||||
Base::Placement Plz = getSketchObject()->Placement.getValue();
|
||||
Base::Placement Plz = getPlacement();
|
||||
Base::Rotation tmp(Plz.getRotation());
|
||||
tmp.multVec(RN,RN);
|
||||
Plz.setRotation(tmp);
|
||||
@@ -4145,7 +4146,7 @@ void ViewProviderSketch::onChanged(const App::Property *prop)
|
||||
}
|
||||
|
||||
void ViewProviderSketch::attach(App::DocumentObject *pcFeat)
|
||||
{
|
||||
{
|
||||
ViewProviderPart::attach(pcFeat);
|
||||
}
|
||||
|
||||
@@ -4156,6 +4157,19 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
// always change to sketcher WB, remember where we come from
|
||||
oldWb = Gui::Command::assureWorkbench("SketcherWorkbench");
|
||||
|
||||
@@ -4592,7 +4606,7 @@ void ViewProviderSketch::unsetEdit(int ModNum)
|
||||
|
||||
void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int ModNum)
|
||||
{
|
||||
Base::Placement plm = getSketchObject()->Placement.getValue();
|
||||
Base::Placement plm = getPlacement();
|
||||
Base::Rotation tmp(plm.getRotation());
|
||||
|
||||
SbRotation rot((float)tmp[0],(float)tmp[1],(float)tmp[2],(float)tmp[3]);
|
||||
@@ -4877,3 +4891,14 @@ bool ViewProviderSketch::onDelete(const std::vector<std::string> &subList)
|
||||
// if not in edit delete the whole object
|
||||
return PartGui::ViewProviderPart::onDelete(subList);
|
||||
}
|
||||
|
||||
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(parentPart)
|
||||
return parentPart->Placement.getValue()*Plz;
|
||||
|
||||
return Plz;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,10 @@
|
||||
#include <Inventor/SbImage.h>
|
||||
#include <Inventor/SbColor.h>
|
||||
#include <Base/Tools2D.h>
|
||||
#include <Base/Placement.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/GLPainter.h>
|
||||
#include <App/Part.h>
|
||||
#include <boost/signals.hpp>
|
||||
#include <QCoreApplication>
|
||||
#include <Gui/Document.h>
|
||||
@@ -345,6 +347,9 @@ protected:
|
||||
void removeSelectPoint(int SelectPoint);
|
||||
void clearSelectPoints(void);
|
||||
|
||||
// handle stacked placements of App::Parts
|
||||
Base::Placement getPlacement();
|
||||
|
||||
// modes while sketching
|
||||
SketchMode Mode;
|
||||
|
||||
@@ -381,8 +386,11 @@ protected:
|
||||
double xInit,yInit;
|
||||
bool relative;
|
||||
|
||||
Gui::Rubberband* rubberband;
|
||||
std::string oldWb;
|
||||
int antiAliasing;
|
||||
|
||||
Gui::Rubberband* rubberband;
|
||||
App::Part* parentPart = nullptr;
|
||||
};
|
||||
|
||||
} // namespace PartGui
|
||||
|
||||
Reference in New Issue
Block a user