diff --git a/ApplicationCode/Commands/RicPickEventHandler.h b/ApplicationCode/Commands/RicPickEventHandler.h index 00b42d40cb..ec66242477 100644 --- a/ApplicationCode/Commands/RicPickEventHandler.h +++ b/ApplicationCode/Commands/RicPickEventHandler.h @@ -41,14 +41,16 @@ class Rim3dView; class Ric3dPickEvent : public caf::PickEvent { public: - Ric3dPickEvent( const std::vector& pickItemInfos, Rim3dView* view ) + Ric3dPickEvent( const std::vector& pickItemInfos, Rim3dView* view, Qt::KeyboardModifiers keyboardModifiers) : m_pickItemInfos( pickItemInfos ) , m_view( view ) + , m_keyboardModifiers( keyboardModifiers ) { } std::vector m_pickItemInfos; Rim3dView* m_view; + Qt::KeyboardModifiers m_keyboardModifiers; }; //================================================================================================== diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp index a7c47a15b3..b22ab63665 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp @@ -225,8 +225,8 @@ bool RicNewGridTimeHistoryCurveFeature::isCommandEnabled() const RiuEclipseSelectionItem* eclSelectionItem = dynamic_cast( items[0] ); if ( eclSelectionItem ) { - if ( eclSelectionItem->m_view->cellResult()->isFlowDiagOrInjectionFlooding() && - eclSelectionItem->m_view->cellResult()->resultVariable() != RIG_NUM_FLOODED_PV ) + if ( eclSelectionItem->m_resultDefinition->isFlowDiagOrInjectionFlooding() && + eclSelectionItem->m_resultDefinition->resultVariable() != RIG_NUM_FLOODED_PV ) { return false; } diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RimGeoMechGeometrySelectionItem.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RimGeoMechGeometrySelectionItem.cpp index fc358eaa99..9e6506e2f7 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RimGeoMechGeometrySelectionItem.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RimGeoMechGeometrySelectionItem.cpp @@ -19,6 +19,7 @@ #include "RimGeoMechGeometrySelectionItem.h" #include "RimGeoMechCase.h" +#include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" #include "Riu3dSelectionManager.h" @@ -59,7 +60,7 @@ RimGeoMechGeometrySelectionItem::~RimGeoMechGeometrySelectionItem() {} //-------------------------------------------------------------------------------------------------- void RimGeoMechGeometrySelectionItem::setFromSelectionItem( const RiuGeoMechSelectionItem* selectionItem ) { - m_geoMechCase = selectionItem->m_view->geoMechCase(); + m_geoMechCase = selectionItem->m_resultDefinition->geoMechCase(); m_gridIndex = selectionItem->m_gridIndex; m_cellIndex = selectionItem->m_cellIndex; diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp index 2fdac28011..cc98f000b1 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp @@ -286,8 +286,10 @@ void RivFemPartGeometryGenerator::setElementVisibility( const cvf::UByteArray* c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( const RigFemPart* part, - size_t elmIdx ) +cvf::ref + RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( const RigFemPart* part, + size_t elmIdx, + const cvf::Vec3d& displayModelOffset ) { cvf::ref quadVertices; @@ -301,7 +303,7 @@ cvf::ref RivFemPartGeometryGenerator::createMeshDrawableFromSi const int* elmNodeIndices = part->connectivities( elmIdx ); - cvf::Vec3d displayOffset = part->boundingBox().min(); + // cvf::Vec3d displayOffset = part->boundingBox().min(); for ( int lfIdx = 0; lfIdx < faceCount; ++lfIdx ) { @@ -310,13 +312,13 @@ cvf::ref RivFemPartGeometryGenerator::createMeshDrawableFromSi if ( faceNodeCount == 4 ) { vertices.push_back( cvf::Vec3f( - cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ) - displayOffset ) ); + cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ) - displayModelOffset ) ); vertices.push_back( cvf::Vec3f( - cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] ) - displayOffset ) ); + cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] ) - displayModelOffset ) ); vertices.push_back( cvf::Vec3f( - cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]] ) - displayOffset ) ); + cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]] ) - displayModelOffset ) ); vertices.push_back( cvf::Vec3f( - cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]] ) - displayOffset ) ); + cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]] ) - displayModelOffset ) ); } else { diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h index 6902a972c1..c4c14b670b 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h @@ -121,7 +121,9 @@ public: return m_triangleMapper.p(); } - static cvf::ref createMeshDrawableFromSingleElement( const RigFemPart* grid, size_t elementIndex ); + static cvf::ref createMeshDrawableFromSingleElement( const RigFemPart* grid, + size_t elementIndex, + const cvf::Vec3d& displayModelOffset ); private: static cvf::ref lineIndicesFromQuadVertexArray( const cvf::Vec3fArray* vertexArray ); diff --git a/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.cpp b/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.cpp index 23aed6b470..b75e3b6242 100644 --- a/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.cpp @@ -37,22 +37,30 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivSingleCellPartGenerator::RivSingleCellPartGenerator( RigEclipseCaseData* rigCaseData, size_t gridIndex, size_t cellIndex ) +RivSingleCellPartGenerator::RivSingleCellPartGenerator( RigEclipseCaseData* rigCaseData, + size_t gridIndex, + size_t cellIndex, + const cvf::Vec3d& displayModelOffset ) : m_rigCaseData( rigCaseData ) , m_gridIndex( gridIndex ) , m_cellIndex( cellIndex ) , m_geoMechCase( nullptr ) + , m_displayModelOffset( displayModelOffset ) { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivSingleCellPartGenerator::RivSingleCellPartGenerator( RimGeoMechCase* rimGeoMechCase, size_t gridIndex, size_t cellIndex ) +RivSingleCellPartGenerator::RivSingleCellPartGenerator( RimGeoMechCase* rimGeoMechCase, + size_t gridIndex, + size_t cellIndex, + const cvf::Vec3d& displayModelOffset ) : m_geoMechCase( rimGeoMechCase ) , m_gridIndex( gridIndex ) , m_cellIndex( cellIndex ) , m_rigCaseData( nullptr ) + , m_displayModelOffset( displayModelOffset ) { } @@ -88,7 +96,8 @@ cvf::ref RivSingleCellPartGenerator::createMeshDrawable() if ( m_rigCaseData && m_cellIndex != cvf::UNDEFINED_SIZE_T ) { return cvf::StructGridGeometryGenerator::createMeshDrawableFromSingleCell( m_rigCaseData->grid( m_gridIndex ), - m_cellIndex ); + m_cellIndex, + m_displayModelOffset ); } else if ( m_geoMechCase && m_cellIndex != cvf::UNDEFINED_SIZE_T ) { @@ -98,7 +107,9 @@ cvf::ref RivSingleCellPartGenerator::createMeshDrawable() RigFemPart* femPart = m_geoMechCase->geoMechData()->femParts()->part( m_gridIndex ); CVF_ASSERT( femPart ); - return RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( femPart, m_cellIndex ); + return RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( femPart, + m_cellIndex, + m_displayModelOffset ); } return nullptr; diff --git a/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.h b/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.h index 10d392df6d..d30cb258b8 100644 --- a/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.h +++ b/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.h @@ -36,8 +36,14 @@ class RimGeoMechCase; class RivSingleCellPartGenerator { public: - RivSingleCellPartGenerator( RigEclipseCaseData* rigCaseData, size_t gridIndex, size_t cellIndex ); - RivSingleCellPartGenerator( RimGeoMechCase* rimGeoMechCase, size_t gridIndex, size_t cellIndex ); + RivSingleCellPartGenerator( RigEclipseCaseData* rigCaseData, + size_t gridIndex, + size_t cellIndex, + const cvf::Vec3d& displayModelOffset ); + RivSingleCellPartGenerator( RimGeoMechCase* rimGeoMechCase, + size_t gridIndex, + size_t cellIndex, + const cvf::Vec3d& displayModelOffset ); cvf::ref createPart( const cvf::Color3f color ); @@ -49,4 +55,5 @@ private: RimGeoMechCase* m_geoMechCase; size_t m_gridIndex; size_t m_cellIndex; + cvf::Vec3d m_displayModelOffset; }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp b/ApplicationCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp index 09875c17bc..7ef23b1a8e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp @@ -23,6 +23,7 @@ #include "RigTimeHistoryResultAccessor.h" #include "RimEclipseCase.h" +#include "RimEclipseResultDefinition.h" #include "RimEclipseView.h" #include "Riu3dSelectionManager.h" @@ -61,7 +62,7 @@ void RimEclipseGeometrySelectionItem::setFromSelectionItem( const RiuEclipseSele m_cellIndex = selectionItem->m_gridLocalCellIndex; m_localIntersectionPointInDisplay = selectionItem->m_localIntersectionPointInDisplay; - m_eclipseCase = selectionItem->m_view->eclipseCase(); + m_eclipseCase = selectionItem->m_resultDefinition->eclipseCase(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 24e9d10a7d..3f54c68364 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -2037,38 +2037,6 @@ bool RimEclipseView::isShowingActiveCellsOnly() return !m_showInactiveCells; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimEclipseView::onCreatePartCollectionFromSelection( cvf::Collection* parts ) -{ - Riu3dSelectionManager* riuSelManager = Riu3dSelectionManager::instance(); - std::vector items; - riuSelManager->selectedItems( items ); - - for ( size_t i = 0; i < items.size(); i++ ) - { - if ( items[i]->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT ) - { - RiuEclipseSelectionItem* eclipseSelItem = static_cast( items[i] ); - if ( eclipseSelItem && eclipseSelItem->m_view == this ) - { - CVF_ASSERT( eclipseSelItem->m_view->eclipseCase() ); - CVF_ASSERT( eclipseSelItem->m_view->eclipseCase()->eclipseCaseData() ); - - RivSingleCellPartGenerator partGen( eclipseSelItem->m_view->eclipseCase()->eclipseCaseData(), - eclipseSelItem->m_gridIndex, - eclipseSelItem->m_gridLocalCellIndex ); - - cvf::ref part = partGen.createPart( eclipseSelItem->m_color ); - part->setTransform( this->scaleTransform() ); - - parts->push_back( part.p() ); - } - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index 0732680cc8..e279ef883f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -156,7 +156,6 @@ protected: void onLoadDataAndUpdate() override; caf::PdmFieldHandle* userDescriptionField() override; - void onCreatePartCollectionFromSelection( cvf::Collection* parts ) override; bool isShowingActiveCellsOnly() override; void onUpdateDisplayModelForCurrentTimeStep() override; void updateVisibleGeometriesAndCellColors(); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index 97da230609..34d6787678 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -258,6 +258,14 @@ void RimGeoMechResultDefinition::setGeoMechCase( RimGeoMechCase* geomCase ) m_geomCase = geomCase; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechCase* RimGeoMechResultDefinition::geoMechCase() const +{ + return m_geomCase; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h index 0985228e3a..bda0038d6f 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h @@ -46,7 +46,8 @@ public: RimGeoMechResultDefinition( void ); ~RimGeoMechResultDefinition( void ) override; - void setGeoMechCase( RimGeoMechCase* geomCase ); + void setGeoMechCase( RimGeoMechCase* geomCase ); + RimGeoMechCase* geoMechCase() const; RigGeoMechCaseData* ownerCaseData() const; bool hasResult(); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index 78e270c1db..d56a415878 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -832,33 +832,6 @@ void RimGeoMechView::calculateCurrentTotalCellVisibility( cvf::UByteArray* total m_vizLogic->calculateCurrentTotalCellVisibility( totalVisibility, timeStep ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimGeoMechView::onCreatePartCollectionFromSelection( cvf::Collection* parts ) -{ - Riu3dSelectionManager* riuSelManager = Riu3dSelectionManager::instance(); - std::vector items; - riuSelManager->selectedItems( items ); - for ( size_t i = 0; i < items.size(); i++ ) - { - if ( items[i]->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT ) - { - RiuGeoMechSelectionItem* geomSelItem = static_cast( items[i] ); - if ( geomSelItem && geomSelItem->m_view == this && geomSelItem->m_view->geoMechCase() ) - { - RivSingleCellPartGenerator partGen( geomSelItem->m_view->geoMechCase(), - geomSelItem->m_gridIndex, - geomSelItem->m_cellIndex ); - cvf::ref part = partGen.createPart( geomSelItem->m_color ); - part->setTransform( this->scaleTransform() ); - - parts->push_back( part.p() ); - } - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index 8966f896e0..ae91d3f43b 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -111,7 +111,6 @@ protected: const QVariant& newValue ) override; void initAfterRead() override; - void onCreatePartCollectionFromSelection( cvf::Collection* parts ) override; void onCreateDisplayModel() override; RimPropertyFilterCollection* nativePropertyFilterCollection(); diff --git a/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp b/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp index 63ee4067c4..009abde900 100644 --- a/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp @@ -124,10 +124,10 @@ void RimGridTimeHistoryCurve::setFromSelectionItem( const RiuSelectionItem* sele geomSelectionItem->setFromSelectionItem( eclSelectionItem ); - if ( eclSelectionItem->m_view ) + if ( eclSelectionItem->m_resultDefinition ) { m_eclipseResultDefinition = new RimEclipseResultDefinition; - m_eclipseResultDefinition->simpleCopy( eclSelectionItem->m_view->cellResult() ); + m_eclipseResultDefinition->simpleCopy( eclSelectionItem->m_resultDefinition ); } } @@ -139,12 +139,11 @@ void RimGridTimeHistoryCurve::setFromSelectionItem( const RiuSelectionItem* sele geomSelectionItem->setFromSelectionItem( geoMechSelectionItem ); - if ( geoMechSelectionItem->m_view ) + if ( geoMechSelectionItem->m_resultDefinition ) { m_geoMechResultDefinition = new RimGeoMechResultDefinition; - m_geoMechResultDefinition->setGeoMechCase( geoMechSelectionItem->m_view->geoMechCase() ); - m_geoMechResultDefinition->setResultAddress( - geoMechSelectionItem->m_view->cellResultResultDefinition()->resultAddress() ); + m_geoMechResultDefinition->setGeoMechCase( geoMechSelectionItem->m_resultDefinition->geoMechCase() ); + m_geoMechResultDefinition->setResultAddress( geoMechSelectionItem->m_resultDefinition->resultAddress() ); } } diff --git a/ApplicationCode/ProjectDataModel/RimGridView.cpp b/ApplicationCode/ProjectDataModel/RimGridView.cpp index 6947ee2b13..c1d2250b92 100644 --- a/ApplicationCode/ProjectDataModel/RimGridView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridView.cpp @@ -23,6 +23,9 @@ #include "Rim3dOverlayInfoConfig.h" #include "RimAnnotationInViewCollection.h" #include "RimCellRangeFilterCollection.h" +#include "RimEclipseCase.h" +#include "RimEclipseResultDefinition.h" +#include "RimGeoMechResultDefinition.h" #include "RimGridCollection.h" #include "RimIntersectionCollection.h" #include "RimIntersectionResultsDefinitionCollection.h" @@ -36,9 +39,13 @@ #include "RimWellMeasurementInViewCollection.h" #include "Riu3DMainWindowTools.h" +#include "Riu3dSelectionManager.h" #include "RiuMainWindow.h" +#include "RivSingleCellPartGenerator.h" + #include "cvfModel.h" +#include "cvfPart.h" #include "cvfScene.h" #include @@ -419,6 +426,59 @@ void RimGridView::initAfterRead() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::onCreatePartCollectionFromSelection( cvf::Collection* parts ) +{ + Riu3dSelectionManager* riuSelManager = Riu3dSelectionManager::instance(); + + std::vector items; + riuSelManager->selectedItems( items ); + + for ( size_t i = 0; i < items.size(); i++ ) + { + if ( items[i]->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT ) + { + RiuGeoMechSelectionItem* geomSelItem = static_cast( items[i] ); + + if ( geomSelItem && geomSelItem->m_view == this && geomSelItem->m_resultDefinition->geoMechCase() ) + { + RivSingleCellPartGenerator partGen( geomSelItem->m_resultDefinition->geoMechCase(), + geomSelItem->m_gridIndex, + geomSelItem->m_cellIndex, + this->ownerCase()->displayModelOffset() ); + + cvf::ref part = partGen.createPart( geomSelItem->m_color ); + part->setTransform( this->scaleTransform() ); + + parts->push_back( part.p() ); + } + } + + if ( items[i]->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT ) + { + RiuEclipseSelectionItem* eclipseSelItem = static_cast( items[i] ); + + if ( eclipseSelItem && eclipseSelItem->m_view == this ) + { + CVF_ASSERT( eclipseSelItem->m_resultDefinition->eclipseCase() ); + CVF_ASSERT( eclipseSelItem->m_resultDefinition->eclipseCase()->eclipseCaseData() ); + + RivSingleCellPartGenerator partGen( eclipseSelItem->m_resultDefinition->eclipseCase()->eclipseCaseData(), + eclipseSelItem->m_gridIndex, + eclipseSelItem->m_gridLocalCellIndex, + this->ownerCase()->displayModelOffset() ); + + cvf::ref part = partGen.createPart( eclipseSelItem->m_color ); + part->setTransform( this->scaleTransform() ); + + parts->push_back( part.p() ); + } + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimGridView.h b/ApplicationCode/ProjectDataModel/RimGridView.h index d28621eb5a..311115511c 100644 --- a/ApplicationCode/ProjectDataModel/RimGridView.h +++ b/ApplicationCode/ProjectDataModel/RimGridView.h @@ -84,7 +84,8 @@ protected: const QVariant& newValue ) override; void initAfterRead() override; -protected: // Fields +protected: + // Fields caf::PdmChildField m_intersectionCollection; caf::PdmChildField m_intersectionResultDefCollection; @@ -97,6 +98,8 @@ protected: // Fields caf::PdmChildField m_wellMeasurementCollection; private: + void onCreatePartCollectionFromSelection( cvf::Collection* parts ) override; + cvf::ref m_currentReservoirCellVisibility; RimViewLinker* viewLinkerIfMasterView() const; bool m_previousGridModeMeshLinesWasFaults; diff --git a/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp b/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp index 66a713a313..c58b70c2b1 100644 --- a/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp @@ -50,6 +50,7 @@ #include +#include "RimGeoMechResultDefinition.h" #include //-------------------------------------------------------------------------------------------------- @@ -639,27 +640,33 @@ public: size_t gridIndex; int caseId; bool validIndex = true; + if ( item->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT ) { const RiuEclipseSelectionItem* eclipseItem = static_cast( item ); - eclipseItem->m_view->eclipseCase() + eclipseItem->m_resultDefinition->eclipseCase() ->eclipseCaseData() ->grid( eclipseItem->m_gridIndex ) ->ijkFromCellIndex( eclipseItem->m_gridLocalCellIndex, &i, &j, &k ); + gridIndex = eclipseItem->m_gridIndex; - caseId = eclipseItem->m_view->eclipseCase()->caseId; + caseId = eclipseItem->m_resultDefinition->eclipseCase()->caseId; } else if ( item->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT ) { const RiuGeoMechSelectionItem* geomechItem = static_cast( item ); - validIndex = geomechItem->m_view->femParts() + + validIndex = geomechItem->m_resultDefinition->ownerCaseData() + ->femParts() ->part( geomechItem->m_gridIndex ) ->getOrCreateStructGrid() ->ijkFromCellIndex( geomechItem->m_cellIndex, &i, &j, &k ); + CVF_ASSERT( validIndex ); + gridIndex = geomechItem->m_gridIndex; - caseId = geomechItem->m_view->geoMechCase()->caseId; + caseId = geomechItem->m_resultDefinition->geoMechCase()->caseId; } else { diff --git a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp index 9bc03a6f14..6da35c4f2c 100644 --- a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -43,6 +43,7 @@ #include "RimIntersectionCollection.h" #include "RimReservoirCellResultsStorage.h" +#include "RimGeoMechResultDefinition.h" #include "Riu3dSelectionManager.h" #include "RiuMainWindow.h" #include "RiuProcessMonitor.h" @@ -1397,7 +1398,7 @@ public: { const RiuEclipseSelectionItem* eclipseItem = static_cast( item ); - if ( eclipseItem->m_view->eclipseCase()->caseId == reservoirCase->caseId ) + if ( eclipseItem->m_resultDefinition->eclipseCase()->caseId == reservoirCase->caseId ) { selectedCells.push_back( std::make_pair( eclipseItem->m_gridIndex, eclipseItem->m_gridLocalCellIndex ) ); @@ -1407,7 +1408,7 @@ public: { const RiuGeoMechSelectionItem* geomechItem = static_cast( item ); - if ( geomechItem->m_view->geoMechCase()->caseId == reservoirCase->caseId ) + if ( geomechItem->m_resultDefinition->geoMechCase()->caseId == reservoirCase->caseId ) { selectedCells.push_back( std::make_pair( geomechItem->m_gridIndex, geomechItem->m_cellIndex ) ); } diff --git a/ApplicationCode/UserInterface/CMakeLists_files.cmake b/ApplicationCode/UserInterface/CMakeLists_files.cmake index d79dad0b6e..3e959e7df5 100644 --- a/ApplicationCode/UserInterface/CMakeLists_files.cmake +++ b/ApplicationCode/UserInterface/CMakeLists_files.cmake @@ -48,6 +48,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h ${CMAKE_CURRENT_LIST_DIR}/RiuViewer.h ${CMAKE_CURRENT_LIST_DIR}/RiuViewerToViewInterface.h ${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.h +${CMAKE_CURRENT_LIST_DIR}/RiuCellAndNncPickEventHandler.h ${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h @@ -135,6 +136,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuToolTipMenu.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuViewer.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuCellAndNncPickEventHandler.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.cpp diff --git a/ApplicationCode/UserInterface/Riu3dSelectionManager.cpp b/ApplicationCode/UserInterface/Riu3dSelectionManager.cpp index d35a162049..72f08a962c 100644 --- a/ApplicationCode/UserInterface/Riu3dSelectionManager.cpp +++ b/ApplicationCode/UserInterface/Riu3dSelectionManager.cpp @@ -20,7 +20,9 @@ #include "Riu3dSelectionManager.h" #include "Rim2dIntersectionView.h" +#include "RimEclipseResultDefinition.h" #include "RimEclipseView.h" +#include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" #include "RimGridView.h" #include "RimSimWellInView.h" @@ -155,7 +157,9 @@ void Riu3dSelectionManager::deleteAllItemsFromSelection( int role ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimEclipseView* view, +RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimGridView* view, + RimEclipseResultDefinition* resultDefinition, + size_t timestepIdx, size_t gridIndex, size_t cellIndex, size_t nncIndex, @@ -163,6 +167,8 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimEclipseView* cvf::StructGridInterface::FaceType face, const cvf::Vec3d& localIntersectionPointInDisplay ) : m_view( view ) + , m_resultDefinition( resultDefinition ) + , m_timestepIdx( timestepIdx ) , m_gridIndex( gridIndex ) , m_gridLocalCellIndex( cellIndex ) , m_nncIndex( nncIndex ) @@ -175,13 +181,17 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimEclipseView* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* view, - size_t gridIndex, - size_t cellIndex, - cvf::Color3f color, - int elementFace, - const cvf::Vec3d& localIntersectionPointInDisplay ) +RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* view, + RimGeoMechResultDefinition* resultDefinition, + size_t timestepIdx, + size_t gridIndex, + size_t cellIndex, + cvf::Color3f color, + int elementFace, + const cvf::Vec3d& localIntersectionPointInDisplay ) : m_view( view ) + , m_resultDefinition( resultDefinition ) + , m_timestepIdx( timestepIdx ) , m_gridIndex( gridIndex ) , m_cellIndex( cellIndex ) , m_color( color ) @@ -194,7 +204,9 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* view, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* view, +RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* view, + RimGeoMechResultDefinition* resultDefinition, + size_t timestepIdx, size_t gridIndex, size_t cellIndex, cvf::Color3f color, @@ -202,6 +214,8 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* const cvf::Vec3d& localIntersectionPointInDisplay, const std::array& intersectionTriangle ) : m_view( view ) + , m_resultDefinition( resultDefinition ) + , m_timestepIdx( timestepIdx ) , m_gridIndex( gridIndex ) , m_cellIndex( cellIndex ) , m_color( color ) diff --git a/ApplicationCode/UserInterface/Riu3dSelectionManager.h b/ApplicationCode/UserInterface/Riu3dSelectionManager.h index 4dcc22416e..298cdf9921 100644 --- a/ApplicationCode/UserInterface/Riu3dSelectionManager.h +++ b/ApplicationCode/UserInterface/Riu3dSelectionManager.h @@ -42,6 +42,8 @@ class RiuSelectionChangedHandler; class RiuSelectionItem; class RivSimWellPipeSourceInfo; class RivWellPathSourceInfo; +class RimEclipseResultDefinition; +class RimGeoMechResultDefinition; //================================================================================================== // @@ -130,7 +132,9 @@ public: class RiuEclipseSelectionItem : public RiuSelectionItem { public: - explicit RiuEclipseSelectionItem( RimEclipseView* view, + explicit RiuEclipseSelectionItem( RimGridView* view, + RimEclipseResultDefinition* resultDefinition, + size_t timestepIdx, size_t gridIndex, size_t cellIndex, size_t nncIndex, @@ -146,13 +150,15 @@ public: } public: - caf::PdmPointer m_view; - size_t m_gridIndex; - size_t m_gridLocalCellIndex; - size_t m_nncIndex; - cvf::Color3f m_color; - cvf::StructGridInterface::FaceType m_face; - cvf::Vec3d m_localIntersectionPointInDisplay; + caf::PdmPointer m_view; + caf::PdmPointer m_resultDefinition; + size_t m_timestepIdx; + size_t m_gridIndex; + size_t m_gridLocalCellIndex; + size_t m_nncIndex; + cvf::Color3f m_color; + cvf::StructGridInterface::FaceType m_face; + cvf::Vec3d m_localIntersectionPointInDisplay; }; //================================================================================================== @@ -163,14 +169,18 @@ public: class RiuGeoMechSelectionItem : public RiuSelectionItem { public: - explicit RiuGeoMechSelectionItem( RimGeoMechView* view, - size_t gridIndex, - size_t cellIndex, - cvf::Color3f color, - int elementFace, - const cvf::Vec3d& localIntersectionPointInDisplay ); + explicit RiuGeoMechSelectionItem( RimGridView* view, + RimGeoMechResultDefinition* resultDefinition, + size_t timestepIdx, + size_t gridIndex, + size_t cellIndex, + cvf::Color3f color, + int elementFace, + const cvf::Vec3d& localIntersectionPointInDisplay ); - explicit RiuGeoMechSelectionItem( RimGeoMechView* view, + explicit RiuGeoMechSelectionItem( RimGridView* view, + RimGeoMechResultDefinition* resultDefinition, + size_t timestepIdx, size_t gridIndex, size_t cellIndex, cvf::Color3f color, @@ -185,14 +195,16 @@ public: } public: - caf::PdmPointer m_view; - size_t m_gridIndex; - size_t m_cellIndex; - cvf::Color3f m_color; - int m_elementFace; - bool m_hasIntersectionTriangle; - std::array m_intersectionTriangle; - cvf::Vec3d m_localIntersectionPointInDisplay; + caf::PdmPointer m_view; + caf::PdmPointer m_resultDefinition; + size_t m_timestepIdx; + size_t m_gridIndex; + size_t m_cellIndex; + cvf::Color3f m_color; + int m_elementFace; + bool m_hasIntersectionTriangle; + std::array m_intersectionTriangle; + cvf::Vec3d m_localIntersectionPointInDisplay; }; //================================================================================================== diff --git a/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.cpp b/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.cpp new file mode 100644 index 0000000000..c4e6371b9f --- /dev/null +++ b/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.cpp @@ -0,0 +1,303 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuCellAndNncPickEventHandler.h" + +#include "RiaColorTables.h" + +#include "Rim2dIntersectionView.h" +#include "RimBoxIntersection.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseView.h" +#include "RimExtrudedCurveIntersection.h" +#include "RimGeoMechCellColors.h" +#include "RimGeoMechView.h" +#include "RimIntersectionResultDefinition.h" + +#include "Riu3dSelectionManager.h" +#include "RiuViewerCommands.h" + +#include "RivBoxIntersectionSourceInfo.h" +#include "RivExtrudedCurveIntersectionSourceInfo.h" +#include "RivFemPartGeometryGenerator.h" +#include "RivFemPickSourceInfo.h" +#include "RivSourceInfo.h" + +#include "cafPdmObjectHandle.h" + +#include "cvfPart.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuCellAndNncPickEventHandler* RiuCellAndNncPickEventHandler::instance() +{ + static RiuCellAndNncPickEventHandler* singleton = new RiuCellAndNncPickEventHandler; + return singleton; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eventObject ) +{ + const std::vector& pickItemInfos = eventObject.m_pickItemInfos; + Rim3dView* mainOrComparisonView = eventObject.m_view; + Qt::KeyboardModifiers keyboardModifiers = eventObject.m_keyboardModifiers; + + const cvf::Part* firstHitPart = nullptr; + uint firstPartTriangleIndex = cvf::UNDEFINED_UINT; + + cvf::Vec3d localIntersectionPoint( cvf::Vec3d::ZERO ); + cvf::Vec3d globalIntersectionPoint( cvf::Vec3d::ZERO ); + size_t nncIndex = cvf::UNDEFINED_SIZE_T; + + { + const cvf::Part* firstNncHitPart = nullptr; + uint nncPartTriangleIndex = cvf::UNDEFINED_UINT; + + if ( pickItemInfos.size() ) + { + size_t indexToFirstNoneNncItem = cvf::UNDEFINED_SIZE_T; + size_t indexToNncItemNearFirstItem = cvf::UNDEFINED_SIZE_T; + + RiuViewerCommands::findFirstItems( mainOrComparisonView, + pickItemInfos, + &indexToFirstNoneNncItem, + &indexToNncItemNearFirstItem ); + + if ( indexToFirstNoneNncItem != cvf::UNDEFINED_SIZE_T ) + { + localIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].localPickedPoint(); + globalIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].globalPickedPoint(); + firstHitPart = pickItemInfos[indexToFirstNoneNncItem].pickedPart(); + firstPartTriangleIndex = pickItemInfos[indexToFirstNoneNncItem].faceIdx(); + } + + if ( indexToNncItemNearFirstItem != cvf::UNDEFINED_SIZE_T ) + { + firstNncHitPart = pickItemInfos[indexToNncItemNearFirstItem].pickedPart(); + nncPartTriangleIndex = pickItemInfos[indexToNncItemNearFirstItem].faceIdx(); + } + } + + if ( firstNncHitPart && firstNncHitPart->sourceInfo() ) + { + const RivSourceInfo* rivSourceInfo = dynamic_cast( firstNncHitPart->sourceInfo() ); + if ( rivSourceInfo ) + { + if ( nncPartTriangleIndex < rivSourceInfo->m_NNCIndices->size() ) + { + nncIndex = rivSourceInfo->m_NNCIndices->get( nncPartTriangleIndex ); + } + } + } + } + + if ( !firstHitPart ) return false; + + size_t gridIndex = cvf::UNDEFINED_SIZE_T; + size_t cellIndex = cvf::UNDEFINED_SIZE_T; + cvf::StructGridInterface::FaceType face = cvf::StructGridInterface::NO_FACE; + int gmFace = -1; + bool intersectionHit = false; + std::array intersectionTriangleHit; + RimGeoMechResultDefinition* geomResDef = nullptr; + RimEclipseResultDefinition* eclResDef = nullptr; + size_t timestepIndex = -1; + + // clang-format off + if ( const RivSourceInfo* rivSourceInfo = + dynamic_cast( firstHitPart->sourceInfo() ) ) + { + gridIndex = rivSourceInfo->gridIndex(); + if ( rivSourceInfo->hasCellFaceMapping() ) + { + CVF_ASSERT( rivSourceInfo->m_cellFaceFromTriangleMapper.notNull() ); + + cellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex( firstPartTriangleIndex ); + face = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace( firstPartTriangleIndex ); + } + } + else if ( const RivFemPickSourceInfo* femSourceInfo = + dynamic_cast( firstHitPart->sourceInfo() ) ) + { + gridIndex = femSourceInfo->femPartIndex(); + cellIndex = femSourceInfo->triangleToElmMapper()->elementIndex( firstPartTriangleIndex ); + gmFace = femSourceInfo->triangleToElmMapper()->elementFace( firstPartTriangleIndex ); + } + else if ( const RivExtrudedCurveIntersectionSourceInfo* intersectionSourceInfo = + dynamic_cast( firstHitPart->sourceInfo() ) ) + { + RiuViewerCommands::findCellAndGridIndex( mainOrComparisonView, + intersectionSourceInfo, + firstPartTriangleIndex, + &cellIndex, + &gridIndex ); + + intersectionHit = true; + intersectionTriangleHit = intersectionSourceInfo->triangle( firstPartTriangleIndex ); + + if ( RimIntersectionResultDefinition* sepInterResDef = intersectionSourceInfo->intersection()->activeSeparateResultDefinition() ) + { + if ( sepInterResDef->isEclipseResultDefinition() ) + { + eclResDef = sepInterResDef->eclipseResultDefinition(); + } + else + { + geomResDef = sepInterResDef->geoMechResultDefinition(); + } + + timestepIndex = sepInterResDef->timeStep(); + } + } + else if ( const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo = + dynamic_cast( firstHitPart->sourceInfo() ) ) + { + RiuViewerCommands::findCellAndGridIndex( mainOrComparisonView, + intersectionBoxSourceInfo, + firstPartTriangleIndex, + &cellIndex, + &gridIndex ); + + intersectionHit = true; + intersectionTriangleHit = intersectionBoxSourceInfo->triangle( firstPartTriangleIndex ); + + if ( RimIntersectionResultDefinition* sepInterResDef = intersectionBoxSourceInfo->intersectionBox()->activeSeparateResultDefinition() ) + { + if ( sepInterResDef->isEclipseResultDefinition() ) + { + eclResDef = sepInterResDef->eclipseResultDefinition(); + } + else + { + geomResDef = sepInterResDef->geoMechResultDefinition(); + } + + timestepIndex = sepInterResDef->timeStep(); + } + } + // clang-format on + + if ( cellIndex == cvf::UNDEFINED_SIZE_T ) + { + Riu3dSelectionManager::instance()->deleteAllItems(); + return false; + } + + bool appendToSelection = false; + if ( keyboardModifiers & Qt::ControlModifier ) + { + appendToSelection = true; + } + + std::vector items; + Riu3dSelectionManager::instance()->selectedItems( items ); + + const caf::ColorTable& colorTable = RiaColorTables::selectionPaletteColors(); + + cvf::Color3f curveColor = colorTable.cycledColor3f( items.size() ); + + if ( !appendToSelection ) + { + curveColor = colorTable.cycledColor3f( 0 ); + } + + RiuSelectionItem* selItem = nullptr; + { + Rim2dIntersectionView* intersectionView = dynamic_cast( mainOrComparisonView ); + RimEclipseView* eclipseView = dynamic_cast( mainOrComparisonView ); + RimGeoMechView* geomView = dynamic_cast( mainOrComparisonView ); + + RimGridView* associatedGridView = dynamic_cast( mainOrComparisonView ); + + if ( intersectionView ) + { + intersectionView->intersection()->firstAncestorOrThisOfType( associatedGridView ); + } + + // Use the clicked views default settings if we have not found any special stuff + + if ( !eclResDef && !geomResDef ) + { + if ( eclipseView ) + { + if ( !eclResDef ) eclResDef = eclipseView->cellResult(); + if ( timestepIndex == -1 ) timestepIndex = eclipseView->currentTimeStep(); + } + + if ( geomView ) + { + if ( !geomResDef ) geomResDef = geomView->cellResult(); + if ( timestepIndex == -1 ) timestepIndex = geomView->currentTimeStep(); + } + } + + if ( eclResDef ) + { + selItem = new RiuEclipseSelectionItem( associatedGridView, + eclResDef, + timestepIndex, + gridIndex, + cellIndex, + nncIndex, + curveColor, + face, + localIntersectionPoint ); + } + + if ( geomResDef ) + { + if ( intersectionHit ) + selItem = new RiuGeoMechSelectionItem( associatedGridView, + geomResDef, + timestepIndex, + gridIndex, + cellIndex, + curveColor, + gmFace, + localIntersectionPoint, + intersectionTriangleHit ); + else + selItem = new RiuGeoMechSelectionItem( associatedGridView, + geomResDef, + timestepIndex, + gridIndex, + cellIndex, + curveColor, + gmFace, + localIntersectionPoint ); + } + + if ( intersectionView ) selItem = new Riu2dIntersectionSelectionItem( intersectionView, selItem ); + } + + if ( appendToSelection ) + { + Riu3dSelectionManager::instance()->appendItemToSelection( selItem ); + } + else if ( selItem ) + { + Riu3dSelectionManager::instance()->setSelectedItem( selItem ); + } + + return false; +} diff --git a/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.h b/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.h new file mode 100644 index 0000000000..5d03adbc76 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.h @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicPickEventHandler.h" + +//================================================================================================== +/// +//================================================================================================== +class RiuCellAndNncPickEventHandler : public RicDefaultPickEventHandler +{ +public: + static RiuCellAndNncPickEventHandler* instance(); + +protected: + bool handle3dPickEvent( const Ric3dPickEvent& eventObject ) override; +}; diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp index 22ca27d12c..2775914345 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -41,18 +41,18 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuFemResultTextBuilder::RiuFemResultTextBuilder( RimGeoMechView* reservoirView, - int gridIndex, - int cellIndex, - int timeStepIndex ) +RiuFemResultTextBuilder::RiuFemResultTextBuilder( RimGridView* displayCoordView, + RimGeoMechResultDefinition* geomResDef, + int gridIndex, + int cellIndex, + int timeStepIndex ) : m_isIntersectionTriangleSet( false ) { - CVF_ASSERT( reservoirView ); - - m_reservoirView = reservoirView; - m_gridIndex = gridIndex; - m_cellIndex = cellIndex; - m_timeStepIndex = timeStepIndex; + m_displayCoordView = displayCoordView; + m_geomResDef = geomResDef; + m_gridIndex = gridIndex; + m_cellIndex = cellIndex; + m_timeStepIndex = timeStepIndex; m_intersectionPointInDisplay = cvf::Vec3d::UNDEFINED; m_face = cvf::StructGridInterface::NO_FACE; @@ -98,9 +98,7 @@ QString RiuFemResultTextBuilder::mainResultText() { QString text; - RimGeoMechResultDefinition* cellResultDefinition = m_reservoirView->cellResultResultDefinition(); - - text = closestNodeResultText( cellResultDefinition ); + text = closestNodeResultText( m_geomResDef ); if ( !text.isEmpty() ) text += "\n"; @@ -109,7 +107,7 @@ QString RiuFemResultTextBuilder::mainResultText() appendDetails( text, formationDetails() ); text += "\n"; - if ( cellResultDefinition->resultPositionType() != RIG_ELEMENT ) + if ( m_geomResDef->resultPositionType() != RIG_ELEMENT ) { appendDetails( text, gridResultDetails() ); } @@ -124,9 +122,9 @@ QString RiuFemResultTextBuilder::geometrySelectionText( QString itemSeparator ) { QString text; - if ( m_reservoirView->geoMechCase() ) + if ( m_geomResDef->geoMechCase() ) { - RigGeoMechCaseData* geomData = m_reservoirView->geoMechCase()->geoMechData(); + RigGeoMechCaseData* geomData = m_geomResDef->geoMechCase()->geoMechData(); if ( geomData ) { RigFemPart* femPart = geomData->femParts()->part( m_gridIndex ); @@ -167,14 +165,17 @@ QString RiuFemResultTextBuilder::geometrySelectionText( QString itemSeparator ) } else { - cvf::ref transForm = m_reservoirView->displayCoordTransform(); - cvf::Vec3d domainCoord = transForm->translateToDomainCoord( m_intersectionPointInDisplay ); + if ( m_displayCoordView ) + { + cvf::ref transForm = m_displayCoordView->displayCoordTransform(); + cvf::Vec3d domainCoord = transForm->translateToDomainCoord( m_intersectionPointInDisplay ); - formattedText.sprintf( "Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", - domainCoord.x(), - domainCoord.y(), - -domainCoord.z() ); - text += formattedText; + formattedText.sprintf( "Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", + domainCoord.x(), + domainCoord.y(), + -domainCoord.z() ); + text += formattedText; + } } } } @@ -190,16 +191,11 @@ QString RiuFemResultTextBuilder::gridResultDetails() { QString text; - if ( m_reservoirView->geoMechCase() && m_reservoirView->geoMechCase()->geoMechData() ) + if ( m_geomResDef->geoMechCase() && m_geomResDef->geoMechCase()->geoMechData() ) { - RigGeoMechCaseData* eclipseCaseData = m_reservoirView->geoMechCase()->geoMechData(); + RigGeoMechCaseData* eclipseCaseData = m_geomResDef->geoMechCase()->geoMechData(); - this->appendTextFromResultColors( eclipseCaseData, - m_gridIndex, - m_cellIndex, - m_timeStepIndex, - m_reservoirView->cellResultResultDefinition(), - &text ); + this->appendTextFromResultColors( eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_geomResDef, &text ); if ( !text.isEmpty() ) { @@ -216,7 +212,7 @@ QString RiuFemResultTextBuilder::gridResultDetails() QString RiuFemResultTextBuilder::formationDetails() { QString text; - RimCase* rimCase = m_reservoirView->ownerCase(); + RimCase* rimCase = m_geomResDef->geoMechCase(); if ( rimCase ) { if ( rimCase->activeFormationNames() && rimCase->activeFormationNames()->formationNamesData() ) @@ -225,9 +221,9 @@ QString RiuFemResultTextBuilder::formationDetails() size_t k = cvf::UNDEFINED_SIZE_T; { - if ( m_reservoirView->geoMechCase() ) + if ( m_geomResDef->geoMechCase() ) { - RigGeoMechCaseData* geomData = m_reservoirView->geoMechCase()->geoMechData(); + RigGeoMechCaseData* geomData = m_geomResDef->geoMechCase()->geoMechData(); if ( geomData ) { size_t i = 0; @@ -394,29 +390,31 @@ QString RiuFemResultTextBuilder::closestNodeResultText( RimGeoMechResultDefiniti if ( resultColors->hasResult() ) { - if ( !( m_reservoirView->geoMechCase() && m_reservoirView->geoMechCase()->geoMechData() ) ) return text; + if ( !( m_geomResDef->geoMechCase() && m_geomResDef->geoMechCase()->geoMechData() ) ) return text; - RigGeoMechCaseData* geomData = m_reservoirView->geoMechCase()->geoMechData(); + RigGeoMechCaseData* geomData = m_geomResDef->geoMechCase()->geoMechData(); const std::vector& scalarResults = geomData->femPartResults()->resultValues( resultColors->resultAddress(), m_gridIndex, m_timeStepIndex ); - if ( scalarResults.size() ) + if ( scalarResults.size() && m_displayCoordView ) { RigFemPart* femPart = geomData->femParts()->part( m_gridIndex ); RigFemResultPosEnum activeResultPosition = resultColors->resultPositionType(); - cvf::Vec3d intersectionPointInDomain = m_reservoirView->displayCoordTransform()->translateToDomainCoord( + cvf::Vec3d intersectionPointInDomain = m_displayCoordView->displayCoordTransform()->translateToDomainCoord( m_intersectionPointInDisplay ); + RigFemClosestResultIndexCalculator closestIndexCalc( femPart, activeResultPosition, m_cellIndex, m_face, intersectionPointInDomain ); - int resultIndex = closestIndexCalc.resultIndexToClosestResult(); - int closestNodeId = closestIndexCalc.closestNodeId(); - int closestElmNodResIdx = closestIndexCalc.closestElementNodeResIdx(); + + int resultIndex = closestIndexCalc.resultIndexToClosestResult(); + int closestNodeId = closestIndexCalc.closestNodeId(); + int closestElmNodResIdx = closestIndexCalc.closestElementNodeResIdx(); float scalarValue = ( resultIndex >= 0 ) ? scalarResults[resultIndex] : std::numeric_limits::infinity(); diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h index 861017fe7f..1e5249449b 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h @@ -30,6 +30,7 @@ class RimEclipseCellColors; class RimGeoMechResultDefinition; class RimGeoMechView; class Rim2dIntersectionView; +class RimGridView; namespace cvf { @@ -43,7 +44,11 @@ class Part; class RiuFemResultTextBuilder { public: - RiuFemResultTextBuilder( RimGeoMechView* reservoirView, int gridIndex, int cellIndex, int timeStepIndex ); + RiuFemResultTextBuilder( RimGridView* displayCoordView, + RimGeoMechResultDefinition* geomResDef, + int gridIndex, + int cellIndex, + int timeStepIndex ); void setFace( int face ); void setIntersectionPointInDisplay( cvf::Vec3d intersectionPointInDisplay ); void setIntersectionTriangle( const std::array& triangle ); @@ -69,8 +74,9 @@ private: QString* resultInfoText ); private: - caf::PdmPointer m_reservoirView; - caf::PdmPointer m_2dIntersectionView; + caf::PdmPointer m_displayCoordView; + caf::PdmPointer m_geomResDef; + caf::PdmPointer m_2dIntersectionView; int m_gridIndex; int m_cellIndex; diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp index 9ed116368b..5c3b4389da 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -30,6 +30,7 @@ #include "RigFemResultPosEnum.h" #include "RigGeoMechCaseData.h" +#include "Rim2dIntersectionView.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechResultDefinition.h" @@ -63,7 +64,7 @@ //-------------------------------------------------------------------------------------------------- RiuMohrsCirclePlot::RiuMohrsCirclePlot( QWidget* parent ) : RiuDockedQwtPlot( parent ) - , m_sourceGeoMechViewOfLastPlot( nullptr ) + , m_viewToFollowAnimationFrom( nullptr ) , m_scheduleUpdateAxisScaleTimer( nullptr ) { RiuQwtPlotTools::setCommonPlotBehaviour( this ); @@ -99,25 +100,30 @@ RiuMohrsCirclePlot::~RiuMohrsCirclePlot() //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::appendSelection( const RiuSelectionItem* selectionItem ) { + m_viewToFollowAnimationFrom = nullptr; + if ( this->isVisible() ) { - m_sourceGeoMechViewOfLastPlot = nullptr; + Rim3dView* newFollowAnimView = nullptr; + RiuGeoMechSelectionItem* geoMechSelectionItem = nullptr; + + geoMechSelectionItem = extractGeoMechSelectionItem( selectionItem, newFollowAnimView ); - const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast( - selectionItem ); if ( geoMechSelectionItem ) { - RimGeoMechView* geoMechView = geoMechSelectionItem->m_view; - CVF_ASSERT( geoMechView ); - const size_t gridIndex = geoMechSelectionItem->m_gridIndex; const size_t cellIndex = geoMechSelectionItem->m_cellIndex; const cvf::Color3f color = geoMechSelectionItem->m_color; - queryData( geoMechView, gridIndex, cellIndex, cvf::Color3ub( color ) ); + addOrUpdateCurves( geoMechSelectionItem->m_resultDefinition, + geoMechSelectionItem->m_timestepIdx, + gridIndex, + cellIndex, + cvf::Color3ub( color ) ); + updatePlot(); - m_sourceGeoMechViewOfLastPlot = geoMechView; + m_viewToFollowAnimationFrom = geoMechSelectionItem->m_view; } } else @@ -133,7 +139,7 @@ void RiuMohrsCirclePlot::clearPlot() { deletePlotItems(); - m_sourceGeoMechViewOfLastPlot = nullptr; + m_viewToFollowAnimationFrom = nullptr; this->replot(); } @@ -148,9 +154,10 @@ void RiuMohrsCirclePlot::updateOnTimeStepChanged( Rim3dView* changedView ) return; } - // Don't update the plot if the view that changed time step is different from the view that was the source of the current plot - RimGeoMechView* geoMechView = dynamic_cast( changedView ); - if ( !geoMechView || geoMechView != m_sourceGeoMechViewOfLastPlot ) + // Don't update the plot if the view that changed time step is different + // from the view that was the source of the current plot + + if ( changedView != m_viewToFollowAnimationFrom ) { return; } @@ -160,7 +167,11 @@ void RiuMohrsCirclePlot::updateOnTimeStepChanged( Rim3dView* changedView ) for ( const MohrsCirclesInfo& mohrInfo : mohrsCiclesInfosCopy ) { - queryData( mohrInfo.view, mohrInfo.gridIndex, mohrInfo.elmIndex, mohrInfo.color ); + addOrUpdateCurves( mohrInfo.geomResDef, + changedView->currentTimeStep(), + mohrInfo.gridIndex, + mohrInfo.elmIndex, + mohrInfo.color ); } updatePlot(); @@ -185,7 +196,7 @@ QSize RiuMohrsCirclePlot::minimumSizeHint() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::addMohrCircles( const MohrsCirclesInfo& mohrsCirclesInfo ) +void RiuMohrsCirclePlot::addOrUpdateMohrCircleCurves( const MohrsCirclesInfo& mohrsCirclesInfo ) { const cvf::Vec3f& principals = mohrsCirclesInfo.principals; @@ -263,12 +274,12 @@ void RiuMohrsCirclePlot::deleteCircles() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::addEnvelopeCurve( const cvf::Vec3f& principals, RimGeoMechView* view ) +void RiuMohrsCirclePlot::addorUpdateEnvelopeCurve( const cvf::Vec3f& principals, const RimGeoMechCase* geomCase ) { - if ( !view ) return; + if ( !geomCase ) return; - double cohesion = view->geoMechCase()->cohesion(); - double frictionAngle = view->geoMechCase()->frictionAngleDeg(); + double cohesion = geomCase->cohesion(); + double frictionAngle = geomCase->frictionAngleDeg(); if ( cohesion == HUGE_VAL || frictionAngle == HUGE_VAL || frictionAngle >= 90 ) { @@ -294,17 +305,17 @@ void RiuMohrsCirclePlot::addEnvelopeCurve( const cvf::Vec3f& principals, RimGeoM yVals[1] = ( cohesion / x ) * ( x + principals[0] ); // If envelope for the view already exists, check if a "larger" envelope should be created - if ( m_envolopePlotItems.find( view ) != m_envolopePlotItems.end() ) + if ( m_envolopePlotItems.find( geomCase ) != m_envolopePlotItems.end() ) { - if ( yVals[1] <= m_envolopePlotItems[view]->maxYValue() ) + if ( yVals[1] <= m_envolopePlotItems[geomCase]->maxYValue() ) { return; } else { - m_envolopePlotItems[view]->detach(); - delete m_envolopePlotItems[view]; - m_envolopePlotItems.erase( view ); + m_envolopePlotItems[geomCase]->detach(); + delete m_envolopePlotItems[geomCase]; + m_envolopePlotItems.erase( geomCase ); } } @@ -315,17 +326,17 @@ void RiuMohrsCirclePlot::addEnvelopeCurve( const cvf::Vec3f& principals, RimGeoM qwtCurve->setStyle( QwtPlotCurve::Lines ); qwtCurve->setRenderHint( QwtPlotItem::RenderAntialiased, true ); - const QPen curvePen( envelopeColor( view ) ); + const QPen curvePen( envelopeColor( geomCase ) ); qwtCurve->setPen( curvePen ); qwtCurve->setTitle( QString( "Envelope for %1, (S0: %2, Φ: %3)" ) - .arg( view->geoMechCase()->caseUserDescription ) + .arg( geomCase->caseUserDescription() ) .arg( cohesion ) .arg( frictionAngle ) ); qwtCurve->attach( this ); - m_envolopePlotItems[view] = qwtCurve; + m_envolopePlotItems[geomCase] = qwtCurve; } //-------------------------------------------------------------------------------------------------- @@ -333,7 +344,7 @@ void RiuMohrsCirclePlot::addEnvelopeCurve( const cvf::Vec3f& principals, RimGeoM //-------------------------------------------------------------------------------------------------- void RiuMohrsCirclePlot::deleteEnvelopes() { - for ( const std::pair& envelope : m_envolopePlotItems ) + for ( const std::pair& envelope : m_envolopePlotItems ) { envelope.second->detach(); delete envelope.second; @@ -345,26 +356,26 @@ void RiuMohrsCirclePlot::deleteEnvelopes() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::queryData( RimGeoMechView* geoMechView, - size_t gridIndex, - size_t elmIndex, - const cvf::Color3ub& color ) +bool RiuMohrsCirclePlot::addOrUpdateCurves( const RimGeoMechResultDefinition* geomResDef, + size_t timeStepIndex, + size_t gridIndex, + size_t elmIndex, + const cvf::Color3ub& color ) { - CVF_ASSERT( geoMechView ); - m_sourceGeoMechViewOfLastPlot = geoMechView; + RigFemPart* femPart = geomResDef->ownerCaseData()->femParts()->part( gridIndex ); - RigFemPart* femPart = geoMechView->femParts()->part( gridIndex ); - if ( femPart->elementType( elmIndex ) != HEX8P ) return; + if ( femPart->elementType( elmIndex ) != HEX8P ) return false; - int frameIdx = geoMechView->currentTimeStep(); - RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); - RigFemResultAddress address( RigFemResultPosEnum::RIG_ELEMENT_NODAL, "SE", "" ); + RigFemPartResultsCollection* resultCollection = geomResDef->geoMechCase()->geoMechData()->femPartResults(); + + RigFemResultAddress address( RigFemResultPosEnum::RIG_ELEMENT_NODAL, "SE", "" ); // TODO: All tensors are calculated every time this function is called. FIX - std::vector vertexTensors = resultCollection->tensors( address, 0, frameIdx ); + + std::vector vertexTensors = resultCollection->tensors( address, 0, (int)timeStepIndex ); if ( vertexTensors.empty() ) { - return; + return false; } // Calculate average tensor in element @@ -379,11 +390,11 @@ void RiuMohrsCirclePlot::queryData( RimGeoMechView* geoMechView, if ( !isValidPrincipals( principals ) ) { - return; + return false; } - double cohesion = geoMechView->geoMechCase()->cohesion(); - double frictionAngleDeg = geoMechView->geoMechCase()->frictionAngleDeg(); + double cohesion = geomResDef->geoMechCase()->cohesion(); + double frictionAngleDeg = geomResDef->geoMechCase()->frictionAngleDeg(); size_t i, j, k; bool validIndex = femPart->getOrCreateStructGrid()->ijkFromCellIndex( elmIndex, &i, &j, &k ); @@ -397,12 +408,20 @@ void RiuMohrsCirclePlot::queryData( RimGeoMechView* geoMechView, i, j, k, - geoMechView, + geomResDef, calculateFOS( principals, frictionAngleDeg, cohesion ), color ); - addMohrsCirclesInfo( mohrsCircle ); + m_mohrsCiclesInfos.push_back( mohrsCircle ); + + addorUpdateEnvelopeCurve( mohrsCircle.principals, mohrsCircle.geomResDef->geoMechCase() ); + addOrUpdateMohrCircleCurves( mohrsCircle ); + updateTransparentCurvesOnPrincipals(); + + return true; } + + return false; } //-------------------------------------------------------------------------------------------------- @@ -415,18 +434,6 @@ void RiuMohrsCirclePlot::updatePlot() scheduleUpdateAxisScale(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMohrsCirclePlot::addMohrsCirclesInfo( const MohrsCirclesInfo& mohrsCircleInfo ) -{ - m_mohrsCiclesInfos.push_back( mohrsCircleInfo ); - - addEnvelopeCurve( mohrsCircleInfo.principals, mohrsCircleInfo.view ); - addMohrCircles( mohrsCircleInfo ); - updateTransparentCurvesOnPrincipals(); -} - //-------------------------------------------------------------------------------------------------- /// Add a transparent curve to make tooltip available on principals crossing the x-axis //-------------------------------------------------------------------------------------------------- @@ -568,19 +575,19 @@ float RiuMohrsCirclePlot::calculateFOS( const cvf::Vec3f& principals, double fri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QColor RiuMohrsCirclePlot::envelopeColor( RimGeoMechView* view ) +QColor RiuMohrsCirclePlot::envelopeColor( const RimGeoMechCase* geomCase ) { - if ( m_envolopeColors.find( view ) == m_envolopeColors.end() ) + if ( m_envolopeColors.find( geomCase ) == m_envolopeColors.end() ) { cvf::Color3ub cvfColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3ub( m_envolopeColors.size() ); QColor color( cvfColor.r(), cvfColor.g(), cvfColor.b() ); - m_envolopeColors[view] = color; + m_envolopeColors[geomCase] = color; } - return m_envolopeColors[view]; + return m_envolopeColors[geomCase]; } //-------------------------------------------------------------------------------------------------- @@ -635,7 +642,7 @@ void RiuMohrsCirclePlot::idealAxesEndPoints( double* xMin, double* xMax, double* *yMax = -HUGE_VAL; double maxYEnvelope = -HUGE_VAL; - for ( const std::pair& envelope : m_envolopePlotItems ) + for ( const std::pair& envelope : m_envolopePlotItems ) { double tempMax = envelope.second->maxYValue(); if ( tempMax > maxYEnvelope ) @@ -647,7 +654,7 @@ void RiuMohrsCirclePlot::idealAxesEndPoints( double* xMin, double* xMax, double* *yMax = std::max( maxYEnvelope, 1.2 * largestCircleRadiusInPlot() ); double minXEvelope = HUGE_VAL; - for ( const std::pair& envelope : m_envolopePlotItems ) + for ( const std::pair& envelope : m_envolopePlotItems ) { double tempMin = envelope.second->minXValue(); if ( tempMin < minXEvelope ) @@ -712,3 +719,37 @@ void RiuMohrsCirclePlot::setAxesScaleAndReplot() this->replot(); } + +RiuGeoMechSelectionItem* RiuMohrsCirclePlot::extractGeoMechSelectionItem( const RiuSelectionItem* selectionItem, + Rim3dView*& newFollowAnimView ) +{ + newFollowAnimView = nullptr; + RiuGeoMechSelectionItem* geoMechSelectionItem = nullptr; + + geoMechSelectionItem = dynamic_cast( const_cast( selectionItem ) ); + + if ( geoMechSelectionItem ) + { + // If we clicked in an geoMech view, and hit something using the standard result definition there, + // set this up to follow the animation there. + + RimGeoMechView* clickedInEclView = dynamic_cast( geoMechSelectionItem->m_view.p() ); + + if ( clickedInEclView && clickedInEclView->cellResult() == geoMechSelectionItem->m_resultDefinition.p() ) + { + newFollowAnimView = geoMechSelectionItem->m_view; + } + } + else + { + auto intersectionSelItem = dynamic_cast( selectionItem ); + + if ( intersectionSelItem && intersectionSelItem->geoMechSelectionItem() ) + { + geoMechSelectionItem = intersectionSelItem->geoMechSelectionItem(); + newFollowAnimView = intersectionSelItem->view(); + } + } + + return geoMechSelectionItem; +} diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h index 579b4b6619..19a103b8a4 100644 --- a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -35,6 +35,9 @@ class QWidget; class Rim3dView; class RimGeoMechView; class RiuSelectionItem; +class RimGeoMechCase; +class RimGeoMechResultDefinition; +class RiuGeoMechSelectionItem; //================================================================================================== // @@ -57,34 +60,34 @@ public: private: struct MohrsCirclesInfo { - MohrsCirclesInfo( cvf::Vec3f principals, - size_t gridIndex, - size_t elmIndex, - size_t i, - size_t j, - size_t k, - RimGeoMechView* view, - double factorOfSafety, - cvf::Color3ub color ) + MohrsCirclesInfo( cvf::Vec3f principals, + size_t gridIndex, + size_t elmIndex, + size_t i, + size_t j, + size_t k, + const RimGeoMechResultDefinition* geomResDef, + double factorOfSafety, + cvf::Color3ub color ) : principals( principals ) , gridIndex( gridIndex ) , elmIndex( elmIndex ) , i( i ) , j( j ) , k( k ) - , view( view ) + , geomResDef( geomResDef ) , factorOfSafety( factorOfSafety ) , color( color ) { } - cvf::Vec3f principals; - size_t gridIndex; - size_t elmIndex; - size_t i, j, k; - RimGeoMechView* view; - double factorOfSafety; - cvf::Color3ub color; + cvf::Vec3f principals; + size_t gridIndex; + size_t elmIndex; + size_t i, j, k; + const RimGeoMechResultDefinition* geomResDef; + double factorOfSafety; + cvf::Color3ub color; }; private: @@ -94,33 +97,36 @@ private: void idealAxesEndPoints( double* xMin, double* xMax, double* yMax ) const; - void addMohrCircles( const MohrsCirclesInfo& mohrsCirclesInfo ); + void addOrUpdateMohrCircleCurves( const MohrsCirclesInfo& mohrsCirclesInfo ); void deleteCircles(); - void addEnvelopeCurve( const cvf::Vec3f& principals, RimGeoMechView* view ); + void addorUpdateEnvelopeCurve( const cvf::Vec3f& principals, const RimGeoMechCase* geomCase ); void deleteEnvelopes(); - void queryData( RimGeoMechView* geoMechView, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color ); + bool addOrUpdateCurves( const RimGeoMechResultDefinition* geomResDef, + size_t timeStepIndex, + size_t gridIndex, + size_t elmIndex, + const cvf::Color3ub& color ); void updatePlot(); - void addMohrsCirclesInfo( const MohrsCirclesInfo& mohrsCircleInfo ); - void updateTransparentCurvesOnPrincipals(); double largestCircleRadiusInPlot() const; double smallestPrincipal() const; double largestPrincipal() const; - static bool isValidPrincipals( const cvf::Vec3f& principals ); - - static float calculateFOS( const cvf::Vec3f& principals, double frictionAngle, double cohesion ); - - QColor envelopeColor( RimGeoMechView* view ); + QColor envelopeColor( const RimGeoMechCase* geomCase ); void deletePlotItems(); void scheduleUpdateAxisScale(); + static bool isValidPrincipals( const cvf::Vec3f& principals ); + static float calculateFOS( const cvf::Vec3f& principals, double frictionAngle, double cohesion ); + static RiuGeoMechSelectionItem* extractGeoMechSelectionItem( const RiuSelectionItem* selectionItem, + Rim3dView*& newFollowAnimView ); + private slots: void setAxesScaleAndReplot(); @@ -128,12 +134,12 @@ private: std::vector m_circlePlotItems; std::vector m_transparentCurves; - std::map m_envolopePlotItems; - std::map m_envolopeColors; + std::map m_envolopePlotItems; + std::map m_envolopeColors; std::vector m_mohrsCiclesInfos; - RimGeoMechView* m_sourceGeoMechViewOfLastPlot; + Rim3dView* m_viewToFollowAnimationFrom; QTimer* m_scheduleUpdateAxisScaleTimer; }; diff --git a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp index 20710bdbc2..e4d5a07176 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp +++ b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp @@ -30,6 +30,7 @@ #include "Rim2dIntersectionView.h" #include "Rim3dView.h" +#include "RimEclipseCellColors.h" #include "RimEclipseResultCase.h" #include "RimEclipseView.h" #include "RimExtrudedCurveIntersection.h" @@ -51,7 +52,7 @@ //-------------------------------------------------------------------------------------------------- RiuPvtPlotUpdater::RiuPvtPlotUpdater( RiuPvtPlotPanel* targetPlotPanel ) : m_targetPlotPanel( targetPlotPanel ) - , m_sourceEclipseViewOfLastPlot( nullptr ) + , m_viewToFollowAnimationFrom( nullptr ) { } @@ -65,32 +66,26 @@ void RiuPvtPlotUpdater::updateOnSelectionChanged( const RiuSelectionItem* select return; } - m_sourceEclipseViewOfLastPlot = nullptr; - bool mustClearPlot = true; + Rim3dView* newFollowAnimView = nullptr; + RiuEclipseSelectionItem* eclipseSelectionItem = nullptr; - RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast( - const_cast( selectionItem ) ); - RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : nullptr; + eclipseSelectionItem = RiuRelativePermeabilityPlotUpdater::extractEclipseSelectionItem( selectionItem, + newFollowAnimView ); - if ( !eclipseSelectionItem && !eclipseView ) + bool mustClearPlot = true; + m_viewToFollowAnimationFrom = nullptr; + + if ( m_targetPlotPanel->isVisible() && eclipseSelectionItem ) { - const Riu2dIntersectionSelectionItem* intersectionSelItem = dynamic_cast( - selectionItem ); - if ( intersectionSelItem && intersectionSelItem->eclipseSelectionItem() ) + if ( queryDataAndUpdatePlot( eclipseSelectionItem->m_resultDefinition, + eclipseSelectionItem->m_timestepIdx, + eclipseSelectionItem->m_gridIndex, + eclipseSelectionItem->m_gridLocalCellIndex, + m_targetPlotPanel ) ) { - eclipseSelectionItem = intersectionSelItem->eclipseSelectionItem(); - eclipseView = eclipseSelectionItem->m_view; - } - } + mustClearPlot = false; - if ( m_targetPlotPanel->isVisible() && eclipseSelectionItem && eclipseView ) - { - const size_t gridIndex = eclipseSelectionItem->m_gridIndex; - const size_t gridLocalCellIndex = eclipseSelectionItem->m_gridLocalCellIndex; - if ( queryDataAndUpdatePlot( *eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel ) ) - { - mustClearPlot = false; - m_sourceEclipseViewOfLastPlot = eclipseView; + m_viewToFollowAnimationFrom = newFollowAnimView; } } @@ -110,21 +105,30 @@ void RiuPvtPlotUpdater::updateOnTimeStepChanged( Rim3dView* changedView ) return; } - // Don't update the plot if the view that changed time step is different from the view that was the source of the current plot - const RimEclipseView* eclipseView = dynamic_cast( changedView ); - if ( !eclipseView || eclipseView != m_sourceEclipseViewOfLastPlot ) + // Don't update the plot if the view that changed time step is different + // from the view that was the source of the current plot + + if ( changedView != m_viewToFollowAnimationFrom ) { return; } // Fetch the current global selection and only continue if the selection's view matches the view with time step change - const RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast( - Riu3dSelectionManager::instance()->selectedItem() ); - if ( eclipseSelectionItem && eclipseSelectionItem->m_view == eclipseView ) + + const RiuSelectionItem* selectionItem = Riu3dSelectionManager::instance()->selectedItem(); + Rim3dView* newFollowAnimView = nullptr; + RiuEclipseSelectionItem* eclipseSelectionItem = nullptr; + + eclipseSelectionItem = RiuRelativePermeabilityPlotUpdater::extractEclipseSelectionItem( selectionItem, + newFollowAnimView ); + + if ( eclipseSelectionItem && newFollowAnimView == changedView ) { - const size_t gridIndex = eclipseSelectionItem->m_gridIndex; - const size_t gridLocalCellIndex = eclipseSelectionItem->m_gridLocalCellIndex; - if ( !queryDataAndUpdatePlot( *eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel ) ) + if ( !queryDataAndUpdatePlot( eclipseSelectionItem->m_resultDefinition, + newFollowAnimView->currentTimeStep(), + eclipseSelectionItem->m_gridIndex, + eclipseSelectionItem->m_gridLocalCellIndex, + m_targetPlotPanel ) ) { m_targetPlotPanel->clearPlot(); } @@ -134,14 +138,15 @@ void RiuPvtPlotUpdater::updateOnTimeStepChanged( Rim3dView* changedView ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiuPvtPlotUpdater::queryDataAndUpdatePlot( const RimEclipseView& eclipseView, - size_t gridIndex, - size_t gridLocalCellIndex, - RiuPvtPlotPanel* plotPanel ) +bool RiuPvtPlotUpdater::queryDataAndUpdatePlot( const RimEclipseResultDefinition* eclipseResDef, + size_t timeStepIndex, + size_t gridIndex, + size_t gridLocalCellIndex, + RiuPvtPlotPanel* plotPanel ) { CVF_ASSERT( plotPanel ); - RimEclipseResultCase* eclipseResultCase = dynamic_cast( eclipseView.eclipseCase() ); + RimEclipseResultCase* eclipseResultCase = dynamic_cast( eclipseResDef->eclipseCase() ); RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : nullptr; if ( eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface() ) { @@ -157,8 +162,6 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot( const RimEclipseView& eclipseVie eclipseResultCase->flowDiagSolverInterface() ->calculatePvtCurves( RigFlowDiagSolverInterface::PVT_CT_VISCOSITY, activeCellIndex ); - const size_t timeStepIndex = static_cast( eclipseView.currentTimeStep() ); - // The following calls will read results from file in preparation for the queries below RigCaseCellResultsData* cellResultsData = eclipseCaseData->results( RiaDefines::MATRIX_MODEL ); cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "RS" ) ); @@ -220,7 +223,11 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot( const RimEclipseView& eclipseVie &viscosityDynProps.mu_o, &viscosityDynProps.mu_g ); - QString cellRefText = constructCellReferenceText( eclipseCaseData, gridIndex, gridLocalCellIndex, cellPVTNUM ); + QString cellRefText = RiuRelativePermeabilityPlotUpdater::constructCellReferenceText( eclipseCaseData, + gridIndex, + gridLocalCellIndex, + "PVTNUM", + cellPVTNUM ); plotPanel->setPlotData( eclipseCaseData->unitsType(), fvfCurveArr, @@ -236,47 +243,3 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot( const RimEclipseView& eclipseVie return false; } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiuPvtPlotUpdater::constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData, - size_t gridIndex, - size_t gridLocalCellIndex, - double pvtnum ) -{ - const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; - const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid( gridIndex ) : nullptr; - if ( grid && gridLocalCellIndex < grid->cellCount() ) - { - size_t i = 0; - size_t j = 0; - size_t k = 0; - if ( grid->ijkFromCellIndex( gridLocalCellIndex, &i, &j, &k ) ) - { - // Adjust to 1-based Eclipse indexing - i++; - j++; - k++; - - QString retText; - if ( gridIndex == 0 ) - { - retText = QString( "Cell: [%1, %2, %3]" ).arg( i ).arg( j ).arg( k ); - } - else - { - retText = QString( "LGR %1, Cell: [%2, %3, %4]" ).arg( gridIndex ).arg( i ).arg( j ).arg( k ); - } - - if ( pvtnum != HUGE_VAL ) - { - retText += QString( " (PVTNUM=%1)" ).arg( pvtnum ); - } - - return retText; - } - } - - return QString(); -} diff --git a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h index 4525f937ab..df25eb304f 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h +++ b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h @@ -26,6 +26,7 @@ class RiuPvtPlotPanel; class Rim3dView; class RimEclipseView; class RigEclipseCaseData; +class RimEclipseResultDefinition; //================================================================================================== // @@ -41,16 +42,13 @@ public: void updateOnTimeStepChanged( Rim3dView* changedView ); private: - static bool queryDataAndUpdatePlot( const RimEclipseView& eclipseView, - size_t gridIndex, - size_t gridLocalCellIndex, - RiuPvtPlotPanel* plotPanel ); - static QString constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData, - size_t gridIndex, - size_t gridLocalCellIndex, - double pvtnum ); + static bool queryDataAndUpdatePlot( const RimEclipseResultDefinition* eclipseResultDef, + size_t timeStepIndex, + size_t gridIndex, + size_t gridLocalCellIndex, + RiuPvtPlotPanel* plotPanel ); private: QPointer m_targetPlotPanel; - const Rim3dView* m_sourceEclipseViewOfLastPlot; + const Rim3dView* m_viewToFollowAnimationFrom; }; diff --git a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp index 4aad4410b4..3b0ab7b2e5 100644 --- a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp +++ b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp @@ -29,6 +29,7 @@ #include "Rim2dIntersectionView.h" #include "Rim3dView.h" +#include "RimEclipseCellColors.h" #include "RimEclipseResultCase.h" #include "RimEclipseView.h" #include "RimExtrudedCurveIntersection.h" @@ -50,10 +51,12 @@ //-------------------------------------------------------------------------------------------------- RiuRelativePermeabilityPlotUpdater::RiuRelativePermeabilityPlotUpdater( RiuRelativePermeabilityPlotPanel* targetPlotPanel ) : m_targetPlotPanel( targetPlotPanel ) - , m_sourceEclipseViewOfLastPlot( nullptr ) + , m_viewToFollowAnimationFrom( nullptr ) { } + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -64,32 +67,25 @@ void RiuRelativePermeabilityPlotUpdater::updateOnSelectionChanged( const RiuSele return; } - m_sourceEclipseViewOfLastPlot = nullptr; - bool mustClearPlot = true; + Rim3dView* newFollowAnimView = nullptr; + RiuEclipseSelectionItem* eclipseSelectionItem = nullptr; - RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast( - const_cast( selectionItem ) ); - RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : nullptr; + eclipseSelectionItem = extractEclipseSelectionItem( selectionItem, newFollowAnimView ); - if ( !eclipseSelectionItem && !eclipseView ) + bool mustClearPlot = true; + m_viewToFollowAnimationFrom = nullptr; + + if ( m_targetPlotPanel->isVisible() && eclipseSelectionItem ) { - const Riu2dIntersectionSelectionItem* intersectionSelItem = dynamic_cast( - selectionItem ); - if ( intersectionSelItem && intersectionSelItem->eclipseSelectionItem() ) + if ( queryDataAndUpdatePlot( eclipseSelectionItem->m_resultDefinition, + eclipseSelectionItem->m_timestepIdx, + eclipseSelectionItem->m_gridIndex, + eclipseSelectionItem->m_gridLocalCellIndex, + m_targetPlotPanel ) ) { - eclipseSelectionItem = intersectionSelItem->eclipseSelectionItem(); - eclipseView = eclipseSelectionItem->m_view; - } - } + mustClearPlot = false; - if ( m_targetPlotPanel->isVisible() && eclipseSelectionItem && eclipseView ) - { - const size_t gridIndex = eclipseSelectionItem->m_gridIndex; - const size_t gridLocalCellIndex = eclipseSelectionItem->m_gridLocalCellIndex; - if ( queryDataAndUpdatePlot( *eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel ) ) - { - mustClearPlot = false; - m_sourceEclipseViewOfLastPlot = eclipseView; + m_viewToFollowAnimationFrom = newFollowAnimView; } } @@ -109,21 +105,29 @@ void RiuRelativePermeabilityPlotUpdater::updateOnTimeStepChanged( Rim3dView* cha return; } - // Don't update the plot if the view that changed time step is different from the view that was the source of the current plot - const RimEclipseView* eclipseView = dynamic_cast( changedView ); - if ( !eclipseView || eclipseView != m_sourceEclipseViewOfLastPlot ) + // Don't update the plot if the view that changed time step is different + // from the view that was the source of the current plot + + if ( changedView != m_viewToFollowAnimationFrom ) { return; } // Fetch the current global selection and only continue if the selection's view matches the view with time step change - const RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast( - Riu3dSelectionManager::instance()->selectedItem() ); - if ( eclipseSelectionItem && eclipseSelectionItem->m_view == eclipseView ) + + const RiuSelectionItem* selectionItem = Riu3dSelectionManager::instance()->selectedItem(); + Rim3dView* newFollowAnimView = nullptr; + RiuEclipseSelectionItem* eclipseSelectionItem = nullptr; + + eclipseSelectionItem = extractEclipseSelectionItem( selectionItem, newFollowAnimView ); + + if ( eclipseSelectionItem && newFollowAnimView == changedView ) { - const size_t gridIndex = eclipseSelectionItem->m_gridIndex; - const size_t gridLocalCellIndex = eclipseSelectionItem->m_gridLocalCellIndex; - if ( !queryDataAndUpdatePlot( *eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel ) ) + if ( !queryDataAndUpdatePlot( eclipseSelectionItem->m_resultDefinition, + newFollowAnimView->currentTimeStep(), + eclipseSelectionItem->m_gridIndex, + eclipseSelectionItem->m_gridLocalCellIndex, + m_targetPlotPanel ) ) { m_targetPlotPanel->clearPlot(); } @@ -133,18 +137,21 @@ void RiuRelativePermeabilityPlotUpdater::updateOnTimeStepChanged( Rim3dView* cha //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot( const RimEclipseView& eclipseView, +bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot( const RimEclipseResultDefinition* eclipseResDef, + size_t timeStepIndex, size_t gridIndex, size_t gridLocalCellIndex, RiuRelativePermeabilityPlotPanel* plotPanel ) { CVF_ASSERT( plotPanel ); - RimEclipseResultCase* eclipseResultCase = dynamic_cast( eclipseView.eclipseCase() ); + RimEclipseResultCase* eclipseResultCase = dynamic_cast( eclipseResDef->eclipseCase() ); RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : nullptr; + if ( eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface() ) { size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex( eclipseCaseData, gridIndex, gridLocalCellIndex ); + if ( activeCellIndex != cvf::UNDEFINED_SIZE_T ) { // cvf::Trace::show("Updating RelPerm plot for active cell index: %d", static_cast(activeCellIndex)); @@ -159,7 +166,6 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot( const RimEclips cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::STATIC_NATIVE, "SATNUM" ) ); // Fetch SWAT and SGAS cell values for the selected cell - const size_t timeStepIndex = static_cast( eclipseView.currentTimeStep() ); cvf::ref swatAccessor = RigResultAccessorFactory::createFromResultAddress( eclipseCaseData, gridIndex, @@ -187,8 +193,9 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot( const RimEclips : HUGE_VAL; // cvf::Trace::show("cellSWAT = %f cellSGAS = %f cellSATNUM = %f", cellSWAT, cellSGAS, cellSATNUM); - QString cellRefText = constructCellReferenceText( eclipseCaseData, gridIndex, gridLocalCellIndex, cellSATNUM ); - QString caseName = eclipseResultCase->caseUserDescription; + QString cellRefText = + constructCellReferenceText( eclipseCaseData, gridIndex, gridLocalCellIndex, "SATNUM", cellSATNUM ); + QString caseName = eclipseResultCase->caseUserDescription; plotPanel->setPlotData( eclipseCaseData->unitsType(), relPermCurveArr, cellSWAT, cellSGAS, caseName, cellRefText ); @@ -205,7 +212,8 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot( const RimEclips QString RiuRelativePermeabilityPlotUpdater::constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex, - double satnum ) + const QString& valueName, + double cellValue ) { const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid( gridIndex ) : nullptr; @@ -230,9 +238,9 @@ QString RiuRelativePermeabilityPlotUpdater::constructCellReferenceText( const Ri { retText = QString( "LGR %1, Cell: [%2, %3, %4]" ).arg( gridIndex ).arg( i ).arg( j ).arg( k ); } - if ( satnum != HUGE_VAL ) + if ( cellValue != HUGE_VAL ) { - retText += QString( " (SATNUM=%1)" ).arg( satnum ); + retText += QString( " (%1=%2)" ).arg( valueName ).arg( cellValue ); } return retText; @@ -242,6 +250,45 @@ QString RiuRelativePermeabilityPlotUpdater::constructCellReferenceText( const Ri return QString(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuEclipseSelectionItem* +RiuRelativePermeabilityPlotUpdater::extractEclipseSelectionItem( const RiuSelectionItem* selectionItem, + Rim3dView*& newFollowAnimView ) +{ + newFollowAnimView = nullptr; + RiuEclipseSelectionItem* eclipseSelectionItem = nullptr; + + eclipseSelectionItem = dynamic_cast( const_cast( selectionItem ) ); + + if ( eclipseSelectionItem ) + { + // If we clicked in an eclipse view, and hit something using the standard result definition there, + // set this up to follow the animation there. + + RimEclipseView* clickedInEclView = dynamic_cast( eclipseSelectionItem->m_view.p() ); + + if ( clickedInEclView && clickedInEclView->cellResult() == eclipseSelectionItem->m_resultDefinition.p() ) + { + newFollowAnimView = eclipseSelectionItem->m_view; + } + } + else + { + auto intersectionSelItem = dynamic_cast( selectionItem ); + + if ( intersectionSelItem && intersectionSelItem->eclipseSelectionItem() ) + { + eclipseSelectionItem = intersectionSelItem->eclipseSelectionItem(); + newFollowAnimView = intersectionSelItem->view(); + } + } + + return eclipseSelectionItem; +} + + //================================================================================================== // // @@ -255,17 +302,21 @@ size_t CellLookupHelper::mapToActiveCellIndex( const RigEclipseCaseData* eclipse size_t gridIndex, size_t gridLocalCellIndex ) { - const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; - const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid( gridIndex ) : nullptr; + const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; + + const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid( gridIndex ) : nullptr; + if ( grid && gridLocalCellIndex < grid->cellCount() ) { // Note!! // Which type of porosity model to choose? Currently hard-code to MATRIX_MODEL const RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::MATRIX_MODEL ); + CVF_ASSERT( activeCellInfo ); const size_t reservoirCellIndex = grid->reservoirCellIndex( gridLocalCellIndex ); const size_t activeCellIndex = activeCellInfo->cellResultIndex( reservoirCellIndex ); + return activeCellIndex; } diff --git a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h index 2e2848a662..dee64a9db2 100644 --- a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h +++ b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h @@ -26,6 +26,9 @@ class RiuRelativePermeabilityPlotPanel; class Rim3dView; class RimEclipseView; class RigEclipseCaseData; +class RimEclipseResultDefinition; +class RiuSelectionItem; +class RiuEclipseSelectionItem; //================================================================================================== // @@ -40,19 +43,24 @@ public: void updateOnSelectionChanged( const RiuSelectionItem* selectionItem ); void updateOnTimeStepChanged( Rim3dView* changedView ); + static RiuEclipseSelectionItem* extractEclipseSelectionItem( const RiuSelectionItem* selectionItem, + Rim3dView*& newFollowAnimView ); + static QString constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData, + size_t gridIndex, + size_t gridLocalCellIndex, + const QString& valueName, + double cellValue ); + private: - static bool queryDataAndUpdatePlot( const RimEclipseView& eclipseView, - size_t gridIndex, - size_t gridLocalCellIndex, - RiuRelativePermeabilityPlotPanel* plotPanel ); - static QString constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData, - size_t gridIndex, - size_t gridLocalCellIndex, - double satnum ); + static bool queryDataAndUpdatePlot( const RimEclipseResultDefinition* eclipseResDef, + size_t timeStepIndex, + size_t gridIndex, + size_t gridLocalCellIndex, + RiuRelativePermeabilityPlotPanel* plotPanel ); private: QPointer m_targetPlotPanel; - const Rim3dView* m_sourceEclipseViewOfLastPlot; + const Rim3dView* m_viewToFollowAnimationFrom; }; //================================================================================================== diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp index a88f4d560a..f0fabee214 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp @@ -40,22 +40,26 @@ #include "RivExtrudedCurveIntersectionPartMgr.h" +#include "RimIntersectionResultDefinition.h" #include "cafDisplayCoordTransform.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuResultTextBuilder::RiuResultTextBuilder( RimEclipseView* reservoirView, - size_t gridIndex, - size_t cellIndex, - size_t timeStepIndex ) +RiuResultTextBuilder::RiuResultTextBuilder( RimGridView* settingsView, + RimEclipseResultDefinition* eclResDef, + size_t gridIndex, + size_t cellIndex, + size_t timeStepIndex ) { - CVF_ASSERT( reservoirView ); + CVF_ASSERT( eclResDef ); - m_reservoirView = reservoirView; - m_gridIndex = gridIndex; - m_cellIndex = cellIndex; - m_timeStepIndex = timeStepIndex; + m_displayCoordView = settingsView; + m_viewWithFaultsSettings = dynamic_cast( settingsView ); + m_eclResDef = eclResDef; + m_gridIndex = gridIndex; + m_cellIndex = cellIndex; + m_timeStepIndex = timeStepIndex; m_nncIndex = cvf::UNDEFINED_SIZE_T; m_intersectionPointInDisplay = cvf::Vec3d::UNDEFINED; @@ -65,17 +69,21 @@ RiuResultTextBuilder::RiuResultTextBuilder( RimEclipseView* reservoirView, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuResultTextBuilder::RiuResultTextBuilder( RimEclipseView* reservoirView, size_t reservoirCellIndex, size_t timeStepIndex ) +RiuResultTextBuilder::RiuResultTextBuilder( RimGridView* settingsView, + RimEclipseResultDefinition* eclResDef, + size_t reservoirCellIndex, + size_t timeStepIndex ) { - CVF_ASSERT( reservoirView ); + CVF_ASSERT( eclResDef ); - m_reservoirView = reservoirView; + m_displayCoordView = settingsView; + m_viewWithFaultsSettings = dynamic_cast( settingsView ); + m_eclResDef = eclResDef; + m_gridIndex = 0; + m_cellIndex = 0; + m_timeStepIndex = timeStepIndex; - m_gridIndex = 0; - m_cellIndex = 0; - - RimEclipseCase* eclipseCase = nullptr; - reservoirView->firstAncestorOrThisOfType( eclipseCase ); + RimEclipseCase* eclipseCase = eclResDef->eclipseCase(); if ( eclipseCase && eclipseCase->eclipseCaseData() ) { RigEclipseCaseData* caseData = eclipseCase->eclipseCaseData(); @@ -93,8 +101,6 @@ RiuResultTextBuilder::RiuResultTextBuilder( RimEclipseView* reservoirView, size_ } } - m_timeStepIndex = timeStepIndex; - m_nncIndex = cvf::UNDEFINED_SIZE_T; m_intersectionPointInDisplay = cvf::Vec3d::UNDEFINED; m_face = cvf::StructGridInterface::NO_FACE; @@ -189,9 +195,9 @@ QString RiuResultTextBuilder::geometrySelectionText( QString itemSeparator ) { QString text; - if ( m_reservoirView && m_reservoirView->eclipseCase() ) + if ( m_eclResDef && m_eclResDef->eclipseCase() ) { - const RigEclipseCaseData* eclipseCase = m_reservoirView->eclipseCase()->eclipseCaseData(); + const RigEclipseCaseData* eclipseCase = m_eclResDef->eclipseCase()->eclipseCaseData(); if ( eclipseCase ) { if ( m_cellIndex != cvf::UNDEFINED_SIZE_T ) @@ -229,9 +235,6 @@ QString RiuResultTextBuilder::geometrySelectionText( QString itemSeparator ) if ( m_intersectionPointInDisplay != cvf::Vec3d::UNDEFINED ) { - cvf::ref transForm = m_reservoirView->displayCoordTransform(); - cvf::Vec3d domainCoord = transForm->translateToDomainCoord( m_intersectionPointInDisplay ); - QString formattedText; if ( m_2dIntersectionView ) { @@ -252,11 +255,17 @@ QString RiuResultTextBuilder::geometrySelectionText( QString itemSeparator ) } else { - formattedText.sprintf( "Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", - domainCoord.x(), - domainCoord.y(), - -domainCoord.z() ); - text += formattedText; + if ( m_displayCoordView ) + { + cvf::ref transForm = m_displayCoordView->displayCoordTransform(); + cvf::Vec3d domainCoord = transForm->translateToDomainCoord( m_intersectionPointInDisplay ); + + formattedText.sprintf( "Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", + domainCoord.x(), + domainCoord.y(), + -domainCoord.z() ); + text += formattedText; + } } } } @@ -272,16 +281,11 @@ QString RiuResultTextBuilder::gridResultDetails() { QString text; - if ( m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->eclipseCaseData() ) + if ( m_eclResDef->eclipseCase() && m_eclResDef->eclipseCase()->eclipseCaseData() ) { - RigEclipseCaseData* eclipseCaseData = m_reservoirView->eclipseCase()->eclipseCaseData(); + RigEclipseCaseData* eclipseCaseData = m_eclResDef->eclipseCase()->eclipseCaseData(); - this->appendTextFromResultColors( eclipseCaseData, - m_gridIndex, - m_cellIndex, - m_timeStepIndex, - m_reservoirView->cellResult(), - &text ); + this->appendTextFromResultColors( eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_eclResDef, &text ); if ( !text.isEmpty() ) { @@ -299,9 +303,9 @@ QString RiuResultTextBuilder::faultResultDetails() { QString text; - if ( m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->eclipseCaseData() ) + if ( m_eclResDef->eclipseCase() && m_eclResDef->eclipseCase()->eclipseCaseData() ) { - RigEclipseCaseData* eclipseCaseData = m_reservoirView->eclipseCase()->eclipseCaseData(); + RigEclipseCaseData* eclipseCaseData = m_eclResDef->eclipseCase()->eclipseCaseData(); RigGridBase* grid = eclipseCaseData->grid( m_gridIndex ); RigMainGrid* mainGrid = grid->mainGrid(); @@ -315,14 +319,14 @@ QString RiuResultTextBuilder::faultResultDetails() cvf::StructGridInterface::FaceEnum faceHelper( m_face ); text += "Fault Face : " + faceHelper.text() + "\n"; - if ( m_reservoirView->faultResultSettings()->hasValidCustomResult() ) + if ( m_viewWithFaultsSettings && m_viewWithFaultsSettings->faultResultSettings()->hasValidCustomResult() ) { text += "Fault result data:\n"; this->appendTextFromResultColors( eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, - m_reservoirView->currentFaultResultColors(), + m_viewWithFaultsSettings->currentFaultResultColors(), &text ); } } @@ -337,7 +341,7 @@ QString RiuResultTextBuilder::faultResultDetails() QString RiuResultTextBuilder::formationDetails() { QString text; - RimCase* rimCase = m_reservoirView->eclipseCase(); + RimCase* rimCase = m_eclResDef->eclipseCase(); if ( rimCase ) { if ( rimCase->activeFormationNames() && rimCase->activeFormationNames()->formationNamesData() ) @@ -346,7 +350,7 @@ QString RiuResultTextBuilder::formationDetails() size_t k = cvf::UNDEFINED_SIZE_T; { - const RigEclipseCaseData* eclipseData = m_reservoirView->eclipseCase()->eclipseCaseData(); + const RigEclipseCaseData* eclipseData = m_eclResDef->eclipseCase()->eclipseCaseData(); if ( eclipseData ) { if ( m_cellIndex != cvf::UNDEFINED_SIZE_T ) @@ -380,7 +384,7 @@ QString RiuResultTextBuilder::formationDetails() //-------------------------------------------------------------------------------------------------- QString RiuResultTextBuilder::gridResultText() { - QString text = cellResultText( m_reservoirView->cellResult() ); + QString text = cellResultText( m_eclResDef ); return text; } @@ -392,19 +396,21 @@ QString RiuResultTextBuilder::faultResultText() { QString text; - if ( m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->eclipseCaseData() ) + if ( m_eclResDef->eclipseCase() && m_eclResDef->eclipseCase()->eclipseCaseData() ) { - RigEclipseCaseData* eclipseCaseData = m_reservoirView->eclipseCase()->eclipseCaseData(); - RigGridBase* grid = eclipseCaseData->grid( m_gridIndex ); - RigMainGrid* mainGrid = grid->mainGrid(); + RigEclipseCaseData* eclipseCaseData = m_eclResDef->eclipseCase()->eclipseCaseData(); + + RigGridBase* grid = eclipseCaseData->grid( m_gridIndex ); + RigMainGrid* mainGrid = grid->mainGrid(); const RigFault* fault = mainGrid->findFaultFromCellIndexAndCellFace( m_cellIndex, m_face ); + if ( fault ) { cvf::StructGridInterface::FaceEnum faceHelper( m_face ); - if ( m_reservoirView->faultResultSettings()->hasValidCustomResult() ) + if ( m_viewWithFaultsSettings && m_viewWithFaultsSettings->faultResultSettings()->hasValidCustomResult() ) { - text = cellResultText( m_reservoirView->currentFaultResultColors() ); + text = cellResultText( m_viewWithFaultsSettings->currentFaultResultColors() ); } } } @@ -421,9 +427,9 @@ QString RiuResultTextBuilder::nncResultText() if ( m_nncIndex != cvf::UNDEFINED_SIZE_T ) { - if ( m_reservoirView.notNull() && m_reservoirView->eclipseCase() ) + if ( m_eclResDef.notNull() && m_eclResDef->eclipseCase() ) { - RigEclipseCaseData* eclipseCase = m_reservoirView->eclipseCase()->eclipseCaseData(); + RigEclipseCaseData* eclipseCase = m_eclResDef->eclipseCase()->eclipseCaseData(); RigMainGrid* grid = eclipseCase->mainGrid(); CVF_ASSERT( grid ); @@ -433,31 +439,35 @@ QString RiuResultTextBuilder::nncResultText() if ( nncData && m_nncIndex < nncData->connections().size() ) { - const RigConnection& conn = nncData->connections()[m_nncIndex]; + const RigConnection& conn = nncData->connections()[m_nncIndex]; + cvf::StructGridInterface::FaceEnum face( conn.m_c1Face ); - if ( m_reservoirView->currentFaultResultColors() ) + if ( m_viewWithFaultsSettings && m_viewWithFaultsSettings->currentFaultResultColors() ) { RigEclipseResultAddress eclipseResultAddress = - m_reservoirView->currentFaultResultColors()->eclipseResultAddress(); - RiaDefines::ResultCatType resultType = m_reservoirView->currentFaultResultColors()->resultType(); - const std::vector* nncValues = nullptr; + m_viewWithFaultsSettings->currentFaultResultColors()->eclipseResultAddress(); + RiaDefines::ResultCatType resultType = + m_viewWithFaultsSettings->currentFaultResultColors()->resultType(); + + const std::vector* nncValues = nullptr; + if ( resultType == RiaDefines::STATIC_NATIVE ) { nncValues = nncData->staticConnectionScalarResult( eclipseResultAddress ); } else if ( resultType == RiaDefines::DYNAMIC_NATIVE ) { - if ( m_reservoirView.notNull() && m_reservoirView->eclipseCase() ) + if ( m_eclResDef.notNull() && m_eclResDef->eclipseCase() ) { - size_t nativeTimeStep = m_reservoirView->eclipseCase()->uiToNativeTimeStepIndex( - m_timeStepIndex ); + size_t nativeTimeStep = m_eclResDef->eclipseCase()->uiToNativeTimeStepIndex( m_timeStepIndex ); nncValues = nncData->dynamicConnectionScalarResult( eclipseResultAddress, nativeTimeStep ); } } + if ( nncValues && ( m_nncIndex < nncValues->size() ) ) { - QString resultVar = m_reservoirView->currentFaultResultColors()->resultVariableUiName(); + QString resultVar = m_viewWithFaultsSettings->currentFaultResultColors()->resultVariableUiName(); double scalarValue = ( *nncValues )[m_nncIndex]; text = QString( "%1 : %2" ).arg( resultVar ).arg( scalarValue ); @@ -473,12 +483,12 @@ QString RiuResultTextBuilder::nncResultText() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuResultTextBuilder::appendTextFromResultColors( RigEclipseCaseData* eclipseCase, - size_t gridIndex, - size_t cellIndex, - size_t timeStepIndex, - RimEclipseCellColors* resultColors, - QString* resultInfoText ) +void RiuResultTextBuilder::appendTextFromResultColors( RigEclipseCaseData* eclipseCase, + size_t gridIndex, + size_t cellIndex, + size_t timeStepIndex, + RimEclipseResultDefinition* resultColors, + QString* resultInfoText ) { if ( !resultColors ) { @@ -678,19 +688,19 @@ QString RiuResultTextBuilder::cellEdgeResultDetails() { QString text; - if ( m_reservoirView->cellEdgeResult()->hasResult() ) + if ( m_viewWithFaultsSettings && m_viewWithFaultsSettings->cellEdgeResult()->hasResult() ) { text += "-- Cell edge result data --\n"; - if ( m_reservoirView->cellEdgeResult()->isUsingSingleVariable() ) + if ( m_viewWithFaultsSettings->cellEdgeResult()->isUsingSingleVariable() ) { - text += cellResultText( m_reservoirView->cellEdgeResult()->singleVarEdgeResultColors() ); + text += cellResultText( m_viewWithFaultsSettings->cellEdgeResult()->singleVarEdgeResultColors() ); text += "\n"; } else { std::vector metaData; - m_reservoirView->cellEdgeResult()->cellEdgeMetaData( &metaData ); + m_viewWithFaultsSettings->cellEdgeResult()->cellEdgeMetaData( &metaData ); std::set uniqueResultIndices; @@ -707,9 +717,9 @@ QString RiuResultTextBuilder::cellEdgeResultDetails() adjustedTimeStep = 0; } - RiaDefines::PorosityModelType porosityModel = m_reservoirView->cellResult()->porosityModel(); + RiaDefines::PorosityModelType porosityModel = m_eclResDef->porosityModel(); cvf::ref resultAccessor = - RigResultAccessorFactory::createFromResultAddress( m_reservoirView->eclipseCase()->eclipseCaseData(), + RigResultAccessorFactory::createFromResultAddress( m_eclResDef->eclipseCase()->eclipseCaseData(), m_gridIndex, porosityModel, adjustedTimeStep, @@ -737,9 +747,9 @@ QString RiuResultTextBuilder::nncDetails() if ( m_nncIndex != cvf::UNDEFINED_SIZE_T ) { - if ( m_reservoirView.notNull() && m_reservoirView->eclipseCase() ) + if ( m_eclResDef.notNull() && m_eclResDef->eclipseCase() ) { - RigEclipseCaseData* eclipseCase = m_reservoirView->eclipseCase()->eclipseCaseData(); + RigEclipseCaseData* eclipseCase = m_eclResDef->eclipseCase()->eclipseCaseData(); RigMainGrid* grid = eclipseCase->mainGrid(); CVF_ASSERT( grid ); @@ -832,24 +842,24 @@ void RiuResultTextBuilder::appendDetails( QString& text, const QString& details //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiuResultTextBuilder::cellResultText( RimEclipseCellColors* resultColors ) +QString RiuResultTextBuilder::cellResultText( RimEclipseResultDefinition* eclResDef ) { QString text; - if ( m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->eclipseCaseData() ) + if ( m_eclResDef->eclipseCase() && m_eclResDef->eclipseCase()->eclipseCaseData() ) { - RigEclipseCaseData* eclipseCaseData = m_reservoirView->eclipseCase()->eclipseCaseData(); + RigEclipseCaseData* eclipseCaseData = m_eclResDef->eclipseCase()->eclipseCaseData(); - if ( resultColors->isTernarySaturationSelected() ) + if ( eclResDef->isTernarySaturationSelected() ) { - RigCaseCellResultsData* gridCellResults = m_reservoirView->cellResult()->currentGridCellResults(); + RigCaseCellResultsData* gridCellResults = m_eclResDef->currentGridCellResults(); if ( gridCellResults ) { gridCellResults->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "SOIL" ) ); gridCellResults->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "SGAS" ) ); gridCellResults->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "SWAT" ) ); - RiaDefines::PorosityModelType porosityModel = resultColors->porosityModel(); + RiaDefines::PorosityModelType porosityModel = eclResDef->porosityModel(); cvf::ref dataAccessObjectX = RigResultAccessorFactory::createFromResultAddress( eclipseCaseData, @@ -897,7 +907,7 @@ QString RiuResultTextBuilder::cellResultText( RimEclipseCellColors* resultColors else { size_t adjustedTimeStep = m_timeStepIndex; - if ( resultColors->hasStaticResult() ) + if ( eclResDef->hasStaticResult() ) { adjustedTimeStep = 0; } @@ -906,16 +916,32 @@ QString RiuResultTextBuilder::cellResultText( RimEclipseCellColors* resultColors RigResultAccessorFactory::createFromResultDefinition( eclipseCaseData, m_gridIndex, adjustedTimeStep, - resultColors ); + eclResDef ); if ( resultAccessor.notNull() ) { double scalarValue = resultAccessor->cellFaceScalar( m_cellIndex, m_face ); - QString resultVar = resultColors->resultVariableUiName(); + QString resultVar = eclResDef->resultVariableUiName(); QString resultValueText; - if ( resultColors->hasCategoryResult() ) + if ( eclResDef->hasCategoryResult() ) { - RimRegularLegendConfig* legendConfig = resultColors->legendConfig(); + auto resColorDef = dynamic_cast( eclResDef ); + + RimRegularLegendConfig* legendConfig = nullptr; + + if ( resColorDef ) + { + legendConfig = resColorDef->legendConfig(); + } + else + { + RimIntersectionResultDefinition* interResDef = nullptr; + eclResDef->firstAncestorOrThisOfType( interResDef ); + if ( interResDef ) + { + legendConfig = interResDef->regularLegendConfig(); + } + } resultValueText += legendConfig->categoryNameFromCategoryValue( scalarValue ); } @@ -939,9 +965,9 @@ QString RiuResultTextBuilder::wellResultText() { QString text; - if ( m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->eclipseCaseData() ) + if ( m_eclResDef->eclipseCase() && m_eclResDef->eclipseCase()->eclipseCaseData() ) { - cvf::Collection simWellData = m_reservoirView->eclipseCase()->eclipseCaseData()->wellResults(); + cvf::Collection simWellData = m_eclResDef->eclipseCase()->eclipseCaseData()->wellResults(); for ( size_t i = 0; i < simWellData.size(); i++ ) { RigSimWellData* singleWellResultData = simWellData.at( i ); diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.h b/ApplicationCode/UserInterface/RiuResultTextBuilder.h index b6798cad5c..050f73df21 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.h +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.h @@ -25,8 +25,11 @@ class RimEclipseView; class RimEclipseCellColors; class Rim2dIntersectionView; -class QString; class RigEclipseCaseData; +class RimEclipseResultDefinition; +class RimGridView; + +class QString; namespace cvf { @@ -40,8 +43,15 @@ class Part; class RiuResultTextBuilder { public: - RiuResultTextBuilder( RimEclipseView* reservoirView, size_t gridIndex, size_t cellIndex, size_t timeStepIndex ); - RiuResultTextBuilder( RimEclipseView* reservoirView, size_t reservoirCellIndex, size_t timeStepIndex ); + RiuResultTextBuilder( RimGridView* settingsView, + RimEclipseResultDefinition* eclResDef, + size_t gridIndex, + size_t cellIndex, + size_t timeStepIndex ); + RiuResultTextBuilder( RimGridView* settingsView, + RimEclipseResultDefinition* eclResDef, + size_t reservoirCellIndex, + size_t timeStepIndex ); void setFace( cvf::StructGridInterface::FaceType face ); void setNncIndex( size_t nncIndex ); @@ -66,18 +76,21 @@ private: QString nncResultText(); QString wellResultText(); - QString cellResultText( RimEclipseCellColors* resultColors ); + QString cellResultText( RimEclipseResultDefinition* resultColors ); - void appendTextFromResultColors( RigEclipseCaseData* eclipseCase, - size_t gridIndex, - size_t cellIndex, - size_t timeStepIndex, - RimEclipseCellColors* resultColors, - QString* resultInfoText ); + void appendTextFromResultColors( RigEclipseCaseData* eclipseCase, + size_t gridIndex, + size_t cellIndex, + size_t timeStepIndex, + RimEclipseResultDefinition* resultColors, + QString* resultInfoText ); private: - caf::PdmPointer m_reservoirView; - caf::PdmPointer m_2dIntersectionView; + caf::PdmPointer m_displayCoordView; + caf::PdmPointer m_viewWithFaultsSettings; + + caf::PdmPointer m_eclResDef; + caf::PdmPointer m_2dIntersectionView; size_t m_gridIndex; size_t m_cellIndex; diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index 7c52e1ceec..395df237f1 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -134,43 +134,41 @@ void RiuSelectionChangedHandler::handleSetSelectedItem( const RiuSelectionItem* //-------------------------------------------------------------------------------------------------- void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuEclipseSelectionItem* eclipseSelectionItem ) const { - RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p(); + RimEclipseResultDefinition* eclResDef = eclipseSelectionItem->m_resultDefinition; - if ( eclipseView->cellResult()->isFlowDiagOrInjectionFlooding() && - eclipseView->cellResult()->resultVariable() != RIG_NUM_FLOODED_PV ) + if ( eclResDef->isFlowDiagOrInjectionFlooding() && eclResDef->resultVariable() != RIG_NUM_FLOODED_PV ) { // NB! Do not read out data for flow results, as this can be a time consuming operation return; } - else if ( eclipseView->cellResult()->hasDynamicResult() && - !RiaDefines::isPerCellFaceResult( eclipseView->cellResult()->resultVariable() ) && - eclipseView->eclipseCase() && eclipseView->eclipseCase()->eclipseCaseData() ) + else if ( eclResDef->hasDynamicResult() && !RiaDefines::isPerCellFaceResult( eclResDef->resultVariable() ) && + eclResDef->eclipseCase() && eclResDef->eclipseCase()->eclipseCaseData() ) { - RiaDefines::PorosityModelType porosityModel = eclipseView->cellResult()->porosityModel(); + RiaDefines::PorosityModelType porosityModel = eclResDef->porosityModel(); std::vector timeStepDates = - eclipseView->eclipseCase()->eclipseCaseData()->results( porosityModel )->timeStepDates(); + eclResDef->eclipseCase()->eclipseCaseData()->results( porosityModel )->timeStepDates(); - QString curveName = eclipseView->eclipseCase()->caseUserDescription(); + QString curveName = eclResDef->eclipseCase()->caseUserDescription(); curveName += ", "; - curveName += eclipseView->cellResult()->resultVariableUiShortName(); + curveName += eclResDef->resultVariableUiShortName(); curveName += ", "; curveName += QString( "Grid index %1" ).arg( eclipseSelectionItem->m_gridIndex ); curveName += ", "; - curveName += RigTimeHistoryResultAccessor::geometrySelectionText( eclipseView->eclipseCase()->eclipseCaseData(), + curveName += RigTimeHistoryResultAccessor::geometrySelectionText( eclResDef->eclipseCase()->eclipseCaseData(), eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridLocalCellIndex ); std::vector timeHistoryValues = - RigTimeHistoryResultAccessor::timeHistoryValues( eclipseView->eclipseCase()->eclipseCaseData(), - eclipseView->cellResult(), + RigTimeHistoryResultAccessor::timeHistoryValues( eclResDef->eclipseCase()->eclipseCaseData(), + eclResDef, eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridLocalCellIndex, timeStepDates.size() ); CVF_ASSERT( timeStepDates.size() == timeHistoryValues.size() ); - RiuMainWindow::instance()->resultPlot()->addCurve( eclipseView->eclipseCase(), + RiuMainWindow::instance()->resultPlot()->addCurve( eclResDef->eclipseCase(), curveName, eclipseSelectionItem->m_color, timeStepDates, @@ -183,22 +181,20 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuEclipseSele //-------------------------------------------------------------------------------------------------- void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuGeoMechSelectionItem* geomSelectionItem ) const { - RimGeoMechView* geoMechView = geomSelectionItem->m_view.p(); + RimGeoMechResultDefinition* geomResDef = geomSelectionItem->m_resultDefinition; - if ( geoMechView && geoMechView->cellResultResultDefinition() && - geoMechView->cellResultResultDefinition()->hasResult() && geoMechView->geoMechCase() && - geoMechView->geoMechCase()->geoMechData() ) + if ( geomResDef && geomResDef->hasResult() && geomResDef->geoMechCase() && geomResDef->geoMechCase()->geoMechData() ) { std::unique_ptr timeHistResultAccessor; - cvf::Vec3d intersectionPointInDomain = geoMechView->displayCoordTransform()->translateToDomainCoord( + cvf::Vec3d intersectionPointInDomain = geomSelectionItem->m_view->displayCoordTransform()->translateToDomainCoord( geomSelectionItem->m_localIntersectionPointInDisplay ); if ( geomSelectionItem->m_hasIntersectionTriangle ) { timeHistResultAccessor = std::unique_ptr( - new RiuFemTimeHistoryResultAccessor( geoMechView->geoMechCase()->geoMechData(), - geoMechView->cellResultResultDefinition()->resultAddress(), + new RiuFemTimeHistoryResultAccessor( geomResDef->geoMechCase()->geoMechData(), + geomResDef->resultAddress(), geomSelectionItem->m_gridIndex, static_cast( geomSelectionItem->m_cellIndex ), geomSelectionItem->m_elementFace, @@ -208,8 +204,8 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuGeoMechSele else { timeHistResultAccessor = std::unique_ptr( - new RiuFemTimeHistoryResultAccessor( geoMechView->geoMechCase()->geoMechData(), - geoMechView->cellResultResultDefinition()->resultAddress(), + new RiuFemTimeHistoryResultAccessor( geomResDef->geoMechCase()->geoMechData(), + geomResDef->resultAddress(), geomSelectionItem->m_gridIndex, static_cast( geomSelectionItem->m_cellIndex ), geomSelectionItem->m_elementFace, @@ -217,12 +213,12 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuGeoMechSele } QString curveName; - curveName.append( geoMechView->geoMechCase()->caseUserDescription() + ", " ); + curveName.append( geomResDef->geoMechCase()->caseUserDescription() + ", " ); - caf::AppEnum resPosAppEnum = geoMechView->cellResultResultDefinition()->resultPositionType(); + caf::AppEnum resPosAppEnum = geomResDef->resultPositionType(); curveName.append( resPosAppEnum.uiText() + ", " ); - curveName.append( geoMechView->cellResultResultDefinition()->resultFieldUiName() + ", " ); - curveName.append( geoMechView->cellResultResultDefinition()->resultComponentUiName() + " " ); + curveName.append( geomResDef->resultFieldUiName() + ", " ); + curveName.append( geomResDef->resultComponentUiName() + " " ); if ( resPosAppEnum == RIG_ELEMENT_NODAL_FACE ) { @@ -243,10 +239,10 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuGeoMechSele std::vector timeHistoryValues = timeHistResultAccessor->timeHistoryValues(); - std::vector dates = geoMechView->geoMechCase()->timeStepDates(); + std::vector dates = geomResDef->geoMechCase()->timeStepDates(); if ( dates.size() == timeHistoryValues.size() ) { - RiuMainWindow::instance()->resultPlot()->addCurve( geoMechView->geoMechCase(), + RiuMainWindow::instance()->resultPlot()->addCurve( geomResDef->geoMechCase(), curveName, geomSelectionItem->m_color, dates, @@ -260,7 +256,7 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuGeoMechSele dummyStepTimes.push_back( i ); } - RiuMainWindow::instance()->resultPlot()->addCurve( geoMechView->geoMechCase(), + RiuMainWindow::instance()->resultPlot()->addCurve( geomResDef->geoMechCase(), curveName, geomSelectionItem->m_color, dummyStepTimes, @@ -364,12 +360,12 @@ void RiuSelectionChangedHandler::updateResultInfo( const RiuSelectionItem* itemA { const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast( selItem ); - RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p(); - - RiuResultTextBuilder textBuilder( eclipseView, + RiuResultTextBuilder textBuilder( eclipseSelectionItem->m_view, + eclipseSelectionItem->m_resultDefinition, eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridLocalCellIndex, - eclipseView->currentTimeStep() ); + eclipseSelectionItem->m_timestepIdx ); + textBuilder.setFace( eclipseSelectionItem->m_face ); textBuilder.setNncIndex( eclipseSelectionItem->m_nncIndex ); textBuilder.setIntersectionPointInDisplay( eclipseSelectionItem->m_localIntersectionPointInDisplay ); @@ -383,16 +379,20 @@ void RiuSelectionChangedHandler::updateResultInfo( const RiuSelectionItem* itemA { const RiuGeoMechSelectionItem* geomSelectionItem = static_cast( selItem ); - RimGeoMechView* geomView = geomSelectionItem->m_view.p(); - RiuFemResultTextBuilder textBuilder( geomView, + RiuFemResultTextBuilder textBuilder( geomSelectionItem->m_view, + geomSelectionItem->m_resultDefinition, (int)geomSelectionItem->m_gridIndex, (int)geomSelectionItem->m_cellIndex, - geomView->currentTimeStep() ); + (int)geomSelectionItem->m_timestepIdx ); + textBuilder.setIntersectionPointInDisplay( geomSelectionItem->m_localIntersectionPointInDisplay ); textBuilder.setFace( geomSelectionItem->m_elementFace ); textBuilder.set2dIntersectionView( intersectionView ); + if ( geomSelectionItem->m_hasIntersectionTriangle ) + { textBuilder.setIntersectionTriangle( geomSelectionItem->m_intersectionTriangle ); + } resultInfo = textBuilder.mainResultText(); diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 3de6a3a02e..660885b372 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -28,6 +28,7 @@ #include "RicEclipsePropertyFilterNewExec.h" #include "RicGeoMechPropertyFilterNewExec.h" #include "RicPickEventHandler.h" +#include "RiuCellAndNncPickEventHandler.h" #include "WellLogCommands/Ric3dWellLogCurvePickEventHandler.h" #include "WellPathCommands/RicIntersectionPickEventHandler.h" #include "WellPathCommands/RicWellPathPickEventHandler.h" @@ -137,6 +138,7 @@ RiuViewerCommands::RiuViewerCommands( RiuViewer* ownerViewer ) addDefaultPickEventHandler( Ric3dWellLogCurvePickEventHandler::instance() ); addDefaultPickEventHandler( RicWellPathPickEventHandler::instance() ); addDefaultPickEventHandler( RicContourMapPickEventHandler::instance() ); + addDefaultPickEventHandler( RiuCellAndNncPickEventHandler::instance() ); } } @@ -643,7 +645,7 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard if ( pickItemInfos.size() ) { - Ric3dPickEvent viewerEventObject( pickItemInfos, mainOrComparisonView ); + Ric3dPickEvent viewerEventObject( pickItemInfos, mainOrComparisonView, keyboardModifiers ); if ( sm_overridingPickHandler && sm_overridingPickHandler->handle3dPickEvent( viewerEventObject ) ) { @@ -660,77 +662,33 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard } // Old pick handling. Todo: Encapsulate in pickEventHandlers - - size_t gridIndex = cvf::UNDEFINED_SIZE_T; - size_t cellIndex = cvf::UNDEFINED_SIZE_T; - size_t nncIndex = cvf::UNDEFINED_SIZE_T; - cvf::StructGridInterface::FaceType face = cvf::StructGridInterface::NO_FACE; - int gmFace = -1; - bool intersectionHit = false; - std::array intersectionTriangleHit; - - cvf::Vec3d localIntersectionPoint( cvf::Vec3d::ZERO ); - cvf::Vec3d globalIntersectionPoint( cvf::Vec3d::ZERO ); - - // Extract all the above information from the pick { const cvf::Part* firstHitPart = nullptr; uint firstPartTriangleIndex = cvf::UNDEFINED_UINT; - - const cvf::Part* firstNncHitPart = nullptr; - uint nncPartTriangleIndex = cvf::UNDEFINED_UINT; + cvf::Vec3d globalIntersectionPoint( cvf::Vec3d::ZERO ); if ( pickItemInfos.size() ) { - size_t indexToFirstNoneNncItem = cvf::UNDEFINED_SIZE_T; - ; + size_t indexToFirstNoneNncItem = cvf::UNDEFINED_SIZE_T; size_t indexToNncItemNearFirstItem = cvf::UNDEFINED_SIZE_T; - ; findFirstItems( mainOrComparisonView, pickItemInfos, &indexToFirstNoneNncItem, &indexToNncItemNearFirstItem ); if ( indexToFirstNoneNncItem != cvf::UNDEFINED_SIZE_T ) { - localIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].localPickedPoint(); - globalIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].globalPickedPoint(); firstHitPart = pickItemInfos[indexToFirstNoneNncItem].pickedPart(); firstPartTriangleIndex = pickItemInfos[indexToFirstNoneNncItem].faceIdx(); - } - - if ( indexToNncItemNearFirstItem != cvf::UNDEFINED_SIZE_T ) - { - firstNncHitPart = pickItemInfos[indexToNncItemNearFirstItem].pickedPart(); - nncPartTriangleIndex = pickItemInfos[indexToNncItemNearFirstItem].faceIdx(); - } - } - - if ( firstNncHitPart && firstNncHitPart->sourceInfo() ) - { - const RivSourceInfo* rivSourceInfo = dynamic_cast( firstNncHitPart->sourceInfo() ); - if ( rivSourceInfo ) - { - if ( nncPartTriangleIndex < rivSourceInfo->m_NNCIndices->size() ) - { - nncIndex = rivSourceInfo->m_NNCIndices->get( nncPartTriangleIndex ); - } + globalIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].globalPickedPoint(); } } if ( firstHitPart && firstHitPart->sourceInfo() ) { - const RivObjectSourceInfo* rivObjectSourceInfo = dynamic_cast( - firstHitPart->sourceInfo() ); - const RivSourceInfo* rivSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); - const RivFemPickSourceInfo* femSourceInfo = dynamic_cast( - firstHitPart->sourceInfo() ); - const RivExtrudedCurveIntersectionSourceInfo* crossSectionSourceInfo = - dynamic_cast( firstHitPart->sourceInfo() ); - const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo = - dynamic_cast( firstHitPart->sourceInfo() ); - const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast( - firstHitPart->sourceInfo() ); - const RivWellConnectionSourceInfo* wellConnectionSourceInfo = dynamic_cast( - firstHitPart->sourceInfo() ); + // clang-format off + const RivObjectSourceInfo* rivObjectSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); + const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); + const RivWellConnectionSourceInfo* wellConnectionSourceInfo = dynamic_cast( firstHitPart->sourceInfo() ); + // clang-format on if ( rivObjectSourceInfo ) { @@ -800,50 +758,18 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard RiuMainWindow::instance()->selectAsCurrentItem( textAnnot, true ); } } - - if ( rivSourceInfo ) + else if ( const RivExtrudedCurveIntersectionSourceInfo* crossSectionSourceInfo = + dynamic_cast( firstHitPart->sourceInfo() ) ) { - gridIndex = rivSourceInfo->gridIndex(); - if ( rivSourceInfo->hasCellFaceMapping() ) - { - CVF_ASSERT( rivSourceInfo->m_cellFaceFromTriangleMapper.notNull() ); - - cellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex( firstPartTriangleIndex ); - face = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace( firstPartTriangleIndex ); - } - } - else if ( femSourceInfo ) - { - gridIndex = femSourceInfo->femPartIndex(); - cellIndex = femSourceInfo->triangleToElmMapper()->elementIndex( firstPartTriangleIndex ); - gmFace = femSourceInfo->triangleToElmMapper()->elementFace( firstPartTriangleIndex ); - } - else if ( crossSectionSourceInfo ) - { - findCellAndGridIndex( mainOrComparisonView, - crossSectionSourceInfo, - firstPartTriangleIndex, - &cellIndex, - &gridIndex ); - intersectionHit = true; - intersectionTriangleHit = crossSectionSourceInfo->triangle( firstPartTriangleIndex ); - bool allowActiveViewChange = dynamic_cast( m_viewer->ownerViewWindow() ) == nullptr; RiuMainWindow::instance()->selectAsCurrentItem( crossSectionSourceInfo->intersection(), allowActiveViewChange ); } - else if ( intersectionBoxSourceInfo ) + else if ( const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo = + dynamic_cast( firstHitPart->sourceInfo() ) ) { - findCellAndGridIndex( mainOrComparisonView, - intersectionBoxSourceInfo, - firstPartTriangleIndex, - &cellIndex, - &gridIndex ); - intersectionHit = true; - intersectionTriangleHit = intersectionBoxSourceInfo->triangle( firstPartTriangleIndex ); - RiuMainWindow::instance()->selectAsCurrentItem( intersectionBoxSourceInfo->intersectionBox() ); } else if ( eclipseWellSourceInfo ) @@ -901,6 +827,7 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard { RiuResultTextBuilder textBuilder( eclipseView, + eclipseView->cellResult(), globalCellIndex, eclipseView->currentTimeStep() ); @@ -968,6 +895,7 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard { RiuResultTextBuilder textBuilder( eclipseView, + eclipseView->cellResult(), globalCellIndex, eclipseView->currentTimeStep() ); @@ -987,85 +915,6 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard } } } - - if ( cellIndex == cvf::UNDEFINED_SIZE_T ) - { - Riu3dSelectionManager::instance()->deleteAllItems(); - } - else - { - bool appendToSelection = false; - if ( keyboardModifiers & Qt::ControlModifier ) - { - appendToSelection = true; - } - - std::vector items; - Riu3dSelectionManager::instance()->selectedItems( items ); - - const caf::ColorTable& colorTable = RiaColorTables::selectionPaletteColors(); - - cvf::Color3f curveColor = colorTable.cycledColor3f( items.size() ); - - if ( !appendToSelection ) - { - curveColor = colorTable.cycledColor3f( 0 ); - } - - RiuSelectionItem* selItem = nullptr; - { - Rim2dIntersectionView* intersectionView = dynamic_cast( mainOrComparisonView ); - RimEclipseView* eclipseView = dynamic_cast( mainOrComparisonView ); - RimGeoMechView* geomView = dynamic_cast( mainOrComparisonView ); - - if ( intersectionView ) - { - intersectionView->intersection()->firstAncestorOrThisOfType( eclipseView ); - intersectionView->intersection()->firstAncestorOrThisOfType( geomView ); - } - - if ( eclipseView ) - { - selItem = new RiuEclipseSelectionItem( eclipseView, - gridIndex, - cellIndex, - nncIndex, - curveColor, - face, - localIntersectionPoint ); - } - - if ( geomView ) - { - if ( intersectionHit ) - selItem = new RiuGeoMechSelectionItem( geomView, - gridIndex, - cellIndex, - curveColor, - gmFace, - localIntersectionPoint, - intersectionTriangleHit ); - else - selItem = new RiuGeoMechSelectionItem( geomView, - gridIndex, - cellIndex, - curveColor, - gmFace, - localIntersectionPoint ); - } - - if ( intersectionView ) selItem = new Riu2dIntersectionSelectionItem( intersectionView, selItem ); - } - - if ( appendToSelection ) - { - Riu3dSelectionManager::instance()->appendItemToSelection( selItem ); - } - else if ( selItem ) - { - Riu3dSelectionManager::instance()->setSelectedItem( selItem ); - } - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.h b/ApplicationCode/UserInterface/RiuViewerCommands.h index 9141d803d8..1685a75343 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.h +++ b/ApplicationCode/UserInterface/RiuViewerCommands.h @@ -69,17 +69,22 @@ public: cvf::Vec3d lastPickPositionInDomainCoords() const; bool isCurrentPickInComparisonView() const; + static void findFirstItems( Rim3dView* mainOrComparisonView, + const std::vector& pickItemInfos, + size_t* indexToFirstNoneNncItem, + size_t* indexToNncItemNearFirsItem ); + static void findCellAndGridIndex( Rim3dView* mainOrComparisonView, + const RivExtrudedCurveIntersectionSourceInfo* intersectionSourceInfo, + cvf::uint firstPartTriangleIndex, + size_t* cellIndex, + size_t* gridIndex ); + static void findCellAndGridIndex( Rim3dView* mainOrComparisonView, + const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo, + cvf::uint firstPartTriangleIndex, + size_t* cellIndex, + size_t* gridIndex ); + private: - void findCellAndGridIndex( Rim3dView* mainOrComparisonView, - const RivExtrudedCurveIntersectionSourceInfo* intersectionSourceInfo, - cvf::uint firstPartTriangleIndex, - size_t* cellIndex, - size_t* gridIndex ); - void findCellAndGridIndex( Rim3dView* mainOrComparisonView, - const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo, - cvf::uint firstPartTriangleIndex, - size_t* cellIndex, - size_t* gridIndex ); void ijkFromCellIndex( Rim3dView* mainOrComparisonView, size_t gridIdx, size_t cellIndex, @@ -87,12 +92,8 @@ private: size_t* j, size_t* k ); - void findFirstItems( Rim3dView* mainOrComparisonView, - const std::vector& pickItemInfos, - size_t* indexToFirstNoneNncItem, - size_t* indexToNncItemNearFirsItem ); - bool handleOverlayItemPicking( int winPosX, int winPosY ); + void handleTextPicking( int winPosX, int winPosY, cvf::HitItemCollection* hitItems ); void addCompareToViewMenu( caf::CmdFeatureMenuBuilder* menuBuilder ); @@ -110,5 +111,4 @@ private: static Ric3dViewPickEventHandler* sm_overridingPickHandler; static std::vector sm_defaultPickEventHandlers; - void handleTextPicking( int winPosX, int winPosY, cvf::HitItemCollection* hitItems ); }; diff --git a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp index 55f7a799c6..36ab18f6aa 100644 --- a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp +++ b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp @@ -260,11 +260,23 @@ ref StructGridGeometryGenerator::createOutlineMeshDrawable(double c return geo; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +ref StructGridGeometryGenerator::createMeshDrawableFromSingleCell(const StructGridInterface* grid, + size_t cellIndex) +{ + return createMeshDrawableFromSingleCell(grid, + cellIndex, + grid->displayModelOffset()); +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -ref StructGridGeometryGenerator::createMeshDrawableFromSingleCell(const StructGridInterface* grid, size_t cellIndex) +ref StructGridGeometryGenerator::createMeshDrawableFromSingleCell(const StructGridInterface* grid, + size_t cellIndex, + const cvf::Vec3d& displayModelOffset) { cvf::Vec3d cornerVerts[8]; grid->cellCornerVertices(cellIndex, cornerVerts); @@ -281,7 +293,7 @@ ref StructGridGeometryGenerator::createMeshDrawableFromSingleCell(c int n; for (n = 0; n < 4; n++) { - vertices.push_back(cvf::Vec3f(cornerVerts[faceConn[n]] - grid->displayModelOffset())); + vertices.push_back(cvf::Vec3f(cornerVerts[faceConn[n]] - displayModelOffset)); } } diff --git a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.h b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.h index ade37fbdbc..c4946be7e3 100644 --- a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.h +++ b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.h @@ -188,7 +188,12 @@ public: ref createMeshDrawable(); ref createOutlineMeshDrawable(double creaseAngle); - static ref createMeshDrawableFromSingleCell(const StructGridInterface* grid, size_t cellIndex); + static ref createMeshDrawableFromSingleCell(const StructGridInterface* grid, + size_t cellIndex); + + static ref createMeshDrawableFromSingleCell(const StructGridInterface* grid, + size_t cellIndex, + const cvf::Vec3d& displayModelOffset); private: static ref