(#272) Added visualization for custom cell edge results

This commit is contained in:
Magne Sjaastad 2016-08-03 16:01:44 +02:00
parent ba5426bf41
commit 5c3f74b833
6 changed files with 123 additions and 22 deletions

View File

@ -21,9 +21,11 @@
#include "RimCellEdgeColors.h"
#include "RigCaseCellResultsData.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimLegendConfig.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimEclipseView.h"
#include "cafPdmUiListEditor.h"
#include "cvfMath.h"
@ -49,6 +51,10 @@ RimCellEdgeColors::RimCellEdgeColors()
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());
legendConfig = new RimLegendConfig();
@ -63,6 +69,7 @@ RimCellEdgeColors::RimCellEdgeColors()
RimCellEdgeColors::~RimCellEdgeColors()
{
delete legendConfig();
delete m_customFaultResultColors;
}
//--------------------------------------------------------------------------------------------------
@ -72,6 +79,7 @@ void RimCellEdgeColors::setReservoirView(RimEclipseView* ownerReservoirView)
{
m_reservoirView = ownerReservoirView;
this->legendConfig()->setReservoirView(ownerReservoirView);
m_customFaultResultColors->setReservoirView(ownerReservoirView);
}
//--------------------------------------------------------------------------------------------------
@ -81,30 +89,56 @@ void RimCellEdgeColors::loadResult()
{
CVF_ASSERT(m_reservoirView && m_reservoirView->currentGridCellResults());
resetResultIndices();
QStringList vars = findResultVariableNames();
updateIgnoredScalarValue();
int i;
for (i = 0; i < vars.size(); ++i)
if (resultVariable == RimCellEdgeColors::customEdgeResultUiText())
{
size_t resultindex = m_reservoirView->currentGridCellResults()->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, vars[i]);
int cubeFaceIdx;
for (cubeFaceIdx = 0; cubeFaceIdx < 6; ++cubeFaceIdx)
{
if ( ((cubeFaceIdx == 0 || cubeFaceIdx == 1) && useXVariable())
|| ((cubeFaceIdx == 2 || cubeFaceIdx == 3) && useYVariable())
|| ((cubeFaceIdx == 4 || cubeFaceIdx == 5) && useZVariable()))
{
QString varEnd = EdgeFaceEnum::textFromIndex(cubeFaceIdx);
size_t resultindex = m_reservoirView->currentGridCellResults()->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, m_customFaultResultColors->resultVariable());
if (vars[i].endsWith(varEnd))
for (int cubeFaceIdx = 0; cubeFaceIdx < 6; ++cubeFaceIdx)
{
m_resultNameToIndexPairs[cubeFaceIdx] = std::make_pair(m_customFaultResultColors->resultVariable(), resultindex);
}
}
else
{
resetResultIndices();
QStringList vars = findResultVariableNames();
updateIgnoredScalarValue();
int i;
for (i = 0; i < vars.size(); ++i)
{
size_t resultindex = m_reservoirView->currentGridCellResults()->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, vars[i]);
int cubeFaceIdx;
for (cubeFaceIdx = 0; cubeFaceIdx < 6; ++cubeFaceIdx)
{
if ( ((cubeFaceIdx == 0 || cubeFaceIdx == 1) && useXVariable())
|| ((cubeFaceIdx == 2 || cubeFaceIdx == 3) && useYVariable())
|| ((cubeFaceIdx == 4 || cubeFaceIdx == 5) && useZVariable()))
{
m_resultNameToIndexPairs[cubeFaceIdx] = std::make_pair(vars[i], resultindex);
QString varEnd = EdgeFaceEnum::textFromIndex(cubeFaceIdx);
if (vars[i].endsWith(varEnd))
{
m_resultNameToIndexPairs[cubeFaceIdx] = std::make_pair(vars[i], resultindex);
}
}
}
}
}
}
updateFieldVisibility();
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellEdgeColors::initAfterRead()
{
m_customFaultResultColors->initAfterRead();
updateFieldVisibility();
}
//--------------------------------------------------------------------------------------------------
@ -199,7 +233,9 @@ QList<caf::PdmOptionItemInfo> RimCellEdgeColors::calculateValueOptions(const caf
}
optionList.push_front(caf::PdmOptionItemInfo( RimDefines::undefinedResultName(), "" ));
optionList.push_front(caf::PdmOptionItemInfo(RimDefines::undefinedResultName(), ""));
optionList.push_back(caf::PdmOptionItemInfo(RimCellEdgeColors::customEdgeResultUiText(), RimCellEdgeColors::customEdgeResultUiText()));
if (useOptionsOnly) *useOptionsOnly = true;
@ -210,6 +246,30 @@ QList<caf::PdmOptionItemInfo> RimCellEdgeColors::calculateValueOptions(const caf
return QList<caf::PdmOptionItemInfo>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellEdgeColors::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&resultVariable);
if (resultVariable().compare(RimCellEdgeColors::customEdgeResultUiText()) == 0)
{
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Custom Edge Result");
group1->add(&(m_customFaultResultColors->m_resultTypeUiField));
group1->add(&(m_customFaultResultColors->m_porosityModelUiField));
group1->add(&(m_customFaultResultColors->m_resultVariableUiField));
}
else
{
uiOrdering.add(&useXVariable);
uiOrdering.add(&useYVariable);
uiOrdering.add(&useZVariable);
}
uiOrdering.forgetRemainingFields();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -266,6 +326,14 @@ void RimCellEdgeColors::gridScalarResultNames(QStringList* resultNames)
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellEdgeColors::updateFieldVisibility()
{
m_customFaultResultColors->updateFieldVisibility();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -367,6 +435,14 @@ void RimCellEdgeColors::posNegClosestToZero(double& pos, double& neg)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCellEdgeColors::setEclipseCase(RimEclipseCase* eclipseCase)
{
m_customFaultResultColors->setEclipseCase(eclipseCase);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -29,10 +29,11 @@
#include "cafPdmObject.h"
class RigCaseCellResultsData;
class RimEclipseCase;
class RimEclipseCellColors;
class RimEclipseView;
class RimLegendConfig;
//==================================================================================================
///
///
@ -54,6 +55,7 @@ public:
typedef caf::AppEnum<RimCellEdgeColors::EdgeFaceType> EdgeFaceEnum;
void setReservoirView(RimEclipseView* ownerReservoirView);
void setEclipseCase(RimEclipseCase* eclipseCase);
caf::PdmField<QString> resultVariable;
caf::PdmField<bool> enableCellEdgeColors;
@ -69,16 +71,21 @@ public:
void posNegClosestToZero(double& pos, double& neg);
protected:
virtual void initAfterRead();
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);
QStringList findResultVariableNames();
private:
void updateFieldVisibility();
void resetResultIndices();
void updateIgnoredScalarValue();
static QString customEdgeResultUiText() { return "Custom Edge Result"; }
virtual caf::PdmFieldHandle* objectToggleField();
caf::PdmField<bool> useXVariable;
@ -88,5 +95,7 @@ private:
caf::FixedArray<std::pair<QString, size_t>, 6 > m_resultNameToIndexPairs;
caf::PdmPointer<RimEclipseView> m_reservoirView;
double m_ignoredResultScalar;
caf::PdmChildField<RimEclipseCellColors*> m_customFaultResultColors;
};

View File

@ -20,6 +20,7 @@
#include "RimEclipseCellColors.h"
#include "RimCellEdgeColors.h"
#include "RimEclipseFaultColors.h"
#include "RimEclipseView.h"
#include "RimTernaryLegendConfig.h"
@ -96,6 +97,12 @@ void RimEclipseCellColors::fieldChangedByUi(const caf::PdmFieldHandle* changedFi
{
faultColors->updateConnectedEditors();
}
RimCellEdgeColors* cellEdgeColors = dynamic_cast<RimCellEdgeColors*>(this->parentField()->ownerObject());
if (cellEdgeColors)
{
cellEdgeColors->updateConnectedEditors();
}
}
if (m_reservoirView) m_reservoirView->createDisplayModelAndRedraw();

View File

@ -56,6 +56,7 @@ protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
friend class RimEclipseFaultColors;
friend class RimCellEdgeColors;
virtual void initAfterRead();
private:

View File

@ -23,6 +23,7 @@
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RimCellEdgeColors.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseFaultColors.h"
@ -180,6 +181,12 @@ void RimEclipseResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
faultColors->updateConnectedEditors();
}
RimCellEdgeColors* cellEdgeColors = dynamic_cast<RimCellEdgeColors*>(this->parentField()->ownerObject());
if (cellEdgeColors)
{
cellEdgeColors->updateConnectedEditors();
}
if (curve)
{
curve->updateConnectedEditors();

View File

@ -1059,6 +1059,7 @@ void RimEclipseView::setEclipseCase(RimEclipseCase* reservoir)
cellResult()->setEclipseCase(reservoir);
faultResultSettings()->customFaultResult()->setEclipseCase(reservoir);
cellEdgeResult()->setEclipseCase(reservoir);
}
//--------------------------------------------------------------------------------------------------