#272 Improved meta data for custom cell edge results

This commit is contained in:
Magne Sjaastad
2016-08-06 08:44:49 +02:00
parent 7890705ccd
commit d9973743ee
7 changed files with 133 additions and 32 deletions

View File

@@ -28,6 +28,8 @@
#include "RimReservoirCellResultsStorage.h"
#include "cafPdmUiListEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include "cvfMath.h"
@@ -41,21 +43,18 @@ RimCellEdgeColors::RimCellEdgeColors()
CAF_PDM_InitObject("Cell Edge Result", ":/EdgeResult_1.png", "", "");
CAF_PDM_InitField(&enableCellEdgeColors, "EnableCellEdgeColors", true, "Enable cell edge results", "", "", "");
enableCellEdgeColors.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&resultVariable, "CellEdgeVariable", "Result property", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_resultVariable, "CellEdgeVariable", "Result property", "", "", "");
CAF_PDM_InitField(&useXVariable, "UseXVariable", true, "Use X values", "", "", "");
CAF_PDM_InitField(&useYVariable, "UseYVariable", true, "Use Y values", "", "", "");
CAF_PDM_InitField(&useZVariable, "UseZVariable", true, "Use Z values", "", "", "");
CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", ":/Legend.png", "", "");
legendConfig.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_customFaultResultColors, "CustomEdgeResult", "Custom Edge Result", ":/CellResult.png", "", "");
m_customFaultResultColors = new RimEclipseCellColors();
m_customFaultResultColors.uiCapability()->setUiHidden(true);
resultVariable.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
m_resultVariable.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
legendConfig = new RimLegendConfig();
@@ -89,9 +88,9 @@ void RimCellEdgeColors::loadResult()
{
CVF_ASSERT(m_reservoirView && m_reservoirView->currentGridCellResults());
if (resultVariable == RimCellEdgeColors::customEdgeResultUiText())
if (m_resultVariable == RimCellEdgeColors::customEdgeResultUiText())
{
size_t resultindex = m_reservoirView->currentGridCellResults()->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, m_customFaultResultColors->resultVariable());
size_t resultindex = m_reservoirView->currentGridCellResults()->findOrLoadScalarResult(m_customFaultResultColors->resultType(), m_customFaultResultColors->resultVariable());
for (int cubeFaceIdx = 0; cubeFaceIdx < 6; ++cubeFaceIdx)
{
@@ -172,7 +171,7 @@ namespace caf
QList<caf::PdmOptionItemInfo> RimCellEdgeColors::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
{
if (fieldNeedingOptions == &resultVariable)
if (fieldNeedingOptions == &m_resultVariable)
{
if (m_reservoirView && m_reservoirView->currentGridCellResults())
{
@@ -251,9 +250,9 @@ QList<caf::PdmOptionItemInfo> RimCellEdgeColors::calculateValueOptions(const caf
//--------------------------------------------------------------------------------------------------
void RimCellEdgeColors::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&resultVariable);
uiOrdering.add(&m_resultVariable);
if (resultVariable().compare(RimCellEdgeColors::customEdgeResultUiText()) == 0)
if (m_resultVariable().compare(RimCellEdgeColors::customEdgeResultUiText()) == 0)
{
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Custom Edge Result");
group1->add(&(m_customFaultResultColors->m_resultTypeUiField));
@@ -267,7 +266,16 @@ void RimCellEdgeColors::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin
uiOrdering.add(&useZVariable);
}
uiOrdering.forgetRemainingFields();
uiOrdering.setForgetRemainingFields(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellEdgeColors::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
{
uiTreeOrdering.add(legendConfig());
uiTreeOrdering.setForgetRemainingFields(true);
}
//--------------------------------------------------------------------------------------------------
@@ -277,7 +285,7 @@ QStringList RimCellEdgeColors::findResultVariableNames()
{
QStringList varNames;
if (m_reservoirView && m_reservoirView->currentGridCellResults() && !resultVariable().isEmpty())
if (m_reservoirView && m_reservoirView->currentGridCellResults() && !m_resultVariable().isEmpty())
{
QStringList varList;
varList = m_reservoirView->currentGridCellResults()->cellResults()->resultNames(RimDefines::STATIC_NATIVE);
@@ -288,7 +296,7 @@ QStringList RimCellEdgeColors::findResultVariableNames()
{
if (RimDefines::isPerCellFaceResult(varList[i])) continue;
if (varList[i].startsWith(resultVariable))
if (varList[i].startsWith(m_resultVariable))
{
varNames.append(varList[i]);
}
@@ -314,7 +322,7 @@ void RimCellEdgeColors::gridScalarIndices(size_t resultIndices[6])
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellEdgeColors::gridScalarResultNames(QStringList* resultNames)
void RimCellEdgeColors::gridScalarResultNames(std::vector<QString>* resultNames)
{
CVF_ASSERT(resultNames);
@@ -323,7 +331,36 @@ void RimCellEdgeColors::gridScalarResultNames(QStringList* resultNames)
{
resultNames->push_back(m_resultNameToIndexPairs[cubeFaceIndex].first);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellEdgeColors::cellEdgeMetaData(std::vector<RimCellEdgeMetaData>* metaDataVector)
{
CVF_ASSERT(metaDataVector);
size_t resultIndices[6];
this->gridScalarIndices(resultIndices);
std::vector<QString> resultNames;
this->gridScalarResultNames(&resultNames);
bool isStatic = true;
if (m_resultVariable == RimCellEdgeColors::customEdgeResultUiText())
{
isStatic = m_customFaultResultColors->resultType() == RimDefines::STATIC_NATIVE;
}
for (size_t i = 0; i < 6; i++)
{
RimCellEdgeMetaData metaData;
metaData.m_resultIndex = resultIndices[i];
metaData.m_resultVariable = resultNames[i];
metaData.m_isStatic = isStatic;
metaDataVector->push_back(metaData);
}
}
//--------------------------------------------------------------------------------------------------
@@ -368,7 +405,7 @@ bool RimCellEdgeColors::hasResult() const
//--------------------------------------------------------------------------------------------------
void RimCellEdgeColors::updateIgnoredScalarValue()
{
if (resultVariable == "MULT" || resultVariable == "riMULT")
if (m_resultVariable == "MULT" || m_resultVariable == "riMULT")
{
m_ignoredResultScalar = 1.0;
}
@@ -443,6 +480,29 @@ void RimCellEdgeColors::setEclipseCase(RimEclipseCase* eclipseCase)
m_customFaultResultColors->setEclipseCase(eclipseCase);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellEdgeColors::setResultVariable(const QString& variableName)
{
m_resultVariable = variableName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimCellEdgeColors::resultVariable() const
{
if (m_resultVariable == RimCellEdgeColors::customEdgeResultUiText())
{
return m_customFaultResultColors->resultVariable();
}
else
{
return m_resultVariable;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -34,6 +34,14 @@ class RimEclipseCellColors;
class RimEclipseView;
class RimLegendConfig;
class RimCellEdgeMetaData
{
public:
size_t m_resultIndex;
QString m_resultVariable;
bool m_isStatic;
};
//==================================================================================================
///
///
@@ -57,13 +65,16 @@ public:
void setReservoirView(RimEclipseView* ownerReservoirView);
void setEclipseCase(RimEclipseCase* eclipseCase);
caf::PdmField<QString> resultVariable;
void setResultVariable(const QString& variableName);
QString resultVariable() const;
caf::PdmField<bool> enableCellEdgeColors;
caf::PdmChildField<RimLegendConfig*> legendConfig;
double ignoredScalarValue() { return m_ignoredResultScalar; }
void gridScalarIndices(size_t resultIndices[6]);
void gridScalarResultNames(QStringList* resultNames);
void cellEdgeMetaData(std::vector<RimCellEdgeMetaData>* metaData);
void loadResult();
bool hasResult() const;
@@ -75,6 +86,7 @@ protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly );
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering);
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "");
QStringList findResultVariableNames();
@@ -84,10 +96,12 @@ private:
void resetResultIndices();
void updateIgnoredScalarValue();
void gridScalarResultNames(std::vector<QString>* resultNames);
static QString customEdgeResultUiText() { return "Custom Edge Result"; }
virtual caf::PdmFieldHandle* objectToggleField();
caf::PdmField<QString> m_resultVariable;
caf::PdmField<bool> useXVariable;
caf::PdmField<bool> useYVariable;
caf::PdmField<bool> useZVariable;

View File

@@ -157,7 +157,7 @@ RimEclipseView* RimEclipseCase::createAndAddReservoirView()
{
RimEclipseView* riv = new RimEclipseView();
riv->setEclipseCase(this);
riv->cellEdgeResult()->resultVariable = "MULT";
riv->cellEdgeResult()->setResultVariable("MULT");
riv->cellEdgeResult()->enableCellEdgeColors = false;
caf::PdmDocument::updateUiIconStateRecursively(riv);
@@ -243,7 +243,7 @@ void RimEclipseCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
RimCellEdgeColors* cellEdgeResult = reservoirView->cellEdgeResult;
CVF_ASSERT(cellEdgeResult);
cellEdgeResult->resultVariable.v() = RimDefines::undefinedResultName();
cellEdgeResult->setResultVariable(RimDefines::undefinedResultName());
cellEdgeResult->loadResult();
reservoirView->createDisplayModelAndRedraw();

View File

@@ -132,6 +132,9 @@ void RimEclipseResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
RimWellLogCurve* curve = NULL;
this->firstAnchestorOrThisOfType(curve);
RimCellEdgeColors* cellEdgeColors = NULL;
this->firstAnchestorOrThisOfType(cellEdgeColors);
if (&m_resultVariableUiField == changedField)
{
m_porosityModel = m_porosityModelUiField;
@@ -164,6 +167,16 @@ void RimEclipseResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
}
}
if (cellEdgeColors)
{
cellEdgeColors->loadResult();
if (view)
{
view->scheduleCreateDisplayModelAndRedraw();
}
}
if (curve)
{
curve->updatePlotData();
@@ -181,7 +194,6 @@ void RimEclipseResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
faultColors->updateConnectedEditors();
}
RimCellEdgeColors* cellEdgeColors = dynamic_cast<RimCellEdgeColors*>(this->parentField()->ownerObject());
if (cellEdgeColors)
{
cellEdgeColors->updateConnectedEditors();
@@ -210,8 +222,13 @@ QList<caf::PdmOptionItemInfo> RimEclipseResultDefinition::calculateValueOptions(
RimWellLogCurve* curve = NULL;
this->firstAnchestorOrThisOfType(curve);
RimEclipsePropertyFilter* propFilter = dynamic_cast<RimEclipsePropertyFilter*>(this->parentField()->ownerObject());
if (propFilter || curve)
RimEclipsePropertyFilter* propFilter = NULL;
this->firstAnchestorOrThisOfType(propFilter);
RimCellEdgeColors* cellEdge = NULL;
this->firstAnchestorOrThisOfType(cellEdge);
if (propFilter || curve || cellEdge)
{
removePerCellFaceOptionItems(optionItems);
}

View File

@@ -943,7 +943,7 @@ void RimEclipseView::updateLegends()
this->cellEdgeResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, globalMin, globalMax);
m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig->legend());
this->cellEdgeResult()->legendConfig->legend()->setTitle(cvfqt::Utils::toString(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariable));
this->cellEdgeResult()->legendConfig->legend()->setTitle(cvfqt::Utils::toString(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariable()));
}
else
{

View File

@@ -428,7 +428,7 @@ void RimIdenticalGridCaseGroup::clearStatisticsResults()
{
RimEclipseView* rimReservoirView = rimStaticsCase->reservoirViews[j];
rimReservoirView->cellResult()->setResultVariable(RimDefines::undefinedResultName());
rimReservoirView->cellEdgeResult()->resultVariable = RimDefines::undefinedResultName();
rimReservoirView->cellEdgeResult()->setResultVariable(RimDefines::undefinedResultName());
rimReservoirView->loadDataAndUpdate();
}
}

View File

@@ -463,23 +463,33 @@ QString RiuResultTextBuilder::cellEdgeResultDetails()
if (m_reservoirView->cellEdgeResult()->hasResult())
{
size_t resultIndices[6];
QStringList resultNames;
m_reservoirView->cellEdgeResult()->gridScalarIndices(resultIndices);
m_reservoirView->cellEdgeResult()->gridScalarResultNames(&resultNames);
std::vector<RimCellEdgeMetaData> metaData;
m_reservoirView->cellEdgeResult()->cellEdgeMetaData(&metaData);
std::set<size_t> uniqueResultIndices;
text += "-- Cell edge result data --\n";
for (int idx = 0; idx < 6; idx++)
{
if (resultIndices[idx] == cvf::UNDEFINED_SIZE_T) continue;
size_t resultIndex = metaData[idx].m_resultIndex;
if (resultIndex == cvf::UNDEFINED_SIZE_T) continue;
if (uniqueResultIndices.find(resultIndex) != uniqueResultIndices.end()) continue;
size_t adjustedTimeStep = m_timeStepIndex;
if (metaData[idx].m_isStatic)
{
adjustedTimeStep = 0;
}
// Cell edge results are static, results are loaded for first time step only
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_reservoirView->cellResult()->porosityModel());
cvf::ref<RigResultAccessor> resultAccessor = RigResultAccessorFactory::createResultAccessor(m_reservoirView->eclipseCase()->reservoirData(), m_gridIndex, porosityModel, 0, resultIndices[idx]);
cvf::ref<RigResultAccessor> resultAccessor = RigResultAccessorFactory::createResultAccessor(m_reservoirView->eclipseCase()->reservoirData(), m_gridIndex, porosityModel, adjustedTimeStep, resultIndex);
if (resultAccessor.notNull())
{
double scalarValue = resultAccessor->cellScalar(m_cellIndex);
text.append(QString("%1 : %2\n").arg(resultNames[idx]).arg(scalarValue));
text.append(QString("%1 : %2\n").arg(metaData[idx].m_resultVariable).arg(scalarValue));
uniqueResultIndices.insert(resultIndex);
}
}
}