#7811 Modeled Well Path : Optionally show absolute coordinates

This commit is contained in:
Magne Sjaastad
2021-06-28 09:48:38 +02:00
parent eb3c52aeb1
commit 62d67a52c7
9 changed files with 241 additions and 99 deletions

View File

@@ -57,14 +57,7 @@ RicWellTarget3dEditor::~RicWellTarget3dEditor()
ownerRiuViewer->removeStaticModel( m_cvfModel.p() );
}
RimWellPathTarget* oldTarget = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
if ( oldTarget )
{
oldTarget->m_targetType.uiCapability()->removeFieldEditor( this );
oldTarget->m_targetPoint.uiCapability()->removeFieldEditor( this );
oldTarget->m_azimuth.uiCapability()->removeFieldEditor( this );
oldTarget->m_inclination.uiCapability()->removeFieldEditor( this );
}
removeAllFieldEditors();
delete m_manipulator;
}
@@ -88,10 +81,10 @@ void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
RimWellPathGeometryDef* geomDef;
target->firstAncestorOrThisOfTypeAsserted( geomDef );
target->m_targetType.uiCapability()->addFieldEditor( this );
target->m_targetPoint.uiCapability()->addFieldEditor( this );
target->m_azimuth.uiCapability()->addFieldEditor( this );
target->m_inclination.uiCapability()->addFieldEditor( this );
for ( auto field : target->fieldsFor3dManipulator() )
{
field->uiCapability()->addFieldEditor( this );
}
if ( m_manipulator.isNull() )
{
@@ -127,14 +120,7 @@ void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
//--------------------------------------------------------------------------------------------------
void RicWellTarget3dEditor::cleanupBeforeSettingPdmObject()
{
RimWellPathTarget* oldTarget = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
if ( oldTarget )
{
oldTarget->m_targetType.uiCapability()->removeFieldEditor( this );
oldTarget->m_targetPoint.uiCapability()->removeFieldEditor( this );
oldTarget->m_azimuth.uiCapability()->removeFieldEditor( this );
oldTarget->m_inclination.uiCapability()->removeFieldEditor( this );
}
removeAllFieldEditors();
}
//--------------------------------------------------------------------------------------------------
@@ -150,18 +136,38 @@ void RicWellTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Ve
return;
}
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
RimWellPathGeometryDef* geomDef;
target->firstAncestorOrThisOfTypeAsserted( geomDef );
if ( !geomDef ) return;
cvf::Vec3d domainOrigin = dispXf->transformToDomainCoord( origin ) - geomDef->anchorPointXyz();
domainOrigin.z() = -domainOrigin.z();
QVariant originVariant = caf::PdmValueFieldSpecialization<cvf::Vec3d>::convert( domainOrigin );
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
target->enableFullUpdate( false );
caf::PdmUiCommandSystemProxy::instance()->setUiValueToField( target->m_targetPoint.uiCapability(), originVariant );
target->enableFullUpdate( true );
auto domainCoordXYZ = dispXf->transformToDomainCoord( origin );
// If CTRL is pressed, modify the reference point instead of the well path target
bool modifyReferencePoint = ( QApplication::keyboardModifiers() & Qt::ControlModifier );
if ( modifyReferencePoint )
{
auto relativePositionXYZ = domainCoordXYZ - geomDef->anchorPointXyz();
auto delta = target->targetPointXYZ() - relativePositionXYZ;
auto currentRefPointXyz = geomDef->anchorPointXyz();
auto newRefPointXyz = currentRefPointXyz - delta;
geomDef->setReferencePointXyz( newRefPointXyz );
geomDef->changed.send( false );
geomDef->updateWellPathVisualization( true );
for ( auto wt : geomDef->activeWellTargets() )
{
wt->updateConnectedEditors();
}
}
else
{
cvf::Vec3d relativePositionXYD = domainCoordXYZ - geomDef->anchorPointXyz();
relativePositionXYD.z() = -relativePositionXYD.z();
target->updateFrom3DManipulator( relativePositionXYD );
}
}
//--------------------------------------------------------------------------------------------------
@@ -191,3 +197,17 @@ void RicWellTarget3dEditor::slotDragFinished()
target->onMoved();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellTarget3dEditor::removeAllFieldEditors()
{
if ( RimWellPathTarget* oldTarget = dynamic_cast<RimWellPathTarget*>( this->pdmObject() ) )
{
for ( auto field : oldTarget->fieldsFor3dManipulator() )
{
field->uiCapability()->removeFieldEditor( this );
}
}
}

View File

@@ -20,18 +20,19 @@
#include "Ric3dObjectEditorHandle.h"
class RicPointTangentManipulator;
#include "cvfObject.h"
#include "cvfVector3.h"
#include <QPointer>
class RicPointTangentManipulator;
namespace cvf
{
class ModelBasicList;
}
class QString;
#include <QPointer>
class RicWellTarget3dEditor : public Ric3dObjectEditorHandle
{
@@ -50,6 +51,9 @@ private slots:
void slotSelectedIn3D();
void slotDragFinished();
private:
void removeAllFieldEditors();
private:
QPointer<RicPointTangentManipulator> m_manipulator;
cvf::ref<cvf::ModelBasicList> m_cvfModel;