#1297 Property Filter : Update ranges when time step changes

This commit is contained in:
Magne Sjaastad 2017-03-14 17:26:40 +01:00
parent 7db6dc2259
commit a22a58dd5b
5 changed files with 92 additions and 0 deletions

View File

@ -40,6 +40,8 @@
#include "cvfAssert.h"
#include "cvfMath.h"
#include <cmath> // Needed for HUGE_VAL on Linux
namespace caf
{ // Obsolete stuff
@ -377,6 +379,81 @@ void RimEclipsePropertyFilter::computeResultValueRange()
m_upperBound.uiCapability()->setUiName(QString("Max (%1)").arg(max));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilter::updateFromCurrentTimeStep()
{
if (resultDefinition->resultType() != RimDefines::FLOW_DIAGNOSTICS)
{
return;
}
double threshold = 1e-6;
bool followMin = false;
if (fabs(m_lowerBound - m_minimumResultValue) < threshold || m_minimumResultValue == HUGE_VAL)
{
followMin = true;
}
bool followMax = false;
if (fabs(m_upperBound - m_maximumResultValue) < threshold || m_maximumResultValue == -HUGE_VAL)
{
followMax = true;
}
double min = HUGE_VAL;
double max = -HUGE_VAL;
clearCategories();
RimView* view = nullptr;
this->firstAncestorOrThisOfTypeAsserted(view);
int timeStep = view->currentTimeStep();
RigFlowDiagResultAddress resAddr = resultDefinition->flowDiagResAddress();
if (resultDefinition->flowDiagSolution())
{
RigFlowDiagResults* results = resultDefinition->flowDiagSolution()->flowDiagResults();
results->minMaxScalarValues(resAddr, timeStep, &min, &max);
if (resultDefinition->hasCategoryResult())
{
setCategoryNames(resultDefinition->flowDiagSolution()->tracerNames());
}
}
if (min == HUGE_VAL && max == -HUGE_VAL)
{
m_lowerBound.uiCapability()->setUiName(QString("Min (inf)"));
m_upperBound.uiCapability()->setUiName(QString("Max (inf)"));
}
else
{
m_maximumResultValue = max;
m_minimumResultValue = min;
if (followMin)
{
m_lowerBound = min;
}
if (followMax)
{
m_upperBound = m_maximumResultValue;
}
m_lowerBound.uiCapability()->setUiName(QString("Min (%1)").arg(min));
m_upperBound.uiCapability()->setUiName(QString("Max (%1)").arg(max));
}
m_lowerBound.uiCapability()->updateConnectedEditors();
m_upperBound.uiCapability()->updateConnectedEditors();
updateFilterName();
this->name.uiCapability()->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -53,6 +53,7 @@ public:
void setToDefaultValues();
void updateFilterName();
void computeResultValueRange();
void updateFromCurrentTimeStep();
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void initAfterRead();

View File

@ -167,3 +167,14 @@ void RimEclipsePropertyFilterCollection::updateIconState()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipsePropertyFilterCollection::updateFromCurrentTimeStep()
{
for (RimEclipsePropertyFilter* cellFilter : propertyFilters())
{
cellFilter->updateFromCurrentTimeStep();
}
}

View File

@ -51,6 +51,7 @@ public:
void loadAndInitializePropertyFilters();
void updateIconState();
void updateFromCurrentTimeStep();
protected:
// Overridden methods

View File

@ -473,6 +473,8 @@ void RimEclipseView::createDisplayModel()
//--------------------------------------------------------------------------------------------------
void RimEclipseView::updateCurrentTimeStep()
{
m_propertyFilterCollection()->updateFromCurrentTimeStep();
updateLegends(); // To make sure the scalar mappers are set up correctly
std::vector<RivCellSetEnum> geometriesToRecolor;