diff --git a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.cpp b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.cpp index e6aa6235d3..706a76c054 100644 --- a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.cpp +++ b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.cpp @@ -70,6 +70,15 @@ void RicPointTangentManipulator::setTangent(const cvf::Vec3d& tangent) emit notifyRedraw(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPointTangentManipulator::setHandleSize(double handleSize) +{ + m_partManager->setHandleSize(handleSize); + emit notifyRedraw(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -177,7 +186,8 @@ bool RicPointTangentManipulator::eventFilter(QObject *obj, QEvent* inputEvent) #include "cvfHitItem.h" #include - +#include "cvfGeometryBuilderTriangles.h" +#include "cvfGeometryUtils.h" // @@ -188,7 +198,8 @@ bool RicPointTangentManipulator::eventFilter(QObject *obj, QEvent* inputEvent) RicPointTangentManipulatorPartMgr::RicPointTangentManipulatorPartMgr() : m_tangentOnStartManipulation(cvf::Vec3d::UNDEFINED), m_originOnStartManipulation(cvf::Vec3d::UNDEFINED), - m_currentHandleIndex(cvf::UNDEFINED_SIZE_T) + m_currentHandleIndex(cvf::UNDEFINED_SIZE_T), + m_handleSize(1.0) { } @@ -225,6 +236,14 @@ void RicPointTangentManipulatorPartMgr::setTangent(const cvf::Vec3d& tangent) clearAllGeometryAndParts(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPointTangentManipulatorPartMgr::setHandleSize(double handleSize) +{ + m_handleSize = handleSize; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -375,13 +394,17 @@ void RicPointTangentManipulatorPartMgr::recreateAllGeometryAndParts() void RicPointTangentManipulatorPartMgr::createAllHandleParts() { createHorizontalPlaneHandle(); + createVerticalAxisHandle(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- void RicPointTangentManipulatorPartMgr::createHorizontalPlaneHandle() { using namespace cvf; cvf::ref vertexArray = new cvf::Vec3fArray(6); - float handleSize = 1.0; + vertexArray->set(0, {-1, -1, 0} ); vertexArray->set(1, { 1, -1, 0}); vertexArray->set(2, { 1, 1, 0}); @@ -392,20 +415,71 @@ void RicPointTangentManipulatorPartMgr::createHorizontalPlaneHandle() Vec3f origin(m_origin); for (cvf::Vec3f& vx: *vertexArray) { - vx *= handleSize; + vx *= 0.5*m_handleSize; vx += origin; } ref geo = createTriangelDrawableGeo(vertexArray.p()); HandleType handleId = HORIZONTAL_PLANE; - cvf::Color4f color = cvf::Color4f(cvf::Color3::MAGENTA); + cvf::Color4f color = cvf::Color4f({1.0f, 0.0f, 1.0f, 0.5f}); cvf::String partName("PointTangentManipulator Horizontal Plane Handle"); addHandlePart(geo.p(), color, handleId, partName); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPointTangentManipulatorPartMgr::createVerticalAxisHandle() +{ + using namespace cvf; + + cvf::ref< cvf::GeometryBuilderTriangles> geomBuilder = new cvf::GeometryBuilderTriangles; + cvf::GeometryUtils::createBox({-0.25f, -0.25f, -1.0f}, { 0.25f, 0.25f, 1.0f}, geomBuilder.p()); + + cvf::ref vertexArray = geomBuilder->vertices(); + cvf::ref indexArray = geomBuilder->triangles(); + + Vec3f origin(m_origin); + for (cvf::Vec3f& vx: *vertexArray) + { + vx *= 0.5*m_handleSize; + vx += origin; + } + + ref geo = createIndexedTriangelDrawableGeo(vertexArray.p(), indexArray.p()); + + HandleType handleId = VERTICAL_AXIS; + cvf::Color4f color = cvf::Color4f({0.0f, 0.2f, 0.8f, 0.5f}); + cvf::String partName("PointTangentManipulator Vertical Axis Handle"); + + addHandlePart(geo.p(), color, handleId, partName); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RicPointTangentManipulatorPartMgr::createIndexedTriangelDrawableGeo(cvf::Vec3fArray* triangleVertexArray, + cvf::UIntArray* triangleIndices) +{ + using namespace cvf; + ref geo = new DrawableGeo; + ref primSet = new PrimitiveSetIndexedUInt(PT_TRIANGLES, triangleIndices); + + geo->setVertexArray(triangleVertexArray); + geo->addPrimitiveSet(primSet.p()); + geo->computeNormals(); + + return geo; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- cvf::ref RicPointTangentManipulatorPartMgr::createTriangelDrawableGeo(cvf::Vec3fArray* triangleVertexArray) { using namespace cvf; @@ -630,6 +704,8 @@ void RicWellPathGeometry3dEditor::configureAndUpdateUi(const QString& uiConfigNa #include "RimWellPathTarget.h" #include "RiuViewer.h" #include "cafDisplayCoordTransform.h" +#include "Rim3dView.h" +#include "RimCase.h" CAF_PDM_UI_OBJECT_3D_EDITOR_SOURCE_INIT(RicWellTarget3dEditor); @@ -692,11 +768,18 @@ void RicWellTarget3dEditor::configureAndUpdateUi(const QString& uiConfigName) m_ownerViewer->addStaticModelOnce(m_cvfModel.p()); } - RiuViewer* viewer = dynamic_cast(m_ownerViewer.data()); - cvf::ref dispXf = viewer->ownerReservoirView()->displayCoordTransform(); + cvf::ref dispXf; + double handleSize = 1.0; + { + RiuViewer* viewer = dynamic_cast(m_ownerViewer.data()); + dispXf = viewer->ownerReservoirView()->displayCoordTransform(); + Rim3dView* view = dynamic_cast(viewer->ownerReservoirView()); + handleSize = 0.5 * view->ownerCase()->characteristicCellSize(); + } m_manipulator->setOrigin(dispXf->transformToDisplayCoord( target->targetPointXYZ() + geomDef->referencePoint())); m_manipulator->setTangent(target->tangent()); + m_manipulator->setHandleSize(handleSize); m_cvfModel->removeAllParts(); m_manipulator->appendPartsToModel(m_cvfModel.p()); diff --git a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.h b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.h index 1dcaa8678f..9a18e5dce8 100644 --- a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.h +++ b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.h @@ -54,6 +54,7 @@ public: void setOrigin(const cvf::Vec3d& origin); void setTangent(const cvf::Vec3d& tangent); + void setHandleSize(double handleSize); void appendPartsToModel(cvf::ModelBasicList* model); @@ -92,6 +93,8 @@ class HitItem; template class Array; typedef Array Vec3fArray; +typedef Array UIntArray; + } class RicPointTangentManipulatorPartMgr : public cvf::Object @@ -111,6 +114,7 @@ public: void setOrigin(const cvf::Vec3d& origin); void setTangent(const cvf::Vec3d& tangent); + void setHandleSize(double handleSize); void originAndTangent(cvf::Vec3d* origin, cvf::Vec3d* tangent); bool isManipulatorActive() const; @@ -126,6 +130,7 @@ private: void recreateAllGeometryAndParts(); void createHorizontalPlaneHandle(); + void createVerticalAxisHandle(); void addHandlePart(cvf::DrawableGeo* geo, const cvf::Color4f& color, @@ -138,6 +143,8 @@ private: const cvf::String& partName); static cvf::ref createTriangelDrawableGeo(cvf::Vec3fArray* triangleVertexArray); + static cvf::ref createIndexedTriangelDrawableGeo(cvf::Vec3fArray* triangleVertexArray, + cvf::UIntArray* triangleIndices); static cvf::ref createPart(cvf::DrawableGeo* geo, const cvf::Color4f& color, const cvf::String& partName); @@ -149,6 +156,7 @@ private: cvf::Vec3d m_origin; cvf::Vec3d m_tangent; + double m_handleSize; cvf::Vec3d m_initialPickPoint; cvf::Vec3d m_tangentOnStartManipulation; @@ -168,7 +176,9 @@ private: #include "cafSelectionChangedReceiver.h" #include "cafPdmUiObjectEditorHandle.h" #include "cafFactory.h" - +// PdmUiObjectEditorHandle +// PdmUiObjectWidgetEditorHandle --<| PdmUiWidgetBasedObjectEditor PdmUiObjectFormLayoutEditor +// PdmUiObject3dEditorHandle namespace caf {