#4969 Fix Well path and annotation draggers not visible and does not work in comparison view

This commit is contained in:
Jacob Støren 2019-11-06 14:04:42 +01:00
parent 904808394b
commit 277f8c8b7a
17 changed files with 173 additions and 78 deletions

View File

@ -70,10 +70,12 @@ void RicTextAnnotation3dEditor::configureAndUpdateUi( const QString& uiConfigNam
{
RimTextAnnotation* textAnnot = dynamic_cast<RimTextAnnotation*>( this->pdmObject() );
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
Rim3dView* view = mainOrComparisonView();
if ( !textAnnot || !textAnnot->isActive() )
if ( !textAnnot || !textAnnot->isActive() || !view )
{
m_cvfModel->removeAllParts();
if ( m_cvfModel.notNull() ) m_cvfModel->removeAllParts();
return;
}
@ -94,16 +96,12 @@ void RicTextAnnotation3dEditor::configureAndUpdateUi( const QString& uiConfigNam
SLOT( slotAnchorUpdated( const cvf::Vec3d&, const cvf::Vec3d& ) ) );
m_cvfModel = new cvf::ModelBasicList;
ownerRiuViewer->addStaticModelOnce( m_cvfModel.p() );
ownerRiuViewer->addStaticModelOnce( m_cvfModel.p(), isInComparisonView() );
}
cvf::ref<caf::DisplayCoordTransform> dispXf;
double handleSize = 1.0;
{
dispXf = ownerRiuViewer->ownerReservoirView()->displayCoordTransform();
Rim3dView* view = dynamic_cast<Rim3dView*>( ownerRiuViewer->ownerReservoirView() );
handleSize = 0.7 * view->ownerCase()->characteristicCellSize();
}
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
double handleSize = 0.7 * view->ownerCase()->characteristicCellSize();
cvf::Vec3d labelPos( textAnnot->m_labelPointXyd() );
labelPos.z() *= -1.0;
m_labelManipulator->setOrigin( dispXf->transformToDisplayCoord( labelPos ) );
@ -145,6 +143,7 @@ void RicTextAnnotation3dEditor::slotLabelUpdated( const cvf::Vec3d& origin, cons
{
return;
}
updatePoint( textAnnot->m_labelPointXyd.uiCapability(), origin );
}
@ -159,6 +158,7 @@ void RicTextAnnotation3dEditor::slotAnchorUpdated( const cvf::Vec3d& origin, con
{
return;
}
updatePoint( textAnnot->m_anchorPointXyd.uiCapability(), origin );
}
@ -167,11 +167,11 @@ void RicTextAnnotation3dEditor::slotAnchorUpdated( const cvf::Vec3d& origin, con
//--------------------------------------------------------------------------------------------------
void RicTextAnnotation3dEditor::updatePoint( caf::PdmUiFieldHandle* uiField, const cvf::Vec3d& newPos )
{
cvf::ref<caf::DisplayCoordTransform> dispXf;
{
RiuViewer* viewer = dynamic_cast<RiuViewer*>( ownerViewer() );
dispXf = viewer->ownerReservoirView()->displayCoordTransform();
}
Rim3dView* view = mainOrComparisonView();
if ( !view ) return;
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
cvf::Vec3d domainPos = dispXf->transformToDomainCoord( newPos );
domainPos.z() = -domainPos.z();

View File

@ -18,7 +18,7 @@
#pragma once
#include "cafPdmUi3dObjectEditorHandle.h"
#include "WellPathCommands/PointTangentManipulator/Ric3dObjectEditorHandle.h"
class RicPointTangentManipulator;
@ -33,7 +33,7 @@ class ModelBasicList;
class QString;
#include <QPointer>
class RicTextAnnotation3dEditor : public caf::PdmUi3dObjectEditorHandle
class RicTextAnnotation3dEditor : public Ric3dObjectEditorHandle
{
CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT;
Q_OBJECT

View File

@ -17,6 +17,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicWellPathFormationsImportFileFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPolylineTargetsPickEventHandler.h
${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineTargetFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicDeletePolylineTargetFeature.h
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/Ric3dObjectEditorHandle.h
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulator.h
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellTarget3dEditor.h
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellPathGeometry3dEditor.h
@ -43,6 +44,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicWellPathFormationsImportFileFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPolylineTargetsPickEventHandler.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineTargetFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicDeletePolylineTargetFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/Ric3dObjectEditorHandle.cpp
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulator.cpp
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellTarget3dEditor.cpp
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellPathGeometry3dEditor.cpp

View File

@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "Ric3dObjectEditorHandle.h"
#include "Rim3dView.h"
#include "RiuViewer.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim3dView* Ric3dObjectEditorHandle::mainOrComparisonView()
{
RiuViewer* viewer = dynamic_cast<RiuViewer*>( ownerViewer() );
if ( !viewer ) return nullptr;
if ( isInComparisonView() )
{
if ( viewer->currentScene( isInComparisonView() ) )
{
Rim3dView* view = dynamic_cast<Rim3dView*>( viewer->ownerReservoirView() );
if ( view )
{
return view->activeComparisonView();
}
}
return nullptr;
}
else
{
return dynamic_cast<Rim3dView*>( viewer->ownerReservoirView() );
}
}

View File

@ -0,0 +1,28 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmUi3dObjectEditorHandle.h"
class Rim3dView;
class Ric3dObjectEditorHandle : public caf::PdmUi3dObjectEditorHandle
{
protected:
Rim3dView* mainOrComparisonView();
};

View File

@ -31,6 +31,7 @@
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfRay.h"
#include "cvfRayIntersectSpec.h"
#include <QDebug>
#include <QMouseEvent>
@ -104,6 +105,9 @@ bool RicPointTangentManipulator::eventFilter( QObject* obj, QEvent* inputEvent )
if ( m_partManager->isManipulatorActive() )
{
m_isDraggingInComparisonView = m_viewer->isMousePosWithinComparisonView( mouseEvent->x(),
mouseEvent->y() );
emit notifySelected();
return true;
@ -117,17 +121,14 @@ bool RicPointTangentManipulator::eventFilter( QObject* obj, QEvent* inputEvent )
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( inputEvent );
// qDebug() << "Inside mouse move";
// qDebug() << mouseEvent->pos();
cvf::ref<cvf::RayIntersectSpec> rayIs =
m_viewer->rayIntersectSpecFromWindowCoordinates( mouseEvent->pos().x(),
mouseEvent->pos().y(),
m_isDraggingInComparisonView );
int translatedMousePosX = mouseEvent->pos().x();
int translatedMousePosY = m_viewer->height() - mouseEvent->pos().y();
cvf::ref<cvf::Ray> ray = m_viewer->mainCamera()->rayFromWindowCoordinates( translatedMousePosX,
translatedMousePosY );
if ( !ray.isNull() )
if ( !rayIs.isNull() && rayIs->ray() )
{
m_partManager->updateManipulatorFromRay( ray.p() );
m_partManager->updateManipulatorFromRay( rayIs->ray() );
cvf::Vec3d origin;
cvf::Vec3d tangent;

View File

@ -68,6 +68,7 @@ protected:
private:
QPointer<caf::Viewer> m_viewer;
bool m_isDraggingInComparisonView = false;
cvf::ref<RicPointTangentManipulatorPartMgr> m_partManager;
};

View File

@ -80,7 +80,7 @@ void RicPolyline3dEditor::configureAndUpdateUi( const QString& uiConfigName )
for ( auto target : targets )
{
auto targetEditor = new RicPolylineTarget3dEditor;
targetEditor->setViewer( ownerViewer() );
targetEditor->setViewer( ownerViewer(), isInComparisonView() );
targetEditor->setPdmObject( target );
m_targetEditors.push_back( targetEditor );
targetEditor->updateUi();

View File

@ -71,10 +71,12 @@ void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigNam
{
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
Rim3dView* view = mainOrComparisonView();
if ( !target || !target->isEnabled() )
if ( !target || !target->isEnabled() || !view )
{
m_cvfModel->removeAllParts();
if ( m_cvfModel.notNull() ) m_cvfModel->removeAllParts();
return;
}
@ -93,16 +95,11 @@ void RicPolylineTarget3dEditor::configureAndUpdateUi( const QString& uiConfigNam
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() );
ownerRiuViewer->addStaticModelOnce( m_cvfModel.p(), isInComparisonView() );
}
cvf::ref<caf::DisplayCoordTransform> dispXf;
double handleSize = 1.0;
{
dispXf = ownerRiuViewer->ownerReservoirView()->displayCoordTransform();
Rim3dView* view = dynamic_cast<Rim3dView*>( ownerRiuViewer->ownerReservoirView() );
handleSize = 0.7 * view->ownerCase()->characteristicCellSize();
}
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
double handleSize = 0.7 * view->ownerCase()->characteristicCellSize();
m_manipulator->setOrigin( dispXf->transformToDisplayCoord( target->targetPointXYZ() ) );
// m_manipulator->setTangent(target->tangent());
@ -131,17 +128,14 @@ void RicPolylineTarget3dEditor::cleanupBeforeSettingPdmObject()
void RicPolylineTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Vec3d& tangent )
{
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );
Rim3dView* view = mainOrComparisonView();
if ( !target )
if ( !target || !view )
{
return;
}
cvf::ref<caf::DisplayCoordTransform> dispXf;
{
RiuViewer* viewer = dynamic_cast<RiuViewer*>( ownerViewer() );
dispXf = viewer->ownerReservoirView()->displayCoordTransform();
}
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
RimUserDefinedPolylinesAnnotation* polylineDef;
target->firstAncestorOrThisOfTypeAsserted( polylineDef );
@ -155,6 +149,9 @@ void RicPolylineTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf
target->enableFullUpdate( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPolylineTarget3dEditor::slotSelectedIn3D()
{
RimPolylineTarget* target = dynamic_cast<RimPolylineTarget*>( this->pdmObject() );

View File

@ -18,7 +18,7 @@
#pragma once
#include "cafPdmUi3dObjectEditorHandle.h"
#include "Ric3dObjectEditorHandle.h"
class RicPointTangentManipulator;
@ -33,7 +33,7 @@ class ModelBasicList;
class QString;
#include <QPointer>
class RicPolylineTarget3dEditor : public caf::PdmUi3dObjectEditorHandle
class RicPolylineTarget3dEditor : public Ric3dObjectEditorHandle
{
CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT;
Q_OBJECT

View File

@ -70,7 +70,7 @@ void RicWellPathGeometry3dEditor::configureAndUpdateUi( const QString& uiConfigN
for ( auto target : targets )
{
auto targetEditor = new RicWellTarget3dEditor;
targetEditor->setViewer( ownerViewer() );
targetEditor->setViewer( ownerViewer(), isInComparisonView() );
targetEditor->setPdmObject( target );
m_targetEditors.push_back( targetEditor );
targetEditor->updateUi();

View File

@ -74,10 +74,12 @@ void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
{
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
RiuViewer* ownerRiuViewer = dynamic_cast<RiuViewer*>( ownerViewer() );
Rim3dView* view = mainOrComparisonView();
if ( !target || !target->isEnabled() )
if ( !target || !target->isEnabled() || !view )
{
m_cvfModel->removeAllParts();
if ( m_cvfModel.notNull() ) m_cvfModel->removeAllParts();
return;
}
@ -102,17 +104,11 @@ void RicWellTarget3dEditor::configureAndUpdateUi( const QString& uiConfigName )
QObject::connect( m_manipulator, SIGNAL( notifyDragFinished() ), this, SLOT( slotDragFinished() ) );
m_cvfModel = new cvf::ModelBasicList;
ownerRiuViewer->addStaticModelOnce( m_cvfModel.p() );
ownerRiuViewer->addStaticModelOnce( m_cvfModel.p(), isInComparisonView() );
}
cvf::ref<caf::DisplayCoordTransform> dispXf;
double handleSize = 1.0;
{
dispXf = ownerRiuViewer->ownerReservoirView()->displayCoordTransform();
Rim3dView* view = dynamic_cast<Rim3dView*>( ownerRiuViewer->ownerReservoirView() );
handleSize = 0.7 * view->ownerCase()->characteristicCellSize();
}
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
double handleSize = 0.7 * view->ownerCase()->characteristicCellSize();
m_manipulator->setOrigin( dispXf->transformToDisplayCoord( target->targetPointXYZ() + geomDef->referencePointXyz() ) );
m_manipulator->setTangent( target->tangent() );
@ -145,17 +141,14 @@ void RicWellTarget3dEditor::cleanupBeforeSettingPdmObject()
void RicWellTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Vec3d& tangent )
{
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );
Rim3dView* view = mainOrComparisonView();
if ( !target )
if ( !target || !view )
{
return;
}
cvf::ref<caf::DisplayCoordTransform> dispXf;
{
RiuViewer* viewer = dynamic_cast<RiuViewer*>( ownerViewer() );
dispXf = viewer->ownerReservoirView()->displayCoordTransform();
}
cvf::ref<caf::DisplayCoordTransform> dispXf = view->displayCoordTransform();
RimWellPathGeometryDef* geomDef;
target->firstAncestorOrThisOfTypeAsserted( geomDef );
@ -169,6 +162,9 @@ void RicWellTarget3dEditor::slotUpdated( const cvf::Vec3d& origin, const cvf::Ve
target->enableFullUpdate( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellTarget3dEditor::slotSelectedIn3D()
{
RimWellPathTarget* target = dynamic_cast<RimWellPathTarget*>( this->pdmObject() );

View File

@ -18,7 +18,7 @@
#pragma once
#include "cafPdmUi3dObjectEditorHandle.h"
#include "Ric3dObjectEditorHandle.h"
class RicPointTangentManipulator;
@ -33,7 +33,7 @@ class ModelBasicList;
class QString;
#include <QPointer>
class RicWellTarget3dEditor : public caf::PdmUi3dObjectEditorHandle
class RicWellTarget3dEditor : public Ric3dObjectEditorHandle
{
CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT;
Q_OBJECT

View File

@ -64,9 +64,11 @@ PdmUi3dObjectEditorHandle::~PdmUi3dObjectEditorHandle()
/// to be cast able to whatever is needed in subclasses.
/// Not allowed to change. Should be constructor argument, but makes factory stuff difficult.
//--------------------------------------------------------------------------------------------------
void PdmUi3dObjectEditorHandle::setViewer(QWidget* ownerViewer)
void PdmUi3dObjectEditorHandle::setViewer(QWidget* ownerViewer, bool inComparisonView)
{
CAF_ASSERT(m_ownerViewer.isNull());
m_ownerViewer = ownerViewer;
m_isInComparisonView = inComparisonView;
}
}
}

View File

@ -75,14 +75,15 @@ public:
PdmUi3dObjectEditorHandle();
~PdmUi3dObjectEditorHandle() override;
void setViewer(QWidget* ownerViewer);
void setViewer(QWidget* ownerViewer, bool isInComparisonView);
protected:
QWidget* ownerViewer() const { return m_ownerViewer;}
bool isInComparisonView() const { return m_isInComparisonView; }
private:
QPointer<QWidget> m_ownerViewer;
QPointer<QWidget> m_ownerViewer;
bool m_isInComparisonView;
};
}

View File

@ -109,13 +109,28 @@ void PdmUiSelection3dEditorVisualizer::onSelectionManagerSelectionChanged( const
if (!editor3dTypeName.isEmpty())
{
PdmObjectHandle* itemObject = dynamic_cast<PdmObjectHandle*>(item);
if (itemObject)
if ( itemObject )
{
PdmUi3dObjectEditorHandle* editor3d = caf::Factory<PdmUi3dObjectEditorHandle, QString>::instance()->create(editor3dTypeName);
editor3d->setViewer(m_ownerViewer);
editor3d->setPdmObject(itemObject);
m_active3DEditors.emplace_back(editor3d);
editor3d->updateUi();
// Editor in main view
{
PdmUi3dObjectEditorHandle* editor3d = caf::Factory<PdmUi3dObjectEditorHandle, QString>::instance()->create(editor3dTypeName);
editor3d->setViewer(m_ownerViewer, false);
editor3d->setPdmObject(itemObject);
m_active3DEditors.emplace_back(editor3d);
editor3d->updateUi();
}
QVariant isComparisonActive = m_ownerViewer->property("cafViewer_IsComparisonViewActive");
// Editor in comparison view
if (!isComparisonActive.isNull() && isComparisonActive.isValid() && isComparisonActive.toBool())
{
PdmUi3dObjectEditorHandle* editor3d = caf::Factory<PdmUi3dObjectEditorHandle, QString>::instance()->create(editor3dTypeName);
editor3d->setViewer(m_ownerViewer, true);
editor3d->setPdmObject(itemObject);
m_active3DEditors.emplace_back(editor3d);
editor3d->updateUi();
}
}
}
}

View File

@ -14,8 +14,6 @@ RicPointTangentManipulator -* RicPointTangentManipulatorPartMgr
PdmUiObjectEditorHandle <|-- PdmUi3dObjectEditorHandle
PdmUi3dObjectEditorHandle <|-- RicWellTarget3dEditor
RicWellTarget3dEditor --* RicPointTangentManipulator
RicWellPathGeometry3dEditor -* "n" RicWellTarget3dEditor
@ -23,7 +21,11 @@ PdmUi3dObjectEditorHandle <|-- RicWellPathGeometry3dEditor
RicPointTangentManipulator ..up.> "installEventFilter()" Viewer
PdmUi3dObjectEditorHandle <|-- Ric3dObjectEditorHandle
Ric3dObjectEditorHandle <|-- RicWellTarget3dEditor
PdmUiSelection3dEditorVisualizer --* "n" PdmUi3dObjectEditorHandle
Viewer ..down.> "eventFilter()" RicPointTangentManipulator
@enduml