Merge pull request #5094 from OPM/feature-#5019-separate-intersection-results

Feature #5019 separate intersection results
This commit is contained in:
Jacob Støren 2019-11-26 10:15:30 +01:00 committed by GitHub
commit 5593fb198c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
63 changed files with 2734 additions and 1230 deletions

View File

@ -1,6 +1,7 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicAppendIntersectionFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicAppendSeparateIntersectionResultFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellIntersectionFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathIntersectionFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.h
@ -10,6 +11,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicCopyIntersectionsToAllViewsInCaseFeature.h
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicAppendIntersectionFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicAppendSeparateIntersectionResultFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellIntersectionFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathIntersectionFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.cpp

View File

@ -99,7 +99,7 @@ void RicAppendIntersectionFeatureCmd::redo()
CVF_ASSERT( m_intersectionCollection );
RimIntersection* intersection = new RimIntersection();
intersection->name = QString( "Intersection" );
intersection->setName( "Intersection" );
m_intersectionCollection->appendIntersectionAndUpdate( intersection );
RimGridView* view = nullptr;

View File

@ -0,0 +1,119 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "RicAppendSeparateIntersectionResultFeature.h"
#include "RimIntersectionResultDefinition.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "RimGridView.h"
#include "cafCmdExecCommandManager.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicAppendSeparateIntersectionResultFeature, "RicAppendSeparateIntersectionResultFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicAppendSeparateIntersectionResultFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendSeparateIntersectionResultFeature::onActionTriggered( bool isChecked )
{
std::vector<caf::PdmObjectHandle*> collection;
caf::SelectionManager::instance()->objectsByType( &collection );
CVF_ASSERT( collection.size() == 1 );
RimIntersectionResultsDefinitionCollection* intersectionResCollection = nullptr;
collection[0]->firstAncestorOrThisOfType( intersectionResCollection );
CVF_ASSERT( intersectionResCollection );
RicAppendSeparateIntersectionResultFeatureCmd* cmd = new RicAppendSeparateIntersectionResultFeatureCmd(
intersectionResCollection );
caf::CmdExecCommandManager::instance()->processExecuteCommand( cmd );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendSeparateIntersectionResultFeature::setupActionLook( QAction* actionToSetup )
{
// actionToSetup->setIcon( QIcon( ":/CrossSection16x16.png" ) );
actionToSetup->setText( "New Separate Intersection Result" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicAppendSeparateIntersectionResultFeatureCmd::RicAppendSeparateIntersectionResultFeatureCmd(
RimIntersectionResultsDefinitionCollection* intersectionCollection )
: CmdExecuteCommand( nullptr )
, m_intersectionCollection( intersectionCollection )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicAppendSeparateIntersectionResultFeatureCmd::~RicAppendSeparateIntersectionResultFeatureCmd() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicAppendSeparateIntersectionResultFeatureCmd::name()
{
return "New Intersection";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendSeparateIntersectionResultFeatureCmd::redo()
{
CVF_ASSERT( m_intersectionCollection );
RimIntersectionResultDefinition* intersectionResDef = new RimIntersectionResultDefinition();
m_intersectionCollection->appendIntersectionResultDefinition( intersectionResDef );
m_intersectionCollection->updateConnectedEditors();
//if ( m_intersectionCollection->intersectionResultsDefinitions().size() < 2 ) // New default created. Possible
//{
// RimGridView* gridView;
// m_intersectionCollection->firstAncestorOrThisOfTypeAsserted( gridView );
//
// gridView->scheduleCreateDisplayModelAndRedraw();
// gridView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
//}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendSeparateIntersectionResultFeatureCmd::undo() {}

View File

@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdExecuteCommand.h"
#include "cafCmdFeature.h"
#include "cafPdmPointer.h"
class RimIntersectionResultsDefinitionCollection;
//==================================================================================================
///
//==================================================================================================
class RicAppendSeparateIntersectionResultFeatureCmd : public caf::CmdExecuteCommand
{
public:
explicit RicAppendSeparateIntersectionResultFeatureCmd( RimIntersectionResultsDefinitionCollection* intersectionCollection );
~RicAppendSeparateIntersectionResultFeatureCmd() override;
QString name() override;
void redo() override;
void undo() override;
private:
caf::PdmPointer<RimIntersectionResultsDefinitionCollection> m_intersectionCollection;
};
//==================================================================================================
///
//==================================================================================================
class RicAppendSeparateIntersectionResultFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -105,8 +105,8 @@ void RicNewAzimuthDipIntersectionFeatureCmd::redo()
{
CVF_ASSERT( m_intersectionCollection );
RimIntersection* intersection = new RimIntersection();
intersection->name = "Azimuth and Dip";
RimIntersection* intersection = new RimIntersection();
intersection->setName( "Azimuth and Dip" );
intersection->type = RimIntersection::CS_AZIMUTHLINE;
intersection->inputTwoAzimuthPointsFromViewerEnabled = true;

View File

@ -103,8 +103,8 @@ void RicNewPolylineIntersectionFeatureCmd::redo()
{
CVF_ASSERT( m_intersectionCollection );
RimIntersection* intersection = new RimIntersection();
intersection->name = "Polyline";
RimIntersection* intersection = new RimIntersection();
intersection->setName( "Polyline" );
intersection->type = RimIntersection::CS_POLYLINE;
intersection->inputPolyLineFromViewerEnabled = true;

View File

@ -102,9 +102,9 @@ void RicNewSimWellIntersectionCmd::redo()
CVF_ASSERT( m_simWell );
RimIntersection* intersection = new RimIntersection();
intersection->name = m_simWell->name;
intersection->type = RimIntersection::CS_SIMULATION_WELL;
intersection->simulationWell = m_simWell;
intersection->setName( m_simWell->name );
intersection->type = RimIntersection::CS_SIMULATION_WELL;
intersection->simulationWell = m_simWell;
m_intersectionCollection->appendIntersectionAndUpdate( intersection, false );
}

View File

@ -109,9 +109,9 @@ void RicNewWellPathIntersectionFeatureCmd::redo()
CVF_ASSERT( m_wellPath );
RimIntersection* intersection = new RimIntersection();
intersection->name = m_wellPath->name();
intersection->type = RimIntersection::CS_WELL_PATH;
intersection->wellPath = m_wellPath;
intersection->setName( m_wellPath->name() );
intersection->type = RimIntersection::CS_WELL_PATH;
intersection->wellPath = m_wellPath;
m_intersectionCollection->appendIntersectionAndUpdate( intersection, false );
}

View File

@ -54,7 +54,7 @@ void RicAppendIntersectionBoxFeature::onActionTriggered( bool isChecked )
if ( coll )
{
RimIntersectionBox* intersectionBox = new RimIntersectionBox();
intersectionBox->name = QString( "Intersection Box" );
intersectionBox->setName( "Intersection Box" );
coll->appendIntersectionBoxAndUpdate( intersectionBox );

View File

@ -59,7 +59,7 @@ void RicIntersectionBoxAtPosFeature::onActionTriggered( bool isChecked )
CVF_ASSERT( coll );
RimIntersectionBox* intersectionBox = new RimIntersectionBox();
intersectionBox->name = QString( "Intersection box" );
intersectionBox->setName( "Intersection box" );
coll->appendIntersectionBoxAndUpdate( intersectionBox );

View File

@ -44,7 +44,7 @@ void RicIntersectionFeatureImpl::createIntersectionBoxSlize( const QString&
cvf::Vec3d domainCoord = activeView->viewer()->viewerCommands()->lastPickPositionInDomainCoords();
RimIntersectionBox* intersectionBox = new RimIntersectionBox();
intersectionBox->name = name;
intersectionBox->setName( name );
coll->appendIntersectionBoxNoUpdate( intersectionBox );
intersectionBox->setToDefaultSizeSlice( plane, domainCoord );

View File

@ -89,8 +89,8 @@ void RicPasteIntersectionsFeature::onActionTriggered( bool isChecked )
RimIntersection* intersection = dynamic_cast<RimIntersection*>(
intersectionObjects[i]->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
QString nameOfCopy = QString( "Copy of " ) + intersection->name;
intersection->name = nameOfCopy;
QString nameOfCopy = QString( "Copy of " ) + intersection->name();
intersection->setName( nameOfCopy );
if ( i == intersectionObjects.size() - 1 )
{
@ -111,8 +111,8 @@ void RicPasteIntersectionsFeature::onActionTriggered( bool isChecked )
intersectionBoxObjects[i]->xmlCapability()->copyByXmlSerialization(
caf::PdmDefaultObjectFactory::instance() ) );
QString nameOfCopy = QString( "Copy of " ) + intersectionBox->name;
intersectionBox->name = nameOfCopy;
QString nameOfCopy = QString( "Copy of " ) + intersectionBox->name();
intersectionBox->setName(nameOfCopy);
if ( i == intersectionBoxObjects.size() - 1 )
{

View File

@ -35,6 +35,7 @@
#include "RimFormationNamesCollection.h"
#include "RimGeoMechPropertyFilterCollection.h"
#include "RimIntersectionCollection.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "RimProject.h"
#include "RimSimWellInView.h"
#include "RimSummaryCrossPlotCollection.h"
@ -101,6 +102,7 @@ void RicDeleteItemExec::redo()
Rim3dView* view = nullptr;
parentObj->firstAncestorOrThisOfType( view );
RimGridView* gridView = dynamic_cast<RimGridView*>( view );
// Range Filters
@ -144,6 +146,16 @@ void RicDeleteItemExec::redo()
}
}
// Intersection Result Definitions
RimIntersectionResultsDefinitionCollection* separateIntersectResDefColl;
parentObj->firstAncestorOrThisOfType( separateIntersectResDefColl );
if ( gridView && separateIntersectResDefColl )
{
gridView->scheduleCreateDisplayModelAndRedraw();
gridView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
}
// SimWell Fractures
RimSimWellInView* simWell;
parentObj->firstAncestorOrThisOfType( simWell );

View File

@ -43,6 +43,7 @@
#include "RimIdenticalGridCaseGroup.h"
#include "RimIntersection.h"
#include "RimIntersectionBox.h"
#include "RimIntersectionResultDefinition.h"
#include "RimMultiPlotWindow.h"
#include "RimPerforationInterval.h"
#include "RimPolylinesAnnotation.h"
@ -137,6 +138,8 @@ bool isDeletable( caf::PdmUiItem* uiItem )
if ( dynamic_cast<RimTextAnnotation*>( uiItem ) ) return true;
if ( dynamic_cast<RimReachCircleAnnotation*>( uiItem ) ) return true;
if ( dynamic_cast<RimPolylinesAnnotation*>( uiItem ) ) return true;
if ( dynamic_cast<RimIntersectionResultDefinition*>( uiItem ) ) return true;
if ( dynamic_cast<RimGridCrossPlot*>( uiItem ) )
{
RimMultiPlotWindow* plotWindow = nullptr;

View File

@ -68,7 +68,7 @@ void RicHideIntersectionBoxFeature::onActionTriggered( bool isChecked )
RimIntersectionBox* intersectionBox = dynamic_cast<RimIntersectionBox*>( generalSelectionItem->m_object );
if ( intersectionBox )
{
intersectionBox->isActive = false;
intersectionBox->setActive(false);
intersectionBox->updateConnectedEditors();
activeView->scheduleCreateDisplayModelAndRedraw();

View File

@ -68,7 +68,7 @@ void RicHideIntersectionFeature::onActionTriggered( bool isChecked )
RimIntersection* intersection = dynamic_cast<RimIntersection*>( generalSelectionItem->m_object );
if ( intersection )
{
intersection->isActive = false;
intersection->setActive( false );
intersection->updateConnectedEditors();
activeView->scheduleCreateDisplayModelAndRedraw();

View File

@ -3,6 +3,7 @@ set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RivIntersectionGeometryGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RivIntersectionPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivIntersectionSourceInfo.h
${CMAKE_CURRENT_LIST_DIR}/RivIntersectionResultsColoringTools.h
${CMAKE_CURRENT_LIST_DIR}/RivHexGridIntersectionTools.h
${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxGeometryGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxPartMgr.h
@ -14,6 +15,7 @@ set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RivIntersectionGeometryGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivIntersectionPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivIntersectionSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivIntersectionResultsColoringTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RivHexGridIntersectionTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxGeometryGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxPartMgr.cpp

View File

@ -223,3 +223,12 @@ private:
std::array<float, 8> m_weights;
int m_count;
};
class RivIntersectionGeometryGeneratorIF
{
public:
virtual bool isAnyGeometryPresent() const = 0;
virtual const std::vector<size_t>& triangleToCellIndex() const = 0;
virtual const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const = 0;
virtual const cvf::Vec3fArray* triangleVxes() const = 0;
};

View File

@ -18,12 +18,17 @@
#include "RivIntersectionBoxGeometryGenerator.h"
#include "RimCase.h"
#include "RimGridView.h"
#include "RimIntersectionBox.h"
#include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h"
#include "cvfDrawableGeo.h"
#include "cvfPlane.h"
#include "cvfPrimitiveSetDirect.h"
#include "cvfStructGrid.h"
#include <array>
//--------------------------------------------------------------------------------------------------
@ -245,8 +250,16 @@ void RivIntersectionBoxGeometryGenerator::calculateArrays()
std::vector<cvf::Vec3f> triangleVertices;
std::vector<cvf::Vec3f> cellBorderLineVxes;
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
cvf::BoundingBox gridBBox = m_hexGrid->boundingBox();
cvf::Vec3d displayOffset( 0, 0, 0 );
{
RimGridView* gridView = nullptr;
m_intersectionBoxDefinition->firstAncestorOrThisOfType( gridView );
if ( gridView && gridView->ownerCase() )
{
displayOffset = gridView->ownerCase()->displayModelOffset();
}
}
Box box( m_intersectionBoxDefinition->boxOrigin(), m_intersectionBoxDefinition->boxSize() );
std::array<cvf::Plane, 6> boxPlanes = box.planes();

View File

@ -37,7 +37,7 @@ class ScalarMapper;
class DrawableGeo;
} // namespace cvf
class RivIntersectionBoxGeometryGenerator : public cvf::Object
class RivIntersectionBoxGeometryGenerator : public cvf::Object, public RivIntersectionGeometryGeneratorIF
{
public:
RivIntersectionBoxGeometryGenerator( RimIntersectionBox* intersectionBox,
@ -45,19 +45,20 @@ public:
~RivIntersectionBoxGeometryGenerator() override;
bool isAnyGeometryPresent() const;
// Generate geometry
cvf::ref<cvf::DrawableGeo> generateSurface();
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
// Mapping between cells and geometry
const std::vector<size_t>& triangleToCellIndex() const;
const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const;
const cvf::Vec3fArray* triangleVxes() const;
RimIntersectionBox* intersectionBox() const;
// GeomGen Interface
bool isAnyGeometryPresent() const override;
const std::vector<size_t>& triangleToCellIndex() const override;
const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const override;
const cvf::Vec3fArray* triangleVxes() const override;
private:
void calculateArrays();

View File

@ -32,11 +32,13 @@
#include "RimGeoMechCellColors.h"
#include "RimGeoMechView.h"
#include "RimIntersectionBox.h"
#include "RimIntersectionResultDefinition.h"
#include "RimRegularLegendConfig.h"
#include "RimTernaryLegendConfig.h"
#include "RivIntersectionBoxSourceInfo.h"
#include "RivIntersectionPartMgr.h"
#include "RivIntersectionResultsColoringTools.h"
#include "RivMeshLinesSourceInfo.h"
#include "RivPartPriority.h"
#include "RivResultToTextureMapper.h"
@ -64,7 +66,7 @@ RivIntersectionBoxPartMgr::RivIntersectionBoxPartMgr( RimIntersectionBox* inters
m_intersectionBoxFacesTextureCoords = new cvf::Vec2fArray;
cvf::ref<RivIntersectionHexGridInterface> hexGrid = createHexGridInterface();
cvf::ref<RivIntersectionHexGridInterface> hexGrid = intersectionBox->createHexGridInterface();
m_intersectionBoxGenerator = new RivIntersectionBoxGeometryGenerator( m_rimIntersectionBox, hexGrid.p() );
}
@ -82,155 +84,14 @@ void RivIntersectionBoxPartMgr::applySingleColorEffect()
//--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex )
{
if ( !m_intersectionBoxGenerator->isAnyGeometryPresent() ) return;
RimEclipseView* eclipseView;
m_rimIntersectionBox->firstAncestorOrThisOfType( eclipseView );
if ( eclipseView )
{
RimEclipseCellColors* cellResultColors = eclipseView->cellResult();
CVF_ASSERT( cellResultColors );
// CrossSections
if ( m_intersectionBoxFaces.notNull() )
{
if ( cellResultColors->isTernarySaturationSelected() )
{
RivTernaryTextureCoordsCreator texturer( cellResultColors,
cellResultColors->ternaryLegendConfig()->scalarMapper(),
timeStepIndex );
texturer.createTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
m_intersectionBoxGenerator->triangleToCellIndex() );
const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper();
RivScalarMapperUtils::applyTernaryTextureResultsToPart( m_intersectionBoxFaces.p(),
m_intersectionBoxFacesTextureCoords.p(),
mapper,
1.0,
caf::FC_NONE,
eclipseView->isLightingDisabled() );
}
else
{
CVF_ASSERT( m_intersectionBoxGenerator.notNull() );
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
cvf::ref<RigResultAccessor> resultAccessor;
if ( RiaDefines::isPerCellFaceResult( cellResultColors->resultVariable() ) )
{
resultAccessor = new RigHugeValResultAccessor;
}
else
{
resultAccessor = RigResultAccessorFactory::createFromResultDefinition( cellResultColors
->reservoirView()
->eclipseCase()
->eclipseCaseData(),
0,
timeStepIndex,
cellResultColors );
}
RivIntersectionPartMgr::calculateEclipseTextureCoordinates( m_intersectionBoxFacesTextureCoords.p(),
m_intersectionBoxGenerator->triangleToCellIndex(),
resultAccessor.p(),
mapper );
RivScalarMapperUtils::applyTextureResultsToPart( m_intersectionBoxFaces.p(),
m_intersectionBoxFacesTextureCoords.p(),
mapper,
1.0,
caf::FC_NONE,
eclipseView->isLightingDisabled() );
}
}
}
RimGeoMechView* geoView;
m_rimIntersectionBox->firstAncestorOrThisOfType( geoView );
if ( geoView )
{
RimGeoMechCellColors* cellResultColors = geoView->cellResult();
RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData();
if ( !caseData ) return;
RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
if ( resVarAddress.resultPosType == RIG_ELEMENT )
{
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues( resVarAddress,
0,
(int)timeStepIndex );
const std::vector<size_t>& triangleToCellIdx = m_intersectionBoxGenerator->triangleToCellIndex();
RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
resultValues,
triangleToCellIdx,
mapper );
}
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE )
{
// Special direction sensitive result calculation
const cvf::Vec3fArray* triangelVxes = m_intersectionBoxGenerator->triangleVxes();
if ( resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc" )
{
RivIntersectionPartMgr::calculatePlaneAngleTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
triangelVxes,
resVarAddress,
mapper );
}
else
{
const std::vector<RivIntersectionVertexWeights>& vertexWeights =
m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights();
RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
triangelVxes,
vertexWeights,
caseData,
resVarAddress,
(int)timeStepIndex,
mapper );
}
}
else
{
// Do a "Hack" to show elm nodal and not nodal POR results
if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" )
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues( resVarAddress,
0,
(int)timeStepIndex );
RigFemPart* femPart = caseData->femParts()->part( 0 );
bool isElementNodalResult = !( resVarAddress.resultPosType == RIG_NODAL );
const std::vector<RivIntersectionVertexWeights>& vertexWeights =
m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights();
RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords( m_intersectionBoxFacesTextureCoords
.p(),
vertexWeights,
resultValues,
isElementNodalResult,
femPart,
mapper );
}
RivScalarMapperUtils::applyTextureResultsToPart( m_intersectionBoxFaces.p(),
m_intersectionBoxFacesTextureCoords.p(),
mapper,
1.0,
caf::FC_NONE,
geoView->isLightingDisabled() );
}
RivIntersectionResultsColoringTools::updateCellResultColorStatic( timeStepIndex,
true,
m_rimIntersectionBox,
m_intersectionBoxGenerator.p(),
nullptr,
nullptr,
m_intersectionBoxFaces.p(),
m_intersectionBoxFacesTextureCoords.p() );
}
//--------------------------------------------------------------------------------------------------
@ -356,30 +217,3 @@ void RivIntersectionBoxPartMgr::appendMeshLinePartsToModel( cvf::ModelBasicList*
model->addPart( m_intersectionBoxGridLines.p() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RivIntersectionHexGridInterface> RivIntersectionBoxPartMgr::createHexGridInterface()
{
RimEclipseView* eclipseView;
m_rimIntersectionBox->firstAncestorOrThisOfType( eclipseView );
if ( eclipseView )
{
RigMainGrid* grid = eclipseView->mainGrid();
return new RivEclipseIntersectionGrid( grid,
eclipseView->currentActiveCellInfo(),
m_rimIntersectionBox->showInactiveCells() );
}
RimGeoMechView* geoView;
m_rimIntersectionBox->firstAncestorOrThisOfType( geoView );
if ( geoView )
{
RigFemPart* femPart = geoView->femParts()->part( 0 );
return new RivFemIntersectionGrid( femPart );
}
return nullptr;
}

View File

@ -27,13 +27,22 @@ namespace cvf
class ModelBasicList;
class Transform;
class Part;
class ScalarMapper;
} // namespace cvf
class RigMainGrid;
class RigResultAccessor;
class RivTernaryScalarMapper;
class RimCellEdgeColors;
class RimEclipseCellColors;
class RimIntersectionBox;
class RimIntersectionHandle;
class RimEclipseView;
class RimGeoMechView;
class RimEclipseResultDefinition;
class RimGeoMechResultDefinition;
//==================================================================================================
///
@ -55,8 +64,6 @@ private:
void updatePartEffect();
void generatePartGeometry();
cvf::ref<RivIntersectionHexGridInterface> createHexGridInterface();
private:
RimIntersectionBox* m_rimIntersectionBox;

View File

@ -23,6 +23,8 @@
#include "RigResultAccessor.h"
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimGridView.h"
#include "RimIntersection.h"
#include "RivHexGridIntersectionTools.h"
@ -107,7 +109,17 @@ void RivIntersectionGeometryGenerator::calculateSegementTransformPrLinePoint()
{
m_segementTransformPrLinePoint.clear();
cvf::Mat4d invSectionCS = cvf::Mat4d::fromTranslation( -m_hexGrid->displayOffset() );
cvf::Vec3d displayOffset( 0, 0, 0 );
{
RimGridView* gridView = nullptr;
m_crossSection->firstAncestorOrThisOfType( gridView );
if ( gridView && gridView->ownerCase() )
{
displayOffset = gridView->ownerCase()->displayModelOffset();
}
}
cvf::Mat4d invSectionCS = cvf::Mat4d::fromTranslation( -displayOffset );
for ( const auto& polyLine : m_polyLines )
{
@ -211,8 +223,7 @@ void RivIntersectionGeometryGenerator::calculateArrays()
MeshLinesAccumulator meshAcc( m_hexGrid.p() );
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
cvf::BoundingBox gridBBox = m_hexGrid->boundingBox();
cvf::BoundingBox gridBBox = m_hexGrid->boundingBox();
calculateSegementTransformPrLinePoint();
calculateFlattenedOrOffsetedPolyline();

View File

@ -21,6 +21,8 @@
#include "cafPdmPointer.h"
#include "RivHexGridIntersectionTools.h"
#include "cvfArray.h"
#include "cvfBoundingBox.h"
@ -44,7 +46,7 @@ class ScalarMapper;
class DrawableGeo;
} // namespace cvf
class RivIntersectionGeometryGenerator : public cvf::Object
class RivIntersectionGeometryGenerator : public cvf::Object, public RivIntersectionGeometryGeneratorIF
{
public:
RivIntersectionGeometryGenerator( RimIntersection* crossSection,
@ -56,8 +58,6 @@ public:
~RivIntersectionGeometryGenerator() override;
bool isAnyGeometryPresent() const;
// Generate geometry
cvf::ref<cvf::DrawableGeo> generateSurface();
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
@ -77,24 +77,22 @@ public:
return m_faultMeshLabelAndAnchorPositions;
}
// Mapping between cells and geometry
const std::vector<size_t>& triangleToCellIndex() const;
const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const;
const cvf::Vec3fArray* triangleVxes() const;
RimIntersection* crossSection() const;
cvf::Mat4d unflattenTransformMatrix( const cvf::Vec3d& intersectionPointFlat );
// GeomGen Interface
bool isAnyGeometryPresent() const override;
const std::vector<size_t>& triangleToCellIndex() const override;
const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const override;
const cvf::Vec3fArray* triangleVxes() const override;
private:
void calculateArrays();
void calculateSegementTransformPrLinePoint();
void calculateFlattenedOrOffsetedPolyline();
// static size_t indexToNextValidPoint(const std::vector<cvf::Vec3d>& polyLine,
// const cvf::Vec3d extrDir,
// size_t idxToStartOfLineSegment);
RimIntersection* m_crossSection;
cvf::cref<RivIntersectionHexGridInterface> m_hexGrid;
const std::vector<std::vector<cvf::Vec3d>> m_polyLines;

View File

@ -51,6 +51,7 @@
#include "RivHexGridIntersectionTools.h"
#include "RivIntersectionGeometryGenerator.h"
#include "RivIntersectionResultsColoringTools.h"
#include "RivIntersectionSourceInfo.h"
#include "RivMeshLinesSourceInfo.h"
#include "RivObjectSourceInfo.h"
@ -97,7 +98,7 @@ RivIntersectionPartMgr::RivIntersectionPartMgr( RimIntersection* rimCrossSection
if ( polyLines.size() > 0 )
{
cvf::Vec3d direction = m_rimCrossSection->extrusionDirection();
cvf::ref<RivIntersectionHexGridInterface> hexGrid = createHexGridInterface();
cvf::ref<RivIntersectionHexGridInterface> hexGrid = m_rimCrossSection->createHexGridInterface();
m_crossSectionGenerator = new RivIntersectionGeometryGenerator( m_rimCrossSection,
polyLines,
direction,
@ -149,163 +150,23 @@ void RivIntersectionPartMgr::applySingleColorEffect()
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::updateCellResultColor( size_t timeStepIndex,
const cvf::ScalarMapper* scalarColorMapper,
const RivTernaryScalarMapper* ternaryColorMapper )
const cvf::ScalarMapper* explicitScalarColorMapper,
const RivTernaryScalarMapper* explicitTernaryColorMapper )
{
CVF_ASSERT( scalarColorMapper );
if ( m_crossSectionGenerator.isNull() ) return;
if ( !m_crossSectionGenerator->isAnyGeometryPresent() ) return;
RimEclipseView* eclipseView = nullptr;
m_rimCrossSection->firstAncestorOrThisOfType( eclipseView );
if ( eclipseView )
{
RimEclipseCellColors* cellResultColors = eclipseView->cellResult();
CVF_ASSERT( cellResultColors );
CVF_ASSERT( ternaryColorMapper );
// CrossSections
if ( m_crossSectionFaces.notNull() )
{
if ( cellResultColors->isTernarySaturationSelected() )
{
RivTernaryTextureCoordsCreator texturer( cellResultColors, ternaryColorMapper, timeStepIndex );
texturer.createTextureCoords( m_crossSectionFacesTextureCoords.p(),
m_crossSectionGenerator->triangleToCellIndex() );
RivScalarMapperUtils::applyTernaryTextureResultsToPart( m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p(),
ternaryColorMapper,
1.0,
caf::FC_NONE,
eclipseView->isLightingDisabled() );
}
else
{
CVF_ASSERT( m_crossSectionGenerator.notNull() );
cvf::ref<RigResultAccessor> resultAccessor;
if ( RiaDefines::isPerCellFaceResult( cellResultColors->resultVariable() ) )
{
resultAccessor = new RigHugeValResultAccessor;
}
else
{
resultAccessor = RigResultAccessorFactory::createFromResultDefinition( cellResultColors
->reservoirView()
->eclipseCase()
->eclipseCaseData(),
0,
timeStepIndex,
cellResultColors );
}
RivIntersectionPartMgr::calculateEclipseTextureCoordinates( m_crossSectionFacesTextureCoords.p(),
m_crossSectionGenerator->triangleToCellIndex(),
resultAccessor.p(),
scalarColorMapper );
RivScalarMapperUtils::applyTextureResultsToPart( m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p(),
scalarColorMapper,
1.0,
caf::FC_NONE,
eclipseView->isLightingDisabled() );
}
}
}
RimGeoMechView* geoView;
m_rimCrossSection->firstAncestorOrThisOfType( geoView );
if ( geoView )
{
RimGeoMechCellColors* cellResultColors = geoView->cellResult();
RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData();
if ( !caseData ) return;
RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
if ( resVarAddress.resultPosType == RIG_ELEMENT )
{
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues( resVarAddress,
0,
(int)timeStepIndex );
const std::vector<size_t>& triangleToCellIdx = m_crossSectionGenerator->triangleToCellIndex();
RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords( m_crossSectionFacesTextureCoords.p(),
resultValues,
triangleToCellIdx,
scalarColorMapper );
}
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE )
{
// Special direction sensitive result calculation
const cvf::Vec3fArray* triangelVxes = m_crossSectionGenerator->triangleVxes();
if ( resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc" )
{
RivIntersectionPartMgr::calculatePlaneAngleTextureCoords( m_crossSectionFacesTextureCoords.p(),
triangelVxes,
resVarAddress,
scalarColorMapper );
}
else
{
const std::vector<RivIntersectionVertexWeights>& vertexWeights =
m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights();
RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords( m_crossSectionFacesTextureCoords.p(),
triangelVxes,
vertexWeights,
caseData,
resVarAddress,
(int)timeStepIndex,
scalarColorMapper );
}
}
else
{
// Do a "Hack" to show elm nodal and not nodal POR results
if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" )
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues( resVarAddress,
0,
(int)timeStepIndex );
RigFemPart* femPart = caseData->femParts()->part( 0 );
bool isElementNodalResult = !( resVarAddress.resultPosType == RIG_NODAL );
const std::vector<RivIntersectionVertexWeights>& vertexWeights =
m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights();
RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords( m_crossSectionFacesTextureCoords
.p(),
vertexWeights,
resultValues,
isElementNodalResult,
femPart,
scalarColorMapper );
}
RivScalarMapperUtils::applyTextureResultsToPart( m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p(),
scalarColorMapper,
1.0,
caf::FC_NONE,
geoView->isLightingDisabled() );
}
RivIntersectionResultsColoringTools::updateCellResultColorStatic( timeStepIndex,
!m_isFlattened,
m_rimCrossSection,
m_crossSectionGenerator.p(),
explicitScalarColorMapper,
explicitTernaryColorMapper,
m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(
void RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMechTextureCoords(
cvf::Vec2fArray* textureCoords,
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
const std::vector<float>& resultValues,
@ -357,170 +218,6 @@ void RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords( cvf::Vec2fArray* textureCoords,
const std::vector<float>& resultValues,
const std::vector<size_t>& triangleToCellIdx,
const cvf::ScalarMapper* mapper )
{
textureCoords->resize( triangleToCellIdx.size() * 3 );
if ( resultValues.size() == 0 )
{
textureCoords->setAll( cvf::Vec2f( 0.0, 1.0f ) );
}
else
{
cvf::Vec2f* rawPtr = textureCoords->ptr();
for ( size_t triangleIdx = 0; triangleIdx < triangleToCellIdx.size(); triangleIdx++ )
{
size_t resIdx = triangleToCellIdx[triangleIdx];
float resValue = resultValues[resIdx];
size_t triangleVxIdx = triangleIdx * 3;
if ( resValue == HUGE_VAL || resValue != resValue ) // a != a is true for NAN's
{
rawPtr[triangleVxIdx][1] = 1.0f;
rawPtr[triangleVxIdx + 1][1] = 1.0f;
rawPtr[triangleVxIdx + 2][1] = 1.0f;
}
else
{
rawPtr[triangleVxIdx] = mapper->mapToTextureCoord( resValue );
rawPtr[triangleVxIdx + 1] = mapper->mapToTextureCoord( resValue );
rawPtr[triangleVxIdx + 2] = mapper->mapToTextureCoord( resValue );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(
cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
RigGeoMechCaseData* caseData,
const RigFemResultAddress& resVarAddress,
int timeStepIdx,
const cvf::ScalarMapper* mapper )
{
RiuGeoMechXfTensorResultAccessor accessor( caseData->femPartResults(), resVarAddress, timeStepIdx );
textureCoords->resize( vertexWeights.size() );
cvf::Vec2f* rawPtr = textureCoords->ptr();
int vxCount = static_cast<int>( vertexWeights.size() );
int triCount = vxCount / 3;
#pragma omp parallel for schedule( dynamic )
for ( int triangleIdx = 0; triangleIdx < triCount; ++triangleIdx )
{
int triangleVxStartIdx = triangleIdx * 3;
float values[3];
accessor.calculateInterpolatedValue( &( ( *triangelVertices )[triangleVxStartIdx] ),
&( vertexWeights[triangleVxStartIdx] ),
values );
rawPtr[triangleVxStartIdx + 0] = ( values[0] != std::numeric_limits<float>::infinity() )
? mapper->mapToTextureCoord( values[0] )
: cvf::Vec2f( 0.0f, 1.0f );
rawPtr[triangleVxStartIdx + 1] = ( values[1] != std::numeric_limits<float>::infinity() )
? mapper->mapToTextureCoord( values[1] )
: cvf::Vec2f( 0.0f, 1.0f );
rawPtr[triangleVxStartIdx + 2] = ( values[2] != std::numeric_limits<float>::infinity() )
? mapper->mapToTextureCoord( values[2] )
: cvf::Vec2f( 0.0f, 1.0f );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculatePlaneAngleTextureCoords( cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const RigFemResultAddress& resVarAddress,
const cvf::ScalarMapper* mapper )
{
textureCoords->resize( triangelVertices->size() );
cvf::Vec2f* rawPtr = textureCoords->ptr();
int vxCount = static_cast<int>( triangelVertices->size() );
int triCount = vxCount / 3;
std::function<float( const RiaOffshoreSphericalCoords& )> operation;
if ( resVarAddress.componentName == "Pazi" )
{
operation = []( const RiaOffshoreSphericalCoords& sphCoord ) { return (float)sphCoord.azi(); };
}
else if ( resVarAddress.componentName == "Pinc" )
{
operation = []( const RiaOffshoreSphericalCoords& sphCoord ) { return (float)sphCoord.inc(); };
}
#pragma omp parallel for schedule( dynamic )
for ( int triangleIdx = 0; triangleIdx < triCount; ++triangleIdx )
{
int triangleVxStartIdx = triangleIdx * 3;
const cvf::Vec3f* triangle = &( ( *triangelVertices )[triangleVxStartIdx] );
cvf::Mat3f rotMx = cvf::GeometryTools::computePlaneHorizontalRotationMx( triangle[1] - triangle[0],
triangle[2] - triangle[0] );
RiaOffshoreSphericalCoords sphCoord(
cvf::Vec3f( rotMx.rowCol( 0, 2 ),
rotMx.rowCol( 1, 2 ),
rotMx.rowCol( 2, 2 ) ) ); // Use Ez from the matrix as plane normal
float angle = cvf::Math::toDegrees( operation( sphCoord ) );
cvf::Vec2f texCoord = ( angle != std::numeric_limits<float>::infinity() ) ? mapper->mapToTextureCoord( angle )
: cvf::Vec2f( 0.0f, 1.0f );
rawPtr[triangleVxStartIdx + 0] = texCoord;
rawPtr[triangleVxStartIdx + 1] = texCoord;
rawPtr[triangleVxStartIdx + 2] = texCoord;
}
}
//--------------------------------------------------------------------------------------------------
/// Calculates the texture coordinates in a "nearly" one dimensional texture.
/// Undefined values are coded with a y-texturecoordinate value of 1.0 instead of the normal 0.5
//--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateEclipseTextureCoordinates( cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper )
{
if ( !resultAccessor ) return;
size_t numVertices = triangleToCellIdxMap.size() * 3;
textureCoords->resize( numVertices );
cvf::Vec2f* rawPtr = textureCoords->ptr();
int triangleCount = static_cast<int>( triangleToCellIdxMap.size() );
#pragma omp parallel for
for ( int tIdx = 0; tIdx < triangleCount; tIdx++ )
{
double cellScalarValue = resultAccessor->cellScalarGlobIdx( triangleToCellIdxMap[tIdx] );
cvf::Vec2f texCoord = mapper->mapToTextureCoord( cellScalarValue );
if ( cellScalarValue == HUGE_VAL || cellScalarValue != cellScalarValue ) // a != a is true for NAN's
{
texCoord[1] = 1.0f;
}
size_t j;
for ( j = 0; j < 3; j++ )
{
rawPtr[tIdx * 3 + j] = texCoord;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -623,14 +320,24 @@ void RivIntersectionPartMgr::createFaultLabelParts( const std::vector<std::pair<
if ( !labelAndAnchors.size() ) return;
RimEclipseView* eclipseView = nullptr;
m_rimCrossSection->firstAncestorOrThisOfType( eclipseView );
RimFaultInViewCollection* faultInViewColl = eclipseView->faultCollection();
RimFaultInViewCollection* faultInViewColl = nullptr;
if ( !( eclipseView && faultInViewColl->showFaultLabel() ) ) return;
if ( !m_rimCrossSection->activeSeparateResultDefinition() )
{
RimEclipseView* eclipseView = nullptr;
m_rimCrossSection->firstAncestorOrThisOfType( eclipseView );
if ( eclipseView )
{
faultInViewColl = eclipseView->faultCollection();
cvf::Color3f faultLabelColor = faultInViewColl->faultLabelColor();
cvf::Font* font = RiaGuiApplication::instance()->defaultSceneFont();
if ( faultInViewColl && !faultInViewColl->showFaultLabel() ) return;
}
}
cvf::Color3f faultLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor();
if ( faultInViewColl ) faultLabelColor = faultInViewColl->faultLabelColor();
cvf::Font* font = RiaGuiApplication::instance()->defaultSceneFont();
std::vector<cvf::Vec3f> lineVertices;
@ -650,9 +357,11 @@ void RivIntersectionPartMgr::createFaultLabelParts( const std::vector<std::pair<
for ( const auto& labelAndAnchorPair : labelAndAnchors )
{
RimFaultInView* fault = faultInViewColl->findFaultByName( labelAndAnchorPair.first );
if ( !( fault && fault->showFault() ) ) continue;
if ( faultInViewColl )
{
RimFaultInView* fault = faultInViewColl->findFaultByName( labelAndAnchorPair.first );
if ( !( fault && fault->showFault() ) ) continue;
}
cvf::String cvfString = cvfqt::Utils::toString( labelAndAnchorPair.first );
cvf::Vec3f textCoord( labelAndAnchorPair.second );
@ -998,30 +707,3 @@ cvf::Mat4d RivIntersectionPartMgr::unflattenTransformMatrix( const cvf::Vec3d& i
{
return m_crossSectionGenerator->unflattenTransformMatrix( intersectionPointFlat );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RivIntersectionHexGridInterface> RivIntersectionPartMgr::createHexGridInterface()
{
RimEclipseView* eclipseView;
m_rimCrossSection->firstAncestorOrThisOfType( eclipseView );
if ( eclipseView )
{
RigMainGrid* grid = eclipseView->mainGrid();
return new RivEclipseIntersectionGrid( grid,
eclipseView->currentActiveCellInfo(),
m_rimCrossSection->showInactiveCells() );
}
RimGeoMechView* geoView;
m_rimCrossSection->firstAncestorOrThisOfType( geoView );
if ( geoView && geoView->femParts() && geoView->femParts()->partCount() )
{
RigFemPart* femPart = geoView->femParts()->part( 0 );
return new RivFemIntersectionGrid( femPart );
}
return nullptr;
}

View File

@ -68,8 +68,8 @@ public:
void applySingleColorEffect();
void updateCellResultColor( size_t timeStepIndex,
const cvf::ScalarMapper* scalarColorMapper,
const RivTernaryScalarMapper* ternaryColorMapper );
const cvf::ScalarMapper* explicitScalarColorMapper,
const RivTernaryScalarMapper* explicitTernaryColorMapper );
void appendNativeCrossSectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
void appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
@ -80,45 +80,12 @@ public:
cvf::Mat4d unflattenTransformMatrix( const cvf::Vec3d& intersectionPointFlat );
public:
static void calculateEclipseTextureCoordinates( cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper );
static void calculateNodeOrElementNodeBasedGeoMechTextureCoords(
cvf::Vec2fArray* textureCoords,
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
const std::vector<float>& resultValues,
bool isElementNodalResult,
const RigFemPart* femPart,
const cvf::ScalarMapper* mapper );
static void calculateElementBasedGeoMechTextureCoords( cvf::Vec2fArray* textureCoords,
const std::vector<float>& resultValues,
const std::vector<size_t>& triangleToCellIdx,
const cvf::ScalarMapper* mapper );
static void calculateGeoMechTensorXfTextureCoords( cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
RigGeoMechCaseData* caseData,
const RigFemResultAddress& resVarAddress,
int timeStepIdx,
const cvf::ScalarMapper* mapper );
static void calculatePlaneAngleTextureCoords( cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const RigFemResultAddress& resVarAddress,
const cvf::ScalarMapper* mapper );
private:
void generatePartGeometry();
void createFaultLabelParts( const std::vector<std::pair<QString, cvf::Vec3d>>& labelAndAnchors );
void createPolyLineParts( bool useBufferObjects );
void createExtrusionDirParts( bool useBufferObjects );
cvf::ref<RivIntersectionHexGridInterface> createHexGridInterface();
private:
caf::PdmPointer<RimIntersection> m_rimCrossSection;

View File

@ -0,0 +1,478 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RivIntersectionResultsColoringTools.h"
#include "RiuGeoMechXfTensorResultAccessor.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechView.h"
#include "RimGridView.h"
#include "RimIntersectionHandle.h"
#include "RimIntersectionResultDefinition.h"
#include "RimRegularLegendConfig.h"
#include "RimTernaryLegendConfig.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
#include "RigFemResultAddress.h"
#include "RigGeoMechCaseData.h"
#include "RigResultAccessorFactory.h"
#include "RivScalarMapperUtils.h"
#include "RivTernaryTextureCoordsCreator.h"
#include "RiaOffshoreSphericalCoords.h"
#include "cvfGeometryTools.h"
#include "cvfStructGridGeometryGenerator.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionResultsColoringTools::updateCellResultColorStatic(
size_t timeStepIndex,
bool useSeparateIntersectionResDefTimeStep,
RimIntersectionHandle* rimIntersectionHandle,
const RivIntersectionGeometryGeneratorIF* intersectionGeomGenIF,
const cvf::ScalarMapper* explicitScalarColorMapper,
const RivTernaryScalarMapper* explicitTernaryColorMapper,
cvf::Part* intersectionFacesPart,
cvf::Vec2fArray* intersectionFacesTextureCoords )
{
if ( !intersectionGeomGenIF || !intersectionGeomGenIF->isAnyGeometryPresent() ) return;
RimGridView* gridView = nullptr;
rimIntersectionHandle->firstAncestorOrThisOfType( gridView );
if ( !gridView ) return;
bool isLightingDisabled = gridView->isLightingDisabled();
RimEclipseResultDefinition* eclipseResDef = nullptr;
RimGeoMechResultDefinition* geomResultDef = nullptr;
const cvf::ScalarMapper* scalarColorMapper = explicitScalarColorMapper;
const RivTernaryScalarMapper* ternaryColorMapper = explicitTernaryColorMapper;
// Separate intersection result
RimIntersectionResultDefinition* sepResDef = rimIntersectionHandle->activeSeparateResultDefinition();
if ( sepResDef && sepResDef->activeCase() )
{
if ( sepResDef->isEclipseResultDefinition() )
{
eclipseResDef = sepResDef->eclipseResultDefinition();
}
else
{
geomResultDef = sepResDef->geoMechResultDefinition();
}
if ( !scalarColorMapper ) scalarColorMapper = sepResDef->regularLegendConfig()->scalarMapper();
if ( !ternaryColorMapper ) ternaryColorMapper = sepResDef->ternaryLegendConfig()->scalarMapper();
if ( useSeparateIntersectionResDefTimeStep )
{
timeStepIndex = sepResDef->timeStep();
}
}
// Ordinary result
if ( !eclipseResDef && !geomResultDef )
{
RimEclipseView* eclipseView = nullptr;
rimIntersectionHandle->firstAncestorOrThisOfType( eclipseView );
if ( eclipseView )
{
eclipseResDef = eclipseView->cellResult();
if ( !scalarColorMapper ) scalarColorMapper = eclipseView->cellResult()->legendConfig()->scalarMapper();
if ( !ternaryColorMapper )
ternaryColorMapper = eclipseView->cellResult()->ternaryLegendConfig()->scalarMapper();
}
RimGeoMechView* geoView;
rimIntersectionHandle->firstAncestorOrThisOfType( geoView );
if ( geoView )
{
geomResultDef = geoView->cellResult();
if ( !scalarColorMapper ) scalarColorMapper = geoView->cellResult()->legendConfig()->scalarMapper();
}
}
if ( eclipseResDef )
{
if ( eclipseResDef->isTernarySaturationSelected() )
{
RivIntersectionResultsColoringTools::updateEclipseTernaryCellResultColors( eclipseResDef,
ternaryColorMapper,
timeStepIndex,
isLightingDisabled,
intersectionGeomGenIF
->triangleToCellIndex(),
intersectionFacesPart,
intersectionFacesTextureCoords );
}
else
{
RivIntersectionResultsColoringTools::updateEclipseCellResultColors( eclipseResDef,
scalarColorMapper,
timeStepIndex,
isLightingDisabled,
intersectionGeomGenIF->triangleToCellIndex(),
intersectionFacesPart,
intersectionFacesTextureCoords );
}
}
else if ( geomResultDef )
{
RivIntersectionResultsColoringTools::updateGeoMechCellResultColors( geomResultDef,
timeStepIndex,
scalarColorMapper,
isLightingDisabled,
intersectionGeomGenIF,
intersectionFacesPart,
intersectionFacesTextureCoords );
return;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionResultsColoringTools::updateEclipseCellResultColors(
const RimEclipseResultDefinition* eclipseResDef,
const cvf::ScalarMapper* scalarColorMapper,
size_t timeStepIndex,
bool isLightingDisabled,
const std::vector<size_t>& triangleToCellIndexMapping,
cvf::Part* intersectionFacesPart,
cvf::Vec2fArray* intersectionFacesTextureCoords )
{
RigEclipseCaseData* eclipseCaseData = eclipseResDef->eclipseCase()->eclipseCaseData();
cvf::ref<RigResultAccessor> resultAccessor;
if ( RiaDefines::isPerCellFaceResult( eclipseResDef->resultVariable() ) )
{
resultAccessor = new RigHugeValResultAccessor;
}
else
{
resultAccessor = RigResultAccessorFactory::createFromResultDefinition( eclipseCaseData,
0,
timeStepIndex,
eclipseResDef );
}
RivIntersectionResultsColoringTools::calculateEclipseTextureCoordinates( intersectionFacesTextureCoords,
triangleToCellIndexMapping,
resultAccessor.p(),
scalarColorMapper );
RivScalarMapperUtils::applyTextureResultsToPart( intersectionFacesPart,
intersectionFacesTextureCoords,
scalarColorMapper,
1.0,
caf::FC_NONE,
isLightingDisabled );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionResultsColoringTools::updateEclipseTernaryCellResultColors(
const RimEclipseResultDefinition* eclipseResDef,
const RivTernaryScalarMapper* ternaryColorMapper,
size_t timeStepIndex,
bool isLightingDisabled,
const std::vector<size_t>& triangleToCellIndexMapping,
cvf::Part* intersectionFacesPart,
cvf::Vec2fArray* intersectionFacesTextureCoords )
{
RivTernaryTextureCoordsCreator texturer( eclipseResDef, ternaryColorMapper, timeStepIndex );
texturer.createTextureCoords( intersectionFacesTextureCoords, triangleToCellIndexMapping );
RivScalarMapperUtils::applyTernaryTextureResultsToPart( intersectionFacesPart,
intersectionFacesTextureCoords,
ternaryColorMapper,
1.0,
caf::FC_NONE,
isLightingDisabled );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionResultsColoringTools::updateGeoMechCellResultColors(
const RimGeoMechResultDefinition* geomResultDef,
size_t timeStepIndex,
const cvf::ScalarMapper* scalarColorMapper,
bool isLightingDisabled,
const RivIntersectionGeometryGeneratorIF* geomGenerator,
cvf::Part* intersectionFacesPart,
cvf::Vec2fArray* intersectionFacesTextureCoords )
{
RigGeoMechCaseData* caseData = nullptr;
RigFemResultAddress resVarAddress;
{
caseData = geomResultDef->ownerCaseData();
resVarAddress = geomResultDef->resultAddress();
}
if ( !caseData ) return;
const std::vector<size_t>& triangleToCellIdx = geomGenerator->triangleToCellIndex();
const cvf::Vec3fArray* triangelVxes = geomGenerator->triangleVxes();
const std::vector<RivIntersectionVertexWeights>& vertexWeights =
geomGenerator->triangleVxToCellCornerInterpolationWeights();
if ( resVarAddress.resultPosType == RIG_ELEMENT )
{
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues( resVarAddress,
0,
(int)timeStepIndex );
RivIntersectionResultsColoringTools::calculateElementBasedGeoMechTextureCoords( intersectionFacesTextureCoords,
resultValues,
triangleToCellIdx,
scalarColorMapper );
}
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE )
{
// Special direction sensitive result calculation
if ( resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc" )
{
RivIntersectionResultsColoringTools::calculatePlaneAngleTextureCoords( intersectionFacesTextureCoords,
triangelVxes,
resVarAddress,
scalarColorMapper );
}
else
{
RivIntersectionResultsColoringTools::calculateGeoMechTensorXfTextureCoords( intersectionFacesTextureCoords,
triangelVxes,
vertexWeights,
caseData,
resVarAddress,
(int)timeStepIndex,
scalarColorMapper );
}
}
else
{
// Do a "Hack" to show elm nodal and not nodal POR results
if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" )
{
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
}
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues( resVarAddress,
0,
(int)timeStepIndex );
RigFemPart* femPart = caseData->femParts()->part( 0 );
bool isElementNodalResult = !( resVarAddress.resultPosType == RIG_NODAL );
RivIntersectionResultsColoringTools::calculateNodeOrElementNodeBasedGeoMechTextureCoords( intersectionFacesTextureCoords,
vertexWeights,
resultValues,
isElementNodalResult,
femPart,
scalarColorMapper );
}
RivScalarMapperUtils::applyTextureResultsToPart( intersectionFacesPart,
intersectionFacesTextureCoords,
scalarColorMapper,
1.0,
caf::FC_NONE,
isLightingDisabled );
}
//--------------------------------------------------------------------------------------------------
/// Calculates the texture coordinates in a "nearly" one dimensional texture.
/// Undefined values are coded with a y-texturecoordinate value of 1.0 instead of the normal 0.5
//--------------------------------------------------------------------------------------------------
void RivIntersectionResultsColoringTools::calculateEclipseTextureCoordinates( cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper )
{
if ( !resultAccessor ) return;
size_t numVertices = triangleToCellIdxMap.size() * 3;
textureCoords->resize( numVertices );
cvf::Vec2f* rawPtr = textureCoords->ptr();
int triangleCount = static_cast<int>( triangleToCellIdxMap.size() );
#pragma omp parallel for
for ( int tIdx = 0; tIdx < triangleCount; tIdx++ )
{
double cellScalarValue = resultAccessor->cellScalarGlobIdx( triangleToCellIdxMap[tIdx] );
cvf::Vec2f texCoord = mapper->mapToTextureCoord( cellScalarValue );
if ( cellScalarValue == HUGE_VAL || cellScalarValue != cellScalarValue ) // a != a is true for NAN's
{
texCoord[1] = 1.0f;
}
size_t j;
for ( j = 0; j < 3; j++ )
{
rawPtr[tIdx * 3 + j] = texCoord;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionResultsColoringTools::calculateElementBasedGeoMechTextureCoords(
cvf::Vec2fArray* textureCoords,
const std::vector<float>& resultValues,
const std::vector<size_t>& triangleToCellIdx,
const cvf::ScalarMapper* mapper )
{
textureCoords->resize( triangleToCellIdx.size() * 3 );
if ( resultValues.size() == 0 )
{
textureCoords->setAll( cvf::Vec2f( 0.0, 1.0f ) );
}
else
{
cvf::Vec2f* rawPtr = textureCoords->ptr();
for ( size_t triangleIdx = 0; triangleIdx < triangleToCellIdx.size(); triangleIdx++ )
{
size_t resIdx = triangleToCellIdx[triangleIdx];
float resValue = resultValues[resIdx];
size_t triangleVxIdx = triangleIdx * 3;
if ( resValue == HUGE_VAL || resValue != resValue ) // a != a is true for NAN's
{
rawPtr[triangleVxIdx][1] = 1.0f;
rawPtr[triangleVxIdx + 1][1] = 1.0f;
rawPtr[triangleVxIdx + 2][1] = 1.0f;
}
else
{
rawPtr[triangleVxIdx] = mapper->mapToTextureCoord( resValue );
rawPtr[triangleVxIdx + 1] = mapper->mapToTextureCoord( resValue );
rawPtr[triangleVxIdx + 2] = mapper->mapToTextureCoord( resValue );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionResultsColoringTools::calculateGeoMechTensorXfTextureCoords(
cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
RigGeoMechCaseData* caseData,
const RigFemResultAddress& resVarAddress,
int timeStepIdx,
const cvf::ScalarMapper* mapper )
{
RiuGeoMechXfTensorResultAccessor accessor( caseData->femPartResults(), resVarAddress, timeStepIdx );
textureCoords->resize( vertexWeights.size() );
cvf::Vec2f* rawPtr = textureCoords->ptr();
int vxCount = static_cast<int>( vertexWeights.size() );
int triCount = vxCount / 3;
#pragma omp parallel for schedule( dynamic )
for ( int triangleIdx = 0; triangleIdx < triCount; ++triangleIdx )
{
int triangleVxStartIdx = triangleIdx * 3;
float values[3];
accessor.calculateInterpolatedValue( &( ( *triangelVertices )[triangleVxStartIdx] ),
&( vertexWeights[triangleVxStartIdx] ),
values );
rawPtr[triangleVxStartIdx + 0] = ( values[0] != std::numeric_limits<float>::infinity() )
? mapper->mapToTextureCoord( values[0] )
: cvf::Vec2f( 0.0f, 1.0f );
rawPtr[triangleVxStartIdx + 1] = ( values[1] != std::numeric_limits<float>::infinity() )
? mapper->mapToTextureCoord( values[1] )
: cvf::Vec2f( 0.0f, 1.0f );
rawPtr[triangleVxStartIdx + 2] = ( values[2] != std::numeric_limits<float>::infinity() )
? mapper->mapToTextureCoord( values[2] )
: cvf::Vec2f( 0.0f, 1.0f );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionResultsColoringTools::calculatePlaneAngleTextureCoords( cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const RigFemResultAddress& resVarAddress,
const cvf::ScalarMapper* mapper )
{
textureCoords->resize( triangelVertices->size() );
cvf::Vec2f* rawPtr = textureCoords->ptr();
int vxCount = static_cast<int>( triangelVertices->size() );
int triCount = vxCount / 3;
std::function<float( const RiaOffshoreSphericalCoords& )> operation;
if ( resVarAddress.componentName == "Pazi" )
{
operation = []( const RiaOffshoreSphericalCoords& sphCoord ) { return (float)sphCoord.azi(); };
}
else if ( resVarAddress.componentName == "Pinc" )
{
operation = []( const RiaOffshoreSphericalCoords& sphCoord ) { return (float)sphCoord.inc(); };
}
#pragma omp parallel for schedule( dynamic )
for ( int triangleIdx = 0; triangleIdx < triCount; ++triangleIdx )
{
int triangleVxStartIdx = triangleIdx * 3;
const cvf::Vec3f* triangle = &( ( *triangelVertices )[triangleVxStartIdx] );
cvf::Mat3f rotMx = cvf::GeometryTools::computePlaneHorizontalRotationMx( triangle[1] - triangle[0],
triangle[2] - triangle[0] );
RiaOffshoreSphericalCoords sphCoord(
cvf::Vec3f( rotMx.rowCol( 0, 2 ),
rotMx.rowCol( 1, 2 ),
rotMx.rowCol( 2, 2 ) ) ); // Use Ez from the matrix as plane normal
float angle = cvf::Math::toDegrees( operation( sphCoord ) );
cvf::Vec2f texCoord = ( angle != std::numeric_limits<float>::infinity() ) ? mapper->mapToTextureCoord( angle )
: cvf::Vec2f( 0.0f, 1.0f );
rawPtr[triangleVxStartIdx + 0] = texCoord;
rawPtr[triangleVxStartIdx + 1] = texCoord;
rawPtr[triangleVxStartIdx + 2] = texCoord;
}
}

View File

@ -0,0 +1,110 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cvfArray.h"
#include "RivHexGridIntersectionTools.h"
class RimEclipseResultDefinition;
class RimGeoMechResultDefinition;
class RimIntersectionHandle;
class RivIntersectionGeometryGeneratorIF;
class RivTernaryScalarMapper;
class RigResultAccessor;
class RigFemPart;
class RigGeoMechCaseData;
class RigFemResultAddress;
namespace cvf
{
class Part;
class ScalarMapper;
} // namespace cvf
class RivIntersectionResultsColoringTools
{
public:
static void updateCellResultColorStatic( size_t timeStepIndex,
bool useSeparateIntersectionResDefTimeStep,
RimIntersectionHandle* rimIntersectionHandle,
const RivIntersectionGeometryGeneratorIF* intersectionGeomGenIF,
const cvf::ScalarMapper* explicitScalarColorMapper,
const RivTernaryScalarMapper* explicitTernaryColorMapper,
cvf::Part* intersectionFacesPart,
cvf::Vec2fArray* intersectionFacesTextureCoords );
private:
static void updateEclipseCellResultColors( const RimEclipseResultDefinition* eclipseResDef,
const cvf::ScalarMapper* scalarColorMapper,
size_t timeStepIndex,
bool isLightingDisabled,
const std::vector<size_t>& triangleToCellIndexMapping,
cvf::Part* m_intersectionBoxFaces,
cvf::Vec2fArray* m_intersectionBoxFacesTextureCoords );
static void updateEclipseTernaryCellResultColors( const RimEclipseResultDefinition* eclipseResDef,
const RivTernaryScalarMapper* ternaryColorMapper,
size_t timeStepIndex,
bool isLightingDisabled,
const std::vector<size_t>& triangleToCellIndexMapping,
cvf::Part* m_intersectionBoxFaces,
cvf::Vec2fArray* m_intersectionBoxFacesTextureCoords );
static void updateGeoMechCellResultColors( const RimGeoMechResultDefinition* geomResultDef,
size_t timeStepIndex,
const cvf::ScalarMapper* scalarColorMapper,
bool isLightingDisabled,
const RivIntersectionGeometryGeneratorIF* geomGenerator,
cvf::Part* m_intersectionBoxFaces,
cvf::Vec2fArray* m_intersectionBoxFacesTextureCoords );
static void calculateEclipseTextureCoordinates( cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper );
static void calculateNodeOrElementNodeBasedGeoMechTextureCoords(
cvf::Vec2fArray* textureCoords,
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
const std::vector<float>& resultValues,
bool isElementNodalResult,
const RigFemPart* femPart,
const cvf::ScalarMapper* mapper );
static void calculateElementBasedGeoMechTextureCoords( cvf::Vec2fArray* textureCoords,
const std::vector<float>& resultValues,
const std::vector<size_t>& triangleToCellIdx,
const cvf::ScalarMapper* mapper );
static void calculateGeoMechTensorXfTextureCoords( cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
RigGeoMechCaseData* caseData,
const RigFemResultAddress& resVarAddress,
int timeStepIdx,
const cvf::ScalarMapper* mapper );
static void calculatePlaneAngleTextureCoords( cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const RigFemResultAddress& resVarAddress,
const cvf::ScalarMapper* mapper );
};

View File

@ -247,6 +247,7 @@ void RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(
RivTernaryTextureCoordsCreator texturer( cellResultColors,
cellResultColors->ternaryLegendConfig(),
cellResultColors->reservoirView()->wellCollection(),
timeStepIndex,
gridIndex,
quadToCellFaceMapper );

View File

@ -120,6 +120,7 @@ void RivFaultPartMgr::updateCellResultColor( size_t timeStepIndex, RimEclipseCel
{
RivTernaryTextureCoordsCreator texturer( cellResultColors,
cellResultColors->ternaryLegendConfig(),
eclipseView->wellCollection(),
timeStepIndex,
m_grid->gridIndex(),
m_nativeFaultGenerator->quadToCellFaceMapper() );
@ -164,6 +165,7 @@ void RivFaultPartMgr::updateCellResultColor( size_t timeStepIndex, RimEclipseCel
{
RivTernaryTextureCoordsCreator texturer( cellResultColors,
cellResultColors->ternaryLegendConfig(),
eclipseView->wellCollection(),
timeStepIndex,
m_grid->gridIndex(),
m_oppositeFaultGenerator->quadToCellFaceMapper() );

View File

@ -254,6 +254,7 @@ void RivGridPartMgr::updateCellResultColor( size_t timeStepIndex, RimEclipseCell
{
RivTernaryTextureCoordsCreator texturer( cellResultColors,
cellResultColors->ternaryLegendConfig(),
cellResultColors->reservoirView()->wellCollection(),
timeStepIndex,
m_grid->gridIndex(),
m_surfaceGenerator.quadToCellFaceMapper() );

View File

@ -26,7 +26,7 @@
#include "RigTernaryResultAccessor.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h"
#include "RimSimWellInViewCollection.h"
#include "RimTernaryLegendConfig.h"
@ -39,16 +39,17 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors,
RimTernaryLegendConfig* ternaryLegendConfig,
size_t timeStepIndex,
size_t gridIndex,
RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( const RimEclipseResultDefinition* cellResultColors,
RimTernaryLegendConfig* ternaryLegendConfig,
RimSimWellInViewCollection* simWellInViewCollection,
size_t timeStepIndex,
size_t gridIndex,
const cvf::StructGridQuadToCellFaceMapper* quadMapper )
{
CVF_ASSERT( quadMapper );
m_quadMapper = quadMapper;
RigEclipseCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData();
RigEclipseCaseData* eclipseCase = cellResultColors->eclipseCase()->eclipseCaseData();
size_t resTimeStepIdx = timeStepIndex;
@ -79,8 +80,7 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseCellCo
m_resultAccessor->setTernaryResultAccessors( soil.p(), sgas.p(), swat.p() );
cvf::ref<RigPipeInCellEvaluator> pipeInCellEval =
new RigPipeInCellEvaluator( cellResultColors->reservoirView()->wellCollection()->resultWellGeometryVisibilities(
timeStepIndex ),
new RigPipeInCellEvaluator( simWellInViewCollection->resultWellGeometryVisibilities( timeStepIndex ),
eclipseCase->gridCellToResultWellIndex( gridIndex ) );
const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper();
@ -92,12 +92,12 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseCellCo
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors,
const RivTernaryScalarMapper* ternaryColorMapper,
size_t timeStepIndex )
RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( const RimEclipseResultDefinition* cellResultColors,
const RivTernaryScalarMapper* ternaryColorMapper,
size_t timeStepIndex )
: m_quadMapper( nullptr )
{
RigEclipseCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData();
RigEclipseCaseData* eclipseCase = cellResultColors->eclipseCase()->eclipseCaseData();
size_t resTimeStepIdx = timeStepIndex;

View File

@ -25,8 +25,9 @@
#include "cvfArray.h"
#include "cvfObject.h"
class RimEclipseCellColors;
class RimEclipseResultDefinition;
class RimTernaryLegendConfig;
class RimSimWellInViewCollection;
namespace cvf
{
@ -39,15 +40,16 @@ class StructGridQuadToCellFaceMapper;
class RivTernaryTextureCoordsCreator
{
public:
RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors,
RivTernaryTextureCoordsCreator( const RimEclipseResultDefinition* cellResultColors,
RimTernaryLegendConfig* ternaryLegendConfig,
RimSimWellInViewCollection* simWellInViewCollection,
size_t timeStepIndex,
size_t gridIndex,
const cvf::StructGridQuadToCellFaceMapper* quadMapper );
RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors,
const RivTernaryScalarMapper* ternaryColorMapper,
size_t timeStepIndex );
RivTernaryTextureCoordsCreator( const RimEclipseResultDefinition* cellResultColors,
const RivTernaryScalarMapper* ternaryColorMapper,
size_t timeStepIndex );
void createTextureCoords( cvf::Vec2fArray* quadTextureCoords );
void createTextureCoords( cvf::Vec2fArray* triTextureCoords, const std::vector<size_t>& triangleToCellIdx );

View File

@ -87,8 +87,11 @@ ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileChannel.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogRftCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogWbsCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimIntersectionHandle.h
${CMAKE_CURRENT_LIST_DIR}/RimIntersection.h
${CMAKE_CURRENT_LIST_DIR}/RimIntersectionCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimIntersectionResultDefinition.h
${CMAKE_CURRENT_LIST_DIR}/RimIntersectionResultsDefinitionCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimContextCommandBuilder.h
${CMAKE_CURRENT_LIST_DIR}/RimGridCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPlotCurve.h
@ -229,8 +232,11 @@ ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileChannel.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogRftCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogWbsCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimIntersectionHandle.cpp
${CMAKE_CURRENT_LIST_DIR}/RimIntersection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimIntersectionCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimIntersectionResultDefinition.cpp
${CMAKE_CURRENT_LIST_DIR}/RimIntersectionResultsDefinitionCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimContextCommandBuilder.cpp
${CMAKE_CURRENT_LIST_DIR}/RimGridCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlotCurve.cpp

View File

@ -1017,7 +1017,7 @@ void RimGridCrossPlotDataSet::updateLegendRange()
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case() );
if ( eclipseCase )
{
m_groupingProperty->updateLegendData( eclipseCase, m_timeStep() );
m_groupingProperty->updateRangesForEmbeddedLegends( m_timeStep() );
}
}
parent->addOrUpdateDataSetLegend( this );

View File

@ -20,12 +20,14 @@
#include "Rim3dOverlayInfoConfig.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechView.h"
#include "RimGridView.h"
#include "RimIntersection.h"
#include "RimIntersectionResultDefinition.h"
#include "RimRegularLegendConfig.h"
#include "RimSimWellInView.h"
#include "RimTernaryLegendConfig.h"
@ -162,7 +164,16 @@ void Rim2dIntersectionView::scheduleGeometryRegen( RivCellSetEnum geometryType )
RimCase* Rim2dIntersectionView::ownerCase() const
{
RimCase* rimCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted( rimCase );
if ( RimIntersectionResultDefinition* sepInterResultDef = m_intersection->activeSeparateResultDefinition() )
{
rimCase = sepInterResultDef->activeCase();
}
if ( !rimCase )
{
this->firstAncestorOrThisOfTypeAsserted( rimCase );
}
return rimCase;
}
@ -173,9 +184,18 @@ bool Rim2dIntersectionView::isTimeStepDependentDataVisible() const
{
if ( m_intersection() )
{
RimGridView* gridView = nullptr;
m_intersection->firstAncestorOrThisOfTypeAsserted( gridView );
return gridView->isTimeStepDependentDataVisibleInThisOrComparisonView();
if ( RimIntersectionResultDefinition* sepInterResultDef = m_intersection->activeSeparateResultDefinition() )
{
return sepInterResultDef->isEclipseResultDefinition()
? sepInterResultDef->eclipseResultDefinition()->hasDynamicResult()
: sepInterResultDef->geoMechResultDefinition()->hasResult();
}
else
{
RimGridView* gridView = nullptr;
m_intersection->firstAncestorOrThisOfTypeAsserted( gridView );
return gridView->isTimeStepDependentDataVisibleInThisOrComparisonView();
}
}
return false;
@ -190,9 +210,29 @@ void Rim2dIntersectionView::update3dInfo()
QString overlayInfoText;
RimEclipseView* eclView = nullptr;
m_intersection->firstAncestorOrThisOfType( eclView );
if ( eclView && !eclView->overlayInfoConfig()->isActive() )
Rim3dOverlayInfoConfig* overlayInfoConfig = nullptr;
RimGeoMechResultDefinition* geomResDef = nullptr;
RimEclipseResultDefinition* eclResDef = nullptr;
{
RimEclipseView* originEclView = nullptr;
m_intersection->firstAncestorOrThisOfType( originEclView );
RimGeoMechView* originGeoView = nullptr;
m_intersection->firstAncestorOrThisOfType( originGeoView );
if ( originEclView )
{
overlayInfoConfig = originEclView->overlayInfoConfig();
eclResDef = originEclView->cellResult();
}
else if ( originGeoView )
{
overlayInfoConfig = originGeoView->overlayInfoConfig();
geomResDef = originGeoView->cellResultResultDefinition();
}
}
if ( !overlayInfoConfig->isActive() )
{
nativeOrOverrideViewer()->showInfoText( false );
nativeOrOverrideViewer()->showHistogram( false );
@ -202,20 +242,27 @@ void Rim2dIntersectionView::update3dInfo()
nativeOrOverrideViewer()->update();
return;
}
if ( eclView && eclView->overlayInfoConfig()->showCaseInfo() )
if ( RimIntersectionResultDefinition* sepInterResultDef = m_intersection->activeSeparateResultDefinition() )
{
overlayInfoText += "<b>--" + ownerCase()->caseUserDescription() + "--</b>";
if ( sepInterResultDef->isEclipseResultDefinition() )
{
eclResDef = sepInterResultDef->eclipseResultDefinition();
geomResDef = nullptr;
}
else
{
geomResDef = sepInterResultDef->geoMechResultDefinition();
eclResDef = nullptr;
}
}
RimGeoMechView* geoView = nullptr;
m_intersection->firstAncestorOrThisOfType( geoView );
if ( geoView && geoView->overlayInfoConfig()->showCaseInfo() )
if ( overlayInfoConfig->showCaseInfo() )
{
overlayInfoText += "<b>--" + ownerCase()->caseUserDescription() + "--</b>";
}
overlayInfoText += "<p>";
overlayInfoText += "<b>Z-scale:</b> " + QString::number( scaleZ() ) + "<br> ";
if ( m_intersection->simulationWell() )
@ -231,41 +278,28 @@ void Rim2dIntersectionView::update3dInfo()
overlayInfoText += "<b>Intersection:</b> " + m_intersection->name() + "<br>";
}
if ( eclView )
if ( overlayInfoConfig->showAnimProgress() )
{
if ( eclView->overlayInfoConfig()->showAnimProgress() )
{
nativeOrOverrideViewer()->showAnimationProgress( true );
}
else
{
nativeOrOverrideViewer()->showAnimationProgress( false );
}
if ( eclView->overlayInfoConfig()->showResultInfo() )
{
overlayInfoText += "<b>Cell Result:</b> " + eclView->cellResult()->resultVariableUiShortName() + "<br>";
}
nativeOrOverrideViewer()->showAnimationProgress( true );
}
else
{
nativeOrOverrideViewer()->showAnimationProgress( false );
}
if ( geoView )
if ( overlayInfoConfig->showResultInfo() )
{
if ( geoView->overlayInfoConfig()->showAnimProgress() )
if ( eclResDef )
{
nativeOrOverrideViewer()->showAnimationProgress( true );
overlayInfoText += "<b>Cell Result:</b> " + eclResDef->resultVariableUiShortName() + "<br>";
}
else
{
nativeOrOverrideViewer()->showAnimationProgress( false );
}
if ( geoView->overlayInfoConfig()->showResultInfo() )
else if ( geomResDef )
{
QString resultPos;
QString fieldName = geoView->cellResultResultDefinition()->resultFieldUiName();
QString compName = geoView->cellResultResultDefinition()->resultComponentUiName();
QString fieldName = geomResDef->resultFieldUiName();
QString compName = geomResDef->resultComponentUiName();
switch ( geoView->cellResultResultDefinition()->resultPositionType() )
switch ( geomResDef->resultPositionType() )
{
case RIG_NODAL:
resultPos = "Nodal";
@ -285,6 +319,7 @@ void Rim2dIntersectionView::update3dInfo()
default:
break;
}
if ( compName == "" )
{
overlayInfoText += QString( "<b>Cell result:</b> %1, %2<br>" ).arg( resultPos ).arg( fieldName );
@ -405,6 +440,20 @@ bool Rim2dIntersectionView::hasResults()
{
if ( !m_intersection() ) return false;
if ( RimIntersectionResultDefinition* sepInterResultDef = m_intersection->activeSeparateResultDefinition() )
{
if ( sepInterResultDef->isEclipseResultDefinition() )
{
RimEclipseResultDefinition* eclResDef = sepInterResultDef->eclipseResultDefinition();
return eclResDef->hasResult() || eclResDef->isTernarySaturationSelected();
}
else
{
RimGeoMechResultDefinition* geomResDef = sepInterResultDef->geoMechResultDefinition();
return geomResDef->hasResult();
}
}
RimEclipseView* eclView = nullptr;
m_intersection->firstAncestorOrThisOfType( eclView );
if ( eclView )
@ -509,7 +558,7 @@ void Rim2dIntersectionView::onCreateDisplayModel()
RimEclipseView* eclipseView = nullptr;
m_intersection->firstAncestorOrThisOfType( eclipseView );
if ( eclipseView )
// if ( eclipseView ) Do we need this ?
{
m_flatSimWellPipePartMgr = new RivSimWellPipesPartMgr( m_intersection->simulationWell() );
m_flatWellHeadPartMgr = new RivWellHeadPartMgr( m_intersection->simulationWell() );
@ -634,47 +683,80 @@ void Rim2dIntersectionView::onUpdateLegends()
if ( !hasResults() ) return;
RimEclipseView* eclView = nullptr;
m_intersection->firstAncestorOrThisOfType( eclView );
RimGeoMechResultDefinition* geomResDef = nullptr;
RimEclipseResultDefinition* eclResDef = nullptr;
RimRegularLegendConfig* regularLegendConfig = nullptr;
RimTernaryLegendConfig* ternaryLegendConfig = nullptr;
RimGeoMechView* geoView = nullptr;
m_intersection->firstAncestorOrThisOfType( geoView );
{
RimEclipseView* originEclView = nullptr;
m_intersection->firstAncestorOrThisOfType( originEclView );
RimGeoMechView* originGeoView = nullptr;
m_intersection->firstAncestorOrThisOfType( originGeoView );
if ( originEclView )
{
eclResDef = originEclView->cellResult();
regularLegendConfig = originEclView->cellResult()->legendConfig();
ternaryLegendConfig = originEclView->cellResult()->ternaryLegendConfig();
}
else if ( originGeoView )
{
geomResDef = originGeoView->cellResultResultDefinition();
regularLegendConfig = originGeoView->cellResult()->legendConfig();
}
}
if ( RimIntersectionResultDefinition* sepInterResultDef = m_intersection->activeSeparateResultDefinition() )
{
if ( sepInterResultDef->isEclipseResultDefinition() )
{
eclResDef = sepInterResultDef->eclipseResultDefinition();
regularLegendConfig = sepInterResultDef->regularLegendConfig();
ternaryLegendConfig = sepInterResultDef->ternaryLegendConfig();
geomResDef = nullptr;
}
else
{
geomResDef = sepInterResultDef->geoMechResultDefinition();
regularLegendConfig = sepInterResultDef->regularLegendConfig();
eclResDef = nullptr;
}
}
caf::TitledOverlayFrame* legend = nullptr;
if ( eclView )
{
m_legendConfig()->setUiValuesFromLegendConfig( eclView->cellResult()->legendConfig() );
m_ternaryLegendConfig()->setUiValuesFromLegendConfig( eclView->cellResult()->ternaryLegendConfig() );
eclView->cellResult()->updateLegendData( eclView->eclipseCase(),
m_currentTimeStep(),
m_legendConfig(),
m_ternaryLegendConfig() );
// Copy the legend settings from the real view
if ( eclView->cellResult()->isTernarySaturationSelected() )
m_legendConfig()->setUiValuesFromLegendConfig( regularLegendConfig );
if ( ternaryLegendConfig ) m_ternaryLegendConfig()->setUiValuesFromLegendConfig( ternaryLegendConfig );
if ( eclResDef )
{
eclResDef->updateRangesForExplicitLegends( m_legendConfig(), m_ternaryLegendConfig(), m_currentTimeStep() );
if ( eclResDef->isTernarySaturationSelected() )
{
m_ternaryLegendConfig()->setTitle( "Cell Result:\n" );
legend = m_ternaryLegendConfig()->titledOverlayFrame();
m_legendObjectToSelect = eclView->cellResult()->ternaryLegendConfig();
m_legendObjectToSelect = ternaryLegendConfig;
}
else
{
m_legendConfig()->setTitle( "Cell Result:\n" + eclView->cellResult()->resultVariableUiShortName() );
eclResDef->updateLegendTitle( m_legendConfig, "Cell Result:\n" );
legend = m_legendConfig()->titledOverlayFrame();
m_legendObjectToSelect = eclView->cellResult()->legendConfig();
m_legendObjectToSelect = regularLegendConfig;
}
}
if ( geoView )
if ( geomResDef )
{
m_legendConfig()->setUiValuesFromLegendConfig( geoView->cellResult()->legendConfig() );
geoView->updateLegendTextAndRanges( m_legendConfig(), m_currentTimeStep() );
geomResDef->updateLegendTextAndRanges( m_legendConfig(), "Cell Result:\n", m_currentTimeStep() );
legend = m_legendConfig()->titledOverlayFrame();
m_legendObjectToSelect = geoView->cellResult()->legendConfig();
m_legendObjectToSelect = regularLegendConfig;
}
if ( legend )

View File

@ -77,6 +77,8 @@
#include "RimIntersection.h"
#include "RimIntersectionBox.h"
#include "RimIntersectionCollection.h"
#include "RimIntersectionResultDefinition.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "RimModeledWellPath.h"
#include "RimMultiPlotCollection.h"
#include "RimObservedSummaryData.h"
@ -684,6 +686,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder.addSeparator();
menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature";
}
else if ( dynamic_cast<RimIntersectionResultsDefinitionCollection*>( uiItem ) ||
dynamic_cast<RimIntersectionResultDefinition*>( uiItem ) )
{
menuBuilder << "RicAppendSeparateIntersectionResultFeature";
}
else if ( dynamic_cast<RimSimWellInView*>( uiItem ) )
{
menuBuilder << "RicNewWellLogCurveExtractionFeature";

View File

@ -269,287 +269,12 @@ RimEclipseView* RimEclipseCellColors::reservoirView()
return m_reservoirView;
}
bool operator<( const cvf::Color3ub first, const cvf::Color3ub second )
{
if ( first.r() != second.r() ) return first.r() < second.r();
if ( first.g() != second.g() ) return first.g() < second.g();
if ( first.b() != second.b() ) return first.b() < second.b();
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class TupleCompare
void RimEclipseCellColors::updateRangesForEmbeddedLegends( int currentTimeStep )
{
public:
bool operator()( const std::tuple<QString, int, cvf::Color3ub>& t1,
const std::tuple<QString, int, cvf::Color3ub>& t2 ) const
{
using namespace std;
if ( get<0>( t1 ) != get<0>( t2 ) ) return get<0>( t1 ) < get<0>( t2 );
if ( get<1>( t1 ) != get<1>( t2 ) ) return get<1>( t1 ) < get<1>( t2 );
if ( get<2>( t1 ) != get<2>( t2 ) ) return get<2>( t1 ) < get<2>( t2 );
return false;
}
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseCellColors::updateLegendData( RimEclipseCase* rimEclipseCase,
int currentTimeStep,
RimRegularLegendConfig* legendConfig,
RimTernaryLegendConfig* ternaryLegendConfig )
{
if ( !legendConfig ) legendConfig = this->legendConfig();
if ( !ternaryLegendConfig ) ternaryLegendConfig = this->m_ternaryLegendConfig();
if ( this->hasResult() )
{
if ( this->isFlowDiagOrInjectionFlooding() )
{
CVF_ASSERT( currentTimeStep >= 0 );
double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero;
RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults();
RigFlowDiagResultAddress resAddr = this->flowDiagResAddress();
flowResultsData->minMaxScalarValues( resAddr, currentTimeStep, &globalMin, &globalMax );
flowResultsData->posNegClosestToZero( resAddr,
currentTimeStep,
&globalPosClosestToZero,
&globalNegClosestToZero );
double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero;
if ( this->hasDynamicResult() )
{
flowResultsData->minMaxScalarValues( resAddr, currentTimeStep, &localMin, &localMax );
flowResultsData->posNegClosestToZero( resAddr,
currentTimeStep,
&localPosClosestToZero,
&localNegClosestToZero );
}
else
{
localMin = globalMin;
localMax = globalMax;
localPosClosestToZero = globalPosClosestToZero;
localNegClosestToZero = globalNegClosestToZero;
}
CVF_ASSERT( legendConfig );
legendConfig->disableAllTimeStepsRange( true );
legendConfig->setClosestToZeroValues( globalPosClosestToZero,
globalNegClosestToZero,
localPosClosestToZero,
localNegClosestToZero );
legendConfig->setAutomaticRanges( globalMin, globalMax, localMin, localMax );
if ( this->hasCategoryResult() && m_reservoirView )
{
std::set<std::tuple<QString, int, cvf::Color3ub>, TupleCompare> categories;
// std::set<std::tuple<QString, int, cvf::Color3ub> > categories;
std::vector<QString> tracerNames = this->flowDiagSolution()->tracerNames();
int tracerIndex = 0;
for ( const auto& tracerName : tracerNames )
{
RimSimWellInView* well = m_reservoirView->wellCollection()->findWell(
RimFlowDiagSolution::removeCrossFlowEnding( tracerName ) );
cvf::Color3ub color( cvf::Color3::GRAY );
if ( well ) color = cvf::Color3ub( well->wellPipeColor() );
categories.insert( std::make_tuple( tracerName, tracerIndex, color ) );
++tracerIndex;
}
std::vector<std::tuple<QString, int, cvf::Color3ub>> reverseCategories;
for ( auto tupIt = categories.rbegin(); tupIt != categories.rend(); ++tupIt )
{
reverseCategories.push_back( *tupIt );
}
legendConfig->setCategoryItems( reverseCategories );
}
}
else
{
CVF_ASSERT( rimEclipseCase );
if ( !rimEclipseCase ) return;
RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData();
CVF_ASSERT( eclipseCase );
if ( !eclipseCase ) return;
RigCaseCellResultsData* cellResultsData = eclipseCase->results( this->porosityModel() );
CVF_ASSERT( cellResultsData );
double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero;
cellResultsData->minMaxCellScalarValues( this->eclipseResultAddress(), globalMin, globalMax );
cellResultsData->posNegClosestToZero( this->eclipseResultAddress(),
globalPosClosestToZero,
globalNegClosestToZero );
double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero;
if ( this->hasDynamicResult() && currentTimeStep >= 0 )
{
cellResultsData->minMaxCellScalarValues( this->eclipseResultAddress(), currentTimeStep, localMin, localMax );
cellResultsData->posNegClosestToZero( this->eclipseResultAddress(),
currentTimeStep,
localPosClosestToZero,
localNegClosestToZero );
}
else
{
localMin = globalMin;
localMax = globalMax;
localPosClosestToZero = globalPosClosestToZero;
localNegClosestToZero = globalNegClosestToZero;
}
CVF_ASSERT( legendConfig );
legendConfig->disableAllTimeStepsRange( false );
legendConfig->setClosestToZeroValues( globalPosClosestToZero,
globalNegClosestToZero,
localPosClosestToZero,
localNegClosestToZero );
legendConfig->setAutomaticRanges( globalMin, globalMax, localMin, localMax );
if ( this->hasCategoryResult() )
{
if ( this->resultType() == RiaDefines::FORMATION_NAMES )
{
const std::vector<QString>& fnVector = eclipseCase->activeFormationNames()->formationNames();
legendConfig->setNamedCategoriesInverse( fnVector );
}
else if ( this->resultType() == RiaDefines::DYNAMIC_NATIVE &&
this->resultVariable() == RiaDefines::completionTypeResultName() )
{
const std::vector<int>& visibleCategories = cellResultsData->uniqueCellScalarValues(
this->eclipseResultAddress() );
std::vector<RiaDefines::WellPathComponentType> supportedCompletionTypes = {RiaDefines::WELL_PATH,
RiaDefines::FISHBONES,
RiaDefines::PERFORATION_INTERVAL,
RiaDefines::FRACTURE};
RiaColorTables::WellPathComponentColors colors = RiaColorTables::wellPathComponentColors();
std::vector<std::tuple<QString, int, cvf::Color3ub>> categories;
for ( auto completionType : supportedCompletionTypes )
{
if ( std::find( visibleCategories.begin(), visibleCategories.end(), completionType ) !=
visibleCategories.end() )
{
QString categoryText = caf::AppEnum<RiaDefines::WellPathComponentType>::uiText(
completionType );
categories.push_back(
std::make_tuple( categoryText, completionType, colors[completionType] ) );
}
}
legendConfig->setCategoryItems( categories );
}
else
{
legendConfig->setIntegerCategories(
cellResultsData->uniqueCellScalarValues( this->eclipseResultAddress() ) );
}
}
}
}
// Ternary legend update
{
CVF_ASSERT( rimEclipseCase );
if ( !rimEclipseCase ) return;
RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData();
CVF_ASSERT( eclipseCase );
if ( !eclipseCase ) return;
RigCaseCellResultsData* cellResultsData = eclipseCase->results( this->porosityModel() );
size_t maxTimeStepCount = cellResultsData->maxTimeStepCount();
if ( this->isTernarySaturationSelected() && maxTimeStepCount > 1 )
{
RigCaseCellResultsData* gridCellResults = this->currentGridCellResults();
{
RigEclipseResultAddress resAddr( RiaDefines::DYNAMIC_NATIVE, "SOIL" );
if ( gridCellResults->ensureKnownResultLoaded( resAddr ) )
{
double globalMin = 0.0;
double globalMax = 1.0;
double localMin = 0.0;
double localMax = 1.0;
cellResultsData->minMaxCellScalarValues( resAddr, globalMin, globalMax );
cellResultsData->minMaxCellScalarValues( resAddr, currentTimeStep, localMin, localMax );
ternaryLegendConfig->setAutomaticRanges( RimTernaryLegendConfig::TERNARY_SOIL_IDX,
globalMin,
globalMax,
localMin,
localMax );
}
}
{
RigEclipseResultAddress resAddr( RiaDefines::DYNAMIC_NATIVE, "SGAS" );
if ( gridCellResults->ensureKnownResultLoaded( resAddr ) )
{
double globalMin = 0.0;
double globalMax = 1.0;
double localMin = 0.0;
double localMax = 1.0;
cellResultsData->minMaxCellScalarValues( resAddr, globalMin, globalMax );
cellResultsData->minMaxCellScalarValues( resAddr, currentTimeStep, localMin, localMax );
ternaryLegendConfig->setAutomaticRanges( RimTernaryLegendConfig::TERNARY_SGAS_IDX,
globalMin,
globalMax,
localMin,
localMax );
}
}
{
RigEclipseResultAddress resAddr( RiaDefines::DYNAMIC_NATIVE, "SWAT" );
if ( gridCellResults->ensureKnownResultLoaded( resAddr ) )
{
double globalMin = 0.0;
double globalMax = 1.0;
double localMin = 0.0;
double localMax = 1.0;
cellResultsData->minMaxCellScalarValues( resAddr, globalMin, globalMax );
cellResultsData->minMaxCellScalarValues( resAddr, currentTimeStep, localMin, localMax );
ternaryLegendConfig->setAutomaticRanges( RimTernaryLegendConfig::TERNARY_SWAT_IDX,
globalMin,
globalMax,
localMin,
localMax );
}
}
}
}
this->updateRangesForExplicitLegends( legendConfig(), m_ternaryLegendConfig(), currentTimeStep );
}
//--------------------------------------------------------------------------------------------------

View File

@ -45,10 +45,7 @@ public:
void setReservoirView( RimEclipseView* ownerReservoirView );
RimEclipseView* reservoirView();
void updateLegendData( RimEclipseCase* rimEclipseCase,
int timestep,
RimRegularLegendConfig* legendConfig = nullptr,
RimTernaryLegendConfig* ternaryLegendConfig = nullptr );
void updateRangesForEmbeddedLegends( int timestep );
RimRegularLegendConfig* legendConfig();
RimTernaryLegendConfig* ternaryLegendConfig();

View File

@ -21,6 +21,7 @@
#include "RimEclipseResultDefinition.h"
#include "RiaApplication.h"
#include "RiaColorTables.h"
#include "RiaLogging.h"
#include "RiaQDateTimeTools.h"
@ -32,6 +33,7 @@
#include "RigEclipseResultInfo.h"
#include "RigFlowDiagResultAddress.h"
#include "RigFlowDiagResults.h"
#include "RigFormationNames.h"
#include "Rim3dView.h"
#include "Rim3dWellLogCurve.h"
@ -50,9 +52,13 @@
#include "RimGridCrossPlotDataSet.h"
#include "RimGridTimeHistoryCurve.h"
#include "RimIntersectionCollection.h"
#include "RimIntersectionResultDefinition.h"
#include "RimPlotCurve.h"
#include "RimProject.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimSimWellInView.h"
#include "RimSimWellInViewCollection.h"
#include "RimTernaryLegendConfig.h"
#include "RimViewLinker.h"
#include "RimWellLogExtractionCurve.h"
@ -224,7 +230,7 @@ void RimEclipseResultDefinition::setEclipseCase( RimEclipseCase* eclipseCase )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RimEclipseResultDefinition::eclipseCase()
RimEclipseCase* RimEclipseResultDefinition::eclipseCase() const
{
return m_eclipseCase;
}
@ -442,6 +448,13 @@ void RimEclipseResultDefinition::updateAnyFieldHasChanged()
cellColors->updateConnectedEditors();
}
RimIntersectionResultDefinition* intersectResDef = nullptr;
this->firstAncestorOrThisOfType( intersectResDef );
if ( intersectResDef )
{
intersectResDef->updateConnectedEditors();
}
RimGridCrossPlotDataSet* crossPlotCurveSet = nullptr;
this->firstAncestorOrThisOfType( crossPlotCurveSet );
if ( crossPlotCurveSet )
@ -545,6 +558,15 @@ void RimEclipseResultDefinition::loadDataAndUpdate()
}
}
RimIntersectionResultDefinition* sepIntersectionResDef = nullptr;
this->firstAncestorOrThisOfType( sepIntersectionResDef );
if ( sepIntersectionResDef && sepIntersectionResDef->isInAction() )
{
if ( view ) view->scheduleCreateDisplayModelAndRedraw();
RimGridView* gridView = dynamic_cast<RimGridView*>( view );
if ( gridView ) gridView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
}
RimCellEdgeColors* cellEdgeColors = nullptr;
this->firstAncestorOrThisOfType( cellEdgeColors );
if ( cellEdgeColors )
@ -1222,7 +1244,7 @@ void RimEclipseResultDefinition::setResultVariable( const QString& val )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFlowDiagSolution* RimEclipseResultDefinition::flowDiagSolution()
RimFlowDiagSolution* RimEclipseResultDefinition::flowDiagSolution() const
{
return m_flowSolution();
}
@ -1668,6 +1690,320 @@ void RimEclipseResultDefinition::setTernaryEnabled( bool enabled )
m_ternaryEnabled = enabled;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool operator<( const cvf::Color3ub first, const cvf::Color3ub second )
{
if ( first.r() != second.r() ) return first.r() < second.r();
if ( first.g() != second.g() ) return first.g() < second.g();
if ( first.b() != second.b() ) return first.b() < second.b();
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class TupleCompare
{
public:
bool operator()( const std::tuple<QString, int, cvf::Color3ub>& t1,
const std::tuple<QString, int, cvf::Color3ub>& t2 ) const
{
using namespace std;
if ( get<0>( t1 ) != get<0>( t2 ) ) return get<0>( t1 ) < get<0>( t2 );
if ( get<1>( t1 ) != get<1>( t2 ) ) return get<1>( t1 ) < get<1>( t2 );
if ( get<2>( t1 ) != get<2>( t2 ) ) return get<2>( t1 ) < get<2>( t2 );
return false;
}
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegendConfig* legendConfigToUpdate,
RimTernaryLegendConfig* ternaryLegendConfigToUpdate,
int currentTimeStep )
{
RimEclipseCase* rimEclipseCase = this->eclipseCase();
if ( this->hasResult() )
{
if ( this->isFlowDiagOrInjectionFlooding() )
{
CVF_ASSERT( currentTimeStep >= 0 );
double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero;
RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults();
RigFlowDiagResultAddress resAddr = this->flowDiagResAddress();
flowResultsData->minMaxScalarValues( resAddr, currentTimeStep, &globalMin, &globalMax );
flowResultsData->posNegClosestToZero( resAddr,
currentTimeStep,
&globalPosClosestToZero,
&globalNegClosestToZero );
double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero;
if ( this->hasDynamicResult() )
{
flowResultsData->minMaxScalarValues( resAddr, currentTimeStep, &localMin, &localMax );
flowResultsData->posNegClosestToZero( resAddr,
currentTimeStep,
&localPosClosestToZero,
&localNegClosestToZero );
}
else
{
localMin = globalMin;
localMax = globalMax;
localPosClosestToZero = globalPosClosestToZero;
localNegClosestToZero = globalNegClosestToZero;
}
CVF_ASSERT( legendConfigToUpdate );
legendConfigToUpdate->disableAllTimeStepsRange( true );
legendConfigToUpdate->setClosestToZeroValues( globalPosClosestToZero,
globalNegClosestToZero,
localPosClosestToZero,
localNegClosestToZero );
legendConfigToUpdate->setAutomaticRanges( globalMin, globalMax, localMin, localMax );
if ( this->hasCategoryResult() )
{
RimEclipseView* eclView = nullptr;
this->firstAncestorOrThisOfType( eclView );
if ( eclView )
{
std::set<std::tuple<QString, int, cvf::Color3ub>, TupleCompare> categories;
std::vector<QString> tracerNames = this->flowDiagSolution()->tracerNames();
int tracerIndex = 0;
for ( const auto& tracerName : tracerNames )
{
cvf::Color3ub color( cvf::Color3::GRAY );
RimSimWellInView* well = eclView->wellCollection()->findWell(
RimFlowDiagSolution::removeCrossFlowEnding( tracerName ) );
if ( well ) color = cvf::Color3ub( well->wellPipeColor() );
categories.insert( std::make_tuple( tracerName, tracerIndex, color ) );
++tracerIndex;
}
std::vector<std::tuple<QString, int, cvf::Color3ub>> reverseCategories;
for ( auto tupIt = categories.rbegin(); tupIt != categories.rend(); ++tupIt )
{
reverseCategories.push_back( *tupIt );
}
legendConfigToUpdate->setCategoryItems( reverseCategories );
}
}
}
else
{
CVF_ASSERT( rimEclipseCase );
if ( !rimEclipseCase ) return;
RigEclipseCaseData* eclipseCaseData = rimEclipseCase->eclipseCaseData();
CVF_ASSERT( eclipseCaseData );
if ( !eclipseCaseData ) return;
RigCaseCellResultsData* cellResultsData = eclipseCaseData->results( this->porosityModel() );
CVF_ASSERT( cellResultsData );
double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero;
cellResultsData->minMaxCellScalarValues( this->eclipseResultAddress(), globalMin, globalMax );
cellResultsData->posNegClosestToZero( this->eclipseResultAddress(),
globalPosClosestToZero,
globalNegClosestToZero );
double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero;
if ( this->hasDynamicResult() && currentTimeStep >= 0 )
{
cellResultsData->minMaxCellScalarValues( this->eclipseResultAddress(), currentTimeStep, localMin, localMax );
cellResultsData->posNegClosestToZero( this->eclipseResultAddress(),
currentTimeStep,
localPosClosestToZero,
localNegClosestToZero );
}
else
{
localMin = globalMin;
localMax = globalMax;
localPosClosestToZero = globalPosClosestToZero;
localNegClosestToZero = globalNegClosestToZero;
}
CVF_ASSERT( legendConfigToUpdate );
legendConfigToUpdate->disableAllTimeStepsRange( false );
legendConfigToUpdate->setClosestToZeroValues( globalPosClosestToZero,
globalNegClosestToZero,
localPosClosestToZero,
localNegClosestToZero );
legendConfigToUpdate->setAutomaticRanges( globalMin, globalMax, localMin, localMax );
if ( this->hasCategoryResult() )
{
if ( this->resultType() == RiaDefines::FORMATION_NAMES )
{
const std::vector<QString>& fnVector = eclipseCaseData->activeFormationNames()->formationNames();
legendConfigToUpdate->setNamedCategoriesInverse( fnVector );
}
else if ( this->resultType() == RiaDefines::DYNAMIC_NATIVE &&
this->resultVariable() == RiaDefines::completionTypeResultName() )
{
const std::vector<int>& visibleCategories = cellResultsData->uniqueCellScalarValues(
this->eclipseResultAddress() );
std::vector<RiaDefines::WellPathComponentType> supportedCompletionTypes = {RiaDefines::WELL_PATH,
RiaDefines::FISHBONES,
RiaDefines::PERFORATION_INTERVAL,
RiaDefines::FRACTURE};
RiaColorTables::WellPathComponentColors colors = RiaColorTables::wellPathComponentColors();
std::vector<std::tuple<QString, int, cvf::Color3ub>> categories;
for ( auto completionType : supportedCompletionTypes )
{
if ( std::find( visibleCategories.begin(), visibleCategories.end(), completionType ) !=
visibleCategories.end() )
{
QString categoryText = caf::AppEnum<RiaDefines::WellPathComponentType>::uiText(
completionType );
categories.push_back(
std::make_tuple( categoryText, completionType, colors[completionType] ) );
}
}
legendConfigToUpdate->setCategoryItems( categories );
}
else
{
legendConfigToUpdate->setIntegerCategories(
cellResultsData->uniqueCellScalarValues( this->eclipseResultAddress() ) );
}
}
}
}
// Ternary legend update
{
CVF_ASSERT( rimEclipseCase );
if ( !rimEclipseCase ) return;
RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData();
CVF_ASSERT( eclipseCase );
if ( !eclipseCase ) return;
RigCaseCellResultsData* cellResultsData = eclipseCase->results( this->porosityModel() );
size_t maxTimeStepCount = cellResultsData->maxTimeStepCount();
if ( this->isTernarySaturationSelected() && maxTimeStepCount > 1 )
{
RigCaseCellResultsData* gridCellResults = this->currentGridCellResults();
{
RigEclipseResultAddress resAddr( RiaDefines::DYNAMIC_NATIVE, "SOIL" );
if ( gridCellResults->ensureKnownResultLoaded( resAddr ) )
{
double globalMin = 0.0;
double globalMax = 1.0;
double localMin = 0.0;
double localMax = 1.0;
cellResultsData->minMaxCellScalarValues( resAddr, globalMin, globalMax );
cellResultsData->minMaxCellScalarValues( resAddr, currentTimeStep, localMin, localMax );
ternaryLegendConfigToUpdate->setAutomaticRanges( RimTernaryLegendConfig::TERNARY_SOIL_IDX,
globalMin,
globalMax,
localMin,
localMax );
}
}
{
RigEclipseResultAddress resAddr( RiaDefines::DYNAMIC_NATIVE, "SGAS" );
if ( gridCellResults->ensureKnownResultLoaded( resAddr ) )
{
double globalMin = 0.0;
double globalMax = 1.0;
double localMin = 0.0;
double localMax = 1.0;
cellResultsData->minMaxCellScalarValues( resAddr, globalMin, globalMax );
cellResultsData->minMaxCellScalarValues( resAddr, currentTimeStep, localMin, localMax );
ternaryLegendConfigToUpdate->setAutomaticRanges( RimTernaryLegendConfig::TERNARY_SGAS_IDX,
globalMin,
globalMax,
localMin,
localMax );
}
}
{
RigEclipseResultAddress resAddr( RiaDefines::DYNAMIC_NATIVE, "SWAT" );
if ( gridCellResults->ensureKnownResultLoaded( resAddr ) )
{
double globalMin = 0.0;
double globalMax = 1.0;
double localMin = 0.0;
double localMax = 1.0;
cellResultsData->minMaxCellScalarValues( resAddr, globalMin, globalMax );
cellResultsData->minMaxCellScalarValues( resAddr, currentTimeStep, localMin, localMax );
ternaryLegendConfigToUpdate->setAutomaticRanges( RimTernaryLegendConfig::TERNARY_SWAT_IDX,
globalMin,
globalMax,
localMin,
localMax );
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseResultDefinition::updateLegendTitle( RimRegularLegendConfig* legendConfig, const QString& legendHeading )
{
QString title = legendHeading + this->resultVariableUiName();
if ( !this->diffResultUiShortName().isEmpty() )
{
title += QString( "\n%1" ).arg( this->diffResultUiShortName() );
}
if ( this->hasDualPorFractureResult() )
{
QString porosityModelText = caf::AppEnum<RiaDefines::PorosityModelType>::uiText( this->porosityModel() );
title += QString( "\nDual Por : %1" ).arg( porosityModelText );
}
legendConfig->setTitle( title );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -41,6 +41,8 @@ class RigCaseCellResultsData;
class RimEclipseCase;
class RimEclipseView;
class RimReservoirCellResultsStorage;
class RimRegularLegendConfig;
class RimTernaryLegendConfig;
//==================================================================================================
///
@ -75,7 +77,7 @@ public:
void simpleCopy( const RimEclipseResultDefinition* other );
void setEclipseCase( RimEclipseCase* eclipseCase );
RimEclipseCase* eclipseCase();
RimEclipseCase* eclipseCase() const;
RiaDefines::ResultCatType resultType() const
{
@ -94,7 +96,7 @@ public:
virtual void setResultVariable( const QString& val );
void setFlowSolution( RimFlowDiagSolution* flowSol );
RimFlowDiagSolution* flowDiagSolution();
RimFlowDiagSolution* flowDiagSolution() const;
RigFlowDiagResultAddress flowDiagResAddress() const;
void setFlowDiagTracerSelectionType( FlowTracerSelectionType selectionType );
@ -145,6 +147,11 @@ public:
void setTernaryEnabled( bool enabled );
void updateRangesForExplicitLegends( RimRegularLegendConfig* legendConfig,
RimTernaryLegendConfig* ternaryLegendConfig,
int currentTimeStep );
void updateLegendTitle( RimRegularLegendConfig* legendConfig, const QString& legendHeading );
protected:
virtual void updateLegendCategorySettings(){};

View File

@ -55,10 +55,14 @@
#include "RimFlowDiagSolution.h"
#include "RimFracture.h"
#include "RimFractureTemplateCollection.h"
#include "RimGeoMechResultDefinition.h"
#include "RimGridCollection.h"
#include "RimGridCrossPlotDataSet.h"
#include "RimGridView.h"
#include "RimIntersection.h"
#include "RimIntersectionCollection.h"
#include "RimIntersectionResultDefinition.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimRegularLegendConfig.h"
@ -790,9 +794,7 @@ void RimEclipseView::updateVisibleGeometriesAndCellColors()
if ( ( this->hasUserRequestedAnimation() && this->cellResult()->hasResult() ) ||
this->cellResult()->isTernarySaturationSelected() )
{
m_crossSectionCollection->updateCellResultColor( m_currentTimeStep,
this->cellResult()->legendConfig()->scalarMapper(),
this->cellResult()->ternaryLegendConfig()->scalarMapper() );
m_crossSectionCollection->updateCellResultColor( m_currentTimeStep );
}
else
{
@ -1200,11 +1202,25 @@ void RimEclipseView::onUpdateLegends()
RigCaseCellResultsData* results = eclipseCase->results( cellResult()->porosityModel() );
CVF_ASSERT( results );
updateMinMaxValuesAndAddLegendToView( QString( "Cell Results: \n" ), this->cellResult(), results );
updateLegendRangesTextAndVisibility( this->cellResult()->legendConfig(),
this->cellResult()->ternaryLegendConfig(),
QString( "Cell Results: \n" ),
this->cellResult(),
m_currentTimeStep );
if ( this->faultResultSettings()->showCustomFaultResult() && this->faultResultSettings()->hasValidCustomResult() )
{
updateMinMaxValuesAndAddLegendToView( QString( "Fault Results: \n" ), this->currentFaultResultColors(), results );
updateLegendRangesTextAndVisibility( currentFaultResultColors()->legendConfig(),
currentFaultResultColors()->ternaryLegendConfig(),
QString( "Fault Results: \n" ),
this->currentFaultResultColors(),
m_currentTimeStep );
}
for ( RimIntersectionResultDefinition* sepInterResDef :
this->separateIntersectionResultsCollection()->intersectionResultsDefinitions() )
{
sepInterResDef->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), isUsingOverrideViewer() );
}
if ( this->cellEdgeResult()->legendConfig()->showLegend() )
@ -1213,7 +1229,7 @@ void RimEclipseView::onUpdateLegends()
{
if ( this->cellEdgeResult()->isUsingSingleVariable() )
{
this->cellEdgeResult()->singleVarEdgeResultColors()->updateLegendData( m_eclipseCase, m_currentTimeStep );
this->cellEdgeResult()->singleVarEdgeResultColors()->updateRangesForEmbeddedLegends( m_currentTimeStep );
}
else
{
@ -1300,43 +1316,30 @@ void RimEclipseView::onUpdateLegends()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseView::updateMinMaxValuesAndAddLegendToView( QString legendLabel,
RimEclipseCellColors* resultColors,
RigCaseCellResultsData* cellResultsData )
void RimEclipseView::updateLegendRangesTextAndVisibility( RimRegularLegendConfig* legendConfig,
RimTernaryLegendConfig* ternaryLegendConfig,
QString legendHeading,
RimEclipseResultDefinition* eclResultDef,
int timeStepIndex )
{
resultColors->updateLegendData( m_eclipseCase, m_currentTimeStep );
eclResultDef->updateRangesForExplicitLegends( legendConfig, ternaryLegendConfig, timeStepIndex );
if ( resultColors->hasResult() && resultColors->legendConfig()->showLegend() )
if ( eclResultDef->hasResult() && legendConfig->showLegend() )
{
QString title = legendLabel + resultColors->resultVariableUiName();
if ( !resultColors->diffResultUiShortName().isEmpty() )
{
title += QString( "\n%1" ).arg( resultColors->diffResultUiShortName() );
}
eclResultDef->updateLegendTitle( legendConfig, legendHeading );
if ( resultColors->hasDualPorFractureResult() )
{
QString porosityModelText = caf::AppEnum<RiaDefines::PorosityModelType>::uiText(
resultColors->porosityModel() );
title += QString( "\nDual Por : %1" ).arg( porosityModelText );
}
resultColors->legendConfig()->setTitle( title );
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( resultColors->legendConfig()->titledOverlayFrame(),
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( legendConfig->titledOverlayFrame(),
isUsingOverrideViewer() );
}
size_t maxTimeStepCount = cellResultsData->maxTimeStepCount();
if ( resultColors->isTernarySaturationSelected() && maxTimeStepCount > 1 )
size_t maxTimeStepCount = eclResultDef->currentGridCellResults()->maxTimeStepCount();
if ( eclResultDef->isTernarySaturationSelected() && maxTimeStepCount > 1 )
{
if ( resultColors->ternaryLegendConfig()->showLegend() &&
resultColors->ternaryLegendConfig()->titledOverlayFrame() )
if ( ternaryLegendConfig->showLegend() && ternaryLegendConfig->titledOverlayFrame() )
{
resultColors->ternaryLegendConfig()->setTitle( legendLabel );
nativeOrOverrideViewer()
->addColorLegendToBottomLeftCorner( resultColors->ternaryLegendConfig()->titledOverlayFrame(),
isUsingOverrideViewer() );
ternaryLegendConfig->setTitle( legendHeading );
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( ternaryLegendConfig->titledOverlayFrame(),
isUsingOverrideViewer() );
}
}
}
@ -1714,6 +1717,7 @@ void RimEclipseView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
uiTreeOrdering.add( cellResult() );
uiTreeOrdering.add( cellEdgeResult() );
uiTreeOrdering.add( faultResultSettings() );
uiTreeOrdering.add( &m_intersectionResultDefCollection );
uiTreeOrdering.add( wellCollection() );
{
@ -1845,6 +1849,13 @@ void RimEclipseView::onResetLegendsInViewer()
this->cellResult()->ternaryLegendConfig()->recreateLegend();
this->cellEdgeResult()->legendConfig()->recreateLegend();
for ( RimIntersectionResultDefinition* sepInterResDef :
this->separateIntersectionResultsCollection()->intersectionResultsDefinitions() )
{
sepInterResDef->regularLegendConfig()->recreateLegend();
sepInterResDef->ternaryLegendConfig()->recreateLegend();
}
nativeOrOverrideViewer()->removeAllColorLegends();
}
@ -1996,6 +2007,13 @@ std::vector<RimLegendConfig*> RimEclipseView::legendConfigs() const
absLegends.push_back( fractureColors()->activeLegend() );
absLegends.push_back( virtualPerforationResult()->legendConfig() );
for ( RimIntersectionResultDefinition* sepInterResDef :
this->separateIntersectionResultsCollection()->intersectionResultsDefinitions() )
{
absLegends.push_back( sepInterResDef->regularLegendConfig() );
absLegends.push_back( sepInterResDef->ternaryLegendConfig() );
}
return absLegends;
}

View File

@ -59,6 +59,9 @@ class RiuViewer;
class RivReservoirSimWellsPartMgr;
class RivIntersectionPartMgr;
class RivReservoirViewPartMgr;
class RimRegularLegendConfig;
class RimTernaryLegendConfig;
class RimEclipseResultDefinition;
namespace cvf
{
@ -176,9 +179,12 @@ private:
void updateStaticCellColors( RivCellSetEnum geometryType );
void onUpdateLegends() override;
void updateMinMaxValuesAndAddLegendToView( QString legendLabel,
RimEclipseCellColors* resultColors,
RigCaseCellResultsData* cellResultsData );
void updateLegendRangesTextAndVisibility( RimRegularLegendConfig* legendConfig,
RimTernaryLegendConfig* ternaryLegendConfig,
QString legendLabel,
RimEclipseResultDefinition* eclResDef,
int timeStepIndex );
void onResetLegendsInViewer() override;
void updateVirtualConnectionLegendRanges();

View File

@ -26,6 +26,7 @@
#include "RigFemPartGrid.h"
#include "RigFemPartResultsCollection.h"
#include "RigFemResultAddress.h"
#include "RigFormationNames.h"
#include "RigGeoMechCaseData.h"
#include "RiaDefines.h"
@ -37,6 +38,7 @@
#include "RimGeoMechView.h"
#include "RimIntersectionCollection.h"
#include "RimPlotCurve.h"
#include "RimRegularLegendConfig.h"
#include "RimViewLinker.h"
#include "cafPdmUiListEditor.h"
@ -576,9 +578,9 @@ QString RimGeoMechResultDefinition::diffResultUiShortName() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigGeoMechCaseData* RimGeoMechResultDefinition::ownerCaseData()
RigGeoMechCaseData* RimGeoMechResultDefinition::ownerCaseData() const
{
return m_geomCase->geoMechData();
return m_geomCase ? m_geomCase->geoMechData() : nullptr;
}
//--------------------------------------------------------------------------------------------------
@ -601,7 +603,7 @@ bool RimGeoMechResultDefinition::hasResult()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimGeoMechResultDefinition::resultFieldUiName()
QString RimGeoMechResultDefinition::resultFieldUiName() const
{
return convertToUiResultFieldName( m_resultFieldName() );
}
@ -609,7 +611,7 @@ QString RimGeoMechResultDefinition::resultFieldUiName()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimGeoMechResultDefinition::resultComponentUiName()
QString RimGeoMechResultDefinition::resultComponentUiName() const
{
return m_resultComponentName();
}
@ -647,3 +649,77 @@ void RimGeoMechResultDefinition::setResultAddress( const RigFemResultAddress& re
m_resultVariableUiField = composeFieldCompString( m_resultFieldName(), m_resultComponentName() );
m_compactionRefLayerUiField = m_compactionRefLayer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechResultDefinition::updateLegendTextAndRanges( RimRegularLegendConfig* legendConfigToUpdate,
const QString& legendHeading,
int timeStepIndex )
{
if ( !this->ownerCaseData() || !( this->resultAddress().isValid() ) )
{
return;
}
double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero;
double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero;
RigGeoMechCaseData* gmCase = this->ownerCaseData();
CVF_ASSERT( gmCase );
RigFemResultAddress resVarAddress = this->resultAddress();
gmCase->femPartResults()->minMaxScalarValues( resVarAddress, timeStepIndex, &localMin, &localMax );
gmCase->femPartResults()->posNegClosestToZero( resVarAddress,
timeStepIndex,
&localPosClosestToZero,
&localNegClosestToZero );
gmCase->femPartResults()->minMaxScalarValues( resVarAddress, &globalMin, &globalMax );
gmCase->femPartResults()->posNegClosestToZero( resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero );
legendConfigToUpdate->setClosestToZeroValues( globalPosClosestToZero,
globalNegClosestToZero,
localPosClosestToZero,
localNegClosestToZero );
legendConfigToUpdate->setAutomaticRanges( globalMin, globalMax, localMin, localMax );
if ( this->hasCategoryResult() )
{
std::vector<QString> fnVector;
if ( gmCase->femPartResults()->activeFormationNames() )
{
fnVector = gmCase->femPartResults()->activeFormationNames()->formationNames();
}
legendConfigToUpdate->setNamedCategoriesInverse( fnVector );
}
QString legendTitle = legendHeading + caf::AppEnum<RigFemResultPosEnum>( this->resultPositionType() ).uiText() +
"\n" + this->resultFieldUiName();
if ( !this->resultComponentUiName().isEmpty() )
{
legendTitle += ", " + this->resultComponentUiName();
}
if ( this->resultFieldName() == "SE" || this->resultFieldName() == "ST" || this->resultFieldName() == "POR-Bar" ||
this->resultFieldName() == "SM" || this->resultFieldName() == "SEM" || this->resultFieldName() == "Q" )
{
legendTitle += " [Bar]";
}
if ( this->resultFieldName() == "MODULUS" )
{
legendTitle += " [GPa]";
}
if ( !this->diffResultUiShortName().isEmpty() )
{
legendTitle += QString( "\nTime Diff:\n%1" ).arg( this->diffResultUiShortName() );
}
legendConfigToUpdate->setTitle( legendTitle );
}

View File

@ -32,6 +32,7 @@ class RimGeoMechPropertyFilter;
class RifGeoMechReaderInterface;
class RigGeoMechCaseData;
class RimGeoMechCase;
class RimRegularLegendConfig;
//==================================================================================================
///
@ -47,7 +48,7 @@ public:
void setGeoMechCase( RimGeoMechCase* geomCase );
RigGeoMechCaseData* ownerCaseData();
RigGeoMechCaseData* ownerCaseData() const;
bool hasResult();
void loadResult();
void setAddWellPathDerivedResults( bool addWellPathDerivedResults );
@ -62,18 +63,24 @@ public:
QString diffResultUiShortName() const;
void setResultAddress( const RigFemResultAddress& resultAddress );
QString resultFieldUiName();
QString resultComponentUiName();
QString resultFieldUiName() const;
QString resultComponentUiName() const;
bool hasCategoryResult()
bool hasCategoryResult() const
{
return m_resultPositionType() == RIG_FORMATION_NAMES;
}
void updateLegendTextAndRanges( RimRegularLegendConfig* legendConfigToUpdate,
const QString& legendHeading,
int timeStepIndex );
protected:
virtual void updateLegendCategorySettings(){};
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
friend class RimIntersectionResultDefinition;
private:
// Overridden PDM methods

View File

@ -32,14 +32,18 @@
#include "Rim3dOverlayInfoConfig.h"
#include "RimCellRangeFilterCollection.h"
#include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechPropertyFilterCollection.h"
#include "RimGridCollection.h"
#include "RimIntersectionCollection.h"
#include "RimIntersectionResultDefinition.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "RimRegularLegendConfig.h"
#include "RimTensorResults.h"
#include "RimTernaryLegendConfig.h"
#include "RimViewLinker.h"
#include "RimViewNameConfig.h"
@ -286,6 +290,7 @@ void RimGeoMechView::onCreateDisplayModel()
// Cross sections
m_crossSectionVizModel->removeAllParts();
m_crossSectionCollection->rebuildGeometry();
m_crossSectionCollection->appendPartsToModel( *this, m_crossSectionVizModel.p(), scaleTransform() );
nativeOrOverrideViewer()->addStaticModelOnce( m_crossSectionVizModel.p(), isUsingOverrideViewer() );
@ -379,9 +384,7 @@ void RimGeoMechView::onUpdateDisplayModelForCurrentTimeStep()
if ( this->cellResult()->hasResult() )
{
m_crossSectionCollection->updateCellResultColor( m_currentTimeStep,
this->cellResult()->legendConfig()->scalarMapper(),
nullptr );
m_crossSectionCollection->updateCellResultColor( m_currentTimeStep );
}
else
{
@ -423,6 +426,13 @@ void RimGeoMechView::onResetLegendsInViewer()
{
this->cellResult()->legendConfig->recreateLegend();
for ( RimIntersectionResultDefinition* sepInterResDef :
this->separateIntersectionResultsCollection()->intersectionResultsDefinitions() )
{
sepInterResDef->regularLegendConfig()->recreateLegend();
sepInterResDef->ternaryLegendConfig()->recreateLegend();
}
nativeOrOverrideViewer()->removeAllColorLegends();
}
@ -455,6 +465,12 @@ void RimGeoMechView::onUpdateLegends()
isUsingOverrideViewer() );
}
for ( RimIntersectionResultDefinition* sepInterResDef :
this->separateIntersectionResultsCollection()->intersectionResultsDefinitions() )
{
sepInterResDef->updateLegendRangesTextAndVisibility( nativeOrOverrideViewer(), isUsingOverrideViewer() );
}
if ( tensorResults()->showTensors() )
{
updateTensorLegendTextAndRanges( m_tensorResults->arrowColorLegendConfig(), m_currentTimeStep() );
@ -520,74 +536,12 @@ void RimGeoMechView::updateTensorLegendTextAndRanges( RimRegularLegendConfig* le
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::updateLegendTextAndRanges( RimRegularLegendConfig* legendConfig, int timeStepIndex )
{
if ( !m_geomechCase || !m_geomechCase->geoMechData() || !this->isTimeStepDependentDataVisible() ||
!( cellResult()->resultAddress().isValid() ) )
if ( !this->isTimeStepDependentDataVisible() )
{
return;
}
double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero;
double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero;
RigGeoMechCaseData* gmCase = m_geomechCase->geoMechData();
CVF_ASSERT( gmCase );
RigFemResultAddress resVarAddress = cellResult()->resultAddress();
gmCase->femPartResults()->minMaxScalarValues( resVarAddress, timeStepIndex, &localMin, &localMax );
gmCase->femPartResults()->posNegClosestToZero( resVarAddress,
timeStepIndex,
&localPosClosestToZero,
&localNegClosestToZero );
gmCase->femPartResults()->minMaxScalarValues( resVarAddress, &globalMin, &globalMax );
gmCase->femPartResults()->posNegClosestToZero( resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero );
legendConfig->setClosestToZeroValues( globalPosClosestToZero,
globalNegClosestToZero,
localPosClosestToZero,
localNegClosestToZero );
legendConfig->setAutomaticRanges( globalMin, globalMax, localMin, localMax );
if ( cellResult()->hasCategoryResult() )
{
std::vector<QString> fnVector;
if ( gmCase->femPartResults()->activeFormationNames() )
{
fnVector = gmCase->femPartResults()->activeFormationNames()->formationNames();
}
legendConfig->setNamedCategoriesInverse( fnVector );
}
QString legendTitle = "Cell Results:\n" +
caf::AppEnum<RigFemResultPosEnum>( cellResult->resultPositionType() ).uiText() + "\n" +
cellResult->resultFieldUiName();
if ( !cellResult->resultComponentUiName().isEmpty() )
{
legendTitle += ", " + cellResult->resultComponentUiName();
}
if ( cellResult->resultFieldName() == "SE" || cellResult->resultFieldName() == "ST" ||
cellResult->resultFieldName() == "POR-Bar" || cellResult->resultFieldName() == "SM" ||
cellResult->resultFieldName() == "SEM" || cellResult->resultFieldName() == "Q" )
{
legendTitle += " [Bar]";
}
if ( cellResult->resultFieldName() == "MODULUS" )
{
legendTitle += " [GPa]";
}
if ( !cellResult->diffResultUiShortName().isEmpty() )
{
legendTitle += QString( "\nTime Diff:\n%1" ).arg( cellResult->diffResultUiShortName() );
}
legendConfig->setTitle( legendTitle );
cellResult()->updateLegendTextAndRanges( legendConfig, "Cell Result:\n", timeStepIndex );
}
//--------------------------------------------------------------------------------------------------
@ -624,6 +578,12 @@ std::vector<RimLegendConfig*> RimGeoMechView::legendConfigs() const
absLegendConfigs.push_back( cellResult()->legendConfig() );
absLegendConfigs.push_back( tensorResults()->arrowColorLegendConfig() );
for ( RimIntersectionResultDefinition* sepInterResDef :
this->separateIntersectionResultsCollection()->intersectionResultsDefinitions() )
{
absLegendConfigs.push_back( sepInterResDef->regularLegendConfig() );
}
return absLegendConfigs;
}
@ -946,6 +906,7 @@ void RimGeoMechView::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
uiTreeOrdering.add( cellResult() );
uiTreeOrdering.add( m_tensorResults() );
uiTreeOrdering.add( &m_intersectionResultDefCollection );
uiTreeOrdering.add( m_crossSectionCollection() );

View File

@ -25,6 +25,7 @@
#include "RimCellRangeFilterCollection.h"
#include "RimGridCollection.h"
#include "RimIntersectionCollection.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "RimProject.h"
#include "RimPropertyFilterCollection.h"
#include "RimTextAnnotation.h"
@ -65,6 +66,15 @@ RimGridView::RimGridView()
m_crossSectionCollection.uiCapability()->setUiHidden( true );
m_crossSectionCollection = new RimIntersectionCollection();
CAF_PDM_InitFieldNoDefault( &m_intersectionResultDefCollection,
"IntersectionResultDefColl",
"Separate Intersection Results",
"",
"",
"" );
m_intersectionResultDefCollection.uiCapability()->setUiTreeHidden( true );
m_intersectionResultDefCollection = new RimIntersectionResultsDefinitionCollection;
CAF_PDM_InitFieldNoDefault( &m_gridCollection, "GridCollection", "GridCollection", "", "", "" );
m_gridCollection.uiCapability()->setUiHidden( true );
m_gridCollection = new RimGridCollection();
@ -151,6 +161,14 @@ RimIntersectionCollection* RimGridView::crossSectionCollection() const
return m_crossSectionCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIntersectionResultsDefinitionCollection* RimGridView::separateIntersectionResultsCollection() const
{
return m_intersectionResultDefCollection;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -26,6 +26,7 @@ class RimAnnotationInViewCollection;
class RimEclipseContourMapProjection;
class Rim3dOverlayInfoConfig;
class RimIntersectionCollection;
class RimIntersectionResultsDefinitionCollection;
class RimPropertyFilterCollection;
class RimGridCollection;
class RimCellRangeFilterCollection;
@ -44,15 +45,14 @@ public:
cvf::ref<cvf::UByteArray> currentTotalCellVisibility();
RimIntersectionCollection* crossSectionCollection() const;
RimIntersectionCollection* crossSectionCollection() const;
RimIntersectionResultsDefinitionCollection* separateIntersectionResultsCollection() const;
RimAnnotationInViewCollection* annotationCollection() const;
virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0;
void rangeFiltersUpdated();
RimCellRangeFilterCollection* rangeFilterCollection();
const RimCellRangeFilterCollection* rangeFilterCollection() const;
RimAnnotationInViewCollection* annotationCollection() const;
void rangeFiltersUpdated();
RimCellRangeFilterCollection* rangeFilterCollection();
const RimCellRangeFilterCollection* rangeFilterCollection() const;
bool hasOverridenRangeFilterCollection();
void setOverrideRangeFilterCollection( RimCellRangeFilterCollection* rfc );
@ -70,22 +70,23 @@ public:
bool forceChange = false ) override;
protected:
virtual void updateViewFollowingRangeFilterUpdates();
void initAfterRead() override;
void onClearReservoirCellVisibilitiesIfNeccessary() override;
virtual void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStep ) = 0;
void selectOverlayInfoConfig() override;
virtual void updateViewFollowingRangeFilterUpdates();
void onClearReservoirCellVisibilitiesIfNeccessary() override;
virtual void calculateCurrentTotalCellVisibility( cvf::UByteArray* totalVisibility, int timeStep ) = 0;
void selectOverlayInfoConfig() override;
RimGridCollection* gridCollection() const;
void clearReservoirCellVisibilities();
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue ) override;
RimGridCollection* gridCollection() const;
void clearReservoirCellVisibilities();
void initAfterRead() override;
protected: // Fields
caf::PdmChildField<RimIntersectionCollection*> m_crossSectionCollection;
caf::PdmChildField<RimIntersectionCollection*> m_crossSectionCollection;
caf::PdmChildField<RimIntersectionResultsDefinitionCollection*> m_intersectionResultDefCollection;
caf::PdmChildField<Rim3dOverlayInfoConfig*> m_overlayInfoConfig;
caf::PdmChildField<RimCellRangeFilterCollection*> m_rangeFilterCollection;
caf::PdmChildField<RimCellRangeFilterCollection*> m_overrideRangeFilterCollection;

View File

@ -45,6 +45,9 @@
#include "cafPdmUiPushButtonEditor.h"
#include "Rim2dIntersectionView.h"
#include "RimGridView.h"
#include "RimIntersectionResultDefinition.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "cvfBoundingBox.h"
#include "cvfGeometryTools.h"
#include "cvfPlane.h"
@ -81,10 +84,6 @@ RimIntersection::RimIntersection()
{
CAF_PDM_InitObject( "Intersection", ":/CrossSection16x16.png", "", "" );
CAF_PDM_InitField( &name, "UserDescription", QString( "Intersection Name" ), "Name", "", "", "" );
CAF_PDM_InitField( &isActive, "Active", true, "Active", "", "", "" );
isActive.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &type, "Type", "Type", "", "", "" );
CAF_PDM_InitFieldNoDefault( &direction, "Direction", "Direction", "", "", "" );
CAF_PDM_InitFieldNoDefault( &wellPath, "WellPath", "Well Path ", "", "", "" );
@ -110,8 +109,6 @@ RimIntersection::RimIntersection()
CAF_PDM_InitField( &m_lengthUp, "lengthUp", 1000.0, "Length Up", "", "", "" );
CAF_PDM_InitField( &m_lengthDown, "lengthDown", 1000.0, "Length Down", "", "", "" );
CAF_PDM_InitField( &showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells", "", "", "" );
CAF_PDM_InitFieldNoDefault( &inputPolyLineFromViewerEnabled, "m_activateUiAppendPointsCommand", "", "", "", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &inputPolyLineFromViewerEnabled );
inputPolyLineFromViewerEnabled = false;
@ -149,14 +146,25 @@ void RimIntersection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
if ( changedField == &isActive || changedField == &type || changedField == &direction || changedField == &wellPath ||
changedField == &simulationWell || changedField == &m_branchIndex || changedField == &m_extentLength ||
changedField == &m_lengthUp || changedField == &m_lengthDown || changedField == &showInactiveCells )
// clang-format off
if ( changedField == &m_isActive ||
changedField == &type ||
changedField == &direction ||
changedField == &wellPath ||
changedField == &simulationWell ||
changedField == &m_branchIndex ||
changedField == &m_extentLength ||
changedField == &m_lengthUp ||
changedField == &m_lengthDown ||
changedField == &m_showInactiveCells ||
changedField == &m_useSeparateDataSource ||
changedField == &m_separateDataSource )
{
rebuildGeometryAndScheduleCreateDisplayModel();
}
// clang-format on
if ( changedField == &simulationWell || changedField == &isActive || changedField == &type )
if ( changedField == &simulationWell || changedField == &m_isActive || changedField == &type )
{
recomputeSimulationWellBranchData();
}
@ -166,7 +174,7 @@ void RimIntersection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
updateName();
}
if ( changedField == &name )
if ( changedField == &m_name )
{
Rim2dIntersectionView* iView = correspondingIntersectionView();
if ( iView )
@ -226,7 +234,7 @@ void RimIntersection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
//--------------------------------------------------------------------------------------------------
void RimIntersection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &name );
uiOrdering.add( &m_name );
caf::PdmUiGroup* geometryGroup = uiOrdering.addNewGroup( "Intersecting Geometry" );
geometryGroup->add( &type );
@ -275,7 +283,7 @@ void RimIntersection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
optionsGroup->add( &inputExtrusionPointsFromViewerEnabled );
}
optionsGroup->add( &showInactiveCells );
optionsGroup->add( &m_showInactiveCells );
if ( type == CS_POLYLINE )
{
@ -286,6 +294,8 @@ void RimIntersection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
m_extentLength.uiCapability()->setUiReadOnly( false );
}
this->defineSeparateDataSourceUi( uiConfigName, uiOrdering );
updateWellExtentDefaultValue();
uiOrdering.skipRemainingFields( true );
@ -340,25 +350,14 @@ QList<caf::PdmOptionItemInfo> RimIntersection::calculateValueOptions( const caf:
options.push_back( caf::PdmOptionItemInfo( QString::number( bIdx + 1 ), QVariant::fromValue( bIdx ) ) );
}
}
else
{
options = RimIntersectionHandle::calculateValueOptions( fieldNeedingOptions, useOptionsOnly );
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimIntersection::userDescriptionField()
{
return &name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimIntersection::objectToggleField()
{
return &isActive;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -521,7 +520,7 @@ std::vector<cvf::Vec3d> RimIntersection::polyLinesForExtrusionDirection() const
//--------------------------------------------------------------------------------------------------
void RimIntersection::updateSimulationWellCenterline() const
{
if ( isActive() && type == CS_SIMULATION_WELL && simulationWell() )
if ( m_isActive() && type == CS_SIMULATION_WELL && simulationWell() )
{
if ( m_simulationWellBranchCenterlines.empty() )
{
@ -619,15 +618,15 @@ void RimIntersection::updateName()
{
if ( type == CS_SIMULATION_WELL && simulationWell() )
{
name = simulationWell()->name();
m_name = simulationWell()->name();
if ( branchIndex() != -1 )
{
name = name() + " Branch " + QString::number( branchIndex() + 1 );
m_name = m_name() + " Branch " + QString::number( branchIndex() + 1 );
}
}
else if ( type() == CS_WELL_PATH && wellPath() )
{
name = wellPath()->name();
m_name = wellPath()->name();
}
Rim2dIntersectionView* iView = correspondingIntersectionView();

View File

@ -27,9 +27,11 @@
#include "cvfObject.h"
#include "cvfVector3.h"
#include "RimIntersectionHandle.h"
class RimWellPath;
class RivIntersectionPartMgr;
class RimIntersectionResultDefinition;
class RimSimWellInView;
class RimSimWellInViewCollection;
class Rim2dIntersectionView;
@ -45,7 +47,7 @@ class PdmUiPushButtonEditorAttribute;
//
//
//==================================================================================================
class RimIntersection : public caf::PdmObject
class RimIntersection : public RimIntersectionHandle
{
CAF_PDM_HEADER_INIT;
@ -69,12 +71,8 @@ public:
RimIntersection();
~RimIntersection() override;
caf::PdmField<QString> name;
caf::PdmField<bool> isActive;
caf::PdmField<caf::AppEnum<CrossSectionEnum>> type;
caf::PdmField<caf::AppEnum<CrossSectionDirEnum>> direction;
caf::PdmField<bool> showInactiveCells;
caf::PdmPtrField<RimWellPath*> wellPath;
caf::PdmPtrField<RimSimWellInView*> simulationWell;
@ -108,22 +106,16 @@ public:
void rebuildGeometryAndScheduleCreateDisplayModel();
protected:
caf::PdmFieldHandle* userDescriptionField() override;
caf::PdmFieldHandle* objectToggleField() override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
private:
private:
caf::PdmField<int> m_branchIndex;
caf::PdmField<double> m_extentLength;

View File

@ -55,10 +55,6 @@ RimIntersectionBox::RimIntersectionBox()
{
CAF_PDM_InitObject( "Intersection Box", ":/IntersectionBox16x16.png", "", "" );
CAF_PDM_InitField( &name, "UserDescription", QString( "Intersection Name" ), "Name", "", "", "" );
CAF_PDM_InitField( &isActive, "Active", true, "Active", "", "", "" );
isActive.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_singlePlaneState,
"singlePlaneState",
caf::AppEnum<SinglePlaneState>( SinglePlaneState::PLANE_STATE_NONE ),
@ -85,7 +81,6 @@ RimIntersectionBox::RimIntersectionBox()
CAF_PDM_InitField( &m_maxDepth, "MaxDepth", 0.0, "Max", "", "", "" );
m_maxDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells", "", "", "" );
CAF_PDM_InitField( &m_xySliderStepSize, "xySliderStepSize", 1.0, "XY Slider Step Size", "", "", "" );
CAF_PDM_InitField( &m_depthSliderStepSize, "DepthSliderStepSize", 0.5, "Depth Slider Step Size", "", "", "" );
@ -355,7 +350,7 @@ void RimIntersectionBox::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
}
}
if ( changedField != &name )
if ( changedField != &m_name )
{
rebuildGeometryAndScheduleCreateDisplayModel();
}
@ -444,12 +439,12 @@ void RimIntersectionBox::defineEditorAttribute( const caf::PdmFieldHandle* field
//--------------------------------------------------------------------------------------------------
void RimIntersectionBox::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &name );
uiOrdering.add( &m_name );
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Options" );
group->add( &m_singlePlaneState );
group->add( &showInactiveCells );
group->add( &m_showInactiveCells );
}
cvf::BoundingBox cellsBoundingBox = currentCellBoundingBox();
@ -482,6 +477,8 @@ void RimIntersectionBox::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder
}
uiOrdering.add( &m_show3DManipulator );
this->defineSeparateDataSourceUi(uiConfigName, uiOrdering);
}
//--------------------------------------------------------------------------------------------------
@ -489,6 +486,7 @@ void RimIntersectionBox::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder
//--------------------------------------------------------------------------------------------------
void RimIntersectionBox::initAfterRead()
{
RimIntersectionHandle::initAfterRead();
updateVisibility();
}
@ -524,21 +522,6 @@ void RimIntersectionBox::slotUpdateGeometry( const cvf::Vec3d& origin, const cvf
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimIntersectionBox::userDescriptionField()
{
return &name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimIntersectionBox::objectToggleField()
{
return &isActive;
}
//--------------------------------------------------------------------------------------------------
///

View File

@ -21,6 +21,8 @@
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RimIntersectionHandle.h"
#include "cvfBoundingBox.h"
#include "cvfVector3.h"
@ -41,7 +43,7 @@ class ModelBasicList;
//
//
//==================================================================================================
class RimIntersectionBox : public QObject, public caf::PdmObject
class RimIntersectionBox : public QObject, public RimIntersectionHandle
{
Q_OBJECT;
@ -60,11 +62,6 @@ public:
RimIntersectionBox();
~RimIntersectionBox() override;
// Fields
caf::PdmField<QString> name;
caf::PdmField<bool> isActive;
caf::PdmField<bool> showInactiveCells;
cvf::Mat4d boxOrigin() const;
cvf::Vec3d boxSize() const;
SinglePlaneState singlePlaneState() const;
@ -79,9 +76,6 @@ public:
void setToDefaultSizeSlice( SinglePlaneState plane, const cvf::Vec3d& position );
protected:
caf::PdmFieldHandle* userDescriptionField() override;
caf::PdmFieldHandle* objectToggleField() override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;

View File

@ -79,7 +79,7 @@ void RimIntersectionCollection::applySingleColorEffect()
for ( RimIntersection* cs : m_intersections )
{
if ( cs->isActive )
if ( cs->isActive() )
{
cs->intersectionPartMgr()->applySingleColorEffect();
}
@ -87,7 +87,7 @@ void RimIntersectionCollection::applySingleColorEffect()
for ( RimIntersectionBox* cs : m_intersectionBoxes )
{
if ( cs->isActive )
if ( cs->isActive() )
{
cs->intersectionBoxPartMgr()->applySingleColorEffect();
}
@ -97,23 +97,21 @@ void RimIntersectionCollection::applySingleColorEffect()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionCollection::updateCellResultColor( size_t timeStepIndex,
const cvf::ScalarMapper* scalarColorMapper,
const RivTernaryScalarMapper* ternaryColorMapper )
void RimIntersectionCollection::updateCellResultColor( size_t timeStepIndex )
{
if ( !this->isActive() ) return;
for ( RimIntersection* cs : m_intersections )
{
if ( cs->isActive )
if ( cs->isActive() )
{
cs->intersectionPartMgr()->updateCellResultColor( timeStepIndex, scalarColorMapper, ternaryColorMapper );
cs->intersectionPartMgr()->updateCellResultColor( timeStepIndex, nullptr, nullptr );
}
}
for ( RimIntersectionBox* cs : m_intersectionBoxes )
{
if ( cs->isActive )
if ( cs->isActive() )
{
cs->intersectionBoxPartMgr()->updateCellResultColor( timeStepIndex );
}
@ -127,11 +125,11 @@ void RimIntersectionCollection::appendPartsToModel( Rim3dView& view,
cvf::ModelBasicList* model,
cvf::Transform* scaleTransform )
{
if ( !isActive ) return;
if ( !isActive() ) return;
for ( RimIntersection* cs : m_intersections )
{
if ( cs->isActive )
if ( cs->isActive() )
{
cs->intersectionPartMgr()->appendNativeCrossSectionFacesToModel( model, scaleTransform );
cs->intersectionPartMgr()->appendMeshLinePartsToModel( model, scaleTransform );
@ -141,7 +139,7 @@ void RimIntersectionCollection::appendPartsToModel( Rim3dView& view,
for ( RimIntersectionBox* cs : m_intersectionBoxes )
{
if ( cs->isActive )
if ( cs->isActive() )
{
cs->intersectionBoxPartMgr()->appendNativeCrossSectionFacesToModel( model, scaleTransform );
cs->intersectionBoxPartMgr()->appendMeshLinePartsToModel( model, scaleTransform );
@ -302,11 +300,11 @@ void RimIntersectionCollection::fieldChangedByUi( const caf::PdmFieldHandle* cha
//--------------------------------------------------------------------------------------------------
bool RimIntersectionCollection::hasActiveIntersectionForSimulationWell( const RimSimWellInView* simWell ) const
{
if ( !isActive ) return false;
if ( !isActive() ) return false;
for ( RimIntersection* cs : m_intersections )
{
if ( cs->isActive && cs->type() == RimIntersection::CS_SIMULATION_WELL && cs->simulationWell() == simWell )
if ( cs->isActive() && cs->type() == RimIntersection::CS_SIMULATION_WELL && cs->simulationWell() == simWell )
{
return true;
}

View File

@ -69,9 +69,7 @@ public:
// Visualization interface
void applySingleColorEffect();
void updateCellResultColor( size_t timeStepIndex,
const cvf::ScalarMapper* scalarColorMapper,
const RivTernaryScalarMapper* ternaryColorMapper );
void updateCellResultColor( size_t timeStepIndex );
void appendPartsToModel( Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
void rebuildGeometry();

View File

@ -0,0 +1,254 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimIntersectionHandle.h"
#include "RigEclipseCaseData.h"
#include "RigFemPartCollection.h"
#include "RigGeoMechCaseData.h"
#include "RimEclipseCase.h"
#include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechView.h"
#include "RimGridView.h"
#include "RimIntersectionResultDefinition.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "RivHexGridIntersectionTools.h"
CAF_PDM_SOURCE_INIT( RimIntersectionHandle, "RimIntersectionHandle" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIntersectionHandle::RimIntersectionHandle()
{
CAF_PDM_InitField( &m_name, "UserDescription", QString( "Intersection Name" ), "Name", "", "", "" );
CAF_PDM_InitField( &m_isActive, "Active", true, "Active", "", "", "" );
m_isActive.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells", "", "", "" );
CAF_PDM_InitField( &m_useSeparateDataSource, "UseSeparateIntersectionDataSource", true, "Enable", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_separateDataSource, "SeparateIntersectionDataSource", "Source", "", "", "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIntersectionHandle::~RimIntersectionHandle() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimIntersectionHandle::name() const
{
return m_name();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionHandle::setName( const QString& newName )
{
m_name = newName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimIntersectionHandle::isActive() const
{
return m_isActive();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionHandle::setActive( bool isActive )
{
m_isActive = isActive;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimIntersectionHandle::isInactiveCellsVisible() const
{
return m_showInactiveCells;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIntersectionResultDefinition* RimIntersectionHandle::activeSeparateResultDefinition()
{
updateDefaultSeparateDataSource();
if ( !m_useSeparateDataSource ) return nullptr;
if ( !m_separateDataSource ) return nullptr;
if ( !m_separateDataSource->isActive() ) return nullptr;
RimGridView* view;
this->firstAncestorOrThisOfTypeAsserted( view );
if ( !view->separateIntersectionResultsCollection()->isActive() ) return nullptr;
return m_separateDataSource;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RimIntersectionHandle::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_separateDataSource )
{
RimGridView* view;
this->firstAncestorOrThisOfTypeAsserted( view );
std::vector<RimIntersectionResultDefinition*> iResDefs =
view->separateIntersectionResultsCollection()->intersectionResultsDefinitions();
for ( auto iresdef : iResDefs )
{
options.push_back( caf::PdmOptionItemInfo( iresdef->autoName(), iresdef ) );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimIntersectionHandle::userDescriptionField()
{
return &m_name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimIntersectionHandle::objectToggleField()
{
return &m_isActive;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionHandle::initAfterRead()
{
updateDefaultSeparateDataSource();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionHandle::defineSeparateDataSourceUi( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
QString inactiveText;
if ( !this->activeSeparateResultDefinition() )
{
inactiveText = " (Inactive)";
}
caf::PdmUiGroup* separateResultsGroup = uiOrdering.addNewGroup( "Separate Result Reference" + inactiveText );
separateResultsGroup->setCollapsedByDefault( true );
separateResultsGroup->add( &m_useSeparateDataSource );
separateResultsGroup->add( &m_separateDataSource );
m_separateDataSource.uiCapability()->setUiReadOnly( !m_useSeparateDataSource() );
m_separateDataSource.uiCapability()->setUiName( "Source" + inactiveText );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionHandle::updateDefaultSeparateDataSource()
{
if ( m_separateDataSource() == nullptr )
{
RimGridView* view;
this->firstAncestorOrThisOfType( view );
if ( view )
{
std::vector<RimIntersectionResultDefinition*> iResDefs =
view->separateIntersectionResultsCollection()->intersectionResultsDefinitions();
if ( iResDefs.size() )
{
m_separateDataSource = iResDefs[0];
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RivIntersectionHexGridInterface> RimIntersectionHandle::createHexGridInterface()
{
RimIntersectionResultDefinition* resDef = activeSeparateResultDefinition();
if ( resDef && resDef->activeCase() )
{
// Eclipse case
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( resDef->activeCase() );
if ( eclipseCase && eclipseCase->eclipseCaseData() )
{
return new RivEclipseIntersectionGrid( eclipseCase->eclipseCaseData()->mainGrid(),
eclipseCase->eclipseCaseData()->activeCellInfo(
resDef->eclipseResultDefinition()->porosityModel() ),
this->isInactiveCellsVisible() );
}
// Geomech case
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>( resDef->activeCase() );
if ( geomCase && geomCase->geoMechData() && geomCase->geoMechData()->femParts() )
{
RigFemPart* femPart = geomCase->geoMechData()->femParts()->part( 0 );
return new RivFemIntersectionGrid( femPart );
}
}
RimEclipseView* eclipseView;
this->firstAncestorOrThisOfType( eclipseView );
if ( eclipseView )
{
RigMainGrid* grid = eclipseView->mainGrid();
return new RivEclipseIntersectionGrid( grid, eclipseView->currentActiveCellInfo(), this->isInactiveCellsVisible() );
}
RimGeoMechView* geoView;
this->firstAncestorOrThisOfType( geoView );
if ( geoView && geoView->femParts() && geoView->femParts()->partCount() )
{
RigFemPart* femPart = geoView->femParts()->part( 0 );
return new RivFemIntersectionGrid( femPart );
}
return nullptr;
}

View File

@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmField.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "cvfObject.h"
class RimIntersectionResultDefinition;
class RivIntersectionHexGridInterface;
class RimIntersectionHandle : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimIntersectionHandle();
~RimIntersectionHandle() override;
QString name() const;
void setName( const QString& newName );
bool isActive() const;
void setActive( bool isActive );
bool isInactiveCellsVisible() const;
RimIntersectionResultDefinition* activeSeparateResultDefinition();
cvf::ref<RivIntersectionHexGridInterface> createHexGridInterface();
protected:
caf::PdmFieldHandle* userDescriptionField() override final;
caf::PdmFieldHandle* objectToggleField() override final;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
void initAfterRead() override;
void defineSeparateDataSourceUi( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
void updateDefaultSeparateDataSource();
caf::PdmField<QString> m_name;
caf::PdmField<bool> m_isActive;
caf::PdmField<bool> m_showInactiveCells;
caf::PdmField<bool> m_useSeparateDataSource;
caf::PdmPtrField<RimIntersectionResultDefinition*> m_separateDataSource;
};

View File

@ -0,0 +1,407 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimIntersectionResultDefinition.h"
#include "Rim2dIntersectionView.h"
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h"
#include "RimGridView.h"
#include "RimIntersection.h"
#include "RimIntersectionResultsDefinitionCollection.h"
#include "RimRegularLegendConfig.h"
#include "RimTernaryLegendConfig.h"
#include "RimTools.h"
#include "RiuViewer.h"
#include "cafPdmUiTreeOrdering.h"
CAF_PDM_SOURCE_INIT( RimIntersectionResultDefinition, "IntersectionResultDefinition" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIntersectionResultDefinition::RimIntersectionResultDefinition()
{
CAF_PDM_InitObject( "Intersection Result Definition", "", "", "" );
CAF_PDM_InitField( &m_isActive, "IsActive", true, "Active", "", "", "" );
m_isActive.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case", "", "", "" );
CAF_PDM_InitField( &m_timeStep, "TimeStep", 0, "Time Step", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_autoName, "IntersectionResultDefinitionDescription", "Description", "", "", "" );
m_autoName.registerGetMethod( this, &RimIntersectionResultDefinition::autoName );
m_autoName.uiCapability()->setUiHidden( true );
m_autoName.uiCapability()->setUiReadOnly( true );
m_autoName.xmlCapability()->setIOWritable( false );
CAF_PDM_InitFieldNoDefault( &m_eclipseResultDefinition, "EclipseResultDef", "EclipseResultDef", "", "", "" );
m_eclipseResultDefinition.uiCapability()->setUiHidden( true );
m_eclipseResultDefinition.uiCapability()->setUiTreeChildrenHidden( true );
m_eclipseResultDefinition = new RimEclipseResultDefinition;
CAF_PDM_InitFieldNoDefault( &m_geomResultDefinition, "GeoMechResultDef", "GeoMechResultDef", "", "", "" );
m_geomResultDefinition.uiCapability()->setUiHidden( true );
m_geomResultDefinition.uiCapability()->setUiTreeChildrenHidden( true );
m_geomResultDefinition = new RimGeoMechResultDefinition;
CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "Legend", "", "", "" );
m_legendConfig.uiCapability()->setUiHidden( true );
m_legendConfig.uiCapability()->setUiTreeChildrenHidden( false );
m_legendConfig = new RimRegularLegendConfig;
CAF_PDM_InitFieldNoDefault( &m_ternaryLegendConfig, "TernaryLegendConfig", "Legend", "", "", "" );
m_ternaryLegendConfig.uiCapability()->setUiHidden( true );
m_ternaryLegendConfig.uiCapability()->setUiTreeChildrenHidden( false );
m_ternaryLegendConfig = new RimTernaryLegendConfig;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIntersectionResultDefinition::~RimIntersectionResultDefinition() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimIntersectionResultDefinition::isActive() const
{
return m_isActive();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimIntersectionResultDefinition::autoName() const
{
QString timestepName;
QString caseName = "Default undefined source";
if ( m_case )
{
QStringList timestepNames = m_case->timeStepStrings();
if ( timestepNames.size() > m_timeStep() )
{
timestepName = timestepNames[m_timeStep()];
}
caseName = m_case->caseUserDescription();
}
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>( m_case.value() );
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case.value() );
QString resultVarUiName;
if ( eclipseCase )
{
resultVarUiName = m_eclipseResultDefinition->resultVariableUiName();
}
else if ( geomCase )
{
resultVarUiName = m_geomResultDefinition->resultFieldUiName() + ":" +
m_geomResultDefinition->resultComponentUiName();
}
return resultVarUiName + " " + timestepName + " " + caseName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCase* RimIntersectionResultDefinition::activeCase() const
{
return m_case();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimIntersectionResultDefinition::timeStep() const
{
return m_timeStep();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimRegularLegendConfig* RimIntersectionResultDefinition::regularLegendConfig() const
{
return m_legendConfig();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimTernaryLegendConfig* RimIntersectionResultDefinition::ternaryLegendConfig() const
{
return m_ternaryLegendConfig();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimIntersectionResultDefinition::isEclipseResultDefinition()
{
if ( dynamic_cast<RimEclipseCase*>( m_case() ) )
{
return true;
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseResultDefinition* RimIntersectionResultDefinition::eclipseResultDefinition() const
{
return m_eclipseResultDefinition();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechResultDefinition* RimIntersectionResultDefinition::geoMechResultDefinition() const
{
return m_geomResultDefinition();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionResultDefinition::updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer,
bool isUsingOverrideViewer )
{
if ( !this->isInAction() ) return;
if ( this->isEclipseResultDefinition() )
{
RimEclipseResultDefinition* eclResultDef = this->eclipseResultDefinition();
eclResultDef->updateRangesForExplicitLegends( this->regularLegendConfig(),
this->ternaryLegendConfig(),
this->timeStep() );
eclResultDef->updateLegendTitle( this->regularLegendConfig(), "Intersection Results:\n" );
if ( this->regularLegendConfig()->showLegend() && eclResultDef->hasResult() )
{
nativeOrOverrideViewer->addColorLegendToBottomLeftCorner( this->regularLegendConfig()->titledOverlayFrame(),
isUsingOverrideViewer );
}
else if ( eclResultDef->isTernarySaturationSelected() &&
eclResultDef->currentGridCellResults()->maxTimeStepCount() > 1 &&
this->ternaryLegendConfig()->showLegend() && this->ternaryLegendConfig()->titledOverlayFrame() )
{
this->ternaryLegendConfig()->setTitle( "Intersection Results: \n" );
nativeOrOverrideViewer->addColorLegendToBottomLeftCorner( this->ternaryLegendConfig()->titledOverlayFrame(),
isUsingOverrideViewer );
}
}
else
{
this->geoMechResultDefinition()->updateLegendTextAndRanges( this->regularLegendConfig(),
"Intersection Results:\n",
this->timeStep() );
if ( this->geoMechResultDefinition()->hasResult() && this->regularLegendConfig()->showLegend() )
{
nativeOrOverrideViewer->addColorLegendToBottomLeftCorner( this->regularLegendConfig()->titledOverlayFrame(),
isUsingOverrideViewer );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimIntersectionResultDefinition::userDescriptionField()
{
return &m_autoName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimIntersectionResultDefinition::objectToggleField()
{
return &m_isActive;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionResultDefinition::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
if ( changedField == &m_case )
{
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>( m_case.value() );
m_geomResultDefinition->setGeoMechCase( geomCase );
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case.value() );
m_eclipseResultDefinition->setEclipseCase( eclipseCase );
}
this->updateConnectedEditors();
RimIntersectionResultsDefinitionCollection* interResDefColl = nullptr;
this->firstAncestorOrThisOfType( interResDefColl );
bool isInAction = isActive() && interResDefColl && interResDefColl->isActive();
if ( changedField == &m_isActive || ( changedField == &m_timeStep && isInAction ) )
{
RimGridView* gridView = nullptr;
this->firstAncestorOrThisOfType( gridView );
if ( gridView ) gridView->scheduleCreateDisplayModelAndRedraw();
update2dIntersectionViews();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionResultDefinition::update2dIntersectionViews()
{
// Update 2D Intersection views
std::vector<RimIntersection*> intersections;
this->objectsWithReferringPtrFieldsOfType( intersections );
for ( auto intersection : intersections )
{
if ( intersection && intersection->correspondingIntersectionView() )
{
intersection->correspondingIntersectionView()->scheduleCreateDisplayModelAndRedraw();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RimIntersectionResultDefinition::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_case )
{
RimTools::caseOptionItems( &options );
}
else if ( fieldNeedingOptions == &m_timeStep )
{
QStringList timeStepNames;
if ( m_case )
{
timeStepNames = m_case->timeStepStrings();
}
for ( int i = 0; i < timeStepNames.size(); i++ )
{
options.push_back( caf::PdmOptionItemInfo( timeStepNames[i], i ) );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionResultDefinition::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_case );
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>( m_case.value() );
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case.value() );
if ( eclipseCase )
{
m_eclipseResultDefinition->uiOrdering( uiConfigName, uiOrdering );
}
else if ( geomCase )
{
m_geomResultDefinition->uiOrdering( uiConfigName, uiOrdering );
}
if ( ( eclipseCase && m_eclipseResultDefinition->hasDynamicResult() ) || geomCase )
{
uiOrdering.add( &m_timeStep );
}
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionResultDefinition::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering,
QString uiConfigName /*= ""*/ )
{
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>( m_case.value() );
if ( !geomCase && m_eclipseResultDefinition->resultVariable() == RiaDefines::ternarySaturationResultName() )
{
uiTreeOrdering.add( m_ternaryLegendConfig() );
}
else
{
uiTreeOrdering.add( m_legendConfig() );
}
uiTreeOrdering.skipRemainingChildren( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionResultDefinition::initAfterRead()
{
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>( m_case.value() );
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case.value() );
if ( eclipseCase )
{
m_eclipseResultDefinition->setEclipseCase( eclipseCase );
}
else if ( geomCase )
{
m_geomResultDefinition->setGeoMechCase( geomCase );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimIntersectionResultDefinition::isInAction() const
{
RimIntersectionResultsDefinitionCollection* interResDefColl = nullptr;
this->firstAncestorOrThisOfType( interResDefColl );
return isActive() && interResDefColl && interResDefColl->isActive();
}

View File

@ -0,0 +1,84 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
#include "cafPdmPtrField.h"
class RimEclipseResultDefinition;
class RimGeoMechResultDefinition;
class RimCase;
class RimRegularLegendConfig;
class RimTernaryLegendConfig;
class RiuViewer;
class RimIntersectionResultDefinition : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimIntersectionResultDefinition();
~RimIntersectionResultDefinition() override;
bool isActive() const;
bool isInAction() const;
QString autoName() const;
RimCase* activeCase() const;
bool isEclipseResultDefinition();
int timeStep() const;
RimRegularLegendConfig* regularLegendConfig() const;
RimTernaryLegendConfig* ternaryLegendConfig() const;
RimEclipseResultDefinition* eclipseResultDefinition() const;
RimGeoMechResultDefinition* geoMechResultDefinition() const;
void updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer, bool isUsingOverrideViewer );
protected:
virtual caf::PdmFieldHandle* userDescriptionField() override;
virtual caf::PdmFieldHandle* objectToggleField() override;
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue ) override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
virtual void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
virtual void initAfterRead() override;
private:
void update2dIntersectionViews();
caf::PdmField<bool> m_isActive;
caf::PdmProxyValueField<QString> m_autoName;
caf::PdmPtrField<RimCase*> m_case;
caf::PdmChildField<RimEclipseResultDefinition*> m_eclipseResultDefinition;
caf::PdmChildField<RimGeoMechResultDefinition*> m_geomResultDefinition;
caf::PdmField<int> m_timeStep;
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;
caf::PdmChildField<RimTernaryLegendConfig*> m_ternaryLegendConfig;
};

View File

@ -0,0 +1,105 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimIntersectionResultsDefinitionCollection.h"
#include "RimGridView.h"
#include "RimIntersectionCollection.h"
#include "RimIntersectionResultDefinition.h"
CAF_PDM_SOURCE_INIT( RimIntersectionResultsDefinitionCollection, "RimIntersectionResultsDefinitionCollection" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIntersectionResultsDefinitionCollection::RimIntersectionResultsDefinitionCollection()
{
CAF_PDM_InitObject( "Separate Intersection Results", ":/CrossSections16x16.png", "", "" );
CAF_PDM_InitField( &m_isActive, "isActive", false, "Active", "", "", "" );
m_isActive.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_intersectionResultsDefs, "IntersectionResultDefinitions", "Data Sources", "", "", "" );
m_intersectionResultsDefs.uiCapability()->setUiTreeHidden( true );
m_intersectionResultsDefs.push_back( new RimIntersectionResultDefinition ); // Add the default result definition
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIntersectionResultsDefinitionCollection::~RimIntersectionResultsDefinitionCollection() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimIntersectionResultsDefinitionCollection::isActive()
{
return m_isActive();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimIntersectionResultDefinition*> RimIntersectionResultsDefinitionCollection::intersectionResultsDefinitions()
{
return m_intersectionResultsDefs.childObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionResultsDefinitionCollection::appendIntersectionResultDefinition(
RimIntersectionResultDefinition* interResDef )
{
m_intersectionResultsDefs.push_back(interResDef);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimIntersectionResultsDefinitionCollection::objectToggleField()
{
return &m_isActive;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionResultsDefinitionCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
this->updateUiIconFromToggleField();
RimGridView* gridView = nullptr;
this->firstAncestorOrThisOfType( gridView );
if ( gridView )
{
gridView->scheduleCreateDisplayModelAndRedraw();
gridView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimIntersectionResultsDefinitionCollection::initAfterRead()
{
this->updateUiIconFromToggleField();
}

View File

@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
class RimIntersectionResultDefinition;
class RimIntersectionResultsDefinitionCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimIntersectionResultsDefinitionCollection();
~RimIntersectionResultsDefinitionCollection() override;
bool isActive();
std::vector<RimIntersectionResultDefinition*> intersectionResultsDefinitions();
void appendIntersectionResultDefinition( RimIntersectionResultDefinition* interResDef );
protected:
caf::PdmFieldHandle* objectToggleField() override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue ) override;
virtual void initAfterRead() override;
private:
caf::PdmField<bool> m_isActive;
caf::PdmChildArrayField<RimIntersectionResultDefinition*> m_intersectionResultsDefs;
};

View File

@ -40,10 +40,10 @@
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RigResultAccessor>
RigResultAccessorFactory::createFromResultDefinition( const RigEclipseCaseData* eclipseCase,
size_t gridIndex,
size_t timeStepIndex,
RimEclipseResultDefinition* resultDefinition )
RigResultAccessorFactory::createFromResultDefinition( const RigEclipseCaseData* eclipseCase,
size_t gridIndex,
size_t timeStepIndex,
const RimEclipseResultDefinition* resultDefinition )
{
if ( resultDefinition->isFlowDiagOrInjectionFlooding() )
{

View File

@ -33,10 +33,10 @@ class RigEclipseResultAddress;
class RigResultAccessorFactory
{
public:
static cvf::ref<RigResultAccessor> createFromResultDefinition( const RigEclipseCaseData* eclipseCase,
size_t gridIndex,
size_t timeStepIndex,
RimEclipseResultDefinition* resultDefinition );
static cvf::ref<RigResultAccessor> createFromResultDefinition( const RigEclipseCaseData* eclipseCase,
size_t gridIndex,
size_t timeStepIndex,
const RimEclipseResultDefinition* resultDefinition );
static cvf::ref<RigResultAccessor> createFromResultAddress( const RigEclipseCaseData* eclipseCase,
size_t gridIndex,

View File

@ -59,6 +59,7 @@
#include "RimGeoMechView.h"
#include "RimIntersection.h"
#include "RimIntersectionBox.h"
#include "RimIntersectionResultDefinition.h"
#include "RimLegendConfig.h"
#include "RimPerforationInterval.h"
#include "RimProject.h"
@ -1142,22 +1143,30 @@ void RiuViewerCommands::findCellAndGridIndex( Rim3dView* m
size_t* gridIndex )
{
CVF_ASSERT( cellIndex && gridIndex );
RimEclipseCase* eclipseCase = nullptr;
if ( RimIntersectionResultDefinition* sepInterResDef =
crossSectionSourceInfo->crossSection()->activeSeparateResultDefinition() )
{
if ( sepInterResDef->isEclipseResultDefinition() )
{
eclipseCase = dynamic_cast<RimEclipseCase*>( sepInterResDef->activeCase() );
}
}
else
{
eclipseCase = dynamic_cast<RimEclipseCase*>( mainOrComparisonView->ownerCase() );
}
size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
RimCase* ownerCase = mainOrComparisonView->ownerCase();
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( ownerCase );
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>( ownerCase );
if ( eclipseCase )
{
// RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
RimEclipseView* eclipseView;
crossSectionSourceInfo->crossSection()->firstAncestorOrThisOfType( eclipseView );
size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
const RigGridBase* hostGrid = eclipseView->mainGrid()->gridAndGridLocalIdxFromGlobalCellIdx( globalCellIndex,
cellIndex );
*gridIndex = hostGrid->gridIndex();
const RigCell& cell = eclipseCase->mainGrid()->globalCellArray()[globalCellIndex];
*cellIndex = cell.gridLocalCellIndex();
*gridIndex = cell.hostGrid()->gridIndex();
}
else if ( geomCase )
else
{
*cellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
*gridIndex = 0;
@ -1174,19 +1183,30 @@ void RiuViewerCommands::findCellAndGridIndex( Rim3dView*
size_t* gridIndex )
{
CVF_ASSERT( cellIndex && gridIndex );
RimEclipseCase* eclipseCase = nullptr;
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>( mainOrComparisonView );
if ( eclipseView )
if ( RimIntersectionResultDefinition* sepInterResDef =
intersectionBoxSourceInfo->intersectionBox()->activeSeparateResultDefinition() )
{
size_t globalCellIndex = intersectionBoxSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
if ( sepInterResDef->isEclipseResultDefinition() )
{
eclipseCase = dynamic_cast<RimEclipseCase*>( sepInterResDef->activeCase() );
}
}
else
{
eclipseCase = dynamic_cast<RimEclipseCase*>( mainOrComparisonView->ownerCase() );
}
const RigCell& cell = eclipseView->mainGrid()->globalCellArray()[globalCellIndex];
size_t globalCellIndex = intersectionBoxSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
if ( eclipseCase )
{
const RigCell& cell = eclipseCase->mainGrid()->globalCellArray()[globalCellIndex];
*cellIndex = cell.gridLocalCellIndex();
*gridIndex = cell.hostGrid()->gridIndex();
}
else if ( geomView )
else
{
*cellIndex = intersectionBoxSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
*gridIndex = 0;