mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add multiple selected cell edge results
This commit is contained in:
@@ -20,9 +20,12 @@
|
||||
|
||||
#include "RimCellEdgeColors.h"
|
||||
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigFlowDiagResults.h"
|
||||
#include "RicCreateEnsembleWellLogUi.h"
|
||||
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigEclipseResultAddress.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
@@ -30,8 +33,11 @@
|
||||
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
|
||||
#include "cvfMath.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include <array>
|
||||
|
||||
namespace caf
|
||||
@@ -40,7 +46,8 @@ template <>
|
||||
void AppEnum<RimCellEdgeColors::PropertyType>::setUp()
|
||||
{
|
||||
addItem( RimCellEdgeColors::MULTI_AXIS_STATIC_PROPERTY, "MULTI_AXIS_STATIC_PROPERTY", "Multi Axis Static Property" );
|
||||
addItem( RimCellEdgeColors::ANY_SINGLE_PROPERTY, "ANY_SINGLE_PROPERTY", "Any Single Property" );
|
||||
QStringList aliasList = { "ANY_SINGLE_PROPERTY" };
|
||||
addItem( RimCellEdgeColors::CUSTOM_PROPERTIES, "CUSTOM_PROPERTIES", "Selected Properties", aliasList );
|
||||
setDefault( RimCellEdgeColors::MULTI_AXIS_STATIC_PROPERTY );
|
||||
}
|
||||
} // namespace caf
|
||||
@@ -65,13 +72,28 @@ RimCellEdgeColors::RimCellEdgeColors()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendDefinition", "Color Legend", ":/Legend.png" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_singleVarEdgeResultColors, "SingleVarEdgeResult", "Result Property", ":/CellResult.png" );
|
||||
m_singleVarEdgeResultColors = new RimEclipseCellColors();
|
||||
CAF_PDM_InitFieldNoDefault( &m_selectedKeywords, "SelectedProperties", "Selected Properties" );
|
||||
m_selectedKeywords.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitField( &m_showTextValuesIfItemIsUnchecked,
|
||||
"ShowTextValuesIfItemIsUnchecked",
|
||||
false,
|
||||
"Always Show Values in Result Info Window",
|
||||
"",
|
||||
"Allow display of result values in Result Info window if the Cell Edge object is unchecked in "
|
||||
"Property Editor." );
|
||||
|
||||
m_resultVariable.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() );
|
||||
|
||||
m_legendConfig = new RimRegularLegendConfig();
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_singleVarEdgeResultColors_OBSOLETE,
|
||||
"SingleVarEdgeResult",
|
||||
"Result Property",
|
||||
":/CellResult.png" );
|
||||
m_singleVarEdgeResultColors_OBSOLETE = new RimEclipseCellColors();
|
||||
m_singleVarEdgeResultColors_OBSOLETE.uiCapability()->setUiHidden( true );
|
||||
|
||||
m_ignoredResultScalar = cvf::UNDEFINED_DOUBLE;
|
||||
resetResultAddresses();
|
||||
}
|
||||
@@ -89,7 +111,6 @@ RimCellEdgeColors::~RimCellEdgeColors()
|
||||
void RimCellEdgeColors::setReservoirView( RimEclipseView* ownerReservoirView )
|
||||
{
|
||||
m_reservoirView = ownerReservoirView;
|
||||
m_singleVarEdgeResultColors->setReservoirView( ownerReservoirView );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -97,24 +118,47 @@ void RimCellEdgeColors::setReservoirView( RimEclipseView* ownerReservoirView )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellEdgeColors::loadResult()
|
||||
{
|
||||
if ( !m_enableCellEdgeColors ) return;
|
||||
if ( !m_reservoirView->currentGridCellResults() ) return;
|
||||
|
||||
if ( isUsingSingleVariable() )
|
||||
{
|
||||
m_singleVarEdgeResultColors->loadResult();
|
||||
;
|
||||
resetResultAddresses();
|
||||
|
||||
RigEclipseResultAddress resultAddr = m_singleVarEdgeResultColors->eclipseResultAddress();
|
||||
for ( int cubeFaceIdx = 0; cubeFaceIdx < 6; ++cubeFaceIdx )
|
||||
if ( isUserDefinedPropertiesActive() )
|
||||
{
|
||||
std::vector<RiaDefines::ResultCatType> categories = { RiaDefines::ResultCatType::STATIC_NATIVE,
|
||||
RiaDefines::ResultCatType::DYNAMIC_NATIVE,
|
||||
RiaDefines::ResultCatType::INPUT_PROPERTY };
|
||||
|
||||
std::vector<QString> resultNames = m_selectedKeywords();
|
||||
if ( resultNames.size() > 6 )
|
||||
{
|
||||
m_resultNameToAddressPairs[cubeFaceIdx] =
|
||||
std::make_pair( m_singleVarEdgeResultColors->resultVariable(), resultAddr );
|
||||
QString title = "Cell Edge Results";
|
||||
|
||||
QString text =
|
||||
QString( "Selected Cell Edge result property count is %1. Up to 6 results are supported, no "
|
||||
"data will be loaded.\n\nPlease select equal to or less than 6 properties to show data." )
|
||||
.arg( resultNames.size() );
|
||||
|
||||
RiaLogging::errorInMessageBox( nullptr, title, text );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
auto properties = RicCreateEnsembleWellLogUi::properties( resultNames,
|
||||
categories,
|
||||
m_reservoirView->eclipseCase()->eclipseCaseData() );
|
||||
|
||||
for ( size_t i = 0; i < properties.size(); i++ )
|
||||
{
|
||||
auto [name, category] = properties[i];
|
||||
RigEclipseResultAddress adr = RigEclipseResultAddress( category, name );
|
||||
|
||||
m_reservoirView->currentGridCellResults()->ensureKnownResultLoaded( adr );
|
||||
|
||||
m_resultNameToAddressPairs[i] = std::make_pair( name, adr );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
resetResultAddresses();
|
||||
QStringList vars = findResultVariableNames();
|
||||
updateIgnoredScalarValue();
|
||||
|
||||
@@ -151,8 +195,12 @@ void RimCellEdgeColors::loadResult()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellEdgeColors::initAfterRead()
|
||||
{
|
||||
m_singleVarEdgeResultColors->initAfterRead();
|
||||
this->updateUiIconFromToggleField();
|
||||
|
||||
if ( m_singleVarEdgeResultColors_OBSOLETE->resultVariableUiName() != RiaResultNames::undefinedResultName() )
|
||||
{
|
||||
m_selectedKeywords.v().push_back( m_singleVarEdgeResultColors_OBSOLETE->resultVariableUiName() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -192,6 +240,8 @@ void RimCellEdgeColors::EdgeFaceEnum::setUp()
|
||||
|
||||
QList<caf::PdmOptionItemInfo> RimCellEdgeColors::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if ( fieldNeedingOptions == &m_resultVariable )
|
||||
{
|
||||
if ( m_reservoirView && m_reservoirView->currentGridCellResults() )
|
||||
@@ -202,8 +252,6 @@ QList<caf::PdmOptionItemInfo> RimCellEdgeColors::calculateValueOptions( const ca
|
||||
// TODO: Must also handle input properties
|
||||
// varList += m_reservoirView->gridCellResults()->resultNames(RiaDefines::INPUT_PROPERTY);
|
||||
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
std::map<QString, std::array<QString, 6>> varBaseNameToVarsMap;
|
||||
|
||||
int i;
|
||||
@@ -258,6 +306,41 @@ QList<caf::PdmOptionItemInfo> RimCellEdgeColors::calculateValueOptions( const ca
|
||||
}
|
||||
}
|
||||
|
||||
if ( fieldNeedingOptions == &m_selectedKeywords )
|
||||
{
|
||||
RigCaseCellResultsData* resultData = m_reservoirView->currentGridCellResults();
|
||||
|
||||
std::vector<RiaDefines::ResultCatType> resultCategories = { RiaDefines::ResultCatType::STATIC_NATIVE,
|
||||
RiaDefines::ResultCatType::DYNAMIC_NATIVE,
|
||||
RiaDefines::ResultCatType::INPUT_PROPERTY };
|
||||
|
||||
for ( auto catType : resultCategories )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> allOptions =
|
||||
RimEclipseResultDefinition::calcOptionsForVariableUiFieldStandard( catType, resultData );
|
||||
|
||||
bool isFirstOfCategory = true;
|
||||
for ( const caf::PdmOptionItemInfo& option : allOptions )
|
||||
{
|
||||
if ( resultData->hasResultEntry( RigEclipseResultAddress( catType, option.optionUiText() ) ) )
|
||||
{
|
||||
if ( isFirstOfCategory )
|
||||
{
|
||||
// Add the category title only when there is at least one valid result
|
||||
options.push_back(
|
||||
caf::PdmOptionItemInfo::createHeader( caf::AppEnum<RiaDefines::ResultCatType>::uiText( catType ),
|
||||
true ) );
|
||||
isFirstOfCategory = false;
|
||||
}
|
||||
|
||||
options.push_back( option );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
return QList<caf::PdmOptionItemInfo>();
|
||||
}
|
||||
|
||||
@@ -266,11 +349,12 @@ QList<caf::PdmOptionItemInfo> RimCellEdgeColors::calculateValueOptions( const ca
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellEdgeColors::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
uiOrdering.add( &m_showTextValuesIfItemIsUnchecked );
|
||||
uiOrdering.add( &m_propertyType );
|
||||
|
||||
if ( isUsingSingleVariable() )
|
||||
if ( isUserDefinedPropertiesActive() )
|
||||
{
|
||||
m_singleVarEdgeResultColors->uiOrdering( uiConfigName, uiOrdering );
|
||||
uiOrdering.add( &m_selectedKeywords );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -323,13 +407,15 @@ QStringList RimCellEdgeColors::findResultVariableNames()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellEdgeColors::gridScalarIndices( RigEclipseResultAddress resultIndices[6] )
|
||||
std::array<RigEclipseResultAddress, 6> RimCellEdgeColors::resultAddresses() const
|
||||
{
|
||||
int cubeFaceIndex;
|
||||
for ( cubeFaceIndex = 0; cubeFaceIndex < 6; ++cubeFaceIndex )
|
||||
std::array<RigEclipseResultAddress, 6> adr;
|
||||
for ( int cubeFaceIndex = 0; cubeFaceIndex < 6; ++cubeFaceIndex )
|
||||
{
|
||||
resultIndices[cubeFaceIndex] = RigEclipseResultAddress( m_resultNameToAddressPairs[cubeFaceIndex].second );
|
||||
adr[cubeFaceIndex] = RigEclipseResultAddress( m_resultNameToAddressPairs[cubeFaceIndex].second );
|
||||
}
|
||||
|
||||
return adr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -349,9 +435,9 @@ void RimCellEdgeColors::gridScalarResultNames( std::vector<QString>* resultNames
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimCellEdgeColors::isUsingSingleVariable() const
|
||||
bool RimCellEdgeColors::isUserDefinedPropertiesActive() const
|
||||
{
|
||||
return ( m_propertyType == ANY_SINGLE_PROPERTY );
|
||||
return ( m_propertyType == CUSTOM_PROPERTIES );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -361,22 +447,22 @@ void RimCellEdgeColors::cellEdgeMetaData( std::vector<RimCellEdgeMetaData>* meta
|
||||
{
|
||||
CVF_ASSERT( metaDataVector );
|
||||
|
||||
RigEclipseResultAddress resultIndices[6];
|
||||
this->gridScalarIndices( resultIndices );
|
||||
auto addresses = this->resultAddresses();
|
||||
|
||||
std::vector<QString> resultNames;
|
||||
this->gridScalarResultNames( &resultNames );
|
||||
|
||||
bool isStatic = true;
|
||||
if ( isUsingSingleVariable() )
|
||||
{
|
||||
isStatic = m_singleVarEdgeResultColors->resultType() == RiaDefines::ResultCatType::STATIC_NATIVE;
|
||||
}
|
||||
|
||||
for ( size_t i = 0; i < 6; i++ )
|
||||
{
|
||||
if ( isUserDefinedPropertiesActive() )
|
||||
{
|
||||
isStatic = addresses[i].resultCatType() == RiaDefines::ResultCatType::STATIC_NATIVE;
|
||||
}
|
||||
|
||||
RimCellEdgeMetaData metaData;
|
||||
metaData.m_eclipseResultAddress = resultIndices[i];
|
||||
metaData.m_eclipseResultAddress = addresses[i];
|
||||
metaData.m_resultVariable = resultNames[i];
|
||||
metaData.m_isStatic = isStatic;
|
||||
|
||||
@@ -403,7 +489,17 @@ bool RimCellEdgeColors::hasResult() const
|
||||
{
|
||||
if ( !m_enableCellEdgeColors() ) return false;
|
||||
|
||||
if ( isUsingSingleVariable() && m_singleVarEdgeResultColors->isFlowDiagOrInjectionFlooding() )
|
||||
return showTextResult();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimCellEdgeColors::showTextResult() const
|
||||
{
|
||||
if ( !m_enableCellEdgeColors && !m_showTextValuesIfItemIsUnchecked ) return false;
|
||||
|
||||
if ( isUserDefinedPropertiesActive() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -444,32 +540,19 @@ void RimCellEdgeColors::minMaxCellEdgeValues( double& min, double& max )
|
||||
|
||||
if ( m_reservoirView->currentGridCellResults() )
|
||||
{
|
||||
if ( isUsingSingleVariable() && singleVarEdgeResultColors()->isFlowDiagOrInjectionFlooding() )
|
||||
auto resultAddresses = this->resultAddresses();
|
||||
|
||||
size_t faceIdx;
|
||||
for ( faceIdx = 0; faceIdx < 6; faceIdx++ )
|
||||
{
|
||||
int currentTimeStep = m_reservoirView->currentTimeStep();
|
||||
if ( !resultAddresses[faceIdx].isValid() ) continue;
|
||||
|
||||
RigFlowDiagResults* fldResults = singleVarEdgeResultColors()->flowDiagSolution()->flowDiagResults();
|
||||
RigFlowDiagResultAddress resAddr = singleVarEdgeResultColors()->flowDiagResAddress();
|
||||
|
||||
fldResults->minMaxScalarValues( resAddr, currentTimeStep, &globalMin, &globalMax );
|
||||
}
|
||||
else
|
||||
{
|
||||
RigEclipseResultAddress resultAddresses[6];
|
||||
this->gridScalarIndices( resultAddresses );
|
||||
|
||||
size_t faceIdx;
|
||||
for ( faceIdx = 0; faceIdx < 6; faceIdx++ )
|
||||
{
|
||||
if ( !resultAddresses[faceIdx].isValid() ) continue;
|
||||
double cMin, cMax;
|
||||
m_reservoirView->currentGridCellResults()->minMaxCellScalarValues( resultAddresses[faceIdx], cMin, cMax );
|
||||
|
||||
{
|
||||
double cMin, cMax;
|
||||
m_reservoirView->currentGridCellResults()->minMaxCellScalarValues( resultAddresses[faceIdx], cMin, cMax );
|
||||
|
||||
globalMin = std::min( globalMin, cMin );
|
||||
globalMax = std::max( globalMax, cMax );
|
||||
}
|
||||
globalMin = std::min( globalMin, cMin );
|
||||
globalMax = std::max( globalMax, cMax );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -486,8 +569,7 @@ void RimCellEdgeColors::posNegClosestToZero( double& pos, double& neg )
|
||||
pos = HUGE_VAL;
|
||||
neg = -HUGE_VAL;
|
||||
|
||||
RigEclipseResultAddress resultAddresses[6];
|
||||
this->gridScalarIndices( resultAddresses );
|
||||
auto resultAddresses = this->resultAddresses();
|
||||
|
||||
size_t faceIdx;
|
||||
for ( faceIdx = 0; faceIdx < 6; faceIdx++ )
|
||||
@@ -504,22 +586,6 @@ void RimCellEdgeColors::posNegClosestToZero( double& pos, double& neg )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellEdgeColors::updateUiFieldsFromActiveResult()
|
||||
{
|
||||
m_singleVarEdgeResultColors->updateUiFieldsFromActiveResult();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellEdgeColors::setEclipseCase( RimEclipseCase* eclipseCase )
|
||||
{
|
||||
m_singleVarEdgeResultColors->setEclipseCase( eclipseCase );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -528,49 +594,21 @@ void RimCellEdgeColors::setResultVariable( const QString& variableName )
|
||||
m_resultVariable = variableName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimCellEdgeColors::resultVariable() const
|
||||
{
|
||||
if ( isUsingSingleVariable() )
|
||||
{
|
||||
return m_singleVarEdgeResultColors->resultVariable();
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_resultVariable;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimCellEdgeColors::resultVariableUiName() const
|
||||
{
|
||||
if ( isUsingSingleVariable() )
|
||||
{
|
||||
return m_singleVarEdgeResultColors->resultVariableUiName();
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_resultVariable;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimCellEdgeColors::resultVariableUiShortName() const
|
||||
{
|
||||
if ( isUsingSingleVariable() )
|
||||
if ( isUserDefinedPropertiesActive() )
|
||||
{
|
||||
return m_singleVarEdgeResultColors->resultVariableUiShortName();
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_resultVariable;
|
||||
if ( m_selectedKeywords().empty() ) return "";
|
||||
|
||||
if ( m_selectedKeywords().size() == 1 ) return m_selectedKeywords().front();
|
||||
|
||||
return "Multiple Properties";
|
||||
}
|
||||
|
||||
return m_resultVariable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -589,35 +627,12 @@ caf::PdmFieldHandle* RimCellEdgeColors::objectToggleField()
|
||||
return &m_enableCellEdgeColors;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimCellEdgeColors::hasCategoryResult() const
|
||||
{
|
||||
return isUsingSingleVariable() && m_singleVarEdgeResultColors->hasCategoryResult();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseCellColors* RimCellEdgeColors::singleVarEdgeResultColors()
|
||||
{
|
||||
return m_singleVarEdgeResultColors;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimRegularLegendConfig* RimCellEdgeColors::legendConfig()
|
||||
{
|
||||
if ( isUsingSingleVariable() )
|
||||
{
|
||||
return m_singleVarEdgeResultColors->legendConfig();
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_legendConfig;
|
||||
}
|
||||
return m_legendConfig();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user