Merge pull request #5118 from OPM/feature-fix-intersection-with-sep-results-picking

Fix picking on intersections with separate results
This commit is contained in:
Jacob Støren 2019-11-28 15:27:48 +01:00 committed by GitHub
commit 95ba482f54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 1113 additions and 729 deletions

View File

@ -41,14 +41,16 @@ class Rim3dView;
class Ric3dPickEvent : public caf::PickEvent class Ric3dPickEvent : public caf::PickEvent
{ {
public: public:
Ric3dPickEvent( const std::vector<RiuPickItemInfo>& pickItemInfos, Rim3dView* view ) Ric3dPickEvent( const std::vector<RiuPickItemInfo>& pickItemInfos, Rim3dView* view, Qt::KeyboardModifiers keyboardModifiers)
: m_pickItemInfos( pickItemInfos ) : m_pickItemInfos( pickItemInfos )
, m_view( view ) , m_view( view )
, m_keyboardModifiers( keyboardModifiers )
{ {
} }
std::vector<RiuPickItemInfo> m_pickItemInfos; std::vector<RiuPickItemInfo> m_pickItemInfos;
Rim3dView* m_view; Rim3dView* m_view;
Qt::KeyboardModifiers m_keyboardModifiers;
}; };
//================================================================================================== //==================================================================================================

View File

@ -225,8 +225,8 @@ bool RicNewGridTimeHistoryCurveFeature::isCommandEnabled()
const RiuEclipseSelectionItem* eclSelectionItem = dynamic_cast<const RiuEclipseSelectionItem*>( items[0] ); const RiuEclipseSelectionItem* eclSelectionItem = dynamic_cast<const RiuEclipseSelectionItem*>( items[0] );
if ( eclSelectionItem ) if ( eclSelectionItem )
{ {
if ( eclSelectionItem->m_view->cellResult()->isFlowDiagOrInjectionFlooding() && if ( eclSelectionItem->m_resultDefinition->isFlowDiagOrInjectionFlooding() &&
eclSelectionItem->m_view->cellResult()->resultVariable() != RIG_NUM_FLOODED_PV ) eclSelectionItem->m_resultDefinition->resultVariable() != RIG_NUM_FLOODED_PV )
{ {
return false; return false;
} }

View File

@ -19,6 +19,7 @@
#include "RimGeoMechGeometrySelectionItem.h" #include "RimGeoMechGeometrySelectionItem.h"
#include "RimGeoMechCase.h" #include "RimGeoMechCase.h"
#include "RimGeoMechResultDefinition.h"
#include "RimGeoMechView.h" #include "RimGeoMechView.h"
#include "Riu3dSelectionManager.h" #include "Riu3dSelectionManager.h"
@ -59,7 +60,7 @@ RimGeoMechGeometrySelectionItem::~RimGeoMechGeometrySelectionItem() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimGeoMechGeometrySelectionItem::setFromSelectionItem( const RiuGeoMechSelectionItem* selectionItem ) void RimGeoMechGeometrySelectionItem::setFromSelectionItem( const RiuGeoMechSelectionItem* selectionItem )
{ {
m_geoMechCase = selectionItem->m_view->geoMechCase(); m_geoMechCase = selectionItem->m_resultDefinition->geoMechCase();
m_gridIndex = selectionItem->m_gridIndex; m_gridIndex = selectionItem->m_gridIndex;
m_cellIndex = selectionItem->m_cellIndex; m_cellIndex = selectionItem->m_cellIndex;

View File

@ -286,8 +286,10 @@ void RivFemPartGeometryGenerator::setElementVisibility( const cvf::UByteArray* c
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( const RigFemPart* part, cvf::ref<cvf::DrawableGeo>
size_t elmIdx ) RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( const RigFemPart* part,
size_t elmIdx,
const cvf::Vec3d& displayModelOffset )
{ {
cvf::ref<cvf::Vec3fArray> quadVertices; cvf::ref<cvf::Vec3fArray> quadVertices;
@ -301,7 +303,7 @@ cvf::ref<cvf::DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawableFromSi
const int* elmNodeIndices = part->connectivities( elmIdx ); 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 ) for ( int lfIdx = 0; lfIdx < faceCount; ++lfIdx )
{ {
@ -310,13 +312,13 @@ cvf::ref<cvf::DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawableFromSi
if ( faceNodeCount == 4 ) if ( faceNodeCount == 4 )
{ {
vertices.push_back( cvf::Vec3f( vertices.push_back( cvf::Vec3f(
cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ) - displayOffset ) ); cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ) - displayModelOffset ) );
vertices.push_back( cvf::Vec3f( vertices.push_back( cvf::Vec3f(
cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] ) - displayOffset ) ); cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] ) - displayModelOffset ) );
vertices.push_back( cvf::Vec3f( vertices.push_back( cvf::Vec3f(
cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]] ) - displayOffset ) ); cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]] ) - displayModelOffset ) );
vertices.push_back( cvf::Vec3f( vertices.push_back( cvf::Vec3f(
cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]] ) - displayOffset ) ); cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]] ) - displayModelOffset ) );
} }
else else
{ {

View File

@ -121,7 +121,9 @@ public:
return m_triangleMapper.p(); return m_triangleMapper.p();
} }
static cvf::ref<cvf::DrawableGeo> createMeshDrawableFromSingleElement( const RigFemPart* grid, size_t elementIndex ); static cvf::ref<cvf::DrawableGeo> createMeshDrawableFromSingleElement( const RigFemPart* grid,
size_t elementIndex,
const cvf::Vec3d& displayModelOffset );
private: private:
static cvf::ref<cvf::UIntArray> lineIndicesFromQuadVertexArray( const cvf::Vec3fArray* vertexArray ); static cvf::ref<cvf::UIntArray> lineIndicesFromQuadVertexArray( const cvf::Vec3fArray* vertexArray );

View File

@ -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_rigCaseData( rigCaseData )
, m_gridIndex( gridIndex ) , m_gridIndex( gridIndex )
, m_cellIndex( cellIndex ) , m_cellIndex( cellIndex )
, m_geoMechCase( nullptr ) , 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_geoMechCase( rimGeoMechCase )
, m_gridIndex( gridIndex ) , m_gridIndex( gridIndex )
, m_cellIndex( cellIndex ) , m_cellIndex( cellIndex )
, m_rigCaseData( nullptr ) , m_rigCaseData( nullptr )
, m_displayModelOffset( displayModelOffset )
{ {
} }
@ -88,7 +96,8 @@ cvf::ref<cvf::DrawableGeo> RivSingleCellPartGenerator::createMeshDrawable()
if ( m_rigCaseData && m_cellIndex != cvf::UNDEFINED_SIZE_T ) if ( m_rigCaseData && m_cellIndex != cvf::UNDEFINED_SIZE_T )
{ {
return cvf::StructGridGeometryGenerator::createMeshDrawableFromSingleCell( m_rigCaseData->grid( m_gridIndex ), 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 ) else if ( m_geoMechCase && m_cellIndex != cvf::UNDEFINED_SIZE_T )
{ {
@ -98,7 +107,9 @@ cvf::ref<cvf::DrawableGeo> RivSingleCellPartGenerator::createMeshDrawable()
RigFemPart* femPart = m_geoMechCase->geoMechData()->femParts()->part( m_gridIndex ); RigFemPart* femPart = m_geoMechCase->geoMechData()->femParts()->part( m_gridIndex );
CVF_ASSERT( femPart ); CVF_ASSERT( femPart );
return RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( femPart, m_cellIndex ); return RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement( femPart,
m_cellIndex,
m_displayModelOffset );
} }
return nullptr; return nullptr;

View File

@ -36,8 +36,14 @@ class RimGeoMechCase;
class RivSingleCellPartGenerator class RivSingleCellPartGenerator
{ {
public: public:
RivSingleCellPartGenerator( RigEclipseCaseData* rigCaseData, size_t gridIndex, size_t cellIndex ); RivSingleCellPartGenerator( RigEclipseCaseData* rigCaseData,
RivSingleCellPartGenerator( RimGeoMechCase* rimGeoMechCase, size_t gridIndex, size_t cellIndex ); 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<cvf::Part> createPart( const cvf::Color3f color ); cvf::ref<cvf::Part> createPart( const cvf::Color3f color );
@ -49,4 +55,5 @@ private:
RimGeoMechCase* m_geoMechCase; RimGeoMechCase* m_geoMechCase;
size_t m_gridIndex; size_t m_gridIndex;
size_t m_cellIndex; size_t m_cellIndex;
cvf::Vec3d m_displayModelOffset;
}; };

View File

@ -23,6 +23,7 @@
#include "RigTimeHistoryResultAccessor.h" #include "RigTimeHistoryResultAccessor.h"
#include "RimEclipseCase.h" #include "RimEclipseCase.h"
#include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "Riu3dSelectionManager.h" #include "Riu3dSelectionManager.h"
@ -61,7 +62,7 @@ void RimEclipseGeometrySelectionItem::setFromSelectionItem( const RiuEclipseSele
m_cellIndex = selectionItem->m_gridLocalCellIndex; m_cellIndex = selectionItem->m_gridLocalCellIndex;
m_localIntersectionPointInDisplay = selectionItem->m_localIntersectionPointInDisplay; m_localIntersectionPointInDisplay = selectionItem->m_localIntersectionPointInDisplay;
m_eclipseCase = selectionItem->m_view->eclipseCase(); m_eclipseCase = selectionItem->m_resultDefinition->eclipseCase();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -2037,38 +2037,6 @@ bool RimEclipseView::isShowingActiveCellsOnly()
return !m_showInactiveCells; return !m_showInactiveCells;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseView::onCreatePartCollectionFromSelection( cvf::Collection<cvf::Part>* parts )
{
Riu3dSelectionManager* riuSelManager = Riu3dSelectionManager::instance();
std::vector<RiuSelectionItem*> 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<RiuEclipseSelectionItem*>( 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<cvf::Part> part = partGen.createPart( eclipseSelItem->m_color );
part->setTransform( this->scaleTransform() );
parts->push_back( part.p() );
}
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -156,7 +156,6 @@ protected:
void onLoadDataAndUpdate() override; void onLoadDataAndUpdate() override;
caf::PdmFieldHandle* userDescriptionField() override; caf::PdmFieldHandle* userDescriptionField() override;
void onCreatePartCollectionFromSelection( cvf::Collection<cvf::Part>* parts ) override;
bool isShowingActiveCellsOnly() override; bool isShowingActiveCellsOnly() override;
void onUpdateDisplayModelForCurrentTimeStep() override; void onUpdateDisplayModelForCurrentTimeStep() override;
void updateVisibleGeometriesAndCellColors(); void updateVisibleGeometriesAndCellColors();

View File

@ -258,6 +258,14 @@ void RimGeoMechResultDefinition::setGeoMechCase( RimGeoMechCase* geomCase )
m_geomCase = geomCase; m_geomCase = geomCase;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechCase* RimGeoMechResultDefinition::geoMechCase() const
{
return m_geomCase;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -46,7 +46,8 @@ public:
RimGeoMechResultDefinition( void ); RimGeoMechResultDefinition( void );
~RimGeoMechResultDefinition( void ) override; ~RimGeoMechResultDefinition( void ) override;
void setGeoMechCase( RimGeoMechCase* geomCase ); void setGeoMechCase( RimGeoMechCase* geomCase );
RimGeoMechCase* geoMechCase() const;
RigGeoMechCaseData* ownerCaseData() const; RigGeoMechCaseData* ownerCaseData() const;
bool hasResult(); bool hasResult();

View File

@ -832,33 +832,6 @@ void RimGeoMechView::calculateCurrentTotalCellVisibility( cvf::UByteArray* total
m_vizLogic->calculateCurrentTotalCellVisibility( totalVisibility, timeStep ); m_vizLogic->calculateCurrentTotalCellVisibility( totalVisibility, timeStep );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::onCreatePartCollectionFromSelection( cvf::Collection<cvf::Part>* parts )
{
Riu3dSelectionManager* riuSelManager = Riu3dSelectionManager::instance();
std::vector<RiuSelectionItem*> 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<RiuGeoMechSelectionItem*>( 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<cvf::Part> part = partGen.createPart( geomSelItem->m_color );
part->setTransform( this->scaleTransform() );
parts->push_back( part.p() );
}
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -111,7 +111,6 @@ protected:
const QVariant& newValue ) override; const QVariant& newValue ) override;
void initAfterRead() override; void initAfterRead() override;
void onCreatePartCollectionFromSelection( cvf::Collection<cvf::Part>* parts ) override;
void onCreateDisplayModel() override; void onCreateDisplayModel() override;
RimPropertyFilterCollection* nativePropertyFilterCollection(); RimPropertyFilterCollection* nativePropertyFilterCollection();

View File

@ -124,10 +124,10 @@ void RimGridTimeHistoryCurve::setFromSelectionItem( const RiuSelectionItem* sele
geomSelectionItem->setFromSelectionItem( eclSelectionItem ); geomSelectionItem->setFromSelectionItem( eclSelectionItem );
if ( eclSelectionItem->m_view ) if ( eclSelectionItem->m_resultDefinition )
{ {
m_eclipseResultDefinition = new RimEclipseResultDefinition; 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 ); geomSelectionItem->setFromSelectionItem( geoMechSelectionItem );
if ( geoMechSelectionItem->m_view ) if ( geoMechSelectionItem->m_resultDefinition )
{ {
m_geoMechResultDefinition = new RimGeoMechResultDefinition; m_geoMechResultDefinition = new RimGeoMechResultDefinition;
m_geoMechResultDefinition->setGeoMechCase( geoMechSelectionItem->m_view->geoMechCase() ); m_geoMechResultDefinition->setGeoMechCase( geoMechSelectionItem->m_resultDefinition->geoMechCase() );
m_geoMechResultDefinition->setResultAddress( m_geoMechResultDefinition->setResultAddress( geoMechSelectionItem->m_resultDefinition->resultAddress() );
geoMechSelectionItem->m_view->cellResultResultDefinition()->resultAddress() );
} }
} }

View File

@ -23,6 +23,9 @@
#include "Rim3dOverlayInfoConfig.h" #include "Rim3dOverlayInfoConfig.h"
#include "RimAnnotationInViewCollection.h" #include "RimAnnotationInViewCollection.h"
#include "RimCellRangeFilterCollection.h" #include "RimCellRangeFilterCollection.h"
#include "RimEclipseCase.h"
#include "RimEclipseResultDefinition.h"
#include "RimGeoMechResultDefinition.h"
#include "RimGridCollection.h" #include "RimGridCollection.h"
#include "RimIntersectionCollection.h" #include "RimIntersectionCollection.h"
#include "RimIntersectionResultsDefinitionCollection.h" #include "RimIntersectionResultsDefinitionCollection.h"
@ -36,9 +39,13 @@
#include "RimWellMeasurementInViewCollection.h" #include "RimWellMeasurementInViewCollection.h"
#include "Riu3DMainWindowTools.h" #include "Riu3DMainWindowTools.h"
#include "Riu3dSelectionManager.h"
#include "RiuMainWindow.h" #include "RiuMainWindow.h"
#include "RivSingleCellPartGenerator.h"
#include "cvfModel.h" #include "cvfModel.h"
#include "cvfPart.h"
#include "cvfScene.h" #include "cvfScene.h"
#include <set> #include <set>
@ -419,6 +426,59 @@ void RimGridView::initAfterRead()
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridView::onCreatePartCollectionFromSelection( cvf::Collection<cvf::Part>* parts )
{
Riu3dSelectionManager* riuSelManager = Riu3dSelectionManager::instance();
std::vector<RiuSelectionItem*> 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<RiuGeoMechSelectionItem*>( 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<cvf::Part> 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<RiuEclipseSelectionItem*>( 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<cvf::Part> part = partGen.createPart( eclipseSelItem->m_color );
part->setTransform( this->scaleTransform() );
parts->push_back( part.p() );
}
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -84,7 +84,8 @@ protected:
const QVariant& newValue ) override; const QVariant& newValue ) override;
void initAfterRead() override; void initAfterRead() override;
protected: // Fields protected:
// Fields
caf::PdmChildField<RimIntersectionCollection*> m_intersectionCollection; caf::PdmChildField<RimIntersectionCollection*> m_intersectionCollection;
caf::PdmChildField<RimIntersectionResultsDefinitionCollection*> m_intersectionResultDefCollection; caf::PdmChildField<RimIntersectionResultsDefinitionCollection*> m_intersectionResultDefCollection;
@ -97,6 +98,8 @@ protected: // Fields
caf::PdmChildField<RimWellMeasurementInViewCollection*> m_wellMeasurementCollection; caf::PdmChildField<RimWellMeasurementInViewCollection*> m_wellMeasurementCollection;
private: private:
void onCreatePartCollectionFromSelection( cvf::Collection<cvf::Part>* parts ) override;
cvf::ref<cvf::UByteArray> m_currentReservoirCellVisibility; cvf::ref<cvf::UByteArray> m_currentReservoirCellVisibility;
RimViewLinker* viewLinkerIfMasterView() const; RimViewLinker* viewLinkerIfMasterView() const;
bool m_previousGridModeMeshLinesWasFaults; bool m_previousGridModeMeshLinesWasFaults;

View File

@ -50,6 +50,7 @@
#include <QTcpSocket> #include <QTcpSocket>
#include "RimGeoMechResultDefinition.h"
#include <array> #include <array>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -639,27 +640,33 @@ public:
size_t gridIndex; size_t gridIndex;
int caseId; int caseId;
bool validIndex = true; bool validIndex = true;
if ( item->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT ) if ( item->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT )
{ {
const RiuEclipseSelectionItem* eclipseItem = static_cast<const RiuEclipseSelectionItem*>( item ); const RiuEclipseSelectionItem* eclipseItem = static_cast<const RiuEclipseSelectionItem*>( item );
eclipseItem->m_view->eclipseCase() eclipseItem->m_resultDefinition->eclipseCase()
->eclipseCaseData() ->eclipseCaseData()
->grid( eclipseItem->m_gridIndex ) ->grid( eclipseItem->m_gridIndex )
->ijkFromCellIndex( eclipseItem->m_gridLocalCellIndex, &i, &j, &k ); ->ijkFromCellIndex( eclipseItem->m_gridLocalCellIndex, &i, &j, &k );
gridIndex = eclipseItem->m_gridIndex; gridIndex = eclipseItem->m_gridIndex;
caseId = eclipseItem->m_view->eclipseCase()->caseId; caseId = eclipseItem->m_resultDefinition->eclipseCase()->caseId;
} }
else if ( item->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT ) else if ( item->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT )
{ {
const RiuGeoMechSelectionItem* geomechItem = static_cast<const RiuGeoMechSelectionItem*>( item ); const RiuGeoMechSelectionItem* geomechItem = static_cast<const RiuGeoMechSelectionItem*>( item );
validIndex = geomechItem->m_view->femParts()
validIndex = geomechItem->m_resultDefinition->ownerCaseData()
->femParts()
->part( geomechItem->m_gridIndex ) ->part( geomechItem->m_gridIndex )
->getOrCreateStructGrid() ->getOrCreateStructGrid()
->ijkFromCellIndex( geomechItem->m_cellIndex, &i, &j, &k ); ->ijkFromCellIndex( geomechItem->m_cellIndex, &i, &j, &k );
CVF_ASSERT( validIndex ); CVF_ASSERT( validIndex );
gridIndex = geomechItem->m_gridIndex; gridIndex = geomechItem->m_gridIndex;
caseId = geomechItem->m_view->geoMechCase()->caseId; caseId = geomechItem->m_resultDefinition->geoMechCase()->caseId;
} }
else else
{ {

View File

@ -43,6 +43,7 @@
#include "RimIntersectionCollection.h" #include "RimIntersectionCollection.h"
#include "RimReservoirCellResultsStorage.h" #include "RimReservoirCellResultsStorage.h"
#include "RimGeoMechResultDefinition.h"
#include "Riu3dSelectionManager.h" #include "Riu3dSelectionManager.h"
#include "RiuMainWindow.h" #include "RiuMainWindow.h"
#include "RiuProcessMonitor.h" #include "RiuProcessMonitor.h"
@ -1397,7 +1398,7 @@ public:
{ {
const RiuEclipseSelectionItem* eclipseItem = static_cast<const RiuEclipseSelectionItem*>( item ); const RiuEclipseSelectionItem* eclipseItem = static_cast<const RiuEclipseSelectionItem*>( item );
if ( eclipseItem->m_view->eclipseCase()->caseId == reservoirCase->caseId ) if ( eclipseItem->m_resultDefinition->eclipseCase()->caseId == reservoirCase->caseId )
{ {
selectedCells.push_back( selectedCells.push_back(
std::make_pair( eclipseItem->m_gridIndex, eclipseItem->m_gridLocalCellIndex ) ); std::make_pair( eclipseItem->m_gridIndex, eclipseItem->m_gridLocalCellIndex ) );
@ -1407,7 +1408,7 @@ public:
{ {
const RiuGeoMechSelectionItem* geomechItem = static_cast<const RiuGeoMechSelectionItem*>( item ); const RiuGeoMechSelectionItem* geomechItem = static_cast<const RiuGeoMechSelectionItem*>( 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 ) ); selectedCells.push_back( std::make_pair( geomechItem->m_gridIndex, geomechItem->m_cellIndex ) );
} }

View File

@ -48,6 +48,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h
${CMAKE_CURRENT_LIST_DIR}/RiuViewer.h ${CMAKE_CURRENT_LIST_DIR}/RiuViewer.h
${CMAKE_CURRENT_LIST_DIR}/RiuViewerToViewInterface.h ${CMAKE_CURRENT_LIST_DIR}/RiuViewerToViewInterface.h
${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.h ${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.h
${CMAKE_CURRENT_LIST_DIR}/RiuCellAndNncPickEventHandler.h
${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.h ${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.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}/RiuTreeViewEventFilter.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuViewer.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuViewer.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuCellAndNncPickEventHandler.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.cpp

View File

@ -20,7 +20,9 @@
#include "Riu3dSelectionManager.h" #include "Riu3dSelectionManager.h"
#include "Rim2dIntersectionView.h" #include "Rim2dIntersectionView.h"
#include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "RimGeoMechResultDefinition.h"
#include "RimGeoMechView.h" #include "RimGeoMechView.h"
#include "RimGridView.h" #include "RimGridView.h"
#include "RimSimWellInView.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 gridIndex,
size_t cellIndex, size_t cellIndex,
size_t nncIndex, size_t nncIndex,
@ -163,6 +167,8 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimEclipseView*
cvf::StructGridInterface::FaceType face, cvf::StructGridInterface::FaceType face,
const cvf::Vec3d& localIntersectionPointInDisplay ) const cvf::Vec3d& localIntersectionPointInDisplay )
: m_view( view ) : m_view( view )
, m_resultDefinition( resultDefinition )
, m_timestepIdx( timestepIdx )
, m_gridIndex( gridIndex ) , m_gridIndex( gridIndex )
, m_gridLocalCellIndex( cellIndex ) , m_gridLocalCellIndex( cellIndex )
, m_nncIndex( nncIndex ) , m_nncIndex( nncIndex )
@ -175,13 +181,17 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimEclipseView*
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* view, RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGridView* view,
size_t gridIndex, RimGeoMechResultDefinition* resultDefinition,
size_t cellIndex, size_t timestepIdx,
cvf::Color3f color, size_t gridIndex,
int elementFace, size_t cellIndex,
const cvf::Vec3d& localIntersectionPointInDisplay ) cvf::Color3f color,
int elementFace,
const cvf::Vec3d& localIntersectionPointInDisplay )
: m_view( view ) : m_view( view )
, m_resultDefinition( resultDefinition )
, m_timestepIdx( timestepIdx )
, m_gridIndex( gridIndex ) , m_gridIndex( gridIndex )
, m_cellIndex( cellIndex ) , m_cellIndex( cellIndex )
, m_color( color ) , 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 gridIndex,
size_t cellIndex, size_t cellIndex,
cvf::Color3f color, cvf::Color3f color,
@ -202,6 +214,8 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView*
const cvf::Vec3d& localIntersectionPointInDisplay, const cvf::Vec3d& localIntersectionPointInDisplay,
const std::array<cvf::Vec3f, 3>& intersectionTriangle ) const std::array<cvf::Vec3f, 3>& intersectionTriangle )
: m_view( view ) : m_view( view )
, m_resultDefinition( resultDefinition )
, m_timestepIdx( timestepIdx )
, m_gridIndex( gridIndex ) , m_gridIndex( gridIndex )
, m_cellIndex( cellIndex ) , m_cellIndex( cellIndex )
, m_color( color ) , m_color( color )

View File

@ -42,6 +42,8 @@ class RiuSelectionChangedHandler;
class RiuSelectionItem; class RiuSelectionItem;
class RivSimWellPipeSourceInfo; class RivSimWellPipeSourceInfo;
class RivWellPathSourceInfo; class RivWellPathSourceInfo;
class RimEclipseResultDefinition;
class RimGeoMechResultDefinition;
//================================================================================================== //==================================================================================================
// //
@ -130,7 +132,9 @@ public:
class RiuEclipseSelectionItem : public RiuSelectionItem class RiuEclipseSelectionItem : public RiuSelectionItem
{ {
public: public:
explicit RiuEclipseSelectionItem( RimEclipseView* view, explicit RiuEclipseSelectionItem( RimGridView* view,
RimEclipseResultDefinition* resultDefinition,
size_t timestepIdx,
size_t gridIndex, size_t gridIndex,
size_t cellIndex, size_t cellIndex,
size_t nncIndex, size_t nncIndex,
@ -146,13 +150,15 @@ public:
} }
public: public:
caf::PdmPointer<RimEclipseView> m_view; caf::PdmPointer<RimGridView> m_view;
size_t m_gridIndex; caf::PdmPointer<RimEclipseResultDefinition> m_resultDefinition;
size_t m_gridLocalCellIndex; size_t m_timestepIdx;
size_t m_nncIndex; size_t m_gridIndex;
cvf::Color3f m_color; size_t m_gridLocalCellIndex;
cvf::StructGridInterface::FaceType m_face; size_t m_nncIndex;
cvf::Vec3d m_localIntersectionPointInDisplay; cvf::Color3f m_color;
cvf::StructGridInterface::FaceType m_face;
cvf::Vec3d m_localIntersectionPointInDisplay;
}; };
//================================================================================================== //==================================================================================================
@ -163,14 +169,18 @@ public:
class RiuGeoMechSelectionItem : public RiuSelectionItem class RiuGeoMechSelectionItem : public RiuSelectionItem
{ {
public: public:
explicit RiuGeoMechSelectionItem( RimGeoMechView* view, explicit RiuGeoMechSelectionItem( RimGridView* view,
size_t gridIndex, RimGeoMechResultDefinition* resultDefinition,
size_t cellIndex, size_t timestepIdx,
cvf::Color3f color, size_t gridIndex,
int elementFace, size_t cellIndex,
const cvf::Vec3d& localIntersectionPointInDisplay ); 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 gridIndex,
size_t cellIndex, size_t cellIndex,
cvf::Color3f color, cvf::Color3f color,
@ -185,14 +195,16 @@ public:
} }
public: public:
caf::PdmPointer<RimGeoMechView> m_view; caf::PdmPointer<RimGridView> m_view;
size_t m_gridIndex; caf::PdmPointer<RimGeoMechResultDefinition> m_resultDefinition;
size_t m_cellIndex; size_t m_timestepIdx;
cvf::Color3f m_color; size_t m_gridIndex;
int m_elementFace; size_t m_cellIndex;
bool m_hasIntersectionTriangle; cvf::Color3f m_color;
std::array<cvf::Vec3f, 3> m_intersectionTriangle; int m_elementFace;
cvf::Vec3d m_localIntersectionPointInDisplay; bool m_hasIntersectionTriangle;
std::array<cvf::Vec3f, 3> m_intersectionTriangle;
cvf::Vec3d m_localIntersectionPointInDisplay;
}; };
//================================================================================================== //==================================================================================================

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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 <array>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuCellAndNncPickEventHandler* RiuCellAndNncPickEventHandler::instance()
{
static RiuCellAndNncPickEventHandler* singleton = new RiuCellAndNncPickEventHandler;
return singleton;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eventObject )
{
const std::vector<RiuPickItemInfo>& 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<const RivSourceInfo*>( 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<cvf::Vec3f, 3> intersectionTriangleHit;
RimGeoMechResultDefinition* geomResDef = nullptr;
RimEclipseResultDefinition* eclResDef = nullptr;
size_t timestepIndex = -1;
// clang-format off
if ( const RivSourceInfo* rivSourceInfo =
dynamic_cast<const RivSourceInfo*>( 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<const RivFemPickSourceInfo*>( firstHitPart->sourceInfo() ) )
{
gridIndex = femSourceInfo->femPartIndex();
cellIndex = femSourceInfo->triangleToElmMapper()->elementIndex( firstPartTriangleIndex );
gmFace = femSourceInfo->triangleToElmMapper()->elementFace( firstPartTriangleIndex );
}
else if ( const RivExtrudedCurveIntersectionSourceInfo* intersectionSourceInfo =
dynamic_cast<const RivExtrudedCurveIntersectionSourceInfo*>( 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<const RivBoxIntersectionSourceInfo*>( 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<RiuSelectionItem*> 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<Rim2dIntersectionView*>( mainOrComparisonView );
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>( mainOrComparisonView );
RimGridView* associatedGridView = dynamic_cast<RimGridView*>( 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;
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicPickEventHandler.h"
//==================================================================================================
///
//==================================================================================================
class RiuCellAndNncPickEventHandler : public RicDefaultPickEventHandler
{
public:
static RiuCellAndNncPickEventHandler* instance();
protected:
bool handle3dPickEvent( const Ric3dPickEvent& eventObject ) override;
};

View File

@ -41,18 +41,18 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuFemResultTextBuilder::RiuFemResultTextBuilder( RimGeoMechView* reservoirView, RiuFemResultTextBuilder::RiuFemResultTextBuilder( RimGridView* displayCoordView,
int gridIndex, RimGeoMechResultDefinition* geomResDef,
int cellIndex, int gridIndex,
int timeStepIndex ) int cellIndex,
int timeStepIndex )
: m_isIntersectionTriangleSet( false ) : m_isIntersectionTriangleSet( false )
{ {
CVF_ASSERT( reservoirView ); m_displayCoordView = displayCoordView;
m_geomResDef = geomResDef;
m_reservoirView = reservoirView; m_gridIndex = gridIndex;
m_gridIndex = gridIndex; m_cellIndex = cellIndex;
m_cellIndex = cellIndex; m_timeStepIndex = timeStepIndex;
m_timeStepIndex = timeStepIndex;
m_intersectionPointInDisplay = cvf::Vec3d::UNDEFINED; m_intersectionPointInDisplay = cvf::Vec3d::UNDEFINED;
m_face = cvf::StructGridInterface::NO_FACE; m_face = cvf::StructGridInterface::NO_FACE;
@ -98,9 +98,7 @@ QString RiuFemResultTextBuilder::mainResultText()
{ {
QString text; QString text;
RimGeoMechResultDefinition* cellResultDefinition = m_reservoirView->cellResultResultDefinition(); text = closestNodeResultText( m_geomResDef );
text = closestNodeResultText( cellResultDefinition );
if ( !text.isEmpty() ) text += "\n"; if ( !text.isEmpty() ) text += "\n";
@ -109,7 +107,7 @@ QString RiuFemResultTextBuilder::mainResultText()
appendDetails( text, formationDetails() ); appendDetails( text, formationDetails() );
text += "\n"; text += "\n";
if ( cellResultDefinition->resultPositionType() != RIG_ELEMENT ) if ( m_geomResDef->resultPositionType() != RIG_ELEMENT )
{ {
appendDetails( text, gridResultDetails() ); appendDetails( text, gridResultDetails() );
} }
@ -124,9 +122,9 @@ QString RiuFemResultTextBuilder::geometrySelectionText( QString itemSeparator )
{ {
QString text; QString text;
if ( m_reservoirView->geoMechCase() ) if ( m_geomResDef->geoMechCase() )
{ {
RigGeoMechCaseData* geomData = m_reservoirView->geoMechCase()->geoMechData(); RigGeoMechCaseData* geomData = m_geomResDef->geoMechCase()->geoMechData();
if ( geomData ) if ( geomData )
{ {
RigFemPart* femPart = geomData->femParts()->part( m_gridIndex ); RigFemPart* femPart = geomData->femParts()->part( m_gridIndex );
@ -167,14 +165,17 @@ QString RiuFemResultTextBuilder::geometrySelectionText( QString itemSeparator )
} }
else else
{ {
cvf::ref<caf::DisplayCoordTransform> transForm = m_reservoirView->displayCoordTransform(); if ( m_displayCoordView )
cvf::Vec3d domainCoord = transForm->translateToDomainCoord( m_intersectionPointInDisplay ); {
cvf::ref<caf::DisplayCoordTransform> transForm = m_displayCoordView->displayCoordTransform();
cvf::Vec3d domainCoord = transForm->translateToDomainCoord( m_intersectionPointInDisplay );
formattedText.sprintf( "Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", formattedText.sprintf( "Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]",
domainCoord.x(), domainCoord.x(),
domainCoord.y(), domainCoord.y(),
-domainCoord.z() ); -domainCoord.z() );
text += formattedText; text += formattedText;
}
} }
} }
} }
@ -190,16 +191,11 @@ QString RiuFemResultTextBuilder::gridResultDetails()
{ {
QString text; 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, this->appendTextFromResultColors( eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_geomResDef, &text );
m_gridIndex,
m_cellIndex,
m_timeStepIndex,
m_reservoirView->cellResultResultDefinition(),
&text );
if ( !text.isEmpty() ) if ( !text.isEmpty() )
{ {
@ -216,7 +212,7 @@ QString RiuFemResultTextBuilder::gridResultDetails()
QString RiuFemResultTextBuilder::formationDetails() QString RiuFemResultTextBuilder::formationDetails()
{ {
QString text; QString text;
RimCase* rimCase = m_reservoirView->ownerCase(); RimCase* rimCase = m_geomResDef->geoMechCase();
if ( rimCase ) if ( rimCase )
{ {
if ( rimCase->activeFormationNames() && rimCase->activeFormationNames()->formationNamesData() ) if ( rimCase->activeFormationNames() && rimCase->activeFormationNames()->formationNamesData() )
@ -225,9 +221,9 @@ QString RiuFemResultTextBuilder::formationDetails()
size_t k = cvf::UNDEFINED_SIZE_T; 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 ) if ( geomData )
{ {
size_t i = 0; size_t i = 0;
@ -394,29 +390,31 @@ QString RiuFemResultTextBuilder::closestNodeResultText( RimGeoMechResultDefiniti
if ( resultColors->hasResult() ) 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<float>& scalarResults = geomData->femPartResults()->resultValues( resultColors->resultAddress(), const std::vector<float>& scalarResults = geomData->femPartResults()->resultValues( resultColors->resultAddress(),
m_gridIndex, m_gridIndex,
m_timeStepIndex ); m_timeStepIndex );
if ( scalarResults.size() ) if ( scalarResults.size() && m_displayCoordView )
{ {
RigFemPart* femPart = geomData->femParts()->part( m_gridIndex ); RigFemPart* femPart = geomData->femParts()->part( m_gridIndex );
RigFemResultPosEnum activeResultPosition = resultColors->resultPositionType(); RigFemResultPosEnum activeResultPosition = resultColors->resultPositionType();
cvf::Vec3d intersectionPointInDomain = m_reservoirView->displayCoordTransform()->translateToDomainCoord( cvf::Vec3d intersectionPointInDomain = m_displayCoordView->displayCoordTransform()->translateToDomainCoord(
m_intersectionPointInDisplay ); m_intersectionPointInDisplay );
RigFemClosestResultIndexCalculator closestIndexCalc( femPart, RigFemClosestResultIndexCalculator closestIndexCalc( femPart,
activeResultPosition, activeResultPosition,
m_cellIndex, m_cellIndex,
m_face, m_face,
intersectionPointInDomain ); intersectionPointInDomain );
int resultIndex = closestIndexCalc.resultIndexToClosestResult();
int closestNodeId = closestIndexCalc.closestNodeId(); int resultIndex = closestIndexCalc.resultIndexToClosestResult();
int closestElmNodResIdx = closestIndexCalc.closestElementNodeResIdx(); int closestNodeId = closestIndexCalc.closestNodeId();
int closestElmNodResIdx = closestIndexCalc.closestElementNodeResIdx();
float scalarValue = ( resultIndex >= 0 ) ? scalarResults[resultIndex] float scalarValue = ( resultIndex >= 0 ) ? scalarResults[resultIndex]
: std::numeric_limits<float>::infinity(); : std::numeric_limits<float>::infinity();

View File

@ -30,6 +30,7 @@ class RimEclipseCellColors;
class RimGeoMechResultDefinition; class RimGeoMechResultDefinition;
class RimGeoMechView; class RimGeoMechView;
class Rim2dIntersectionView; class Rim2dIntersectionView;
class RimGridView;
namespace cvf namespace cvf
{ {
@ -43,7 +44,11 @@ class Part;
class RiuFemResultTextBuilder class RiuFemResultTextBuilder
{ {
public: 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 setFace( int face );
void setIntersectionPointInDisplay( cvf::Vec3d intersectionPointInDisplay ); void setIntersectionPointInDisplay( cvf::Vec3d intersectionPointInDisplay );
void setIntersectionTriangle( const std::array<cvf::Vec3f, 3>& triangle ); void setIntersectionTriangle( const std::array<cvf::Vec3f, 3>& triangle );
@ -69,8 +74,9 @@ private:
QString* resultInfoText ); QString* resultInfoText );
private: private:
caf::PdmPointer<RimGeoMechView> m_reservoirView; caf::PdmPointer<RimGridView> m_displayCoordView;
caf::PdmPointer<Rim2dIntersectionView> m_2dIntersectionView; caf::PdmPointer<RimGeoMechResultDefinition> m_geomResDef;
caf::PdmPointer<Rim2dIntersectionView> m_2dIntersectionView;
int m_gridIndex; int m_gridIndex;
int m_cellIndex; int m_cellIndex;

View File

@ -30,6 +30,7 @@
#include "RigFemResultPosEnum.h" #include "RigFemResultPosEnum.h"
#include "RigGeoMechCaseData.h" #include "RigGeoMechCaseData.h"
#include "Rim2dIntersectionView.h"
#include "RimGeoMechCase.h" #include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h" #include "RimGeoMechCellColors.h"
#include "RimGeoMechResultDefinition.h" #include "RimGeoMechResultDefinition.h"
@ -63,7 +64,7 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuMohrsCirclePlot::RiuMohrsCirclePlot( QWidget* parent ) RiuMohrsCirclePlot::RiuMohrsCirclePlot( QWidget* parent )
: RiuDockedQwtPlot( parent ) : RiuDockedQwtPlot( parent )
, m_sourceGeoMechViewOfLastPlot( nullptr ) , m_viewToFollowAnimationFrom( nullptr )
, m_scheduleUpdateAxisScaleTimer( nullptr ) , m_scheduleUpdateAxisScaleTimer( nullptr )
{ {
RiuQwtPlotTools::setCommonPlotBehaviour( this ); RiuQwtPlotTools::setCommonPlotBehaviour( this );
@ -99,25 +100,30 @@ RiuMohrsCirclePlot::~RiuMohrsCirclePlot()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::appendSelection( const RiuSelectionItem* selectionItem ) void RiuMohrsCirclePlot::appendSelection( const RiuSelectionItem* selectionItem )
{ {
m_viewToFollowAnimationFrom = nullptr;
if ( this->isVisible() ) if ( this->isVisible() )
{ {
m_sourceGeoMechViewOfLastPlot = nullptr; Rim3dView* newFollowAnimView = nullptr;
RiuGeoMechSelectionItem* geoMechSelectionItem = nullptr;
geoMechSelectionItem = extractGeoMechSelectionItem( selectionItem, newFollowAnimView );
const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast<const RiuGeoMechSelectionItem*>(
selectionItem );
if ( geoMechSelectionItem ) if ( geoMechSelectionItem )
{ {
RimGeoMechView* geoMechView = geoMechSelectionItem->m_view;
CVF_ASSERT( geoMechView );
const size_t gridIndex = geoMechSelectionItem->m_gridIndex; const size_t gridIndex = geoMechSelectionItem->m_gridIndex;
const size_t cellIndex = geoMechSelectionItem->m_cellIndex; const size_t cellIndex = geoMechSelectionItem->m_cellIndex;
const cvf::Color3f color = geoMechSelectionItem->m_color; 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(); updatePlot();
m_sourceGeoMechViewOfLastPlot = geoMechView; m_viewToFollowAnimationFrom = geoMechSelectionItem->m_view;
} }
} }
else else
@ -133,7 +139,7 @@ void RiuMohrsCirclePlot::clearPlot()
{ {
deletePlotItems(); deletePlotItems();
m_sourceGeoMechViewOfLastPlot = nullptr; m_viewToFollowAnimationFrom = nullptr;
this->replot(); this->replot();
} }
@ -148,9 +154,10 @@ void RiuMohrsCirclePlot::updateOnTimeStepChanged( Rim3dView* changedView )
return; 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 // Don't update the plot if the view that changed time step is different
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>( changedView ); // from the view that was the source of the current plot
if ( !geoMechView || geoMechView != m_sourceGeoMechViewOfLastPlot )
if ( changedView != m_viewToFollowAnimationFrom )
{ {
return; return;
} }
@ -160,7 +167,11 @@ void RiuMohrsCirclePlot::updateOnTimeStepChanged( Rim3dView* changedView )
for ( const MohrsCirclesInfo& mohrInfo : mohrsCiclesInfosCopy ) 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(); 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; 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 cohesion = geomCase->cohesion();
double frictionAngle = view->geoMechCase()->frictionAngleDeg(); double frictionAngle = geomCase->frictionAngleDeg();
if ( cohesion == HUGE_VAL || frictionAngle == HUGE_VAL || frictionAngle >= 90 ) 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] ); yVals[1] = ( cohesion / x ) * ( x + principals[0] );
// If envelope for the view already exists, check if a "larger" envelope should be created // 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; return;
} }
else else
{ {
m_envolopePlotItems[view]->detach(); m_envolopePlotItems[geomCase]->detach();
delete m_envolopePlotItems[view]; delete m_envolopePlotItems[geomCase];
m_envolopePlotItems.erase( view ); m_envolopePlotItems.erase( geomCase );
} }
} }
@ -315,17 +326,17 @@ void RiuMohrsCirclePlot::addEnvelopeCurve( const cvf::Vec3f& principals, RimGeoM
qwtCurve->setStyle( QwtPlotCurve::Lines ); qwtCurve->setStyle( QwtPlotCurve::Lines );
qwtCurve->setRenderHint( QwtPlotItem::RenderAntialiased, true ); qwtCurve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
const QPen curvePen( envelopeColor( view ) ); const QPen curvePen( envelopeColor( geomCase ) );
qwtCurve->setPen( curvePen ); qwtCurve->setPen( curvePen );
qwtCurve->setTitle( QString( "<b>Envelope for %1</b>, (<b>S<sub>0</sub></b>: %2, <b>&Phi;</b>: %3)" ) qwtCurve->setTitle( QString( "<b>Envelope for %1</b>, (<b>S<sub>0</sub></b>: %2, <b>&Phi;</b>: %3)" )
.arg( view->geoMechCase()->caseUserDescription ) .arg( geomCase->caseUserDescription() )
.arg( cohesion ) .arg( cohesion )
.arg( frictionAngle ) ); .arg( frictionAngle ) );
qwtCurve->attach( this ); 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() void RiuMohrsCirclePlot::deleteEnvelopes()
{ {
for ( const std::pair<RimGeoMechView*, QwtPlotCurve*>& envelope : m_envolopePlotItems ) for ( const std::pair<const RimGeoMechCase*, QwtPlotCurve*>& envelope : m_envolopePlotItems )
{ {
envelope.second->detach(); envelope.second->detach();
delete envelope.second; delete envelope.second;
@ -345,26 +356,26 @@ void RiuMohrsCirclePlot::deleteEnvelopes()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMohrsCirclePlot::queryData( RimGeoMechView* geoMechView, bool RiuMohrsCirclePlot::addOrUpdateCurves( const RimGeoMechResultDefinition* geomResDef,
size_t gridIndex, size_t timeStepIndex,
size_t elmIndex, size_t gridIndex,
const cvf::Color3ub& color ) size_t elmIndex,
const cvf::Color3ub& color )
{ {
CVF_ASSERT( geoMechView ); RigFemPart* femPart = geomResDef->ownerCaseData()->femParts()->part( gridIndex );
m_sourceGeoMechViewOfLastPlot = geoMechView;
RigFemPart* femPart = geoMechView->femParts()->part( gridIndex ); if ( femPart->elementType( elmIndex ) != HEX8P ) return false;
if ( femPart->elementType( elmIndex ) != HEX8P ) return;
int frameIdx = geoMechView->currentTimeStep(); RigFemPartResultsCollection* resultCollection = geomResDef->geoMechCase()->geoMechData()->femPartResults();
RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults();
RigFemResultAddress address( RigFemResultPosEnum::RIG_ELEMENT_NODAL, "SE", "" ); RigFemResultAddress address( RigFemResultPosEnum::RIG_ELEMENT_NODAL, "SE", "" );
// TODO: All tensors are calculated every time this function is called. FIX // TODO: All tensors are calculated every time this function is called. FIX
std::vector<caf::Ten3f> vertexTensors = resultCollection->tensors( address, 0, frameIdx );
std::vector<caf::Ten3f> vertexTensors = resultCollection->tensors( address, 0, (int)timeStepIndex );
if ( vertexTensors.empty() ) if ( vertexTensors.empty() )
{ {
return; return false;
} }
// Calculate average tensor in element // Calculate average tensor in element
@ -379,11 +390,11 @@ void RiuMohrsCirclePlot::queryData( RimGeoMechView* geoMechView,
if ( !isValidPrincipals( principals ) ) if ( !isValidPrincipals( principals ) )
{ {
return; return false;
} }
double cohesion = geoMechView->geoMechCase()->cohesion(); double cohesion = geomResDef->geoMechCase()->cohesion();
double frictionAngleDeg = geoMechView->geoMechCase()->frictionAngleDeg(); double frictionAngleDeg = geomResDef->geoMechCase()->frictionAngleDeg();
size_t i, j, k; size_t i, j, k;
bool validIndex = femPart->getOrCreateStructGrid()->ijkFromCellIndex( elmIndex, &i, &j, &k ); bool validIndex = femPart->getOrCreateStructGrid()->ijkFromCellIndex( elmIndex, &i, &j, &k );
@ -397,12 +408,20 @@ void RiuMohrsCirclePlot::queryData( RimGeoMechView* geoMechView,
i, i,
j, j,
k, k,
geoMechView, geomResDef,
calculateFOS( principals, frictionAngleDeg, cohesion ), calculateFOS( principals, frictionAngleDeg, cohesion ),
color ); 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(); 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 /// 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( cvf::Color3ub cvfColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3ub(
m_envolopeColors.size() ); m_envolopeColors.size() );
QColor color( cvfColor.r(), cvfColor.g(), cvfColor.b() ); 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; *yMax = -HUGE_VAL;
double maxYEnvelope = -HUGE_VAL; double maxYEnvelope = -HUGE_VAL;
for ( const std::pair<RimGeoMechView*, QwtPlotCurve*>& envelope : m_envolopePlotItems ) for ( const std::pair<const RimGeoMechCase*, QwtPlotCurve*>& envelope : m_envolopePlotItems )
{ {
double tempMax = envelope.second->maxYValue(); double tempMax = envelope.second->maxYValue();
if ( tempMax > maxYEnvelope ) if ( tempMax > maxYEnvelope )
@ -647,7 +654,7 @@ void RiuMohrsCirclePlot::idealAxesEndPoints( double* xMin, double* xMax, double*
*yMax = std::max( maxYEnvelope, 1.2 * largestCircleRadiusInPlot() ); *yMax = std::max( maxYEnvelope, 1.2 * largestCircleRadiusInPlot() );
double minXEvelope = HUGE_VAL; double minXEvelope = HUGE_VAL;
for ( const std::pair<RimGeoMechView*, QwtPlotCurve*>& envelope : m_envolopePlotItems ) for ( const std::pair<const RimGeoMechCase*, QwtPlotCurve*>& envelope : m_envolopePlotItems )
{ {
double tempMin = envelope.second->minXValue(); double tempMin = envelope.second->minXValue();
if ( tempMin < minXEvelope ) if ( tempMin < minXEvelope )
@ -712,3 +719,37 @@ void RiuMohrsCirclePlot::setAxesScaleAndReplot()
this->replot(); this->replot();
} }
RiuGeoMechSelectionItem* RiuMohrsCirclePlot::extractGeoMechSelectionItem( const RiuSelectionItem* selectionItem,
Rim3dView*& newFollowAnimView )
{
newFollowAnimView = nullptr;
RiuGeoMechSelectionItem* geoMechSelectionItem = nullptr;
geoMechSelectionItem = dynamic_cast<RiuGeoMechSelectionItem*>( const_cast<RiuSelectionItem*>( 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<RimGeoMechView*>( geoMechSelectionItem->m_view.p() );
if ( clickedInEclView && clickedInEclView->cellResult() == geoMechSelectionItem->m_resultDefinition.p() )
{
newFollowAnimView = geoMechSelectionItem->m_view;
}
}
else
{
auto intersectionSelItem = dynamic_cast<const Riu2dIntersectionSelectionItem*>( selectionItem );
if ( intersectionSelItem && intersectionSelItem->geoMechSelectionItem() )
{
geoMechSelectionItem = intersectionSelItem->geoMechSelectionItem();
newFollowAnimView = intersectionSelItem->view();
}
}
return geoMechSelectionItem;
}

View File

@ -35,6 +35,9 @@ class QWidget;
class Rim3dView; class Rim3dView;
class RimGeoMechView; class RimGeoMechView;
class RiuSelectionItem; class RiuSelectionItem;
class RimGeoMechCase;
class RimGeoMechResultDefinition;
class RiuGeoMechSelectionItem;
//================================================================================================== //==================================================================================================
// //
@ -57,34 +60,34 @@ public:
private: private:
struct MohrsCirclesInfo struct MohrsCirclesInfo
{ {
MohrsCirclesInfo( cvf::Vec3f principals, MohrsCirclesInfo( cvf::Vec3f principals,
size_t gridIndex, size_t gridIndex,
size_t elmIndex, size_t elmIndex,
size_t i, size_t i,
size_t j, size_t j,
size_t k, size_t k,
RimGeoMechView* view, const RimGeoMechResultDefinition* geomResDef,
double factorOfSafety, double factorOfSafety,
cvf::Color3ub color ) cvf::Color3ub color )
: principals( principals ) : principals( principals )
, gridIndex( gridIndex ) , gridIndex( gridIndex )
, elmIndex( elmIndex ) , elmIndex( elmIndex )
, i( i ) , i( i )
, j( j ) , j( j )
, k( k ) , k( k )
, view( view ) , geomResDef( geomResDef )
, factorOfSafety( factorOfSafety ) , factorOfSafety( factorOfSafety )
, color( color ) , color( color )
{ {
} }
cvf::Vec3f principals; cvf::Vec3f principals;
size_t gridIndex; size_t gridIndex;
size_t elmIndex; size_t elmIndex;
size_t i, j, k; size_t i, j, k;
RimGeoMechView* view; const RimGeoMechResultDefinition* geomResDef;
double factorOfSafety; double factorOfSafety;
cvf::Color3ub color; cvf::Color3ub color;
}; };
private: private:
@ -94,33 +97,36 @@ private:
void idealAxesEndPoints( double* xMin, double* xMax, double* yMax ) const; void idealAxesEndPoints( double* xMin, double* xMax, double* yMax ) const;
void addMohrCircles( const MohrsCirclesInfo& mohrsCirclesInfo ); void addOrUpdateMohrCircleCurves( const MohrsCirclesInfo& mohrsCirclesInfo );
void deleteCircles(); void deleteCircles();
void addEnvelopeCurve( const cvf::Vec3f& principals, RimGeoMechView* view ); void addorUpdateEnvelopeCurve( const cvf::Vec3f& principals, const RimGeoMechCase* geomCase );
void deleteEnvelopes(); 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 updatePlot();
void addMohrsCirclesInfo( const MohrsCirclesInfo& mohrsCircleInfo );
void updateTransparentCurvesOnPrincipals(); void updateTransparentCurvesOnPrincipals();
double largestCircleRadiusInPlot() const; double largestCircleRadiusInPlot() const;
double smallestPrincipal() const; double smallestPrincipal() const;
double largestPrincipal() const; double largestPrincipal() const;
static bool isValidPrincipals( const cvf::Vec3f& principals ); QColor envelopeColor( const RimGeoMechCase* geomCase );
static float calculateFOS( const cvf::Vec3f& principals, double frictionAngle, double cohesion );
QColor envelopeColor( RimGeoMechView* view );
void deletePlotItems(); void deletePlotItems();
void scheduleUpdateAxisScale(); 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: private slots:
void setAxesScaleAndReplot(); void setAxesScaleAndReplot();
@ -128,12 +134,12 @@ private:
std::vector<QwtPlotItem*> m_circlePlotItems; std::vector<QwtPlotItem*> m_circlePlotItems;
std::vector<QwtPlotCurve*> m_transparentCurves; std::vector<QwtPlotCurve*> m_transparentCurves;
std::map<RimGeoMechView*, QwtPlotCurve*> m_envolopePlotItems; std::map<const RimGeoMechCase*, QwtPlotCurve*> m_envolopePlotItems;
std::map<RimGeoMechView*, QColor> m_envolopeColors; std::map<const RimGeoMechCase*, QColor> m_envolopeColors;
std::vector<MohrsCirclesInfo> m_mohrsCiclesInfos; std::vector<MohrsCirclesInfo> m_mohrsCiclesInfos;
RimGeoMechView* m_sourceGeoMechViewOfLastPlot; Rim3dView* m_viewToFollowAnimationFrom;
QTimer* m_scheduleUpdateAxisScaleTimer; QTimer* m_scheduleUpdateAxisScaleTimer;
}; };

View File

@ -30,6 +30,7 @@
#include "Rim2dIntersectionView.h" #include "Rim2dIntersectionView.h"
#include "Rim3dView.h" #include "Rim3dView.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseResultCase.h" #include "RimEclipseResultCase.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "RimExtrudedCurveIntersection.h" #include "RimExtrudedCurveIntersection.h"
@ -51,7 +52,7 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuPvtPlotUpdater::RiuPvtPlotUpdater( RiuPvtPlotPanel* targetPlotPanel ) RiuPvtPlotUpdater::RiuPvtPlotUpdater( RiuPvtPlotPanel* targetPlotPanel )
: m_targetPlotPanel( targetPlotPanel ) : m_targetPlotPanel( targetPlotPanel )
, m_sourceEclipseViewOfLastPlot( nullptr ) , m_viewToFollowAnimationFrom( nullptr )
{ {
} }
@ -65,32 +66,26 @@ void RiuPvtPlotUpdater::updateOnSelectionChanged( const RiuSelectionItem* select
return; return;
} }
m_sourceEclipseViewOfLastPlot = nullptr; Rim3dView* newFollowAnimView = nullptr;
bool mustClearPlot = true; RiuEclipseSelectionItem* eclipseSelectionItem = nullptr;
RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast<RiuEclipseSelectionItem*>( eclipseSelectionItem = RiuRelativePermeabilityPlotUpdater::extractEclipseSelectionItem( selectionItem,
const_cast<RiuSelectionItem*>( selectionItem ) ); newFollowAnimView );
RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : nullptr;
if ( !eclipseSelectionItem && !eclipseView ) bool mustClearPlot = true;
m_viewToFollowAnimationFrom = nullptr;
if ( m_targetPlotPanel->isVisible() && eclipseSelectionItem )
{ {
const Riu2dIntersectionSelectionItem* intersectionSelItem = dynamic_cast<const Riu2dIntersectionSelectionItem*>( if ( queryDataAndUpdatePlot( eclipseSelectionItem->m_resultDefinition,
selectionItem ); eclipseSelectionItem->m_timestepIdx,
if ( intersectionSelItem && intersectionSelItem->eclipseSelectionItem() ) eclipseSelectionItem->m_gridIndex,
eclipseSelectionItem->m_gridLocalCellIndex,
m_targetPlotPanel ) )
{ {
eclipseSelectionItem = intersectionSelItem->eclipseSelectionItem(); mustClearPlot = false;
eclipseView = eclipseSelectionItem->m_view;
}
}
if ( m_targetPlotPanel->isVisible() && eclipseSelectionItem && eclipseView ) m_viewToFollowAnimationFrom = newFollowAnimView;
{
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;
} }
} }
@ -110,21 +105,30 @@ void RiuPvtPlotUpdater::updateOnTimeStepChanged( Rim3dView* changedView )
return; 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 // Don't update the plot if the view that changed time step is different
const RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( changedView ); // from the view that was the source of the current plot
if ( !eclipseView || eclipseView != m_sourceEclipseViewOfLastPlot )
if ( changedView != m_viewToFollowAnimationFrom )
{ {
return; return;
} }
// Fetch the current global selection and only continue if the selection's view matches the view with time step change // 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<const RiuEclipseSelectionItem*>(
Riu3dSelectionManager::instance()->selectedItem() ); const RiuSelectionItem* selectionItem = Riu3dSelectionManager::instance()->selectedItem();
if ( eclipseSelectionItem && eclipseSelectionItem->m_view == eclipseView ) Rim3dView* newFollowAnimView = nullptr;
RiuEclipseSelectionItem* eclipseSelectionItem = nullptr;
eclipseSelectionItem = RiuRelativePermeabilityPlotUpdater::extractEclipseSelectionItem( selectionItem,
newFollowAnimView );
if ( eclipseSelectionItem && newFollowAnimView == changedView )
{ {
const size_t gridIndex = eclipseSelectionItem->m_gridIndex; if ( !queryDataAndUpdatePlot( eclipseSelectionItem->m_resultDefinition,
const size_t gridLocalCellIndex = eclipseSelectionItem->m_gridLocalCellIndex; newFollowAnimView->currentTimeStep(),
if ( !queryDataAndUpdatePlot( *eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel ) ) eclipseSelectionItem->m_gridIndex,
eclipseSelectionItem->m_gridLocalCellIndex,
m_targetPlotPanel ) )
{ {
m_targetPlotPanel->clearPlot(); m_targetPlotPanel->clearPlot();
} }
@ -134,14 +138,15 @@ void RiuPvtPlotUpdater::updateOnTimeStepChanged( Rim3dView* changedView )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RiuPvtPlotUpdater::queryDataAndUpdatePlot( const RimEclipseView& eclipseView, bool RiuPvtPlotUpdater::queryDataAndUpdatePlot( const RimEclipseResultDefinition* eclipseResDef,
size_t gridIndex, size_t timeStepIndex,
size_t gridLocalCellIndex, size_t gridIndex,
RiuPvtPlotPanel* plotPanel ) size_t gridLocalCellIndex,
RiuPvtPlotPanel* plotPanel )
{ {
CVF_ASSERT( plotPanel ); CVF_ASSERT( plotPanel );
RimEclipseResultCase* eclipseResultCase = dynamic_cast<RimEclipseResultCase*>( eclipseView.eclipseCase() ); RimEclipseResultCase* eclipseResultCase = dynamic_cast<RimEclipseResultCase*>( eclipseResDef->eclipseCase() );
RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : nullptr; RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : nullptr;
if ( eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface() ) if ( eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface() )
{ {
@ -157,8 +162,6 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot( const RimEclipseView& eclipseVie
eclipseResultCase->flowDiagSolverInterface() eclipseResultCase->flowDiagSolverInterface()
->calculatePvtCurves( RigFlowDiagSolverInterface::PVT_CT_VISCOSITY, activeCellIndex ); ->calculatePvtCurves( RigFlowDiagSolverInterface::PVT_CT_VISCOSITY, activeCellIndex );
const size_t timeStepIndex = static_cast<size_t>( eclipseView.currentTimeStep() );
// The following calls will read results from file in preparation for the queries below // The following calls will read results from file in preparation for the queries below
RigCaseCellResultsData* cellResultsData = eclipseCaseData->results( RiaDefines::MATRIX_MODEL ); RigCaseCellResultsData* cellResultsData = eclipseCaseData->results( RiaDefines::MATRIX_MODEL );
cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "RS" ) ); cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "RS" ) );
@ -220,7 +223,11 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot( const RimEclipseView& eclipseVie
&viscosityDynProps.mu_o, &viscosityDynProps.mu_o,
&viscosityDynProps.mu_g ); &viscosityDynProps.mu_g );
QString cellRefText = constructCellReferenceText( eclipseCaseData, gridIndex, gridLocalCellIndex, cellPVTNUM ); QString cellRefText = RiuRelativePermeabilityPlotUpdater::constructCellReferenceText( eclipseCaseData,
gridIndex,
gridLocalCellIndex,
"PVTNUM",
cellPVTNUM );
plotPanel->setPlotData( eclipseCaseData->unitsType(), plotPanel->setPlotData( eclipseCaseData->unitsType(),
fvfCurveArr, fvfCurveArr,
@ -236,47 +243,3 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot( const RimEclipseView& eclipseVie
return false; 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();
}

View File

@ -26,6 +26,7 @@ class RiuPvtPlotPanel;
class Rim3dView; class Rim3dView;
class RimEclipseView; class RimEclipseView;
class RigEclipseCaseData; class RigEclipseCaseData;
class RimEclipseResultDefinition;
//================================================================================================== //==================================================================================================
// //
@ -41,16 +42,13 @@ public:
void updateOnTimeStepChanged( Rim3dView* changedView ); void updateOnTimeStepChanged( Rim3dView* changedView );
private: private:
static bool queryDataAndUpdatePlot( const RimEclipseView& eclipseView, static bool queryDataAndUpdatePlot( const RimEclipseResultDefinition* eclipseResultDef,
size_t gridIndex, size_t timeStepIndex,
size_t gridLocalCellIndex, size_t gridIndex,
RiuPvtPlotPanel* plotPanel ); size_t gridLocalCellIndex,
static QString constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData, RiuPvtPlotPanel* plotPanel );
size_t gridIndex,
size_t gridLocalCellIndex,
double pvtnum );
private: private:
QPointer<RiuPvtPlotPanel> m_targetPlotPanel; QPointer<RiuPvtPlotPanel> m_targetPlotPanel;
const Rim3dView* m_sourceEclipseViewOfLastPlot; const Rim3dView* m_viewToFollowAnimationFrom;
}; };

View File

@ -29,6 +29,7 @@
#include "Rim2dIntersectionView.h" #include "Rim2dIntersectionView.h"
#include "Rim3dView.h" #include "Rim3dView.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseResultCase.h" #include "RimEclipseResultCase.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
#include "RimExtrudedCurveIntersection.h" #include "RimExtrudedCurveIntersection.h"
@ -50,10 +51,12 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuRelativePermeabilityPlotUpdater::RiuRelativePermeabilityPlotUpdater( RiuRelativePermeabilityPlotPanel* targetPlotPanel ) RiuRelativePermeabilityPlotUpdater::RiuRelativePermeabilityPlotUpdater( RiuRelativePermeabilityPlotPanel* targetPlotPanel )
: m_targetPlotPanel( targetPlotPanel ) : m_targetPlotPanel( targetPlotPanel )
, m_sourceEclipseViewOfLastPlot( nullptr ) , m_viewToFollowAnimationFrom( nullptr )
{ {
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -64,32 +67,25 @@ void RiuRelativePermeabilityPlotUpdater::updateOnSelectionChanged( const RiuSele
return; return;
} }
m_sourceEclipseViewOfLastPlot = nullptr; Rim3dView* newFollowAnimView = nullptr;
bool mustClearPlot = true; RiuEclipseSelectionItem* eclipseSelectionItem = nullptr;
RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast<RiuEclipseSelectionItem*>( eclipseSelectionItem = extractEclipseSelectionItem( selectionItem, newFollowAnimView );
const_cast<RiuSelectionItem*>( selectionItem ) );
RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : nullptr;
if ( !eclipseSelectionItem && !eclipseView ) bool mustClearPlot = true;
m_viewToFollowAnimationFrom = nullptr;
if ( m_targetPlotPanel->isVisible() && eclipseSelectionItem )
{ {
const Riu2dIntersectionSelectionItem* intersectionSelItem = dynamic_cast<const Riu2dIntersectionSelectionItem*>( if ( queryDataAndUpdatePlot( eclipseSelectionItem->m_resultDefinition,
selectionItem ); eclipseSelectionItem->m_timestepIdx,
if ( intersectionSelItem && intersectionSelItem->eclipseSelectionItem() ) eclipseSelectionItem->m_gridIndex,
eclipseSelectionItem->m_gridLocalCellIndex,
m_targetPlotPanel ) )
{ {
eclipseSelectionItem = intersectionSelItem->eclipseSelectionItem(); mustClearPlot = false;
eclipseView = eclipseSelectionItem->m_view;
}
}
if ( m_targetPlotPanel->isVisible() && eclipseSelectionItem && eclipseView ) m_viewToFollowAnimationFrom = newFollowAnimView;
{
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;
} }
} }
@ -109,21 +105,29 @@ void RiuRelativePermeabilityPlotUpdater::updateOnTimeStepChanged( Rim3dView* cha
return; 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 // Don't update the plot if the view that changed time step is different
const RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( changedView ); // from the view that was the source of the current plot
if ( !eclipseView || eclipseView != m_sourceEclipseViewOfLastPlot )
if ( changedView != m_viewToFollowAnimationFrom )
{ {
return; return;
} }
// Fetch the current global selection and only continue if the selection's view matches the view with time step change // 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<const RiuEclipseSelectionItem*>(
Riu3dSelectionManager::instance()->selectedItem() ); const RiuSelectionItem* selectionItem = Riu3dSelectionManager::instance()->selectedItem();
if ( eclipseSelectionItem && eclipseSelectionItem->m_view == eclipseView ) Rim3dView* newFollowAnimView = nullptr;
RiuEclipseSelectionItem* eclipseSelectionItem = nullptr;
eclipseSelectionItem = extractEclipseSelectionItem( selectionItem, newFollowAnimView );
if ( eclipseSelectionItem && newFollowAnimView == changedView )
{ {
const size_t gridIndex = eclipseSelectionItem->m_gridIndex; if ( !queryDataAndUpdatePlot( eclipseSelectionItem->m_resultDefinition,
const size_t gridLocalCellIndex = eclipseSelectionItem->m_gridLocalCellIndex; newFollowAnimView->currentTimeStep(),
if ( !queryDataAndUpdatePlot( *eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel ) ) eclipseSelectionItem->m_gridIndex,
eclipseSelectionItem->m_gridLocalCellIndex,
m_targetPlotPanel ) )
{ {
m_targetPlotPanel->clearPlot(); 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 gridIndex,
size_t gridLocalCellIndex, size_t gridLocalCellIndex,
RiuRelativePermeabilityPlotPanel* plotPanel ) RiuRelativePermeabilityPlotPanel* plotPanel )
{ {
CVF_ASSERT( plotPanel ); CVF_ASSERT( plotPanel );
RimEclipseResultCase* eclipseResultCase = dynamic_cast<RimEclipseResultCase*>( eclipseView.eclipseCase() ); RimEclipseResultCase* eclipseResultCase = dynamic_cast<RimEclipseResultCase*>( eclipseResDef->eclipseCase() );
RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : nullptr; RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : nullptr;
if ( eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface() ) if ( eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface() )
{ {
size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex( eclipseCaseData, gridIndex, gridLocalCellIndex ); size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex( eclipseCaseData, gridIndex, gridLocalCellIndex );
if ( activeCellIndex != cvf::UNDEFINED_SIZE_T ) if ( activeCellIndex != cvf::UNDEFINED_SIZE_T )
{ {
// cvf::Trace::show("Updating RelPerm plot for active cell index: %d", static_cast<int>(activeCellIndex)); // cvf::Trace::show("Updating RelPerm plot for active cell index: %d", static_cast<int>(activeCellIndex));
@ -159,7 +166,6 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot( const RimEclips
cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::STATIC_NATIVE, "SATNUM" ) ); cellResultsData->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::STATIC_NATIVE, "SATNUM" ) );
// Fetch SWAT and SGAS cell values for the selected cell // Fetch SWAT and SGAS cell values for the selected cell
const size_t timeStepIndex = static_cast<size_t>( eclipseView.currentTimeStep() );
cvf::ref<RigResultAccessor> swatAccessor = cvf::ref<RigResultAccessor> swatAccessor =
RigResultAccessorFactory::createFromResultAddress( eclipseCaseData, RigResultAccessorFactory::createFromResultAddress( eclipseCaseData,
gridIndex, gridIndex,
@ -187,8 +193,9 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot( const RimEclips
: HUGE_VAL; : HUGE_VAL;
// cvf::Trace::show("cellSWAT = %f cellSGAS = %f cellSATNUM = %f", cellSWAT, cellSGAS, cellSATNUM); // cvf::Trace::show("cellSWAT = %f cellSGAS = %f cellSATNUM = %f", cellSWAT, cellSGAS, cellSATNUM);
QString cellRefText = constructCellReferenceText( eclipseCaseData, gridIndex, gridLocalCellIndex, cellSATNUM ); QString cellRefText =
QString caseName = eclipseResultCase->caseUserDescription; constructCellReferenceText( eclipseCaseData, gridIndex, gridLocalCellIndex, "SATNUM", cellSATNUM );
QString caseName = eclipseResultCase->caseUserDescription;
plotPanel->setPlotData( eclipseCaseData->unitsType(), relPermCurveArr, cellSWAT, cellSGAS, caseName, cellRefText ); plotPanel->setPlotData( eclipseCaseData->unitsType(), relPermCurveArr, cellSWAT, cellSGAS, caseName, cellRefText );
@ -205,7 +212,8 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot( const RimEclips
QString RiuRelativePermeabilityPlotUpdater::constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData, QString RiuRelativePermeabilityPlotUpdater::constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData,
size_t gridIndex, size_t gridIndex,
size_t gridLocalCellIndex, size_t gridLocalCellIndex,
double satnum ) const QString& valueName,
double cellValue )
{ {
const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0;
const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid( gridIndex ) : nullptr; 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 ); 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; return retText;
@ -242,6 +250,45 @@ QString RiuRelativePermeabilityPlotUpdater::constructCellReferenceText( const Ri
return QString(); return QString();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuEclipseSelectionItem*
RiuRelativePermeabilityPlotUpdater::extractEclipseSelectionItem( const RiuSelectionItem* selectionItem,
Rim3dView*& newFollowAnimView )
{
newFollowAnimView = nullptr;
RiuEclipseSelectionItem* eclipseSelectionItem = nullptr;
eclipseSelectionItem = dynamic_cast<RiuEclipseSelectionItem*>( const_cast<RiuSelectionItem*>( 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<RimEclipseView*>( eclipseSelectionItem->m_view.p() );
if ( clickedInEclView && clickedInEclView->cellResult() == eclipseSelectionItem->m_resultDefinition.p() )
{
newFollowAnimView = eclipseSelectionItem->m_view;
}
}
else
{
auto intersectionSelItem = dynamic_cast<const Riu2dIntersectionSelectionItem*>( 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 gridIndex,
size_t gridLocalCellIndex ) size_t gridLocalCellIndex )
{ {
const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0;
const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid( gridIndex ) : nullptr;
const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid( gridIndex ) : nullptr;
if ( grid && gridLocalCellIndex < grid->cellCount() ) if ( grid && gridLocalCellIndex < grid->cellCount() )
{ {
// Note!! // Note!!
// Which type of porosity model to choose? Currently hard-code to MATRIX_MODEL // Which type of porosity model to choose? Currently hard-code to MATRIX_MODEL
const RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::MATRIX_MODEL ); const RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::MATRIX_MODEL );
CVF_ASSERT( activeCellInfo ); CVF_ASSERT( activeCellInfo );
const size_t reservoirCellIndex = grid->reservoirCellIndex( gridLocalCellIndex ); const size_t reservoirCellIndex = grid->reservoirCellIndex( gridLocalCellIndex );
const size_t activeCellIndex = activeCellInfo->cellResultIndex( reservoirCellIndex ); const size_t activeCellIndex = activeCellInfo->cellResultIndex( reservoirCellIndex );
return activeCellIndex; return activeCellIndex;
} }

View File

@ -26,6 +26,9 @@ class RiuRelativePermeabilityPlotPanel;
class Rim3dView; class Rim3dView;
class RimEclipseView; class RimEclipseView;
class RigEclipseCaseData; class RigEclipseCaseData;
class RimEclipseResultDefinition;
class RiuSelectionItem;
class RiuEclipseSelectionItem;
//================================================================================================== //==================================================================================================
// //
@ -40,19 +43,24 @@ public:
void updateOnSelectionChanged( const RiuSelectionItem* selectionItem ); void updateOnSelectionChanged( const RiuSelectionItem* selectionItem );
void updateOnTimeStepChanged( Rim3dView* changedView ); 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: private:
static bool queryDataAndUpdatePlot( const RimEclipseView& eclipseView, static bool queryDataAndUpdatePlot( const RimEclipseResultDefinition* eclipseResDef,
size_t gridIndex, size_t timeStepIndex,
size_t gridLocalCellIndex, size_t gridIndex,
RiuRelativePermeabilityPlotPanel* plotPanel ); size_t gridLocalCellIndex,
static QString constructCellReferenceText( const RigEclipseCaseData* eclipseCaseData, RiuRelativePermeabilityPlotPanel* plotPanel );
size_t gridIndex,
size_t gridLocalCellIndex,
double satnum );
private: private:
QPointer<RiuRelativePermeabilityPlotPanel> m_targetPlotPanel; QPointer<RiuRelativePermeabilityPlotPanel> m_targetPlotPanel;
const Rim3dView* m_sourceEclipseViewOfLastPlot; const Rim3dView* m_viewToFollowAnimationFrom;
}; };
//================================================================================================== //==================================================================================================

View File

@ -40,22 +40,26 @@
#include "RivExtrudedCurveIntersectionPartMgr.h" #include "RivExtrudedCurveIntersectionPartMgr.h"
#include "RimIntersectionResultDefinition.h"
#include "cafDisplayCoordTransform.h" #include "cafDisplayCoordTransform.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiuResultTextBuilder::RiuResultTextBuilder( RimEclipseView* reservoirView, RiuResultTextBuilder::RiuResultTextBuilder( RimGridView* settingsView,
size_t gridIndex, RimEclipseResultDefinition* eclResDef,
size_t cellIndex, size_t gridIndex,
size_t timeStepIndex ) size_t cellIndex,
size_t timeStepIndex )
{ {
CVF_ASSERT( reservoirView ); CVF_ASSERT( eclResDef );
m_reservoirView = reservoirView; m_displayCoordView = settingsView;
m_gridIndex = gridIndex; m_viewWithFaultsSettings = dynamic_cast<RimEclipseView*>( settingsView );
m_cellIndex = cellIndex; m_eclResDef = eclResDef;
m_timeStepIndex = timeStepIndex; m_gridIndex = gridIndex;
m_cellIndex = cellIndex;
m_timeStepIndex = timeStepIndex;
m_nncIndex = cvf::UNDEFINED_SIZE_T; m_nncIndex = cvf::UNDEFINED_SIZE_T;
m_intersectionPointInDisplay = cvf::Vec3d::UNDEFINED; 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<RimEclipseView*>( settingsView );
m_eclResDef = eclResDef;
m_gridIndex = 0;
m_cellIndex = 0;
m_timeStepIndex = timeStepIndex;
m_gridIndex = 0; RimEclipseCase* eclipseCase = eclResDef->eclipseCase();
m_cellIndex = 0;
RimEclipseCase* eclipseCase = nullptr;
reservoirView->firstAncestorOrThisOfType( eclipseCase );
if ( eclipseCase && eclipseCase->eclipseCaseData() ) if ( eclipseCase && eclipseCase->eclipseCaseData() )
{ {
RigEclipseCaseData* caseData = 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_nncIndex = cvf::UNDEFINED_SIZE_T;
m_intersectionPointInDisplay = cvf::Vec3d::UNDEFINED; m_intersectionPointInDisplay = cvf::Vec3d::UNDEFINED;
m_face = cvf::StructGridInterface::NO_FACE; m_face = cvf::StructGridInterface::NO_FACE;
@ -189,9 +195,9 @@ QString RiuResultTextBuilder::geometrySelectionText( QString itemSeparator )
{ {
QString text; 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 ( eclipseCase )
{ {
if ( m_cellIndex != cvf::UNDEFINED_SIZE_T ) if ( m_cellIndex != cvf::UNDEFINED_SIZE_T )
@ -229,9 +235,6 @@ QString RiuResultTextBuilder::geometrySelectionText( QString itemSeparator )
if ( m_intersectionPointInDisplay != cvf::Vec3d::UNDEFINED ) if ( m_intersectionPointInDisplay != cvf::Vec3d::UNDEFINED )
{ {
cvf::ref<caf::DisplayCoordTransform> transForm = m_reservoirView->displayCoordTransform();
cvf::Vec3d domainCoord = transForm->translateToDomainCoord( m_intersectionPointInDisplay );
QString formattedText; QString formattedText;
if ( m_2dIntersectionView ) if ( m_2dIntersectionView )
{ {
@ -252,11 +255,17 @@ QString RiuResultTextBuilder::geometrySelectionText( QString itemSeparator )
} }
else else
{ {
formattedText.sprintf( "Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", if ( m_displayCoordView )
domainCoord.x(), {
domainCoord.y(), cvf::ref<caf::DisplayCoordTransform> transForm = m_displayCoordView->displayCoordTransform();
-domainCoord.z() ); cvf::Vec3d domainCoord = transForm->translateToDomainCoord( m_intersectionPointInDisplay );
text += formattedText;
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; 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, this->appendTextFromResultColors( eclipseCaseData, m_gridIndex, m_cellIndex, m_timeStepIndex, m_eclResDef, &text );
m_gridIndex,
m_cellIndex,
m_timeStepIndex,
m_reservoirView->cellResult(),
&text );
if ( !text.isEmpty() ) if ( !text.isEmpty() )
{ {
@ -299,9 +303,9 @@ QString RiuResultTextBuilder::faultResultDetails()
{ {
QString text; 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 ); RigGridBase* grid = eclipseCaseData->grid( m_gridIndex );
RigMainGrid* mainGrid = grid->mainGrid(); RigMainGrid* mainGrid = grid->mainGrid();
@ -315,14 +319,14 @@ QString RiuResultTextBuilder::faultResultDetails()
cvf::StructGridInterface::FaceEnum faceHelper( m_face ); cvf::StructGridInterface::FaceEnum faceHelper( m_face );
text += "Fault Face : " + faceHelper.text() + "\n"; text += "Fault Face : " + faceHelper.text() + "\n";
if ( m_reservoirView->faultResultSettings()->hasValidCustomResult() ) if ( m_viewWithFaultsSettings && m_viewWithFaultsSettings->faultResultSettings()->hasValidCustomResult() )
{ {
text += "Fault result data:\n"; text += "Fault result data:\n";
this->appendTextFromResultColors( eclipseCaseData, this->appendTextFromResultColors( eclipseCaseData,
m_gridIndex, m_gridIndex,
m_cellIndex, m_cellIndex,
m_timeStepIndex, m_timeStepIndex,
m_reservoirView->currentFaultResultColors(), m_viewWithFaultsSettings->currentFaultResultColors(),
&text ); &text );
} }
} }
@ -337,7 +341,7 @@ QString RiuResultTextBuilder::faultResultDetails()
QString RiuResultTextBuilder::formationDetails() QString RiuResultTextBuilder::formationDetails()
{ {
QString text; QString text;
RimCase* rimCase = m_reservoirView->eclipseCase(); RimCase* rimCase = m_eclResDef->eclipseCase();
if ( rimCase ) if ( rimCase )
{ {
if ( rimCase->activeFormationNames() && rimCase->activeFormationNames()->formationNamesData() ) if ( rimCase->activeFormationNames() && rimCase->activeFormationNames()->formationNamesData() )
@ -346,7 +350,7 @@ QString RiuResultTextBuilder::formationDetails()
size_t k = cvf::UNDEFINED_SIZE_T; size_t k = cvf::UNDEFINED_SIZE_T;
{ {
const RigEclipseCaseData* eclipseData = m_reservoirView->eclipseCase()->eclipseCaseData(); const RigEclipseCaseData* eclipseData = m_eclResDef->eclipseCase()->eclipseCaseData();
if ( eclipseData ) if ( eclipseData )
{ {
if ( m_cellIndex != cvf::UNDEFINED_SIZE_T ) if ( m_cellIndex != cvf::UNDEFINED_SIZE_T )
@ -380,7 +384,7 @@ QString RiuResultTextBuilder::formationDetails()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RiuResultTextBuilder::gridResultText() QString RiuResultTextBuilder::gridResultText()
{ {
QString text = cellResultText( m_reservoirView->cellResult() ); QString text = cellResultText( m_eclResDef );
return text; return text;
} }
@ -392,19 +396,21 @@ QString RiuResultTextBuilder::faultResultText()
{ {
QString text; 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(); RigGridBase* grid = eclipseCaseData->grid( m_gridIndex );
RigMainGrid* mainGrid = grid->mainGrid();
const RigFault* fault = mainGrid->findFaultFromCellIndexAndCellFace( m_cellIndex, m_face ); const RigFault* fault = mainGrid->findFaultFromCellIndexAndCellFace( m_cellIndex, m_face );
if ( fault ) if ( fault )
{ {
cvf::StructGridInterface::FaceEnum faceHelper( m_face ); 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_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(); RigMainGrid* grid = eclipseCase->mainGrid();
CVF_ASSERT( grid ); CVF_ASSERT( grid );
@ -433,31 +439,35 @@ QString RiuResultTextBuilder::nncResultText()
if ( nncData && m_nncIndex < nncData->connections().size() ) 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 ); cvf::StructGridInterface::FaceEnum face( conn.m_c1Face );
if ( m_reservoirView->currentFaultResultColors() ) if ( m_viewWithFaultsSettings && m_viewWithFaultsSettings->currentFaultResultColors() )
{ {
RigEclipseResultAddress eclipseResultAddress = RigEclipseResultAddress eclipseResultAddress =
m_reservoirView->currentFaultResultColors()->eclipseResultAddress(); m_viewWithFaultsSettings->currentFaultResultColors()->eclipseResultAddress();
RiaDefines::ResultCatType resultType = m_reservoirView->currentFaultResultColors()->resultType(); RiaDefines::ResultCatType resultType =
const std::vector<double>* nncValues = nullptr; m_viewWithFaultsSettings->currentFaultResultColors()->resultType();
const std::vector<double>* nncValues = nullptr;
if ( resultType == RiaDefines::STATIC_NATIVE ) if ( resultType == RiaDefines::STATIC_NATIVE )
{ {
nncValues = nncData->staticConnectionScalarResult( eclipseResultAddress ); nncValues = nncData->staticConnectionScalarResult( eclipseResultAddress );
} }
else if ( resultType == RiaDefines::DYNAMIC_NATIVE ) 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( size_t nativeTimeStep = m_eclResDef->eclipseCase()->uiToNativeTimeStepIndex( m_timeStepIndex );
m_timeStepIndex );
nncValues = nncData->dynamicConnectionScalarResult( eclipseResultAddress, nativeTimeStep ); nncValues = nncData->dynamicConnectionScalarResult( eclipseResultAddress, nativeTimeStep );
} }
} }
if ( nncValues && ( m_nncIndex < nncValues->size() ) ) if ( nncValues && ( m_nncIndex < nncValues->size() ) )
{ {
QString resultVar = m_reservoirView->currentFaultResultColors()->resultVariableUiName(); QString resultVar = m_viewWithFaultsSettings->currentFaultResultColors()->resultVariableUiName();
double scalarValue = ( *nncValues )[m_nncIndex]; double scalarValue = ( *nncValues )[m_nncIndex];
text = QString( "%1 : %2" ).arg( resultVar ).arg( scalarValue ); text = QString( "%1 : %2" ).arg( resultVar ).arg( scalarValue );
@ -473,12 +483,12 @@ QString RiuResultTextBuilder::nncResultText()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuResultTextBuilder::appendTextFromResultColors( RigEclipseCaseData* eclipseCase, void RiuResultTextBuilder::appendTextFromResultColors( RigEclipseCaseData* eclipseCase,
size_t gridIndex, size_t gridIndex,
size_t cellIndex, size_t cellIndex,
size_t timeStepIndex, size_t timeStepIndex,
RimEclipseCellColors* resultColors, RimEclipseResultDefinition* resultColors,
QString* resultInfoText ) QString* resultInfoText )
{ {
if ( !resultColors ) if ( !resultColors )
{ {
@ -678,19 +688,19 @@ QString RiuResultTextBuilder::cellEdgeResultDetails()
{ {
QString text; QString text;
if ( m_reservoirView->cellEdgeResult()->hasResult() ) if ( m_viewWithFaultsSettings && m_viewWithFaultsSettings->cellEdgeResult()->hasResult() )
{ {
text += "-- Cell edge result data --\n"; 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"; text += "\n";
} }
else else
{ {
std::vector<RimCellEdgeMetaData> metaData; std::vector<RimCellEdgeMetaData> metaData;
m_reservoirView->cellEdgeResult()->cellEdgeMetaData( &metaData ); m_viewWithFaultsSettings->cellEdgeResult()->cellEdgeMetaData( &metaData );
std::set<RigEclipseResultAddress> uniqueResultIndices; std::set<RigEclipseResultAddress> uniqueResultIndices;
@ -707,9 +717,9 @@ QString RiuResultTextBuilder::cellEdgeResultDetails()
adjustedTimeStep = 0; adjustedTimeStep = 0;
} }
RiaDefines::PorosityModelType porosityModel = m_reservoirView->cellResult()->porosityModel(); RiaDefines::PorosityModelType porosityModel = m_eclResDef->porosityModel();
cvf::ref<RigResultAccessor> resultAccessor = cvf::ref<RigResultAccessor> resultAccessor =
RigResultAccessorFactory::createFromResultAddress( m_reservoirView->eclipseCase()->eclipseCaseData(), RigResultAccessorFactory::createFromResultAddress( m_eclResDef->eclipseCase()->eclipseCaseData(),
m_gridIndex, m_gridIndex,
porosityModel, porosityModel,
adjustedTimeStep, adjustedTimeStep,
@ -737,9 +747,9 @@ QString RiuResultTextBuilder::nncDetails()
if ( m_nncIndex != cvf::UNDEFINED_SIZE_T ) 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(); RigMainGrid* grid = eclipseCase->mainGrid();
CVF_ASSERT( grid ); 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; 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 ) if ( gridCellResults )
{ {
gridCellResults->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "SOIL" ) ); gridCellResults->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "SOIL" ) );
gridCellResults->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "SGAS" ) ); gridCellResults->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "SGAS" ) );
gridCellResults->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "SWAT" ) ); gridCellResults->ensureKnownResultLoaded( RigEclipseResultAddress( RiaDefines::DYNAMIC_NATIVE, "SWAT" ) );
RiaDefines::PorosityModelType porosityModel = resultColors->porosityModel(); RiaDefines::PorosityModelType porosityModel = eclResDef->porosityModel();
cvf::ref<RigResultAccessor> dataAccessObjectX = cvf::ref<RigResultAccessor> dataAccessObjectX =
RigResultAccessorFactory::createFromResultAddress( eclipseCaseData, RigResultAccessorFactory::createFromResultAddress( eclipseCaseData,
@ -897,7 +907,7 @@ QString RiuResultTextBuilder::cellResultText( RimEclipseCellColors* resultColors
else else
{ {
size_t adjustedTimeStep = m_timeStepIndex; size_t adjustedTimeStep = m_timeStepIndex;
if ( resultColors->hasStaticResult() ) if ( eclResDef->hasStaticResult() )
{ {
adjustedTimeStep = 0; adjustedTimeStep = 0;
} }
@ -906,16 +916,32 @@ QString RiuResultTextBuilder::cellResultText( RimEclipseCellColors* resultColors
RigResultAccessorFactory::createFromResultDefinition( eclipseCaseData, RigResultAccessorFactory::createFromResultDefinition( eclipseCaseData,
m_gridIndex, m_gridIndex,
adjustedTimeStep, adjustedTimeStep,
resultColors ); eclResDef );
if ( resultAccessor.notNull() ) if ( resultAccessor.notNull() )
{ {
double scalarValue = resultAccessor->cellFaceScalar( m_cellIndex, m_face ); double scalarValue = resultAccessor->cellFaceScalar( m_cellIndex, m_face );
QString resultVar = resultColors->resultVariableUiName(); QString resultVar = eclResDef->resultVariableUiName();
QString resultValueText; QString resultValueText;
if ( resultColors->hasCategoryResult() ) if ( eclResDef->hasCategoryResult() )
{ {
RimRegularLegendConfig* legendConfig = resultColors->legendConfig(); auto resColorDef = dynamic_cast<RimEclipseCellColors*>( 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 ); resultValueText += legendConfig->categoryNameFromCategoryValue( scalarValue );
} }
@ -939,9 +965,9 @@ QString RiuResultTextBuilder::wellResultText()
{ {
QString text; QString text;
if ( m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->eclipseCaseData() ) if ( m_eclResDef->eclipseCase() && m_eclResDef->eclipseCase()->eclipseCaseData() )
{ {
cvf::Collection<RigSimWellData> simWellData = m_reservoirView->eclipseCase()->eclipseCaseData()->wellResults(); cvf::Collection<RigSimWellData> simWellData = m_eclResDef->eclipseCase()->eclipseCaseData()->wellResults();
for ( size_t i = 0; i < simWellData.size(); i++ ) for ( size_t i = 0; i < simWellData.size(); i++ )
{ {
RigSimWellData* singleWellResultData = simWellData.at( i ); RigSimWellData* singleWellResultData = simWellData.at( i );

View File

@ -25,8 +25,11 @@
class RimEclipseView; class RimEclipseView;
class RimEclipseCellColors; class RimEclipseCellColors;
class Rim2dIntersectionView; class Rim2dIntersectionView;
class QString;
class RigEclipseCaseData; class RigEclipseCaseData;
class RimEclipseResultDefinition;
class RimGridView;
class QString;
namespace cvf namespace cvf
{ {
@ -40,8 +43,15 @@ class Part;
class RiuResultTextBuilder class RiuResultTextBuilder
{ {
public: public:
RiuResultTextBuilder( RimEclipseView* reservoirView, size_t gridIndex, size_t cellIndex, size_t timeStepIndex ); RiuResultTextBuilder( RimGridView* settingsView,
RiuResultTextBuilder( RimEclipseView* reservoirView, size_t reservoirCellIndex, size_t timeStepIndex ); 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 setFace( cvf::StructGridInterface::FaceType face );
void setNncIndex( size_t nncIndex ); void setNncIndex( size_t nncIndex );
@ -66,18 +76,21 @@ private:
QString nncResultText(); QString nncResultText();
QString wellResultText(); QString wellResultText();
QString cellResultText( RimEclipseCellColors* resultColors ); QString cellResultText( RimEclipseResultDefinition* resultColors );
void appendTextFromResultColors( RigEclipseCaseData* eclipseCase, void appendTextFromResultColors( RigEclipseCaseData* eclipseCase,
size_t gridIndex, size_t gridIndex,
size_t cellIndex, size_t cellIndex,
size_t timeStepIndex, size_t timeStepIndex,
RimEclipseCellColors* resultColors, RimEclipseResultDefinition* resultColors,
QString* resultInfoText ); QString* resultInfoText );
private: private:
caf::PdmPointer<RimEclipseView> m_reservoirView; caf::PdmPointer<RimGridView> m_displayCoordView;
caf::PdmPointer<Rim2dIntersectionView> m_2dIntersectionView; caf::PdmPointer<RimEclipseView> m_viewWithFaultsSettings;
caf::PdmPointer<RimEclipseResultDefinition> m_eclResDef;
caf::PdmPointer<Rim2dIntersectionView> m_2dIntersectionView;
size_t m_gridIndex; size_t m_gridIndex;
size_t m_cellIndex; size_t m_cellIndex;

View File

@ -134,43 +134,41 @@ void RiuSelectionChangedHandler::handleSetSelectedItem( const RiuSelectionItem*
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuEclipseSelectionItem* eclipseSelectionItem ) const void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuEclipseSelectionItem* eclipseSelectionItem ) const
{ {
RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p(); RimEclipseResultDefinition* eclResDef = eclipseSelectionItem->m_resultDefinition;
if ( eclipseView->cellResult()->isFlowDiagOrInjectionFlooding() && if ( eclResDef->isFlowDiagOrInjectionFlooding() && eclResDef->resultVariable() != RIG_NUM_FLOODED_PV )
eclipseView->cellResult()->resultVariable() != RIG_NUM_FLOODED_PV )
{ {
// NB! Do not read out data for flow results, as this can be a time consuming operation // NB! Do not read out data for flow results, as this can be a time consuming operation
return; return;
} }
else if ( eclipseView->cellResult()->hasDynamicResult() && else if ( eclResDef->hasDynamicResult() && !RiaDefines::isPerCellFaceResult( eclResDef->resultVariable() ) &&
!RiaDefines::isPerCellFaceResult( eclipseView->cellResult()->resultVariable() ) && eclResDef->eclipseCase() && eclResDef->eclipseCase()->eclipseCaseData() )
eclipseView->eclipseCase() && eclipseView->eclipseCase()->eclipseCaseData() )
{ {
RiaDefines::PorosityModelType porosityModel = eclipseView->cellResult()->porosityModel(); RiaDefines::PorosityModelType porosityModel = eclResDef->porosityModel();
std::vector<QDateTime> timeStepDates = std::vector<QDateTime> 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 += ", ";
curveName += eclipseView->cellResult()->resultVariableUiShortName(); curveName += eclResDef->resultVariableUiShortName();
curveName += ", "; curveName += ", ";
curveName += QString( "Grid index %1" ).arg( eclipseSelectionItem->m_gridIndex ); curveName += QString( "Grid index %1" ).arg( eclipseSelectionItem->m_gridIndex );
curveName += ", "; curveName += ", ";
curveName += RigTimeHistoryResultAccessor::geometrySelectionText( eclipseView->eclipseCase()->eclipseCaseData(), curveName += RigTimeHistoryResultAccessor::geometrySelectionText( eclResDef->eclipseCase()->eclipseCaseData(),
eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridIndex,
eclipseSelectionItem->m_gridLocalCellIndex ); eclipseSelectionItem->m_gridLocalCellIndex );
std::vector<double> timeHistoryValues = std::vector<double> timeHistoryValues =
RigTimeHistoryResultAccessor::timeHistoryValues( eclipseView->eclipseCase()->eclipseCaseData(), RigTimeHistoryResultAccessor::timeHistoryValues( eclResDef->eclipseCase()->eclipseCaseData(),
eclipseView->cellResult(), eclResDef,
eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridIndex,
eclipseSelectionItem->m_gridLocalCellIndex, eclipseSelectionItem->m_gridLocalCellIndex,
timeStepDates.size() ); timeStepDates.size() );
CVF_ASSERT( timeStepDates.size() == timeHistoryValues.size() ); CVF_ASSERT( timeStepDates.size() == timeHistoryValues.size() );
RiuMainWindow::instance()->resultPlot()->addCurve( eclipseView->eclipseCase(), RiuMainWindow::instance()->resultPlot()->addCurve( eclResDef->eclipseCase(),
curveName, curveName,
eclipseSelectionItem->m_color, eclipseSelectionItem->m_color,
timeStepDates, timeStepDates,
@ -183,22 +181,20 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuEclipseSele
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuGeoMechSelectionItem* geomSelectionItem ) const void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuGeoMechSelectionItem* geomSelectionItem ) const
{ {
RimGeoMechView* geoMechView = geomSelectionItem->m_view.p(); RimGeoMechResultDefinition* geomResDef = geomSelectionItem->m_resultDefinition;
if ( geoMechView && geoMechView->cellResultResultDefinition() && if ( geomResDef && geomResDef->hasResult() && geomResDef->geoMechCase() && geomResDef->geoMechCase()->geoMechData() )
geoMechView->cellResultResultDefinition()->hasResult() && geoMechView->geoMechCase() &&
geoMechView->geoMechCase()->geoMechData() )
{ {
std::unique_ptr<RiuFemTimeHistoryResultAccessor> timeHistResultAccessor; std::unique_ptr<RiuFemTimeHistoryResultAccessor> timeHistResultAccessor;
cvf::Vec3d intersectionPointInDomain = geoMechView->displayCoordTransform()->translateToDomainCoord( cvf::Vec3d intersectionPointInDomain = geomSelectionItem->m_view->displayCoordTransform()->translateToDomainCoord(
geomSelectionItem->m_localIntersectionPointInDisplay ); geomSelectionItem->m_localIntersectionPointInDisplay );
if ( geomSelectionItem->m_hasIntersectionTriangle ) if ( geomSelectionItem->m_hasIntersectionTriangle )
{ {
timeHistResultAccessor = std::unique_ptr<RiuFemTimeHistoryResultAccessor>( timeHistResultAccessor = std::unique_ptr<RiuFemTimeHistoryResultAccessor>(
new RiuFemTimeHistoryResultAccessor( geoMechView->geoMechCase()->geoMechData(), new RiuFemTimeHistoryResultAccessor( geomResDef->geoMechCase()->geoMechData(),
geoMechView->cellResultResultDefinition()->resultAddress(), geomResDef->resultAddress(),
geomSelectionItem->m_gridIndex, geomSelectionItem->m_gridIndex,
static_cast<int>( geomSelectionItem->m_cellIndex ), static_cast<int>( geomSelectionItem->m_cellIndex ),
geomSelectionItem->m_elementFace, geomSelectionItem->m_elementFace,
@ -208,8 +204,8 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuGeoMechSele
else else
{ {
timeHistResultAccessor = std::unique_ptr<RiuFemTimeHistoryResultAccessor>( timeHistResultAccessor = std::unique_ptr<RiuFemTimeHistoryResultAccessor>(
new RiuFemTimeHistoryResultAccessor( geoMechView->geoMechCase()->geoMechData(), new RiuFemTimeHistoryResultAccessor( geomResDef->geoMechCase()->geoMechData(),
geoMechView->cellResultResultDefinition()->resultAddress(), geomResDef->resultAddress(),
geomSelectionItem->m_gridIndex, geomSelectionItem->m_gridIndex,
static_cast<int>( geomSelectionItem->m_cellIndex ), static_cast<int>( geomSelectionItem->m_cellIndex ),
geomSelectionItem->m_elementFace, geomSelectionItem->m_elementFace,
@ -217,12 +213,12 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuGeoMechSele
} }
QString curveName; QString curveName;
curveName.append( geoMechView->geoMechCase()->caseUserDescription() + ", " ); curveName.append( geomResDef->geoMechCase()->caseUserDescription() + ", " );
caf::AppEnum<RigFemResultPosEnum> resPosAppEnum = geoMechView->cellResultResultDefinition()->resultPositionType(); caf::AppEnum<RigFemResultPosEnum> resPosAppEnum = geomResDef->resultPositionType();
curveName.append( resPosAppEnum.uiText() + ", " ); curveName.append( resPosAppEnum.uiText() + ", " );
curveName.append( geoMechView->cellResultResultDefinition()->resultFieldUiName() + ", " ); curveName.append( geomResDef->resultFieldUiName() + ", " );
curveName.append( geoMechView->cellResultResultDefinition()->resultComponentUiName() + " " ); curveName.append( geomResDef->resultComponentUiName() + " " );
if ( resPosAppEnum == RIG_ELEMENT_NODAL_FACE ) if ( resPosAppEnum == RIG_ELEMENT_NODAL_FACE )
{ {
@ -243,10 +239,10 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuGeoMechSele
std::vector<double> timeHistoryValues = timeHistResultAccessor->timeHistoryValues(); std::vector<double> timeHistoryValues = timeHistResultAccessor->timeHistoryValues();
std::vector<QDateTime> dates = geoMechView->geoMechCase()->timeStepDates(); std::vector<QDateTime> dates = geomResDef->geoMechCase()->timeStepDates();
if ( dates.size() == timeHistoryValues.size() ) if ( dates.size() == timeHistoryValues.size() )
{ {
RiuMainWindow::instance()->resultPlot()->addCurve( geoMechView->geoMechCase(), RiuMainWindow::instance()->resultPlot()->addCurve( geomResDef->geoMechCase(),
curveName, curveName,
geomSelectionItem->m_color, geomSelectionItem->m_color,
dates, dates,
@ -260,7 +256,7 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem( const RiuGeoMechSele
dummyStepTimes.push_back( i ); dummyStepTimes.push_back( i );
} }
RiuMainWindow::instance()->resultPlot()->addCurve( geoMechView->geoMechCase(), RiuMainWindow::instance()->resultPlot()->addCurve( geomResDef->geoMechCase(),
curveName, curveName,
geomSelectionItem->m_color, geomSelectionItem->m_color,
dummyStepTimes, dummyStepTimes,
@ -364,12 +360,12 @@ void RiuSelectionChangedHandler::updateResultInfo( const RiuSelectionItem* itemA
{ {
const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast<const RiuEclipseSelectionItem*>( selItem ); const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast<const RiuEclipseSelectionItem*>( selItem );
RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p(); RiuResultTextBuilder textBuilder( eclipseSelectionItem->m_view,
eclipseSelectionItem->m_resultDefinition,
RiuResultTextBuilder textBuilder( eclipseView,
eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridIndex,
eclipseSelectionItem->m_gridLocalCellIndex, eclipseSelectionItem->m_gridLocalCellIndex,
eclipseView->currentTimeStep() ); eclipseSelectionItem->m_timestepIdx );
textBuilder.setFace( eclipseSelectionItem->m_face ); textBuilder.setFace( eclipseSelectionItem->m_face );
textBuilder.setNncIndex( eclipseSelectionItem->m_nncIndex ); textBuilder.setNncIndex( eclipseSelectionItem->m_nncIndex );
textBuilder.setIntersectionPointInDisplay( eclipseSelectionItem->m_localIntersectionPointInDisplay ); textBuilder.setIntersectionPointInDisplay( eclipseSelectionItem->m_localIntersectionPointInDisplay );
@ -383,16 +379,20 @@ void RiuSelectionChangedHandler::updateResultInfo( const RiuSelectionItem* itemA
{ {
const RiuGeoMechSelectionItem* geomSelectionItem = static_cast<const RiuGeoMechSelectionItem*>( selItem ); const RiuGeoMechSelectionItem* geomSelectionItem = static_cast<const RiuGeoMechSelectionItem*>( selItem );
RimGeoMechView* geomView = geomSelectionItem->m_view.p(); RiuFemResultTextBuilder textBuilder( geomSelectionItem->m_view,
RiuFemResultTextBuilder textBuilder( geomView, geomSelectionItem->m_resultDefinition,
(int)geomSelectionItem->m_gridIndex, (int)geomSelectionItem->m_gridIndex,
(int)geomSelectionItem->m_cellIndex, (int)geomSelectionItem->m_cellIndex,
geomView->currentTimeStep() ); (int)geomSelectionItem->m_timestepIdx );
textBuilder.setIntersectionPointInDisplay( geomSelectionItem->m_localIntersectionPointInDisplay ); textBuilder.setIntersectionPointInDisplay( geomSelectionItem->m_localIntersectionPointInDisplay );
textBuilder.setFace( geomSelectionItem->m_elementFace ); textBuilder.setFace( geomSelectionItem->m_elementFace );
textBuilder.set2dIntersectionView( intersectionView ); textBuilder.set2dIntersectionView( intersectionView );
if ( geomSelectionItem->m_hasIntersectionTriangle ) if ( geomSelectionItem->m_hasIntersectionTriangle )
{
textBuilder.setIntersectionTriangle( geomSelectionItem->m_intersectionTriangle ); textBuilder.setIntersectionTriangle( geomSelectionItem->m_intersectionTriangle );
}
resultInfo = textBuilder.mainResultText(); resultInfo = textBuilder.mainResultText();

View File

@ -28,6 +28,7 @@
#include "RicEclipsePropertyFilterNewExec.h" #include "RicEclipsePropertyFilterNewExec.h"
#include "RicGeoMechPropertyFilterNewExec.h" #include "RicGeoMechPropertyFilterNewExec.h"
#include "RicPickEventHandler.h" #include "RicPickEventHandler.h"
#include "RiuCellAndNncPickEventHandler.h"
#include "WellLogCommands/Ric3dWellLogCurvePickEventHandler.h" #include "WellLogCommands/Ric3dWellLogCurvePickEventHandler.h"
#include "WellPathCommands/RicIntersectionPickEventHandler.h" #include "WellPathCommands/RicIntersectionPickEventHandler.h"
#include "WellPathCommands/RicWellPathPickEventHandler.h" #include "WellPathCommands/RicWellPathPickEventHandler.h"
@ -137,6 +138,7 @@ RiuViewerCommands::RiuViewerCommands( RiuViewer* ownerViewer )
addDefaultPickEventHandler( Ric3dWellLogCurvePickEventHandler::instance() ); addDefaultPickEventHandler( Ric3dWellLogCurvePickEventHandler::instance() );
addDefaultPickEventHandler( RicWellPathPickEventHandler::instance() ); addDefaultPickEventHandler( RicWellPathPickEventHandler::instance() );
addDefaultPickEventHandler( RicContourMapPickEventHandler::instance() ); addDefaultPickEventHandler( RicContourMapPickEventHandler::instance() );
addDefaultPickEventHandler( RiuCellAndNncPickEventHandler::instance() );
} }
} }
@ -643,7 +645,7 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
if ( pickItemInfos.size() ) if ( pickItemInfos.size() )
{ {
Ric3dPickEvent viewerEventObject( pickItemInfos, mainOrComparisonView ); Ric3dPickEvent viewerEventObject( pickItemInfos, mainOrComparisonView, keyboardModifiers );
if ( sm_overridingPickHandler && sm_overridingPickHandler->handle3dPickEvent( viewerEventObject ) ) 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 // 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<cvf::Vec3f, 3> 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; const cvf::Part* firstHitPart = nullptr;
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT; uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
cvf::Vec3d globalIntersectionPoint( cvf::Vec3d::ZERO );
const cvf::Part* firstNncHitPart = nullptr;
uint nncPartTriangleIndex = cvf::UNDEFINED_UINT;
if ( pickItemInfos.size() ) if ( pickItemInfos.size() )
{ {
size_t indexToFirstNoneNncItem = cvf::UNDEFINED_SIZE_T; size_t indexToFirstNoneNncItem = cvf::UNDEFINED_SIZE_T;
;
size_t indexToNncItemNearFirstItem = cvf::UNDEFINED_SIZE_T; size_t indexToNncItemNearFirstItem = cvf::UNDEFINED_SIZE_T;
;
findFirstItems( mainOrComparisonView, pickItemInfos, &indexToFirstNoneNncItem, &indexToNncItemNearFirstItem ); findFirstItems( mainOrComparisonView, pickItemInfos, &indexToFirstNoneNncItem, &indexToNncItemNearFirstItem );
if ( indexToFirstNoneNncItem != cvf::UNDEFINED_SIZE_T ) if ( indexToFirstNoneNncItem != cvf::UNDEFINED_SIZE_T )
{ {
localIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].localPickedPoint();
globalIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].globalPickedPoint();
firstHitPart = pickItemInfos[indexToFirstNoneNncItem].pickedPart(); firstHitPart = pickItemInfos[indexToFirstNoneNncItem].pickedPart();
firstPartTriangleIndex = pickItemInfos[indexToFirstNoneNncItem].faceIdx(); firstPartTriangleIndex = pickItemInfos[indexToFirstNoneNncItem].faceIdx();
} globalIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].globalPickedPoint();
if ( indexToNncItemNearFirstItem != cvf::UNDEFINED_SIZE_T )
{
firstNncHitPart = pickItemInfos[indexToNncItemNearFirstItem].pickedPart();
nncPartTriangleIndex = pickItemInfos[indexToNncItemNearFirstItem].faceIdx();
}
}
if ( firstNncHitPart && firstNncHitPart->sourceInfo() )
{
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>( firstNncHitPart->sourceInfo() );
if ( rivSourceInfo )
{
if ( nncPartTriangleIndex < rivSourceInfo->m_NNCIndices->size() )
{
nncIndex = rivSourceInfo->m_NNCIndices->get( nncPartTriangleIndex );
}
} }
} }
if ( firstHitPart && firstHitPart->sourceInfo() ) if ( firstHitPart && firstHitPart->sourceInfo() )
{ {
const RivObjectSourceInfo* rivObjectSourceInfo = dynamic_cast<const RivObjectSourceInfo*>( // clang-format off
firstHitPart->sourceInfo() ); const RivObjectSourceInfo* rivObjectSourceInfo = dynamic_cast<const RivObjectSourceInfo*>( firstHitPart->sourceInfo() );
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>( firstHitPart->sourceInfo() ); const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>( firstHitPart->sourceInfo() );
const RivFemPickSourceInfo* femSourceInfo = dynamic_cast<const RivFemPickSourceInfo*>( const RivWellConnectionSourceInfo* wellConnectionSourceInfo = dynamic_cast<const RivWellConnectionSourceInfo*>( firstHitPart->sourceInfo() );
firstHitPart->sourceInfo() ); // clang-format on
const RivExtrudedCurveIntersectionSourceInfo* crossSectionSourceInfo =
dynamic_cast<const RivExtrudedCurveIntersectionSourceInfo*>( firstHitPart->sourceInfo() );
const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo =
dynamic_cast<const RivBoxIntersectionSourceInfo*>( firstHitPart->sourceInfo() );
const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>(
firstHitPart->sourceInfo() );
const RivWellConnectionSourceInfo* wellConnectionSourceInfo = dynamic_cast<const RivWellConnectionSourceInfo*>(
firstHitPart->sourceInfo() );
if ( rivObjectSourceInfo ) if ( rivObjectSourceInfo )
{ {
@ -800,50 +758,18 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
RiuMainWindow::instance()->selectAsCurrentItem( textAnnot, true ); RiuMainWindow::instance()->selectAsCurrentItem( textAnnot, true );
} }
} }
else if ( const RivExtrudedCurveIntersectionSourceInfo* crossSectionSourceInfo =
if ( rivSourceInfo ) dynamic_cast<const RivExtrudedCurveIntersectionSourceInfo*>( 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<Rim2dIntersectionView*>( m_viewer->ownerViewWindow() ) == bool allowActiveViewChange = dynamic_cast<Rim2dIntersectionView*>( m_viewer->ownerViewWindow() ) ==
nullptr; nullptr;
RiuMainWindow::instance()->selectAsCurrentItem( crossSectionSourceInfo->intersection(), RiuMainWindow::instance()->selectAsCurrentItem( crossSectionSourceInfo->intersection(),
allowActiveViewChange ); allowActiveViewChange );
} }
else if ( intersectionBoxSourceInfo ) else if ( const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo =
dynamic_cast<const RivBoxIntersectionSourceInfo*>( firstHitPart->sourceInfo() ) )
{ {
findCellAndGridIndex( mainOrComparisonView,
intersectionBoxSourceInfo,
firstPartTriangleIndex,
&cellIndex,
&gridIndex );
intersectionHit = true;
intersectionTriangleHit = intersectionBoxSourceInfo->triangle( firstPartTriangleIndex );
RiuMainWindow::instance()->selectAsCurrentItem( intersectionBoxSourceInfo->intersectionBox() ); RiuMainWindow::instance()->selectAsCurrentItem( intersectionBoxSourceInfo->intersectionBox() );
} }
else if ( eclipseWellSourceInfo ) else if ( eclipseWellSourceInfo )
@ -901,6 +827,7 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
{ {
RiuResultTextBuilder textBuilder( eclipseView, RiuResultTextBuilder textBuilder( eclipseView,
eclipseView->cellResult(),
globalCellIndex, globalCellIndex,
eclipseView->currentTimeStep() ); eclipseView->currentTimeStep() );
@ -968,6 +895,7 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
{ {
RiuResultTextBuilder textBuilder( eclipseView, RiuResultTextBuilder textBuilder( eclipseView,
eclipseView->cellResult(),
globalCellIndex, globalCellIndex,
eclipseView->currentTimeStep() ); 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<RiuSelectionItem*> 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<Rim2dIntersectionView*>( mainOrComparisonView );
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>( 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 );
}
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -69,17 +69,22 @@ public:
cvf::Vec3d lastPickPositionInDomainCoords() const; cvf::Vec3d lastPickPositionInDomainCoords() const;
bool isCurrentPickInComparisonView() const; bool isCurrentPickInComparisonView() const;
static void findFirstItems( Rim3dView* mainOrComparisonView,
const std::vector<RiuPickItemInfo>& 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: 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, void ijkFromCellIndex( Rim3dView* mainOrComparisonView,
size_t gridIdx, size_t gridIdx,
size_t cellIndex, size_t cellIndex,
@ -87,12 +92,8 @@ private:
size_t* j, size_t* j,
size_t* k ); size_t* k );
void findFirstItems( Rim3dView* mainOrComparisonView,
const std::vector<RiuPickItemInfo>& pickItemInfos,
size_t* indexToFirstNoneNncItem,
size_t* indexToNncItemNearFirsItem );
bool handleOverlayItemPicking( int winPosX, int winPosY ); bool handleOverlayItemPicking( int winPosX, int winPosY );
void handleTextPicking( int winPosX, int winPosY, cvf::HitItemCollection* hitItems );
void addCompareToViewMenu( caf::CmdFeatureMenuBuilder* menuBuilder ); void addCompareToViewMenu( caf::CmdFeatureMenuBuilder* menuBuilder );
@ -110,5 +111,4 @@ private:
static Ric3dViewPickEventHandler* sm_overridingPickHandler; static Ric3dViewPickEventHandler* sm_overridingPickHandler;
static std::vector<RicDefaultPickEventHandler*> sm_defaultPickEventHandlers; static std::vector<RicDefaultPickEventHandler*> sm_defaultPickEventHandlers;
void handleTextPicking( int winPosX, int winPosY, cvf::HitItemCollection* hitItems );
}; };

View File

@ -260,11 +260,23 @@ ref<DrawableGeo> StructGridGeometryGenerator::createOutlineMeshDrawable(double c
return geo; return geo;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> StructGridGeometryGenerator::createMeshDrawableFromSingleCell(const StructGridInterface* grid,
size_t cellIndex)
{
return createMeshDrawableFromSingleCell(grid,
cellIndex,
grid->displayModelOffset());
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
ref<DrawableGeo> StructGridGeometryGenerator::createMeshDrawableFromSingleCell(const StructGridInterface* grid, size_t cellIndex) ref<DrawableGeo> StructGridGeometryGenerator::createMeshDrawableFromSingleCell(const StructGridInterface* grid,
size_t cellIndex,
const cvf::Vec3d& displayModelOffset)
{ {
cvf::Vec3d cornerVerts[8]; cvf::Vec3d cornerVerts[8];
grid->cellCornerVertices(cellIndex, cornerVerts); grid->cellCornerVertices(cellIndex, cornerVerts);
@ -281,7 +293,7 @@ ref<DrawableGeo> StructGridGeometryGenerator::createMeshDrawableFromSingleCell(c
int n; int n;
for (n = 0; n < 4; 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));
} }
} }

View File

@ -188,7 +188,12 @@ public:
ref<DrawableGeo> createMeshDrawable(); ref<DrawableGeo> createMeshDrawable();
ref<DrawableGeo> createOutlineMeshDrawable(double creaseAngle); ref<DrawableGeo> createOutlineMeshDrawable(double creaseAngle);
static ref<DrawableGeo> createMeshDrawableFromSingleCell(const StructGridInterface* grid, size_t cellIndex); static ref<DrawableGeo> createMeshDrawableFromSingleCell(const StructGridInterface* grid,
size_t cellIndex);
static ref<DrawableGeo> createMeshDrawableFromSingleCell(const StructGridInterface* grid,
size_t cellIndex,
const cvf::Vec3d& displayModelOffset);
private: private:
static ref<UIntArray> static ref<UIntArray>