From 2284d98bcc0bbb13155d691c8b6a401a472e98a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 21 Aug 2018 16:37:03 +0200 Subject: [PATCH] #2607 Add vertical dragging to well targets --- .../RicPointTangentManipulator.cpp | 33 +++++++++++++++---- .../RicPointTangentManipulator.h | 3 +- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.cpp b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.cpp index cba013f1ba..bd855ea454 100644 --- a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.cpp +++ b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.cpp @@ -322,14 +322,35 @@ void RicPointTangentManipulatorPartMgr::updateManipulatorFromRay(const cvf::Ray* { if (!isManipulatorActive()) return; - cvf::Plane plane; - plane.setFromPointAndNormal(m_origin, cvf::Vec3d::Z_AXIS); - cvf::Vec3d newIntersection; - newMouseRay->planeIntersect(plane, &newIntersection); + if ( m_handleIds[m_currentHandleIndex] == HORIZONTAL_PLANE ) + { + cvf::Plane plane; + plane.setFromPointAndNormal(m_origin, cvf::Vec3d::Z_AXIS); + cvf::Vec3d newIntersection; + newMouseRay->planeIntersect(plane, &newIntersection); - cvf::Vec3d newOrigin = m_originOnStartManipulation + (newIntersection - m_initialPickPoint); + cvf::Vec3d newOrigin = m_originOnStartManipulation + (newIntersection - m_initialPickPoint); - m_origin = newOrigin; + m_origin = newOrigin; + } + else if ( m_handleIds[m_currentHandleIndex] == VERTICAL_AXIS ) + { + cvf::Plane plane; + cvf::Vec3d planeNormal = (newMouseRay->direction() ^ cvf::Vec3d::Z_AXIS) ^ cvf::Vec3d::Z_AXIS; + double length = planeNormal.length(); + + if (length < 1e-5) return; + + planeNormal /= length; + plane.setFromPointAndNormal(m_initialPickPoint, planeNormal ); + cvf::Vec3d newIntersection; + newMouseRay->planeIntersect(plane, &newIntersection); + + cvf::Vec3d newOrigin = m_originOnStartManipulation; + newOrigin.z() += (newIntersection.z() - m_initialPickPoint.z()); + + m_origin = newOrigin; + } //m_tangent = newTangent; clearAllGeometryAndParts(); diff --git a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.h b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.h index 106f602a1f..930aa240f6 100644 --- a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.h +++ b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.h @@ -149,11 +149,11 @@ private: const cvf::Color4f& color, const cvf::String& partName); private: + size_t m_currentHandleIndex; std::vector< HandleType > m_handleIds; // These arrays have the same length cvf::Collection m_handleParts; // These arrays have the same length cvf::Collection m_activeDragModeParts; - cvf::Vec3d m_origin; cvf::Vec3d m_tangent; double m_handleSize; @@ -162,7 +162,6 @@ private: cvf::Vec3d m_tangentOnStartManipulation; cvf::Vec3d m_originOnStartManipulation; - size_t m_currentHandleIndex; };