From 428033475199889e275c1e10170e0acaf33f994f Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Wed, 24 Apr 2013 20:51:05 +0430 Subject: [PATCH] Make sure that App::Plane sketch placement is identical to deprecated SketchOrientationDialog placement --- src/Mod/Part/App/Part2DObject.cpp | 34 +++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/Mod/Part/App/Part2DObject.cpp b/src/Mod/Part/App/Part2DObject.cpp index 2a68c0018..16f754a3a 100644 --- a/src/Mod/Part/App/Part2DObject.cpp +++ b/src/Mod/Part/App/Part2DObject.cpp @@ -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(support)->Placement.getValue(); + Base::Vector3d dir; + Place.getRotation().multVec(Base::Vector3d(0,0,1),dir); + const std::vector &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(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 &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(support); if (!part || !part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) return;