Refactor: extract code for detecting logarithmic result

This commit is contained in:
Kristian Bendiksen 2021-09-20 12:12:51 +02:00
parent e9b070c57f
commit ea3fdef281
5 changed files with 22 additions and 23 deletions

View File

@ -71,6 +71,19 @@ bool RiaResultNames::isPerCellFaceResult( const QString& resultName )
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaResultNames::isLogarithmicResult( const QString& resultName )
{
QStringList subStringsToMatch{ "TRAN", "MULT", "PERM" };
for ( const auto& s : subStringsToMatch )
if ( resultName.contains( s, Qt::CaseInsensitive ) ) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -27,6 +27,7 @@
namespace RiaResultNames
{
bool isPerCellFaceResult( const QString& resultName );
bool isLogarithmicResult( const QString& resultName );
QString undefinedResultName();
QString undefinedGridFaultName();

View File

@ -20,6 +20,8 @@
#include "RimEclipseCellColors.h"
#include "RiaResultNames.h"
#include "RicfCommandObject.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
@ -184,19 +186,7 @@ RimRegularLegendConfig* RimEclipseCellColors::createLegendForResult( const QStri
bool useDiscreteLogLevels,
bool isCategoryResult )
{
bool useLog = false;
{
QStringList subStringsToMatch{ "TRAN", "MULT", "PERM" };
for ( const auto& s : subStringsToMatch )
{
if ( resultName.contains( s, Qt::CaseInsensitive ) )
{
useLog = true;
break;
}
}
}
bool useLog = RiaResultNames::isLogarithmicResult( resultName );
RimRegularLegendConfig::ColorRangesType colorRangeType = RimRegularLegendConfig::ColorRangesType::UNDEFINED;
if ( isCategoryResult )

View File

@ -21,6 +21,7 @@
#include "RiaColorTools.h"
#include "RiaLogging.h"
#include "RiaOptionItemFactory.h"
#include "RiaResultNames.h"
#include "RimEnsembleCurveFilter.h"
#include "RimEnsembleCurveFilterCollection.h"
@ -831,7 +832,7 @@ void RimEnsembleWellLogCurveSet::updateEnsembleCurves( const std::vector<RimWell
//--------------------------------------------------------------------------------------------------
void RimEnsembleWellLogCurveSet::setLogScaleFromSelectedResult( const QString resVar )
{
if ( resVar.toUpper().contains( "PERM" ) )
if ( RiaResultNames::isLogarithmicResult( resVar ) )
{
RimWellLogTrack* track = nullptr;
this->firstAncestorOrThisOfType( track );

View File

@ -21,6 +21,7 @@
#include "RiaColorTables.h"
#include "RiaLogging.h"
#include "RiaResultNames.h"
#include "RiaSimWellBranchTools.h"
#include "RiaWellLogUnitTools.h"
@ -829,18 +830,11 @@ void RimWellLogExtractionCurve::defineUiTreeOrdering( caf::PdmUiTreeOrdering& ui
void RimWellLogExtractionCurve::setLogScaleFromSelectedResult()
{
QString resVar = m_eclipseResultDefinition->resultVariable();
if ( resVar.toUpper().contains( "PERM" ) )
if ( RiaResultNames::isLogarithmicResult( resVar ) )
{
RimWellLogTrack* track = nullptr;
this->firstAncestorOrThisOfType( track );
if ( track )
{
if ( track->curveCount() == 1 )
{
track->setLogarithmicScale( true );
}
}
if ( track && track->curveCount() == 1 ) track->setLogarithmicScale( true );
}
}