Fault result: Added fault result legend

This commit is contained in:
Magne Sjaastad 2014-07-31 08:46:30 +02:00
parent a5e928dec1
commit 0d14436b97
6 changed files with 177 additions and 124 deletions

View File

@ -650,7 +650,7 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas
riv->cellResult()->setResultVariable(RimDefines::undefinedResultName());
}
riv->cellFaultResult()->customResultSlot()->setResultVariable(RimDefines::undefinedResultName());
riv->cellFaultResult()->updateVisibility();
RimUiTreeModelPdm* uiModel = RiuMainWindow::instance()->uiPdmModel();

View File

@ -45,10 +45,10 @@ RimFaultResultSlot::RimFaultResultSlot()
{
CAF_PDM_InitObject("Fault Result Slot", "", "", "");
CAF_PDM_InitField(&visualizationMode, "VisualizationMode", caf::AppEnum<RimFaultResultSlot::FaultVisualizationMode>(RimFaultResultSlot::CELL_RESULT_MAPPING), "Fault Color Mapping", "", "", "");
CAF_PDM_InitField(&m_visualizationMode, "VisualizationMode", caf::AppEnum<RimFaultResultSlot::FaultVisualizationMode>(RimFaultResultSlot::CELL_RESULT_MAPPING), "Fault Color Mapping", "", "", "");
CAF_PDM_InitFieldNoDefault(&customResultSlot, "CustomResultSlot", "Custom Cell Result", ":/CellResult.png", "", "");
customResultSlot = new RimResultSlot();
CAF_PDM_InitFieldNoDefault(&m_customResultSlot, "CustomResultSlot", "Custom Fault Cell Result", ":/CellResult.png", "", "");
m_customResultSlot = new RimResultSlot();
updateVisibility();
}
@ -65,7 +65,8 @@ RimFaultResultSlot::~RimFaultResultSlot()
//--------------------------------------------------------------------------------------------------
void RimFaultResultSlot::setReservoirView(RimReservoirView* ownerReservoirView)
{
customResultSlot->setReservoirView(ownerReservoirView);
m_reservoirView = ownerReservoirView;
m_customResultSlot->setReservoirView(ownerReservoirView);
}
//--------------------------------------------------------------------------------------------------
@ -73,12 +74,14 @@ void RimFaultResultSlot::setReservoirView(RimReservoirView* ownerReservoirView)
//--------------------------------------------------------------------------------------------------
void RimFaultResultSlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &visualizationMode)
if (changedField == &m_visualizationMode)
{
updateVisibility();
RiuMainWindow::instance()->uiPdmModel()->updateUiSubTree(this);
}
if (m_reservoirView) m_reservoirView->createDisplayModelAndRedraw();
}
//--------------------------------------------------------------------------------------------------
@ -94,15 +97,28 @@ void RimFaultResultSlot::initAfterRead()
//--------------------------------------------------------------------------------------------------
void RimFaultResultSlot::updateVisibility()
{
if (this->visualizationMode() == FAULT_COLOR || this->visualizationMode() == CELL_RESULT_MAPPING)
if (this->m_visualizationMode() == FAULT_COLOR || this->m_visualizationMode() == CELL_RESULT_MAPPING)
{
this->customResultSlot.setUiHidden(true);
this->customResultSlot.setUiChildrenHidden(true);
this->m_customResultSlot.setUiHidden(true);
this->m_customResultSlot.setUiChildrenHidden(true);
}
else
{
this->customResultSlot.setUiHidden(false);
this->customResultSlot.setUiChildrenHidden(false);
this->m_customResultSlot.setUiHidden(false);
this->m_customResultSlot.setUiChildrenHidden(false);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimResultSlot* RimFaultResultSlot::customResultSlot()
{
if (this->m_visualizationMode() == CUSTOM_RESULT_MAPPING)
{
return this->m_customResultSlot();
}
return NULL;
}

View File

@ -29,7 +29,7 @@ class RimReservoirView;
///
///
//==================================================================================================
class RimFaultResultSlot : public caf::PdmObject
class RimFaultResultSlot : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
@ -45,17 +45,18 @@ public:
virtual ~RimFaultResultSlot();
void setReservoirView(RimReservoirView* ownerReservoirView);
caf::PdmField<RimResultSlot*> customResultSlot;
RimResultSlot* customResultSlot();
void updateVisibility();
protected:
virtual void initAfterRead();
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
private:
void updateVisibility();
caf::PdmField< caf::AppEnum< FaultVisualizationMode > > m_visualizationMode;
caf::PdmField<RimResultSlot*> m_customResultSlot;
private:
caf::PdmField< caf::AppEnum< FaultVisualizationMode > > visualizationMode;
caf::PdmPointer<RimReservoirView> m_reservoirView;
};

View File

@ -102,10 +102,8 @@ RimReservoirView::RimReservoirView()
CAF_PDM_InitFieldNoDefault(&cellEdgeResult, "GridCellEdgeResult", "Cell Edge Result", ":/EdgeResult_1.png", "", "");
cellEdgeResult = new RimCellEdgeResultSlot();
CAF_PDM_InitFieldNoDefault(&cellFaultResult, "GridCellFaultResult", "Fault Cell Result", ":/CellResult.png", "", "");
cellFaultResult = new RimFaultResultSlot();
cellFaultResult.setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&faultResult, "GridCellFaultResult", "Fault Result", ":/CellResult.png", "", "");
faultResult = new RimFaultResultSlot();
CAF_PDM_InitFieldNoDefault(&overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", "");
overlayInfoConfig = new Rim3dOverlayInfoConfig();
@ -167,7 +165,7 @@ RimReservoirView::RimReservoirView()
this->cellEdgeResult()->legendConfig()->setPosition(cvf::Vec2ui(10, 320));
this->cellEdgeResult()->legendConfig()->setColorRangeMode(RimLegendConfig::PINK_WHITE);
this->cellFaultResult()->setReservoirView(this);
this->faultResult()->setReservoirView(this);
m_reservoirGridPartManager = new RivReservoirViewPartMgr(this);
@ -182,7 +180,7 @@ RimReservoirView::RimReservoirView()
//--------------------------------------------------------------------------------------------------
RimReservoirView::~RimReservoirView()
{
delete this->cellFaultResult();
delete this->faultResult();
delete this->cellResult();
delete this->cellEdgeResult();
delete this->overlayInfoConfig();
@ -521,10 +519,7 @@ void RimReservoirView::createDisplayModel()
// Find the number of time frames the animation needs to show the requested data.
if (this->cellResult()->hasDynamicResult()
|| this->propertyFilterCollection()->hasActiveDynamicFilters()
|| this->wellCollection->hasVisibleWellPipes()
|| this->cellResult()->isTernarySaturationSelected())
if (isTimeStepDependentDataVisible())
{
CVF_ASSERT(currentGridCellResults());
@ -972,7 +967,7 @@ void RimReservoirView::loadDataAndUpdate()
//--------------------------------------------------------------------------------------------------
void RimReservoirView::initAfterRead()
{
this->cellFaultResult()->setReservoirView(this);
this->faultResult()->setReservoirView(this);
this->cellResult()->setReservoirView(this);
this->cellEdgeResult()->setReservoirView(this);
this->rangeFilterCollection()->setReservoirView(this);
@ -1392,97 +1387,10 @@ void RimReservoirView::updateLegends()
RigCaseCellResultsData* results = eclipseCase->results(porosityModel);
CVF_ASSERT(results);
if (this->cellResult()->hasResult())
updateMinMaxValuesAndAddLegendToView(QString("Cell Results: \n"), this->cellResult(), results);
if (this->faultResult()->customResultSlot())
{
double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero;
results->minMaxCellScalarValues(this->cellResult()->gridScalarIndex(), globalMin, globalMax);
results->posNegClosestToZero(this->cellResult()->gridScalarIndex(), globalPosClosestToZero, globalNegClosestToZero);
double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero;
if (this->cellResult()->hasDynamicResult())
{
results->minMaxCellScalarValues(this->cellResult()->gridScalarIndex(), m_currentTimeStep, localMin, localMax);
results->posNegClosestToZero(this->cellResult()->gridScalarIndex(), m_currentTimeStep, localPosClosestToZero, localNegClosestToZero);
}
else
{
localMin = globalMin;
localMax = globalMax;
localPosClosestToZero = globalPosClosestToZero;
localNegClosestToZero = globalNegClosestToZero;
}
this->cellResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
this->cellResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend());
this->cellResult()->legendConfig->legend()->setTitle(cvfqt::Utils::toString(QString("Cell Results: \n") + this->cellResult()->resultVariable()));
}
else
{
this->cellResult()->legendConfig->setClosestToZeroValues(0, 0, 0, 0);
this->cellResult()->legendConfig->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE);
}
size_t maxTimeStepCount = results->maxTimeStepCount();
if (this->cellResult()->isTernarySaturationSelected() && maxTimeStepCount > 1)
{
RimReservoirCellResultsStorage* gridCellResults = this->cellResult()->currentGridCellResults();
{
double globalMin = 0.0;
double globalMax = 1.0;
double localMin = 0.0;
double localMax = 1.0;
size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
if (scalarSetIndex != cvf::UNDEFINED_SIZE_T)
{
results->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax);
results->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax);
this->cellResult()->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SOIL_IDX, globalMin, globalMax, localMin, localMax);
}
}
{
double globalMin = 0.0;
double globalMax = 1.0;
double localMin = 0.0;
double localMax = 1.0;
size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS");
if (scalarSetIndex != cvf::UNDEFINED_SIZE_T)
{
results->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax);
results->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax);
this->cellResult()->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SGAS_IDX, globalMin, globalMax, localMin, localMax);
}
}
{
double globalMin = 0.0;
double globalMax = 1.0;
double localMin = 0.0;
double localMax = 1.0;
size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SWAT");
if (scalarSetIndex != cvf::UNDEFINED_SIZE_T)
{
results->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax);
results->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax);
this->cellResult()->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SWAT_IDX, globalMin, globalMax, localMin, localMax);
}
}
if (this->cellResult()->ternaryLegendConfig->legend())
{
m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->ternaryLegendConfig->legend());
}
updateMinMaxValuesAndAddLegendToView(QString("Fault Results: \n"), this->faultResult()->customResultSlot(), results);
}
if (this->cellEdgeResult()->hasResult())
@ -1505,6 +1413,105 @@ void RimReservoirView::updateLegends()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimReservoirView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimResultSlot* resultSlot, RigCaseCellResultsData* cellResultsData)
{
if (resultSlot->hasResult())
{
double globalMin, globalMax;
double globalPosClosestToZero, globalNegClosestToZero;
cellResultsData->minMaxCellScalarValues(resultSlot->gridScalarIndex(), globalMin, globalMax);
cellResultsData->posNegClosestToZero(resultSlot->gridScalarIndex(), globalPosClosestToZero, globalNegClosestToZero);
double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero;
if (resultSlot->hasDynamicResult())
{
cellResultsData->minMaxCellScalarValues(resultSlot->gridScalarIndex(), m_currentTimeStep, localMin, localMax);
cellResultsData->posNegClosestToZero(resultSlot->gridScalarIndex(), m_currentTimeStep, localPosClosestToZero, localNegClosestToZero);
}
else
{
localMin = globalMin;
localMax = globalMax;
localPosClosestToZero = globalPosClosestToZero;
localNegClosestToZero = globalNegClosestToZero;
}
resultSlot->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
resultSlot->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
m_viewer->addColorLegendToBottomLeftCorner(resultSlot->legendConfig->legend());
resultSlot->legendConfig->legend()->setTitle(cvfqt::Utils::toString(legendLabel + resultSlot->resultVariable()));
}
else
{
resultSlot->legendConfig->setClosestToZeroValues(0, 0, 0, 0);
resultSlot->legendConfig->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE);
}
size_t maxTimeStepCount = cellResultsData->maxTimeStepCount();
if (resultSlot->isTernarySaturationSelected() && maxTimeStepCount > 1)
{
RimReservoirCellResultsStorage* gridCellResults = resultSlot->currentGridCellResults();
{
double globalMin = 0.0;
double globalMax = 1.0;
double localMin = 0.0;
double localMax = 1.0;
size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL");
if (scalarSetIndex != cvf::UNDEFINED_SIZE_T)
{
cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax);
cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax);
resultSlot->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SOIL_IDX, globalMin, globalMax, localMin, localMax);
}
}
{
double globalMin = 0.0;
double globalMax = 1.0;
double localMin = 0.0;
double localMax = 1.0;
size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS");
if (scalarSetIndex != cvf::UNDEFINED_SIZE_T)
{
cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax);
cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax);
resultSlot->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SGAS_IDX, globalMin, globalMax, localMin, localMax);
}
}
{
double globalMin = 0.0;
double globalMax = 1.0;
double localMin = 0.0;
double localMax = 1.0;
size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SWAT");
if (scalarSetIndex != cvf::UNDEFINED_SIZE_T)
{
cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax);
cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax);
resultSlot->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SWAT_IDX, globalMin, globalMax, localMin, localMax);
}
}
if (resultSlot->ternaryLegendConfig->legend())
{
m_viewer->addColorLegendToBottomLeftCorner(resultSlot->ternaryLegendConfig->legend());
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -2044,9 +2051,15 @@ void RimReservoirView::updateFaultColors()
// Update all fault geometry
std::vector<RivReservoirViewPartMgr::ReservoirGeometryCacheType> faultGeometriesToRecolor = visibleFaultGeometryTypes();
RimResultSlot* resultSlot = this->faultResult()->customResultSlot();
if (!resultSlot)
{
resultSlot = this->cellResult();
}
for (size_t i = 0; i < faultGeometriesToRecolor.size(); ++i)
{
m_reservoirGridPartManager->updateFaultColors(faultGeometriesToRecolor[i], m_currentTimeStep, this->cellResult());
m_reservoirGridPartManager->updateFaultColors(faultGeometriesToRecolor[i], m_currentTimeStep, resultSlot);
}
}
@ -2066,3 +2079,27 @@ void RimReservoirView::appendFaultName(RigGridBase* grid, size_t cellIndex, cvf:
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimReservoirView::isTimeStepDependentDataVisible() const
{
if (this->cellResult()->hasDynamicResult()) return true;
if (this->propertyFilterCollection()->hasActiveDynamicFilters()) return true;
if (this->wellCollection->hasVisibleWellPipes()) return true;
if (this->cellResult()->isTernarySaturationSelected()) return true;
if (this->faultResult->customResultSlot())
{
if (this->faultResult->customResultSlot()->hasDynamicResult()) return true;
if (this->faultResult->customResultSlot()->isTernarySaturationSelected()) return true;
}
return false;
}

View File

@ -33,6 +33,7 @@
#include "RivReservoirViewPartMgr.h"
class RigActiveCellInfo;
class RigCaseCellResultsData;
class RigGridBase;
class RigGridCellFaceVisibilityFilter;
class Rim3dOverlayInfoConfig;
@ -170,6 +171,7 @@ public:
void loadDataAndUpdate();
void createDisplayModelAndRedraw();
void scheduleCreateDisplayModelAndRedraw();
bool isTimeStepDependentDataVisible() const;
void scheduleGeometryRegen(unsigned short geometryType);
void scheduleReservoirGridGeometryRegen();
@ -192,12 +194,12 @@ private:
void updateStaticCellColors();
void updateStaticCellColors(unsigned short geometryType);
void updateLegends();
void updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimResultSlot* resultSlot, RigCaseCellResultsData* cellResultsData);
std::vector<RivReservoirViewPartMgr::ReservoirGeometryCacheType> visibleFaultGeometryTypes() const;
void updateFaultForcedVisibility();
void updateFaultColors();
cvf::ref<RivReservoirViewPartMgr> m_reservoirGridPartManager;
cvf::ref<RivReservoirPipesPartMgr> m_pipesPartManager;

View File

@ -666,10 +666,7 @@ void RiuMainWindow::refreshAnimationActions()
if (app->activeReservoirView()->currentGridCellResults())
{
if (app->activeReservoirView()->cellResult()->hasDynamicResult()
|| app->activeReservoirView()->propertyFilterCollection()->hasActiveDynamicFilters()
|| app->activeReservoirView()->wellCollection()->hasVisibleWellPipes()
|| app->activeReservoirView()->cellResult()->isTernarySaturationSelected())
if (app->activeReservoirView()->isTimeStepDependentDataVisible())
{
std::vector<QDateTime> timeStepDates = app->activeReservoirView()->currentGridCellResults()->cellResults()->timeStepDates(0);
bool showHoursAndMinutes = false;