Make sure that App::Plane sketch placement is identical to deprecated SketchOrientationDialog placement
This commit is contained in:
parent
45af3e2a78
commit
4280334751
|
@ -84,13 +84,43 @@ void Part2DObject::positionBySupport(void)
|
|||
throw Base::Exception("Sketch support has been deleted");
|
||||
|
||||
if (support->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
// Find the name of the Baseplane without having to access PartDesignGui::BaseplaneNames[]
|
||||
Place = static_cast<App::Plane*>(support)->Placement.getValue();
|
||||
Base::Vector3d dir;
|
||||
Place.getRotation().multVec(Base::Vector3d(0,0,1),dir);
|
||||
const std::vector<std::string> &sub = Support.getSubValues();
|
||||
if (!sub.empty() && (sub[0] == "back")) {
|
||||
Reverse = true;
|
||||
dir *= -1.0;
|
||||
}
|
||||
|
||||
// Set placement identical to the way it used to be done in the Sketcher::SketchOrientationDialog
|
||||
if (dir == Base::Vector3d(0,0,1)) {
|
||||
Place = Base::Placement(Base::Vector3d(0,0,0),Base::Rotation(Reverse ? -1.0 : 0.0,0.0,0.0,0.0));
|
||||
} else if (dir == Base::Vector3d(0,1,0)) {
|
||||
if (Reverse)
|
||||
Place = Base::Placement(Base::Vector3d(0,0,0),Base::Rotation(Base::Vector3d(0,sqrt(2.0)/2.0,sqrt(2.0)/2.0),M_PI));
|
||||
else
|
||||
Place = Base::Placement(Base::Vector3d(0,0,0),Base::Rotation(Base::Vector3d(-1,0,0),1.5*M_PI));
|
||||
} else if (dir == Base::Vector3d(1,0,0)) {
|
||||
Place = Base::Placement(Base::Vector3d(0,0,0),Base::Rotation(Reverse ? -0.5 : 0.5,0.5,0.5, Reverse ? -0.5 : 0.5));
|
||||
}
|
||||
|
||||
Reverse = false; // We already reversed...
|
||||
|
||||
Place.getRotation().multVec(Base::Vector3d(0,0,1),dir);
|
||||
Base::Vector3d pos = Place.getPosition();
|
||||
plane = gp_Pln(gp_Pnt(pos.x, pos.y, pos.z), gp_Dir(dir.x, dir.y, dir.z));
|
||||
}/* else if (support->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
|
||||
Place = static_cast<App::Plane*>(support)->Placement.getValue();
|
||||
// TODO: How to handle the Reverse property???
|
||||
Base::Vector3d pos = Place.getPosition();
|
||||
Base::Vector3d dir;
|
||||
Place.getRotation().multVec(Base::Vector3d(0,0,1),dir);
|
||||
const std::vector<std::string> &sub = Support.getSubValues();
|
||||
if (!sub.empty())
|
||||
Reverse = (sub[0] == "back");
|
||||
plane = gp_Pln(gp_Pnt(pos.x, pos.y, pos.z), gp_Dir(dir.x, dir.y, dir.z));
|
||||
} else {
|
||||
}*/ else {
|
||||
Part::Feature *part = static_cast<Part::Feature*>(support);
|
||||
if (!part || !part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue
Block a user