mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #5275 from OPM/feature-allen-result-info
#5269 Cycle cell selection when clicking an NNC
This commit is contained in:
commit
b066703529
@ -372,17 +372,17 @@ QString RiaDefines::completionTypeResultName()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaDefines::binaryAllenResultName()
|
||||
QString RiaDefines::formationBinaryAllenResultName()
|
||||
{
|
||||
return "Binary Allen";
|
||||
return "Binary Formation Allen";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaDefines::allCombinationsAllenResultName()
|
||||
QString RiaDefines::formationAllenResultName()
|
||||
{
|
||||
return "All Allen Categories";
|
||||
return "Formation Allen";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -106,8 +106,8 @@ QString mobilePoreVolumeName();
|
||||
QString completionTypeResultName();
|
||||
|
||||
// Fault results
|
||||
QString binaryAllenResultName();
|
||||
QString allCombinationsAllenResultName();
|
||||
QString formationBinaryAllenResultName();
|
||||
QString formationAllenResultName();
|
||||
|
||||
// Mock model text identifiers
|
||||
QString mockModelBasic();
|
||||
|
@ -1391,8 +1391,8 @@ bool RimEclipseResultDefinition::hasCategoryResult() const
|
||||
if ( this->m_resultType() == RiaDefines::FLOW_DIAGNOSTICS && m_resultVariable() == RIG_FLD_MAX_FRACTION_TRACER_RESNAME )
|
||||
return true;
|
||||
|
||||
if ( this->resultVariable() == RiaDefines::allCombinationsAllenResultName() ||
|
||||
this->resultVariable() == RiaDefines::binaryAllenResultName() )
|
||||
if ( this->resultVariable() == RiaDefines::formationAllenResultName() ||
|
||||
this->resultVariable() == RiaDefines::formationBinaryAllenResultName() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -1887,7 +1887,7 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen
|
||||
}
|
||||
else if ( this->resultType() == RiaDefines::ALLEN_DIAGRAMS )
|
||||
{
|
||||
if ( this->resultVariable() == RiaDefines::allCombinationsAllenResultName() )
|
||||
if ( this->resultVariable() == RiaDefines::formationAllenResultName() )
|
||||
{
|
||||
const std::vector<QString>& fnVector = eclipseCaseData->activeFormationNames()->formationNames();
|
||||
std::vector<int> fnameIdxes;
|
||||
@ -1931,7 +1931,7 @@ void RimEclipseResultDefinition::updateRangesForExplicitLegends( RimRegularLegen
|
||||
|
||||
legendConfigToUpdate->setCategoryItems( categories );
|
||||
}
|
||||
else if ( this->resultVariable() == RiaDefines::binaryAllenResultName() )
|
||||
else if ( this->resultVariable() == RiaDefines::formationBinaryAllenResultName() )
|
||||
{
|
||||
std::vector<std::tuple<QString, int, cvf::Color3ub>> categories;
|
||||
categories.emplace_back( std::make_tuple( "Same formation", 0, cvf::Color3ub::BROWN ) );
|
||||
|
@ -34,6 +34,19 @@ public:
|
||||
return m_formationCombinationToCategory;
|
||||
}
|
||||
|
||||
std::pair<int, int> formationIndexCombinationFromCategory( int category )
|
||||
{
|
||||
for ( auto it : m_formationCombinationToCategory )
|
||||
{
|
||||
if ( it.second == category )
|
||||
{
|
||||
return it.first;
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair( -1, -1 );
|
||||
}
|
||||
|
||||
void setFormationCombinationToCategorymap( const std::map<std::pair<int, int>, int>& mapping )
|
||||
{
|
||||
m_formationCombinationToCategory = mapping;
|
||||
|
@ -426,8 +426,8 @@ size_t RigCaseCellResultsData::findOrCreateScalarResultIndex( const RigEclipseRe
|
||||
QString( "%1K" ).arg( baseName ) ) );
|
||||
statisticsCalculator = calc;
|
||||
}
|
||||
else if ( resultName == RiaDefines::allCombinationsAllenResultName() ||
|
||||
resultName == RiaDefines::binaryAllenResultName() )
|
||||
else if ( resultName == RiaDefines::formationAllenResultName() ||
|
||||
resultName == RiaDefines::formationBinaryAllenResultName() )
|
||||
{
|
||||
cvf::ref<RigEclipseAllenFaultsStatCalc> calc = new RigEclipseAllenFaultsStatCalc( m_ownerMainGrid->nncData(),
|
||||
resVarAddr );
|
||||
@ -913,11 +913,11 @@ void RigCaseCellResultsData::createPlaceholderResultEntries()
|
||||
// Fault results
|
||||
{
|
||||
findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ALLEN_DIAGRAMS,
|
||||
RiaDefines::binaryAllenResultName() ),
|
||||
RiaDefines::formationBinaryAllenResultName() ),
|
||||
false );
|
||||
|
||||
findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ALLEN_DIAGRAMS,
|
||||
RiaDefines::allCombinationsAllenResultName() ),
|
||||
RiaDefines::formationAllenResultName() ),
|
||||
false );
|
||||
}
|
||||
|
||||
@ -1227,8 +1227,8 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult( const RigEclipseResu
|
||||
{
|
||||
computeRiTRANSbyAreaComponent( resultName );
|
||||
}
|
||||
else if ( resultName == RiaDefines::allCombinationsAllenResultName() ||
|
||||
resultName == RiaDefines::binaryAllenResultName() )
|
||||
else if ( resultName == RiaDefines::formationAllenResultName() ||
|
||||
resultName == RiaDefines::formationBinaryAllenResultName() )
|
||||
{
|
||||
computeAllenResults( this, m_ownerMainGrid );
|
||||
}
|
||||
@ -3008,32 +3008,32 @@ void RigCaseCellResultsData::computeAllenResults( RigCaseCellResultsData* cellRe
|
||||
if ( hasFormationData )
|
||||
{
|
||||
auto fnAllenResultResAddr = RigEclipseResultAddress( RiaDefines::ALLEN_DIAGRAMS,
|
||||
RiaDefines::allCombinationsAllenResultName() );
|
||||
RiaDefines::formationAllenResultName() );
|
||||
auto fnBinAllenResAddr = RigEclipseResultAddress( RiaDefines::ALLEN_DIAGRAMS,
|
||||
RiaDefines::binaryAllenResultName() );
|
||||
RiaDefines::formationBinaryAllenResultName() );
|
||||
|
||||
// Create and retreive nnc result arrays
|
||||
|
||||
std::vector<double>& fnAllenNncResults = mainGrid->nncData()->makeStaticConnectionScalarResult(
|
||||
RiaDefines::allCombinationsAllenResultName() );
|
||||
RiaDefines::formationAllenResultName() );
|
||||
std::vector<double>& fnBinAllenNncResults = mainGrid->nncData()->makeStaticConnectionScalarResult(
|
||||
RiaDefines::binaryAllenResultName() );
|
||||
RiaDefines::formationBinaryAllenResultName() );
|
||||
|
||||
// Associate them with eclipse result address
|
||||
|
||||
mainGrid->nncData()->setEclResultAddress( RiaDefines::allCombinationsAllenResultName(), fnAllenResultResAddr );
|
||||
mainGrid->nncData()->setEclResultAddress( RiaDefines::binaryAllenResultName(), fnBinAllenResAddr );
|
||||
mainGrid->nncData()->setEclResultAddress( RiaDefines::formationAllenResultName(), fnAllenResultResAddr );
|
||||
mainGrid->nncData()->setEclResultAddress( RiaDefines::formationBinaryAllenResultName(), fnBinAllenResAddr );
|
||||
|
||||
const std::vector<double>& fnData = cellResultsData->cellScalarResults( fnNamesResAddr, 0 );
|
||||
|
||||
// Add a result entry for the special allen grid data (used only for the grid cells without nnc coverage)
|
||||
|
||||
cellResultsData->addStaticScalarResult( RiaDefines::ALLEN_DIAGRAMS,
|
||||
RiaDefines::allCombinationsAllenResultName(),
|
||||
RiaDefines::formationAllenResultName(),
|
||||
false,
|
||||
fnData.size() );
|
||||
cellResultsData->addStaticScalarResult( RiaDefines::ALLEN_DIAGRAMS,
|
||||
RiaDefines::binaryAllenResultName(),
|
||||
RiaDefines::formationBinaryAllenResultName(),
|
||||
false,
|
||||
fnData.size() );
|
||||
|
||||
|
@ -161,7 +161,7 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimGridView*
|
||||
RimEclipseResultDefinition* resultDefinition,
|
||||
size_t timestepIdx,
|
||||
size_t gridIndex,
|
||||
size_t cellIndex,
|
||||
size_t gridLocalCellIndex,
|
||||
size_t nncIndex,
|
||||
cvf::Color3f color,
|
||||
cvf::StructGridInterface::FaceType face,
|
||||
@ -170,7 +170,7 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimGridView*
|
||||
, m_resultDefinition( resultDefinition )
|
||||
, m_timestepIdx( timestepIdx )
|
||||
, m_gridIndex( gridIndex )
|
||||
, m_gridLocalCellIndex( cellIndex )
|
||||
, m_gridLocalCellIndex( gridLocalCellIndex )
|
||||
, m_nncIndex( nncIndex )
|
||||
, m_color( color )
|
||||
, m_face( face )
|
||||
|
@ -136,7 +136,7 @@ public:
|
||||
RimEclipseResultDefinition* resultDefinition,
|
||||
size_t timestepIdx,
|
||||
size_t gridIndex,
|
||||
size_t cellIndex,
|
||||
size_t gridLocalCellIndex,
|
||||
size_t nncIndex,
|
||||
cvf::Color3f color,
|
||||
cvf::StructGridInterface::FaceType face,
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "Rim2dIntersectionView.h"
|
||||
#include "RimBoxIntersection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimExtrudedCurveIntersection.h"
|
||||
@ -38,6 +39,10 @@
|
||||
#include "RivFemPickSourceInfo.h"
|
||||
#include "RivSourceInfo.h"
|
||||
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigNNCData.h"
|
||||
|
||||
#include "cafPdmObjectHandle.h"
|
||||
|
||||
#include "cvfPart.h"
|
||||
@ -113,26 +118,25 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
|
||||
if ( !firstHitPart ) return false;
|
||||
|
||||
size_t gridIndex = cvf::UNDEFINED_SIZE_T;
|
||||
size_t cellIndex = cvf::UNDEFINED_SIZE_T;
|
||||
cvf::StructGridInterface::FaceType face = cvf::StructGridInterface::NO_FACE;
|
||||
int gmFace = -1;
|
||||
bool intersectionHit = false;
|
||||
size_t gridIndex = cvf::UNDEFINED_SIZE_T;
|
||||
size_t gridLocalCellIndex = cvf::UNDEFINED_SIZE_T;
|
||||
cvf::StructGridInterface::FaceType face = cvf::StructGridInterface::NO_FACE;
|
||||
int gmFace = -1;
|
||||
bool intersectionHit = false;
|
||||
std::array<cvf::Vec3f, 3> intersectionTriangleHit;
|
||||
RimGeoMechResultDefinition* geomResDef = nullptr;
|
||||
RimEclipseResultDefinition* eclResDef = nullptr;
|
||||
size_t timestepIndex = -1;
|
||||
|
||||
// clang-format off
|
||||
if ( const RivSourceInfo* rivSourceInfo =
|
||||
dynamic_cast<const RivSourceInfo*>( firstHitPart->sourceInfo() ) )
|
||||
if ( const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>( firstHitPart->sourceInfo() ) )
|
||||
{
|
||||
gridIndex = rivSourceInfo->gridIndex();
|
||||
if ( rivSourceInfo->hasCellFaceMapping() )
|
||||
{
|
||||
CVF_ASSERT( rivSourceInfo->m_cellFaceFromTriangleMapper.notNull() );
|
||||
|
||||
cellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex( firstPartTriangleIndex );
|
||||
gridLocalCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex( firstPartTriangleIndex );
|
||||
face = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace( firstPartTriangleIndex );
|
||||
}
|
||||
}
|
||||
@ -140,17 +144,17 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
dynamic_cast<const RivFemPickSourceInfo*>( firstHitPart->sourceInfo() ) )
|
||||
{
|
||||
gridIndex = femSourceInfo->femPartIndex();
|
||||
cellIndex = femSourceInfo->triangleToElmMapper()->elementIndex( firstPartTriangleIndex );
|
||||
gridLocalCellIndex = femSourceInfo->triangleToElmMapper()->elementIndex( firstPartTriangleIndex );
|
||||
gmFace = femSourceInfo->triangleToElmMapper()->elementFace( firstPartTriangleIndex );
|
||||
}
|
||||
else if ( const RivExtrudedCurveIntersectionSourceInfo* intersectionSourceInfo =
|
||||
dynamic_cast<const RivExtrudedCurveIntersectionSourceInfo*>( firstHitPart->sourceInfo() ) )
|
||||
{
|
||||
RiuViewerCommands::findCellAndGridIndex( mainOrComparisonView,
|
||||
intersectionSourceInfo,
|
||||
firstPartTriangleIndex,
|
||||
&cellIndex,
|
||||
&gridIndex );
|
||||
intersectionSourceInfo,
|
||||
firstPartTriangleIndex,
|
||||
&gridLocalCellIndex,
|
||||
&gridIndex );
|
||||
|
||||
intersectionHit = true;
|
||||
intersectionTriangleHit = intersectionSourceInfo->triangle( firstPartTriangleIndex );
|
||||
@ -173,10 +177,10 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
dynamic_cast<const RivBoxIntersectionSourceInfo*>( firstHitPart->sourceInfo() ) )
|
||||
{
|
||||
RiuViewerCommands::findCellAndGridIndex( mainOrComparisonView,
|
||||
intersectionBoxSourceInfo,
|
||||
firstPartTriangleIndex,
|
||||
&cellIndex,
|
||||
&gridIndex );
|
||||
intersectionBoxSourceInfo,
|
||||
firstPartTriangleIndex,
|
||||
&gridLocalCellIndex,
|
||||
&gridIndex );
|
||||
|
||||
intersectionHit = true;
|
||||
intersectionTriangleHit = intersectionBoxSourceInfo->triangle( firstPartTriangleIndex );
|
||||
@ -197,7 +201,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
if ( cellIndex == cvf::UNDEFINED_SIZE_T )
|
||||
if ( gridLocalCellIndex == cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
Riu3dSelectionManager::instance()->deleteAllItems();
|
||||
return false;
|
||||
@ -253,11 +257,55 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
|
||||
if ( eclResDef )
|
||||
{
|
||||
// Select the other cell if we are about to select the same cell at an nnc.
|
||||
// To make consecutive clicks toggle between closest and furthest cell
|
||||
// clang-format off
|
||||
|
||||
if ( nncIndex != cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
auto selectedItem = dynamic_cast<RiuEclipseSelectionItem*>( Riu3dSelectionManager::instance()->selectedItem() );
|
||||
|
||||
if ( selectedItem &&
|
||||
selectedItem->m_gridIndex == gridIndex &&
|
||||
selectedItem->m_gridLocalCellIndex == gridLocalCellIndex &&
|
||||
selectedItem->m_nncIndex == nncIndex )
|
||||
{
|
||||
RigMainGrid* mainGrid = eclipseView->eclipseCase()->eclipseCaseData()->mainGrid();
|
||||
const RigConnection& nncConn = mainGrid->nncData()->connections()[nncIndex];
|
||||
|
||||
size_t c1LocalIdx = cvf::UNDEFINED_SIZE_T;
|
||||
const RigGridBase* grid1 = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConn.m_c1GlobIdx, &c1LocalIdx);
|
||||
size_t c1GridIdx = grid1->gridIndex();
|
||||
size_t c2LocalIdx = cvf::UNDEFINED_SIZE_T;
|
||||
const RigGridBase* grid2 = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConn.m_c2GlobIdx, &c2LocalIdx);
|
||||
size_t c2GridIdx = grid2->gridIndex();
|
||||
|
||||
if (gridLocalCellIndex == c1LocalIdx && gridIndex == c1GridIdx)
|
||||
{
|
||||
gridLocalCellIndex = c2LocalIdx;
|
||||
gridIndex = c2GridIdx;
|
||||
face = cvf::StructGridInterface::oppositeFace(face);
|
||||
}
|
||||
else if (gridLocalCellIndex == c2LocalIdx && gridIndex == c2GridIdx)
|
||||
{
|
||||
gridLocalCellIndex = c1LocalIdx;
|
||||
gridIndex = c1GridIdx;
|
||||
face = cvf::StructGridInterface::oppositeFace(face);
|
||||
}
|
||||
else
|
||||
{
|
||||
// None really matched, error in nnc data.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
|
||||
selItem = new RiuEclipseSelectionItem( associatedGridView,
|
||||
eclResDef,
|
||||
timestepIndex,
|
||||
gridIndex,
|
||||
cellIndex,
|
||||
gridLocalCellIndex,
|
||||
nncIndex,
|
||||
curveColor,
|
||||
face,
|
||||
@ -271,7 +319,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
geomResDef,
|
||||
timestepIndex,
|
||||
gridIndex,
|
||||
cellIndex,
|
||||
gridLocalCellIndex,
|
||||
curveColor,
|
||||
gmFace,
|
||||
localIntersectionPoint,
|
||||
@ -281,7 +329,7 @@ bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
|
||||
geomResDef,
|
||||
timestepIndex,
|
||||
gridIndex,
|
||||
cellIndex,
|
||||
gridLocalCellIndex,
|
||||
curveColor,
|
||||
gmFace,
|
||||
localIntersectionPoint );
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
#include "RivExtrudedCurveIntersectionPartMgr.h"
|
||||
|
||||
#include "RigAllenDiagramData.h"
|
||||
#include "RimIntersectionResultDefinition.h"
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
|
||||
@ -321,13 +322,17 @@ QString RiuResultTextBuilder::faultResultDetails()
|
||||
|
||||
if ( m_viewWithFaultsSettings && m_viewWithFaultsSettings->faultResultSettings()->hasValidCustomResult() )
|
||||
{
|
||||
text += "Fault result data:\n";
|
||||
this->appendTextFromResultColors( eclipseCaseData,
|
||||
m_gridIndex,
|
||||
m_cellIndex,
|
||||
m_timeStepIndex,
|
||||
m_viewWithFaultsSettings->currentFaultResultColors(),
|
||||
&text );
|
||||
if ( m_viewWithFaultsSettings->faultResultSettings()->customFaultResult()->resultType() !=
|
||||
RiaDefines::ALLEN_DIAGRAMS )
|
||||
{
|
||||
text += "Fault result data:\n";
|
||||
this->appendTextFromResultColors( eclipseCaseData,
|
||||
m_gridIndex,
|
||||
m_cellIndex,
|
||||
m_timeStepIndex,
|
||||
m_viewWithFaultsSettings->currentFaultResultColors(),
|
||||
&text );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -472,6 +477,41 @@ QString RiuResultTextBuilder::nncResultText()
|
||||
|
||||
text = QString( "%1 : %2" ).arg( resultVar ).arg( scalarValue );
|
||||
}
|
||||
|
||||
if ( resultType == RiaDefines::ALLEN_DIAGRAMS )
|
||||
{
|
||||
nncValues = nncData->staticConnectionScalarResult( eclipseResultAddress );
|
||||
QString resultValueText;
|
||||
|
||||
if ( m_viewWithFaultsSettings->currentFaultResultColors()->resultVariable() ==
|
||||
RiaDefines::formationAllenResultName() )
|
||||
{
|
||||
std::pair<int, int> fmIndexPair =
|
||||
eclipseCase->allenDiagramData()->formationIndexCombinationFromCategory(
|
||||
( *nncValues )[m_nncIndex] );
|
||||
|
||||
RigFormationNames* fmNames = eclipseCase->activeFormationNames();
|
||||
// clang-format off
|
||||
if ( fmNames &&
|
||||
fmIndexPair.first >= 0 &&
|
||||
fmIndexPair.second >= 0 &&
|
||||
fmNames->formationNames().size() > fmIndexPair.first &&
|
||||
fmNames->formationNames().size() > fmIndexPair.second )
|
||||
{
|
||||
resultValueText = fmNames->formationNames()[fmIndexPair.first] + " - " +
|
||||
fmNames->formationNames()[fmIndexPair.second];
|
||||
}
|
||||
// clang-format on
|
||||
}
|
||||
else if ( m_viewWithFaultsSettings->currentFaultResultColors()->resultVariable() ==
|
||||
RiaDefines::formationBinaryAllenResultName() )
|
||||
{
|
||||
resultValueText = ( *nncValues )[m_nncIndex] == 0 ? "Same formation" : "Different formation";
|
||||
}
|
||||
|
||||
QString resultVar = m_viewWithFaultsSettings->currentFaultResultColors()->resultVariableUiName();
|
||||
text = QString( "%1 : %2" ).arg( resultVar ).arg( resultValueText );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user