#4118 Limit data points in grid cross plot by cells visible in view

This commit is contained in:
Gaute Lindkvist 2019-02-27 14:33:27 +01:00
parent 618369d7a8
commit d1c14f9729
5 changed files with 107 additions and 7 deletions

View File

@ -30,9 +30,11 @@
#include "RimCase.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimEclipseResultDefinition.h"
#include "RimGridCrossPlot.h"
#include "RimGridCrossPlotCurve.h"
#include "RimGridView.h"
#include "RimProject.h"
#include "RimTools.h"
@ -68,6 +70,8 @@ RimGridCrossPlotCurveSet::RimGridCrossPlotCurveSet()
CAF_PDM_InitField(&m_timeStep, "TimeStep", -1, "Time Step", "", "", "");
m_timeStep.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&m_cellFilterView, "VisibleCellView", "Limit to Cells Visible in View", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_categorization, "Categorization", "Data Categorization", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_xAxisProperty, "XAxisProperty", "X-Axis Property", "", "", "");
@ -240,6 +244,17 @@ void RimGridCrossPlotCurveSet::detachAllCurves()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurveSet::cellFilterViewUpdated()
{
if (m_cellFilterView())
{
loadDataAndUpdate(true);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -295,8 +310,10 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
RigEclipseResultAddress yAddress(m_yAxisProperty->resultType(), m_yAxisProperty->resultVariable());
RigEclipseResultAddress catAddress(m_categoryProperty->resultType(), m_categoryProperty->resultVariable());
std::map<int, cvf::UByteArray> timeStepCellVisibilityMap = calculateCellVisibility(eclipseCase);
RigEclipseCrossPlotResult result = RigEclipseCrossPlotDataExtractor::extract(
eclipseCase->eclipseCaseData(), m_timeStep(), xAddress, yAddress, m_categorization(), catAddress, m_categoryBinCount);
eclipseCase->eclipseCaseData(), m_timeStep(), xAddress, yAddress, m_categorization(), catAddress, m_categoryBinCount, timeStepCellVisibilityMap);
for (const auto& sampleCategory : result.categorySamplesMap)
{
@ -327,6 +344,38 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<int, cvf::UByteArray> RimGridCrossPlotCurveSet::calculateCellVisibility(RimEclipseCase* eclipseCase) const
{
std::map<int, cvf::UByteArray> timeStepCellVisibilityMap;
if (m_cellFilterView)
{
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_cellFilterView());
if (eclipseView)
{
std::set<int> timeSteps;
if (m_timeStep() == -1)
{
for (int i = 0; i < (int)eclipseCase->timeStepDates().size(); ++i)
{
timeSteps.insert(i);
}
}
else
{
timeSteps.insert(m_timeStep());
}
for (int i : timeSteps)
{
eclipseView->calculateCurrentTotalCellVisibility(&timeStepCellVisibilityMap[i], i);
}
}
}
return timeStepCellVisibilityMap;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -336,6 +385,7 @@ void RimGridCrossPlotCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUi
if (m_case)
{
uiOrdering.add(&m_timeStep);
uiOrdering.add(&m_cellFilterView);
uiOrdering.add(&m_categorization);
if (m_categorization() == RESULT_CATEGORIZATION)
@ -389,6 +439,10 @@ void RimGridCrossPlotCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* chang
{
loadDataAndUpdate(true);
}
else if (changedField == &m_cellFilterView)
{
loadDataAndUpdate(true);
}
else if (changedField == &m_isChecked)
{
triggerReplotAndTreeRebuild();
@ -425,6 +479,18 @@ QList<caf::PdmOptionItemInfo> RimGridCrossPlotCurveSet::calculateValueOptions(co
options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i));
}
}
else if (fieldNeedingOptions == &m_cellFilterView)
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case());
if (eclipseCase)
{
options.push_back(caf::PdmOptionItemInfo("Disabled", nullptr));
for (RimEclipseView* view : eclipseCase->reservoirViews.childObjects())
{
options.push_back(caf::PdmOptionItemInfo(view->name(), view, false, view->uiIcon()));
}
}
}
return options;
}

View File

@ -29,10 +29,15 @@
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include <cvfArray.h>
#include <QList>
#include <map>
class RimCase;
class RimGridCrossPlotCurve;
class RimGridView;
class RimEclipseCase;
class RimEclipseResultDefinition;
class QwtPlot;
class QwtPlotCurve;
@ -79,12 +84,16 @@ public:
QString createAutoName() const override;
QString createShortAutoName() const;
void detachAllCurves();
void cellFilterViewUpdated();
std::vector< RimGridCrossPlotCurve*> curves() const;
protected:
void initAfterRead() override;
void onLoadDataAndUpdate(bool updateParentPlot);
std::map<int, cvf::UByteArray> calculateCellVisibility(RimEclipseCase* eclipseCase) const;
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
@ -98,6 +107,7 @@ private:
caf::PdmPtrField<RimCase*> m_case;
caf::PdmField<int> m_timeStep;
caf::PdmPtrField<RimGridView*> m_cellFilterView;
caf::PdmField<CurveCategorizationEnum> m_categorization;
caf::PdmChildField<RimEclipseResultDefinition*> m_xAxisProperty;
caf::PdmChildField<RimEclipseResultDefinition*> m_yAxisProperty;

View File

@ -56,6 +56,7 @@
#include "RimFracture.h"
#include "RimFractureTemplateCollection.h"
#include "RimGridCollection.h"
#include "RimGridCrossPlotCurveSet.h"
#include "RimIntersection.h"
#include "RimIntersectionCollection.h"
#include "RimOilField.h"
@ -552,9 +553,9 @@ void RimEclipseView::createDisplayModel()
updateLegends();
}
std::vector<RimFlowCharacteristicsPlot*> objects;
this->objectsWithReferringPtrFieldsOfType(objects);
for (auto plot : objects)
std::vector<RimFlowCharacteristicsPlot*> characteristicsPlots;
this->objectsWithReferringPtrFieldsOfType(characteristicsPlots);
for (auto plot : characteristicsPlots)
{
if (plot != nullptr)
{
@ -562,6 +563,16 @@ void RimEclipseView::createDisplayModel()
}
}
std::vector<RimGridCrossPlotCurveSet*> curveSets;
this->objectsWithReferringPtrFieldsOfType(curveSets);
for (auto curveSet : curveSets)
{
if (curveSet != nullptr)
{
curveSet->cellFilterViewUpdated();
}
}
RicExportToSharingServerScheduler::instance()->scheduleUpdateSession();
}

View File

@ -40,7 +40,8 @@ RigEclipseCrossPlotResult RigEclipseCrossPlotDataExtractor::extract(RigEclipseCa
const RigEclipseResultAddress& yAddress,
RigGridCrossPlotCurveCategorization categorizationType,
const RigEclipseResultAddress& catAddress,
int categoryBinCount)
int categoryBinCount,
std::map<int, cvf::UByteArray> timeStepCellVisibilityMap)
{
RigEclipseCrossPlotResult result;
RigEclipseCrossPlotResult::CategorySamplesMap& categorySamplesMap = result.categorySamplesMap;
@ -92,6 +93,12 @@ RigEclipseCrossPlotResult RigEclipseCrossPlotDataExtractor::extract(RigEclipseCa
for (int timeStep : timeStepsToInclude)
{
const cvf::UByteArray* cellVisibility = nullptr;
if (timeStepCellVisibilityMap.count(timeStep))
{
cellVisibility = &timeStepCellVisibilityMap[timeStep];
}
int xIndex = timeStep >= (int)xValuesForAllSteps.size() ? 0 : timeStep;
int yIndex = timeStep >= (int)yValuesForAllSteps.size() ? 0 : timeStep;
@ -107,6 +114,8 @@ RigEclipseCrossPlotResult RigEclipseCrossPlotDataExtractor::extract(RigEclipseCa
for (size_t globalCellIdx = 0; globalCellIdx < activeCellInfo->reservoirCellCount(); ++globalCellIdx)
{
if (cellVisibility && !(*cellVisibility)[globalCellIdx]) continue;
double xValue = xAccessor.cellScalarGlobIdx(globalCellIdx);
double yValue = yAccessor.cellScalarGlobIdx(globalCellIdx);

View File

@ -19,6 +19,9 @@
#include "RigGridCrossPlotCurveCategorization.h"
#include "cvfBase.h"
#include "cvfArray.h"
#include <map>
#include <utility>
#include <vector>
@ -48,5 +51,6 @@ public:
const RigEclipseResultAddress& yAddress,
RigGridCrossPlotCurveCategorization categorizationType,
const RigEclipseResultAddress& categoryAddress,
int categoryBinCount);
int categoryBinCount,
std::map<int, cvf::UByteArray> timeStepCellVisibilityMap);
};