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/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..99f37cfc01 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -2051,12 +2051,13 @@ void RimEclipseView::onCreatePartCollectionFromSelection( cvf::Collectiontype() == 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() ); + CVF_ASSERT( eclipseSelItem->m_resultDefinition->eclipseCase() ); + CVF_ASSERT( eclipseSelItem->m_resultDefinition->eclipseCase()->eclipseCaseData() ); - RivSingleCellPartGenerator partGen( eclipseSelItem->m_view->eclipseCase()->eclipseCaseData(), + RivSingleCellPartGenerator partGen( eclipseSelItem->m_resultDefinition->eclipseCase()->eclipseCaseData(), eclipseSelItem->m_gridIndex, eclipseSelItem->m_gridLocalCellIndex ); 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..f85f1fc7b8 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -837,20 +837,24 @@ void RimGeoMechView::calculateCurrentTotalCellVisibility( cvf::UByteArray* total //-------------------------------------------------------------------------------------------------- void RimGeoMechView::onCreatePartCollectionFromSelection( cvf::Collection* parts ) { - Riu3dSelectionManager* riuSelManager = Riu3dSelectionManager::instance(); + 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() ) + + if ( geomSelItem && geomSelItem->m_view == this && geomSelItem->m_resultDefinition->geoMechCase() ) { - RivSingleCellPartGenerator partGen( geomSelItem->m_view->geoMechCase(), + RivSingleCellPartGenerator partGen( geomSelItem->m_resultDefinition->geoMechCase(), geomSelItem->m_gridIndex, geomSelItem->m_cellIndex ); - cvf::ref part = partGen.createPart( geomSelItem->m_color ); + + cvf::ref part = partGen.createPart( geomSelItem->m_color ); part->setTransform( this->scaleTransform() ); parts->push_back( part.p() ); diff --git a/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp b/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp index 63ee4067c4..25643ec4b6 100644 --- a/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp @@ -127,7 +127,7 @@ void RimGridTimeHistoryCurve::setFromSelectionItem( const RiuSelectionItem* sele if ( eclSelectionItem->m_view ) { m_eclipseResultDefinition = new RimEclipseResultDefinition; - m_eclipseResultDefinition->simpleCopy( eclSelectionItem->m_view->cellResult() ); + m_eclipseResultDefinition->simpleCopy( eclSelectionItem->m_resultDefinition ); } } @@ -142,9 +142,8 @@ void RimGridTimeHistoryCurve::setFromSelectionItem( const RiuSelectionItem* sele if ( geoMechSelectionItem->m_view ) { 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/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/Riu3dSelectionManager.cpp b/ApplicationCode/UserInterface/Riu3dSelectionManager.cpp index 306a222c44..72f08a962c 100644 --- a/ApplicationCode/UserInterface/Riu3dSelectionManager.cpp +++ b/ApplicationCode/UserInterface/Riu3dSelectionManager.cpp @@ -20,13 +20,13 @@ #include "Riu3dSelectionManager.h" #include "Rim2dIntersectionView.h" +#include "RimEclipseResultDefinition.h" #include "RimEclipseView.h" +#include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" #include "RimGridView.h" #include "RimSimWellInView.h" #include "RimWellPath.h" -#include "RimEclipseResultDefinition.h" -#include "RimGeoMechResultDefinition.h" #include "RivSimWellPipeSourceInfo.h" #include "RivWellPathSourceInfo.h" @@ -157,7 +157,7 @@ void Riu3dSelectionManager::deleteAllItemsFromSelection( int role ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimEclipseView* view, +RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimGridView* view, RimEclipseResultDefinition* resultDefinition, size_t timestepIdx, size_t gridIndex, @@ -181,7 +181,7 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimEclipseView* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* view, +RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* view, RimGeoMechResultDefinition* resultDefinition, size_t timestepIdx, size_t gridIndex, @@ -204,7 +204,7 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* vi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* view, +RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* view, RimGeoMechResultDefinition* resultDefinition, size_t timestepIdx, size_t gridIndex, diff --git a/ApplicationCode/UserInterface/Riu3dSelectionManager.h b/ApplicationCode/UserInterface/Riu3dSelectionManager.h index a9c80b01ac..298cdf9921 100644 --- a/ApplicationCode/UserInterface/Riu3dSelectionManager.h +++ b/ApplicationCode/UserInterface/Riu3dSelectionManager.h @@ -132,7 +132,7 @@ public: class RiuEclipseSelectionItem : public RiuSelectionItem { public: - explicit RiuEclipseSelectionItem( RimEclipseView* view, + explicit RiuEclipseSelectionItem( RimGridView* view, RimEclipseResultDefinition* resultDefinition, size_t timestepIdx, size_t gridIndex, @@ -150,7 +150,7 @@ public: } public: - caf::PdmPointer m_view; + caf::PdmPointer m_view; caf::PdmPointer m_resultDefinition; size_t m_timestepIdx; size_t m_gridIndex; @@ -169,7 +169,7 @@ public: class RiuGeoMechSelectionItem : public RiuSelectionItem { public: - explicit RiuGeoMechSelectionItem( RimGeoMechView* view, + explicit RiuGeoMechSelectionItem( RimGridView* view, RimGeoMechResultDefinition* resultDefinition, size_t timestepIdx, size_t gridIndex, @@ -178,7 +178,7 @@ public: int elementFace, const cvf::Vec3d& localIntersectionPointInDisplay ); - explicit RiuGeoMechSelectionItem( RimGeoMechView* view, + explicit RiuGeoMechSelectionItem( RimGridView* view, RimGeoMechResultDefinition* resultDefinition, size_t timestepIdx, size_t gridIndex, @@ -195,7 +195,7 @@ public: } public: - caf::PdmPointer m_view; + caf::PdmPointer m_view; caf::PdmPointer m_resultDefinition; size_t m_timestepIdx; size_t m_gridIndex; diff --git a/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.cpp b/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.cpp index 6c0caf3489..c4e6371b9f 100644 --- a/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.cpp +++ b/ApplicationCode/UserInterface/RiuCellAndNncPickEventHandler.cpp @@ -21,9 +21,13 @@ #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" @@ -115,48 +119,82 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve 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() ) ) + if ( const RivSourceInfo* rivSourceInfo = + dynamic_cast( firstHitPart->sourceInfo() ) ) + { + gridIndex = rivSourceInfo->gridIndex(); + if ( rivSourceInfo->hasCellFaceMapping() ) { - gridIndex = rivSourceInfo->gridIndex(); - if ( rivSourceInfo->hasCellFaceMapping() ) - { - CVF_ASSERT( rivSourceInfo->m_cellFaceFromTriangleMapper.notNull() ); + CVF_ASSERT( rivSourceInfo->m_cellFaceFromTriangleMapper.notNull() ); - cellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex( firstPartTriangleIndex ); - face = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace( firstPartTriangleIndex ); + 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 RivFemPickSourceInfo* femSourceInfo = - dynamic_cast( firstHitPart->sourceInfo() ) ) + } + 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() ) { - gridIndex = femSourceInfo->femPartIndex(); - cellIndex = femSourceInfo->triangleToElmMapper()->elementIndex( firstPartTriangleIndex ); - gmFace = femSourceInfo->triangleToElmMapper()->elementFace( firstPartTriangleIndex ); - } - else if ( const RivExtrudedCurveIntersectionSourceInfo* crossSectionSourceInfo = - dynamic_cast( firstHitPart->sourceInfo() ) ) - { - RiuViewerCommands::findCellAndGridIndex( mainOrComparisonView, - crossSectionSourceInfo, - firstPartTriangleIndex, - &cellIndex, - &gridIndex ); - intersectionHit = true; - intersectionTriangleHit = crossSectionSourceInfo->triangle( firstPartTriangleIndex ); - } - else if ( const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo = - dynamic_cast( firstHitPart->sourceInfo() ) ) - { - RiuViewerCommands::findCellAndGridIndex( mainOrComparisonView, - intersectionBoxSourceInfo, - firstPartTriangleIndex, - &cellIndex, - &gridIndex ); - intersectionHit = true; - intersectionTriangleHit = intersectionBoxSourceInfo->triangle( firstPartTriangleIndex ); + if ( sepInterResDef->isEclipseResultDefinition() ) + { + eclResDef = sepInterResDef->eclipseResultDefinition(); + } + else + { + geomResDef = sepInterResDef->geoMechResultDefinition(); + } + + timestepIndex = sepInterResDef->timeStep(); } + } // clang-format on if ( cellIndex == cvf::UNDEFINED_SIZE_T ) @@ -189,17 +227,35 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve RimEclipseView* eclipseView = dynamic_cast( mainOrComparisonView ); RimGeoMechView* geomView = dynamic_cast( mainOrComparisonView ); + RimGridView* associatedGridView = dynamic_cast( mainOrComparisonView ); + if ( intersectionView ) { - intersectionView->intersection()->firstAncestorOrThisOfType( eclipseView ); - intersectionView->intersection()->firstAncestorOrThisOfType( geomView ); + intersectionView->intersection()->firstAncestorOrThisOfType( associatedGridView ); } - if ( eclipseView ) + // Use the clicked views default settings if we have not found any special stuff + + if ( !eclResDef && !geomResDef ) { - selItem = new RiuEclipseSelectionItem( eclipseView, - nullptr, - -1, + 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, @@ -208,12 +264,12 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve localIntersectionPoint ); } - if ( geomView ) + if ( geomResDef ) { if ( intersectionHit ) - selItem = new RiuGeoMechSelectionItem( geomView, - nullptr, - -1, + selItem = new RiuGeoMechSelectionItem( associatedGridView, + geomResDef, + timestepIndex, gridIndex, cellIndex, curveColor, @@ -221,9 +277,9 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve localIntersectionPoint, intersectionTriangleHit ); else - selItem = new RiuGeoMechSelectionItem( geomView, - nullptr, - -1, + selItem = new RiuGeoMechSelectionItem( associatedGridView, + geomResDef, + timestepIndex, gridIndex, cellIndex, curveColor, 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/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index 7c52e1ceec..6223e1376e 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,39 +360,48 @@ void RiuSelectionChangedHandler::updateResultInfo( const RiuSelectionItem* itemA { const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast( selItem ); - RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p(); + RimEclipseView* eclipseView = dynamic_cast( eclipseSelectionItem->m_view.p() ); - RiuResultTextBuilder textBuilder( eclipseView, - eclipseSelectionItem->m_gridIndex, - eclipseSelectionItem->m_gridLocalCellIndex, - eclipseView->currentTimeStep() ); - textBuilder.setFace( eclipseSelectionItem->m_face ); - textBuilder.setNncIndex( eclipseSelectionItem->m_nncIndex ); - textBuilder.setIntersectionPointInDisplay( eclipseSelectionItem->m_localIntersectionPointInDisplay ); - textBuilder.set2dIntersectionView( intersectionView ); + if ( eclipseView ) + { + RiuResultTextBuilder textBuilder( eclipseView, + eclipseSelectionItem->m_gridIndex, + eclipseSelectionItem->m_gridLocalCellIndex, + eclipseSelectionItem->m_timestepIdx ); + textBuilder.setFace( eclipseSelectionItem->m_face ); + textBuilder.setNncIndex( eclipseSelectionItem->m_nncIndex ); + textBuilder.setIntersectionPointInDisplay( eclipseSelectionItem->m_localIntersectionPointInDisplay ); + textBuilder.set2dIntersectionView( intersectionView ); - resultInfo = textBuilder.mainResultText(); + resultInfo = textBuilder.mainResultText(); - pickInfo = textBuilder.geometrySelectionText( ", " ); + pickInfo = textBuilder.geometrySelectionText( ", " ); + } } else if ( selItem->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT ) { const RiuGeoMechSelectionItem* geomSelectionItem = static_cast( selItem ); - RimGeoMechView* geomView = geomSelectionItem->m_view.p(); - RiuFemResultTextBuilder textBuilder( geomView, - (int)geomSelectionItem->m_gridIndex, - (int)geomSelectionItem->m_cellIndex, - geomView->currentTimeStep() ); - textBuilder.setIntersectionPointInDisplay( geomSelectionItem->m_localIntersectionPointInDisplay ); - textBuilder.setFace( geomSelectionItem->m_elementFace ); - textBuilder.set2dIntersectionView( intersectionView ); - if ( geomSelectionItem->m_hasIntersectionTriangle ) - textBuilder.setIntersectionTriangle( geomSelectionItem->m_intersectionTriangle ); + RimGeoMechView* geomView = dynamic_cast( geomSelectionItem->m_view.p() ); - resultInfo = textBuilder.mainResultText(); + if ( geomView ) + { + RiuFemResultTextBuilder textBuilder( geomView, + (int)geomSelectionItem->m_gridIndex, + (int)geomSelectionItem->m_cellIndex, + (int)geomSelectionItem->m_timestepIdx ); - pickInfo = textBuilder.geometrySelectionText( ", " ); + 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(); + + pickInfo = textBuilder.geometrySelectionText( ", " ); + } } }