diff --git a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulatorPartMgr.cpp b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulatorPartMgr.cpp index 00de79edd2..efad98b2cd 100644 --- a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulatorPartMgr.cpp +++ b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulatorPartMgr.cpp @@ -48,6 +48,7 @@ RicPointTangentManipulatorPartMgr::RicPointTangentManipulatorPartMgr() , m_originOnStartManipulation( cvf::Vec3d::UNDEFINED ) , m_activeHandle( NONE ) , m_handleSize( 1.0 ) + , m_isGeometryUpdateNeeded( true ) { } @@ -66,7 +67,7 @@ void RicPointTangentManipulatorPartMgr::setOrigin( const cvf::Vec3d& origin ) m_origin = origin; if ( m_originOnStartManipulation.isUndefined() ) m_originOnStartManipulation = origin; - clearAllGeometryAndParts(); + m_isGeometryUpdateNeeded = true; } //-------------------------------------------------------------------------------------------------- @@ -79,7 +80,7 @@ void RicPointTangentManipulatorPartMgr::setTangent( const cvf::Vec3d& tangent ) m_tangent = tangent; if ( m_tangentOnStartManipulation.isUndefined() ) m_tangentOnStartManipulation = m_tangent; - clearAllGeometryAndParts(); + m_isGeometryUpdateNeeded = true; } //-------------------------------------------------------------------------------------------------- @@ -88,6 +89,8 @@ void RicPointTangentManipulatorPartMgr::setTangent( const cvf::Vec3d& tangent ) void RicPointTangentManipulatorPartMgr::setHandleSize( double handleSize ) { m_handleSize = handleSize; + + m_isGeometryUpdateNeeded = true; } //-------------------------------------------------------------------------------------------------- @@ -117,6 +120,11 @@ void RicPointTangentManipulatorPartMgr::appendPartsToModel( cvf::ModelBasicList* recreateAllGeometryAndParts(); } + if ( m_isGeometryUpdateNeeded ) + { + createGeometryOnly(); + } + for ( auto& idPartIt : m_handleParts ) { model->addPart( idPartIt.second.p() ); @@ -193,7 +201,7 @@ void RicPointTangentManipulatorPartMgr::updateManipulatorFromRay( const cvf::Ray } // m_tangent = newTangent; - clearAllGeometryAndParts(); + m_isGeometryUpdateNeeded = true; } //-------------------------------------------------------------------------------------------------- @@ -204,32 +212,13 @@ void RicPointTangentManipulatorPartMgr::endManipulator() m_activeHandle = NONE; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicPointTangentManipulatorPartMgr::clearAllGeometryAndParts() -{ - m_handleParts.clear(); - m_activeDragModeParts.clear(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicPointTangentManipulatorPartMgr::recreateAllGeometryAndParts() { - createAllHandleParts(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicPointTangentManipulatorPartMgr::clearGeometryOnly() -{ - for ( auto& idPartIt : m_handleParts ) - { - idPartIt.second->setDrawable( nullptr ); - } + createHorizontalPlaneHandle(); + createVerticalAxisHandle(); } //-------------------------------------------------------------------------------------------------- @@ -237,16 +226,8 @@ void RicPointTangentManipulatorPartMgr::clearGeometryOnly() //-------------------------------------------------------------------------------------------------- void RicPointTangentManipulatorPartMgr::createGeometryOnly() { - // m_handleParts[] -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicPointTangentManipulatorPartMgr::createAllHandleParts() -{ - createHorizontalPlaneHandle(); - createVerticalAxisHandle(); + m_handleParts[HORIZONTAL_PLANE]->setDrawable( createHorizontalPlaneGeo().p() ); + m_handleParts[VERTICAL_AXIS]->setDrawable( createVerticalAxisGeo().p() ); } //-------------------------------------------------------------------------------------------------- @@ -297,7 +278,7 @@ cvf::ref RicPointTangentManipulatorPartMgr::createHorizontalPl void RicPointTangentManipulatorPartMgr::createVerticalAxisHandle() { using namespace cvf; - cvf::ref geo = createVertexAxisGeo(); + cvf::ref geo = createVerticalAxisGeo(); HandleType handleId = VERTICAL_AXIS; cvf::Color4f color = cvf::Color4f( 0.0f, 0.2f, 0.8f, 0.5f ); @@ -309,7 +290,7 @@ void RicPointTangentManipulatorPartMgr::createVerticalAxisHandle() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RicPointTangentManipulatorPartMgr::createVertexAxisGeo() +cvf::ref RicPointTangentManipulatorPartMgr::createVerticalAxisGeo() { using namespace cvf; diff --git a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulatorPartMgr.h b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulatorPartMgr.h index 8962aac6a3..b6a2009ef2 100644 --- a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulatorPartMgr.h +++ b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulatorPartMgr.h @@ -72,18 +72,14 @@ public: void appendPartsToModel( cvf::ModelBasicList* model ); private: - void clearGeometryOnly(); void createGeometryOnly(); - - void createAllHandleParts(); - void clearAllGeometryAndParts(); void recreateAllGeometryAndParts(); void createHorizontalPlaneHandle(); cvf::ref createHorizontalPlaneGeo(); void createVerticalAxisHandle(); - cvf::ref createVertexAxisGeo(); + cvf::ref createVerticalAxisGeo(); void addHandlePart( cvf::DrawableGeo* geo, const cvf::Color4f& color, HandleType handleId, const cvf::String& partName ); @@ -98,13 +94,16 @@ private: static cvf::ref createPart( cvf::DrawableGeo* geo, const cvf::Color4f& color, const cvf::String& partName ); private: - HandleType m_activeHandle; std::map> m_handleParts; // These arrays have the same length cvf::Collection m_activeDragModeParts; - cvf::Vec3d m_origin; - cvf::Vec3d m_tangent; - double m_handleSize; - cvf::Vec3d m_initialPickPoint; - cvf::Vec3d m_tangentOnStartManipulation; - cvf::Vec3d m_originOnStartManipulation; + + cvf::Vec3d m_origin; + cvf::Vec3d m_tangent; + double m_handleSize; + bool m_isGeometryUpdateNeeded; + + HandleType m_activeHandle; + cvf::Vec3d m_initialPickPoint; + cvf::Vec3d m_tangentOnStartManipulation; + cvf::Vec3d m_originOnStartManipulation; }; diff --git a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicWellTarget3dEditor.cpp b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicWellTarget3dEditor.cpp index cb66e3872f..4549948391 100644 --- a/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicWellTarget3dEditor.cpp +++ b/ApplicationCode/Commands/WellPathCommands/PointTangentManipulator/RicWellTarget3dEditor.cpp @@ -92,13 +92,17 @@ void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName ) if ( m_manipulator.isNull() ) { m_manipulator = new RicPointTangentManipulator( ownerRiuViewer ); + QObject::connect( m_manipulator, SIGNAL( notifyUpdate( const cvf::Vec3d&, const cvf::Vec3d& ) ), this, SLOT( slotUpdated( const cvf::Vec3d&, const cvf::Vec3d& ) ) ); + QObject::connect( m_manipulator, SIGNAL( notifySelected() ), this, SLOT( slotSelectedIn3D() ) ); QObject::connect( m_manipulator, SIGNAL( notifyDragFinished() ), this, SLOT( slotDragFinished() ) ); + m_cvfModel = new cvf::ModelBasicList; + ownerRiuViewer->addStaticModelOnce( m_cvfModel.p() ); } @@ -113,6 +117,7 @@ void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName ) m_manipulator->setOrigin( dispXf->transformToDisplayCoord( target->targetPointXYZ() + geomDef->referencePointXyz() ) ); m_manipulator->setTangent( target->tangent() ); m_manipulator->setHandleSize( handleSize ); + m_cvfModel->removeAllParts(); m_manipulator->appendPartsToModel( m_cvfModel.p() );