Filter framework

This commit is contained in:
Magne Sjaastad 2019-03-19 09:28:00 +01:00
parent 18d482ec9a
commit 924916fdd7
16 changed files with 700 additions and 59 deletions

View File

@ -109,6 +109,7 @@ list( APPEND REFERENCED_CMAKE_FILES
ProjectDataModel/CMakeLists_files.cmake ProjectDataModel/CMakeLists_files.cmake
ProjectDataModel/GridCrossPlots/CMakeLists_files.cmake ProjectDataModel/GridCrossPlots/CMakeLists_files.cmake
ProjectDataModel/GridCrossPlots/CellFilters/CMakeLists_files.cmake
ProjectDataModel/Summary/CMakeLists_files.cmake ProjectDataModel/Summary/CMakeLists_files.cmake
ProjectDataModel/Flow/CMakeLists_files.cmake ProjectDataModel/Flow/CMakeLists_files.cmake
ProjectDataModel/Annotations/CMakeLists_files.cmake ProjectDataModel/Annotations/CMakeLists_files.cmake

View File

@ -0,0 +1,22 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimPlotCellFilter.h
${CMAKE_CURRENT_LIST_DIR}/RimPlotCellFilterCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPlotCellPropertyFilter.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimPlotCellFilter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlotCellFilterCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPlotCellPropertyFilter.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "ProjectDataModel\\GridCrossPlots\\CellFilters" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake )

View File

@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimPlotCellFilter.h"
namespace caf
{
template<>
void caf::AppEnum<RimPlotCellFilter::FilterModeType>::setUp()
{
addItem(RimPlotCellFilter::INCLUDE, "INCLUDE", "Include");
addItem(RimPlotCellFilter::EXCLUDE, "EXCLUDE", "Exclude");
setDefault(RimPlotCellFilter::INCLUDE);
}
} // namespace caf
CAF_PDM_ABSTRACT_SOURCE_INIT(RimPlotCellFilter, "RimPlotCellFilter");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotCellFilter::RimPlotCellFilter()
{
CAF_PDM_InitFieldNoDefault(&m_filterType, "FilterType", "Filter Type", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCellFilter::updateCellVisibility(size_t timeStepIndex, cvf::UByteArray* cellVisibility)
{
updateCellVisibilityFromFilter(timeStepIndex, cellVisibility);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotCellFilter::FilterModeType RimPlotCellFilter::filterType() const
{
return m_filterType();
}

View File

@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimCheckableNamedObject.h"
#include "cvfArray.h"
#include "cvfBase.h"
//==================================================================================================
///
//==================================================================================================
class RimPlotCellFilter : public RimCheckableNamedObject
{
CAF_PDM_HEADER_INIT;
public:
enum FilterModeType
{
INCLUDE,
EXCLUDE
};
public:
RimPlotCellFilter();
void updateCellVisibility(size_t timeStepIndex, cvf::UByteArray* cellVisibility);
FilterModeType filterType() const;
protected:
virtual void updateCellVisibilityFromFilter(size_t timeStepIndex, cvf::UByteArray* cellVisibility) = 0;
private:
caf::PdmField<caf::AppEnum<FilterModeType>> m_filterType;
};

View File

@ -0,0 +1,68 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimPlotCellFilterCollection.h"
CAF_PDM_SOURCE_INIT(RimPlotCellFilterCollection, "RimPlotCellFilterCollection");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotCellFilterCollection::RimPlotCellFilterCollection()
{
CAF_PDM_InitObject("Plot Cell Filters", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_cellFilters, "CellFilters", "Cell Filters", "", "", "");
// m_crossPlotCurveSets.uiCapability()->setUiHidden(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCellFilterCollection::addCellFilter(RimPlotCellFilter* cellFilter)
{
m_cellFilters.push_back(cellFilter);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimPlotCellFilterCollection::cellFilterCount() const
{
return m_cellFilters.size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCellFilterCollection::computeCellVisibilityFromFilter(size_t timeStepIndex, cvf::UByteArray* cellVisibility)
{
updateCellVisibilityFromFilter(timeStepIndex, cellVisibility);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCellFilterCollection::updateCellVisibilityFromFilter(size_t timeStepIndex, cvf::UByteArray* cellVisibility)
{
for (RimPlotCellFilter* f : m_cellFilters())
{
f->updateCellVisibility(timeStepIndex, cellVisibility);
}
}

View File

@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimPlotCellFilter.h"
#include "cafPdmChildArrayField.h"
//==================================================================================================
///
//==================================================================================================
class RimPlotCellFilterCollection : public RimPlotCellFilter
{
CAF_PDM_HEADER_INIT;
public:
RimPlotCellFilterCollection();
void addCellFilter(RimPlotCellFilter* cellFilter);
size_t cellFilterCount() const;
void computeCellVisibilityFromFilter(size_t timeStepIndex, cvf::UByteArray* cellVisibility);
protected:
void updateCellVisibilityFromFilter(size_t timeStepIndex, cvf::UByteArray* cellVisibility) override;
private:
caf::PdmChildArrayField<RimPlotCellFilter*> m_cellFilters;
};

View File

@ -0,0 +1,147 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimPlotCellPropertyFilter.h"
#include "RimEclipseResultDefinition.h"
#include "RimGeoMechResultDefinition.h"
#include "RigActiveCellInfo.h"
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"
#include "RimEclipseCase.h"
#include "cafPdmUiDoubleSliderEditor.h"
CAF_PDM_SOURCE_INIT(RimPlotCellPropertyFilter, "RimPlotCellPropertyFilter");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimPlotCellPropertyFilter::RimPlotCellPropertyFilter()
{
CAF_PDM_InitObject("Plot Cell Property Filter", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_resultDefinition, "ResultDefinition", "Result Definition", "", "", "");
// Set to hidden to avoid this item to been displayed as a child item
// Fields in this object are displayed using defineUiOrdering()
m_resultDefinition.uiCapability()->setUiHidden(true);
m_resultDefinition.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitField(&m_lowerBound, "LowerBound", 0.0, "Min", "", "", "");
m_lowerBound.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
CAF_PDM_InitField(&m_upperBound, "UpperBound", 0.0, "Max", "", "", "");
m_upperBound.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCellPropertyFilter::setResultDefinition(caf::PdmObject* resultDefinition)
{
m_resultDefinition = resultDefinition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCellPropertyFilter::setValueRange(double lowerBound, double upperBound)
{
m_lowerBound = lowerBound;
m_upperBound = upperBound;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseResultDefinition* RimPlotCellPropertyFilter::eclipseResultDefinition()
{
caf::PdmObject* pdmObj = m_resultDefinition;
return dynamic_cast<RimEclipseResultDefinition*>(pdmObj);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCellPropertyFilter::updateCellVisibilityFromFilter(size_t timeStepIndex, cvf::UByteArray* visibleCells)
{
CVF_ASSERT(visibleCells);
RimEclipseResultDefinition* resDef = eclipseResultDefinition();
if (resDef)
{
resDef->loadResult();
RimEclipseCase* eclCase = resDef->eclipseCase();
if (!eclCase) return;
eclCase->ensureReservoirCaseIsOpen();
RigEclipseCaseData* eclipseCaseData = eclCase->eclipseCaseData();
if (!eclipseCaseData) return;
RigCaseCellResultsData* cellResultsData = resDef->currentGridCellResults();
if (!cellResultsData) return;
const std::vector<double>& cellResultValues = cellResultsData->cellScalarResults(resDef->eclipseResultAddress(), timeStepIndex);
if (cellResultValues.empty()) return;
const RigActiveCellInfo* actCellInfo = cellResultsData->activeCellInfo();
size_t cellCount = actCellInfo->reservoirCellCount();
bool isUsingGlobalActiveIndex = cellResultsData->isUsingGlobalActiveIndex(resDef->eclipseResultAddress());
double lowerBound = m_lowerBound;
double upperBound = m_upperBound;
for (size_t reservoirCellIndex = 0; reservoirCellIndex < cellCount; ++reservoirCellIndex)
{
if (!actCellInfo->isActive(reservoirCellIndex)) continue;
size_t cellResultIndex = reservoirCellIndex;
if (isUsingGlobalActiveIndex)
{
cellResultIndex = actCellInfo->cellResultIndex(reservoirCellIndex);
}
if (cellResultIndex != cvf::UNDEFINED_SIZE_T && cellResultIndex < cellResultValues.size())
{
if ((*visibleCells)[reservoirCellIndex])
{
double scalarValue = cellResultValues[cellResultIndex];
if (lowerBound <= scalarValue && scalarValue <= upperBound)
{
if (filterType() == RimPlotCellFilter::EXCLUDE)
{
(*visibleCells)[reservoirCellIndex] = false;
}
}
else
{
if (filterType() == RimPlotCellFilter::INCLUDE)
{
(*visibleCells)[reservoirCellIndex] = false;
}
}
}
}
}
}
}

View File

@ -0,0 +1,57 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimPlotCellFilter.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cvfArray.h"
#include "cvfBase.h"
class RimEclipseResultDefinition;
//==================================================================================================
///
//==================================================================================================
class RimPlotCellPropertyFilter : public RimPlotCellFilter
{
CAF_PDM_HEADER_INIT;
public:
RimPlotCellPropertyFilter();
void setResultDefinition(caf::PdmObject* resultDefinition);
void setValueRange(double lowerBound, double upperBound);
protected:
void updateCellVisibilityFromFilter(size_t timeStepIndex, cvf::UByteArray* visibleCells) override;
private:
RimEclipseResultDefinition* eclipseResultDefinition();
private:
caf::PdmChildField<caf::PdmObject*> m_resultDefinition;
caf::PdmField<double> m_lowerBound;
caf::PdmField<double> m_upperBound;
cvf::ref<cvf::UByteArray> m_visibleCells;
};

View File

@ -37,9 +37,10 @@
#include "RimCase.h" #include "RimCase.h"
#include "RimEclipseCase.h" #include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimEclipseCellColors.h" #include "RimEclipseCellColors.h"
#include "RimEclipseResultCase.h"
#include "RimEclipseResultDefinition.h" #include "RimEclipseResultDefinition.h"
#include "RimEclipseView.h"
#include "RimGridCrossPlot.h" #include "RimGridCrossPlot.h"
#include "RimGridCrossPlotCurve.h" #include "RimGridCrossPlotCurve.h"
#include "RimGridView.h" #include "RimGridView.h"
@ -47,6 +48,8 @@
#include "RimRegularLegendConfig.h" #include "RimRegularLegendConfig.h"
#include "RimTools.h" #include "RimTools.h"
#include "CellFilters/RimPlotCellFilterCollection.h"
#include "cafCategoryMapper.h" #include "cafCategoryMapper.h"
#include "cafColorTable.h" #include "cafColorTable.h"
#include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiComboBoxEditor.h"
@ -57,7 +60,6 @@
#include "cvfqtUtils.h" #include "cvfqtUtils.h"
#include <QString> #include <QString>
#include "RimEclipseResultCase.h"
CAF_PDM_SOURCE_INIT(RimGridCrossPlotCurveSet, "GridCrossPlotCurveSet"); CAF_PDM_SOURCE_INIT(RimGridCrossPlotCurveSet, "GridCrossPlotCurveSet");
@ -72,7 +74,7 @@ void RimGridCrossPlotCurveSet::CurveGroupingEnum::setUp()
addItem(RigGridCrossPlotCurveGrouping::GROUP_BY_RESULT, "RESULT", "Result Property"); addItem(RigGridCrossPlotCurveGrouping::GROUP_BY_RESULT, "RESULT", "Result Property");
setDefault(RigGridCrossPlotCurveGrouping::GROUP_BY_TIME); setDefault(RigGridCrossPlotCurveGrouping::GROUP_BY_TIME);
} }
} } // namespace caf
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@ -118,6 +120,9 @@ RimGridCrossPlotCurveSet::RimGridCrossPlotCurveSet()
CAF_PDM_InitField(&m_useCustomColor, "UseCustomColor", false, "Use Custom Color", "", "", ""); CAF_PDM_InitField(&m_useCustomColor, "UseCustomColor", false, "Use Custom Color", "", "", "");
CAF_PDM_InitField(&m_customColor, "CustomColor", cvf::Color3f(cvf::Color3f::BLACK), "Custom Color", "", "", ""); CAF_PDM_InitField(&m_customColor, "CustomColor", cvf::Color3f(cvf::Color3f::BLACK), "Custom Color", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_plotCellFilterCollection, "PlotCellFilterCollection", "Cell Filters", "", "", "");
m_plotCellFilterCollection = new RimPlotCellFilterCollection;
setDefaults(); setDefaults();
} }
@ -341,18 +346,13 @@ std::vector<QString> RimGridCrossPlotCurveSet::groupStrings() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::map<RimGridCrossPlotCurveSet::NameComponents, QString> std::map<RimGridCrossPlotCurveSet::NameComponents, QString> RimGridCrossPlotCurveSet::nameComponents() const
RimGridCrossPlotCurveSet::nameComponents() const
{ {
std::map<RimGridCrossPlotCurveSet::NameComponents, QString> componentNames; std::map<RimGridCrossPlotCurveSet::NameComponents, QString> componentNames;
if (m_nameConfig->addCaseName()) if (m_nameConfig->addCaseName()) componentNames[GCP_CASE_NAME] = caseNameString();
componentNames[GCP_CASE_NAME] = caseNameString(); if (m_nameConfig->addAxisVariables()) componentNames[GCP_AXIS_VARIABLES] = axisVariableString();
if (m_nameConfig->addAxisVariables()) if (m_nameConfig->addTimestep()) componentNames[GCP_TIME_STEP] = timeStepString();
componentNames[GCP_AXIS_VARIABLES] = axisVariableString(); if (m_nameConfig->addGrouping()) componentNames[GCP_GROUP_NAME] = groupTitle();
if (m_nameConfig->addTimestep())
componentNames[GCP_TIME_STEP] = timeStepString();
if (m_nameConfig->addGrouping())
componentNames[GCP_GROUP_NAME] = groupTitle();
return componentNames; return componentNames;
} }
@ -431,7 +431,6 @@ void RimGridCrossPlotCurveSet::createCurves(const RigEclipseCrossPlotResult& res
m_groupedResults.clear(); m_groupedResults.clear();
if (!groupingEnabled()) if (!groupingEnabled())
{ {
RimGridCrossPlotCurve* curve = new RimGridCrossPlotCurve(); RimGridCrossPlotCurve* curve = new RimGridCrossPlotCurve();
if (m_useCustomColor) if (m_useCustomColor)
{ {
@ -458,10 +457,8 @@ void RimGridCrossPlotCurveSet::createCurves(const RigEclipseCrossPlotResult& res
{ {
for (size_t i = 0; i < result.xValues.size(); ++i) for (size_t i = 0; i < result.xValues.size(); ++i)
{ {
int categoryNum = int categoryNum = m_grouping == GROUP_BY_RESULT ? static_cast<int>(result.groupValuesContinuous[i])
m_grouping == GROUP_BY_RESULT : result.groupValuesDiscrete[i];
? static_cast<int>(result.groupValuesContinuous[i])
: result.groupValuesDiscrete[i];
m_groupedResults[categoryNum].xValues.push_back(result.xValues[i]); m_groupedResults[categoryNum].xValues.push_back(result.xValues[i]);
m_groupedResults[categoryNum].yValues.push_back(result.yValues[i]); m_groupedResults[categoryNum].yValues.push_back(result.yValues[i]);
@ -469,7 +466,6 @@ void RimGridCrossPlotCurveSet::createCurves(const RigEclipseCrossPlotResult& res
m_groupedResults[categoryNum].groupValuesContinuous.push_back(result.groupValuesContinuous[i]); m_groupedResults[categoryNum].groupValuesContinuous.push_back(result.groupValuesContinuous[i]);
if (!result.groupValuesDiscrete.empty()) if (!result.groupValuesDiscrete.empty())
m_groupedResults[categoryNum].groupValuesDiscrete.push_back(result.groupValuesDiscrete[i]); m_groupedResults[categoryNum].groupValuesDiscrete.push_back(result.groupValuesDiscrete[i]);
} }
} }
else else
@ -478,9 +474,9 @@ void RimGridCrossPlotCurveSet::createCurves(const RigEclipseCrossPlotResult& res
for (size_t i = 0; i < result.xValues.size(); ++i) for (size_t i = 0; i < result.xValues.size(); ++i)
{ {
auto upperBoundIt = std::lower_bound(tickValues.begin(), tickValues.end(), result.groupValuesContinuous[i]); auto upperBoundIt = std::lower_bound(tickValues.begin(), tickValues.end(), result.groupValuesContinuous[i]);
int upperBoundIndex = static_cast<int>(upperBoundIt - tickValues.begin()); int upperBoundIndex = static_cast<int>(upperBoundIt - tickValues.begin());
int categoryNum = std::min((int) tickValues.size() - 2, std::max(0, upperBoundIndex - 1)); int categoryNum = std::min((int)tickValues.size() - 2, std::max(0, upperBoundIndex - 1));
m_groupedResults[categoryNum].xValues.push_back(result.xValues[i]); m_groupedResults[categoryNum].xValues.push_back(result.xValues[i]);
m_groupedResults[categoryNum].yValues.push_back(result.yValues[i]); m_groupedResults[categoryNum].yValues.push_back(result.yValues[i]);
if (!result.groupValuesContinuous.empty()) if (!result.groupValuesContinuous.empty())
@ -561,6 +557,44 @@ std::map<int, cvf::UByteArray> RimGridCrossPlotCurveSet::calculateCellVisibility
} }
} }
} }
else if (m_plotCellFilterCollection->cellFilterCount() > 0)
{
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());
}
RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData();
if (eclipseCaseData)
{
RiaDefines::PorosityModelType porosityModel = RiaDefines::MATRIX_MODEL;
RigCaseCellResultsData* cellResultsData = eclipseCaseData->results(porosityModel);
if (cellResultsData)
{
const RigActiveCellInfo* actCellInfo = cellResultsData->activeCellInfo();
size_t cellCount = actCellInfo->reservoirCellCount();
for (int i : timeSteps)
{
cvf::UByteArray* cellVisibility = &timeStepCellVisibilityMap[i];
cellVisibility->resize(cellCount);
cellVisibility->setAll(true);
m_plotCellFilterCollection->computeCellVisibilityFromFilter(i, cellVisibility);
}
}
}
}
return timeStepCellVisibilityMap; return timeStepCellVisibilityMap;
} }
@ -576,8 +610,7 @@ void RimGridCrossPlotCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUi
uiOrdering.add(&m_cellFilterView); uiOrdering.add(&m_cellFilterView);
uiOrdering.add(&m_grouping); uiOrdering.add(&m_grouping);
if (m_grouping() == GROUP_BY_TIME && if (m_grouping() == GROUP_BY_TIME && !(m_xAxisProperty->hasDynamicResult() || m_yAxisProperty->hasDynamicResult()))
!(m_xAxisProperty->hasDynamicResult() || m_yAxisProperty->hasDynamicResult()))
{ {
m_grouping = NO_GROUPING; m_grouping = NO_GROUPING;
} }
@ -649,7 +682,6 @@ void RimGridCrossPlotCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* chang
{ {
legendConfig()->setColorRange(RimRegularLegendConfig::NORMAL); legendConfig()->setColorRange(RimRegularLegendConfig::NORMAL);
legendConfig()->setMappingMode(RimRegularLegendConfig::LINEAR_DISCRETE); legendConfig()->setMappingMode(RimRegularLegendConfig::LINEAR_DISCRETE);
} }
loadDataAndUpdate(true); loadDataAndUpdate(true);
@ -710,7 +742,7 @@ QList<caf::PdmOptionItemInfo> RimGridCrossPlotCurveSet::calculateValueOptions(co
} }
else if (fieldNeedingOptions == &m_grouping) else if (fieldNeedingOptions == &m_grouping)
{ {
std::set<RigGridCrossPlotCurveGrouping> validOptions = { NO_GROUPING, GROUP_BY_TIME, GROUP_BY_FORMATION, GROUP_BY_RESULT }; std::set<RigGridCrossPlotCurveGrouping> validOptions = {NO_GROUPING, GROUP_BY_TIME, GROUP_BY_FORMATION, GROUP_BY_RESULT};
if (!hasMultipleTimeSteps()) if (!hasMultipleTimeSteps())
{ {
validOptions.erase(GROUP_BY_TIME); validOptions.erase(GROUP_BY_TIME);
@ -764,7 +796,7 @@ void RimGridCrossPlotCurveSet::updateLegend()
} }
else if (m_grouping() == GROUP_BY_TIME) else if (m_grouping() == GROUP_BY_TIME)
{ {
QStringList timeStepNames = m_case->timeStepStrings(); QStringList timeStepNames = m_case->timeStepStrings();
std::vector<QString> categoryNames; std::vector<QString> categoryNames;
for (auto name : timeStepNames) for (auto name : timeStepNames)
{ {
@ -847,8 +879,7 @@ void RimGridCrossPlotCurveSet::swapAxisProperties(bool updatePlot)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurveSet::exportFormattedData(RifEclipseDataTableFormatter& formatter) const void RimGridCrossPlotCurveSet::exportFormattedData(RifEclipseDataTableFormatter& formatter) const
{ {
if (m_groupedResults.empty()) if (m_groupedResults.empty()) return;
return;
if (m_grouping != NO_GROUPING) if (m_grouping != NO_GROUPING)
{ {
@ -881,8 +912,8 @@ void RimGridCrossPlotCurveSet::exportFormattedData(RifEclipseDataTableFormatter&
} }
else else
{ {
int groupIndex = it->first; int groupIndex = it->first;
QString groupName = createGroupName(groupIndex); QString groupName = createGroupName(groupIndex);
formatter.add(res.xValues[i]); formatter.add(res.xValues[i]);
formatter.add(res.yValues[i]); formatter.add(res.yValues[i]);
formatter.add(groupIndex); formatter.add(groupIndex);
@ -916,7 +947,8 @@ bool RimGridCrossPlotCurveSet::isYAxisLogarithmic() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurveSet::setFromCaseAndEquilibriumRegion(RimEclipseResultCase* eclipseCase, const QString& dynamicResultName) void RimGridCrossPlotCurveSet::setFromCaseAndEquilibriumRegion(RimEclipseResultCase* eclipseCase,
const QString& dynamicResultName)
{ {
m_case = eclipseCase; m_case = eclipseCase;
@ -931,14 +963,21 @@ void RimGridCrossPlotCurveSet::setFromCaseAndEquilibriumRegion(RimEclipseResultC
m_grouping = NO_GROUPING; m_grouping = NO_GROUPING;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurveSet::addCellFilter(RimPlotCellFilter* cellFilter)
{
m_plotCellFilterCollection->addCellFilter(cellFilter);
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimGridCrossPlotCurveSet::setCustomColor(const cvf::Color3f color) void RimGridCrossPlotCurveSet::setCustomColor(const cvf::Color3f color)
{ {
m_useCustomColor = true; m_useCustomColor = true;
m_customColor = color; m_customColor = color;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1015,7 +1054,7 @@ void RimGridCrossPlotCurveSet::setDefaults()
if (!project->eclipseCases().empty()) if (!project->eclipseCases().empty())
{ {
RimEclipseCase* eclipseCase = project->eclipseCases().front(); RimEclipseCase* eclipseCase = project->eclipseCases().front();
m_case = eclipseCase; m_case = eclipseCase;
m_xAxisProperty->setEclipseCase(eclipseCase); m_xAxisProperty->setEclipseCase(eclipseCase);
m_yAxisProperty->setEclipseCase(eclipseCase); m_yAxisProperty->setEclipseCase(eclipseCase);
m_groupingProperty->setEclipseCase(eclipseCase); m_groupingProperty->setEclipseCase(eclipseCase);
@ -1053,6 +1092,8 @@ void RimGridCrossPlotCurveSet::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTr
uiTreeOrdering.add(curve); uiTreeOrdering.add(curve);
} }
uiTreeOrdering.add(&m_plotCellFilterCollection);
uiTreeOrdering.skipRemainingChildren(true); uiTreeOrdering.skipRemainingChildren(true);
} }
@ -1062,7 +1103,6 @@ void RimGridCrossPlotCurveSet::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTr
bool RimGridCrossPlotCurveSet::hasMultipleTimeSteps() const bool RimGridCrossPlotCurveSet::hasMultipleTimeSteps() const
{ {
return m_timeStep() == -1 && (m_xAxisProperty->hasDynamicResult() || m_yAxisProperty->hasDynamicResult()); return m_timeStep() == -1 && (m_xAxisProperty->hasDynamicResult() || m_yAxisProperty->hasDynamicResult());
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1075,13 +1115,12 @@ void RimGridCrossPlotCurveSet::filterInvalidCurveValues(RigEclipseCrossPlotResul
if (xLog || yLog) if (xLog || yLog)
{ {
RigEclipseCrossPlotResult validResult; RigEclipseCrossPlotResult validResult;
for (size_t i = 0; i < result->xValues.size(); ++i) for (size_t i = 0; i < result->xValues.size(); ++i)
{ {
double xValue = result->xValues[i]; double xValue = result->xValues[i];
double yValue = result->yValues[i]; double yValue = result->yValues[i];
bool invalid = (xLog && xValue <= 0.0) || (yLog && yValue <= 0.0); bool invalid = (xLog && xValue <= 0.0) || (yLog && yValue <= 0.0);
if (!invalid) if (!invalid)
{ {
validResult.xValues.push_back(xValue); validResult.xValues.push_back(xValue);

View File

@ -50,6 +50,8 @@ class RimRegularLegendConfig;
class QwtPlot; class QwtPlot;
class QwtPlotCurve; class QwtPlotCurve;
class QString; class QString;
class RimPlotCellFilterCollection;
class RimPlotCellFilter;
class RimGridCrossPlotCurveSetNameConfig : public RimNameConfig class RimGridCrossPlotCurveSetNameConfig : public RimNameConfig
{ {
@ -125,8 +127,10 @@ public:
bool isYAxisLogarithmic() const; bool isYAxisLogarithmic() const;
void setFromCaseAndEquilibriumRegion(RimEclipseResultCase* eclipseResultCase, const QString& dynamicResultName); void setFromCaseAndEquilibriumRegion(RimEclipseResultCase* eclipseResultCase, const QString& dynamicResultName);
void addCellFilter(RimPlotCellFilter* cellFilter);
void setCustomColor(const cvf::Color3f color); void setCustomColor(const cvf::Color3f color);
protected: protected:
void initAfterRead() override; void initAfterRead() override;
void onLoadDataAndUpdate(bool updateParentPlot); void onLoadDataAndUpdate(bool updateParentPlot);
@ -168,4 +172,6 @@ private:
caf::PdmField<bool> m_useCustomColor; caf::PdmField<bool> m_useCustomColor;
caf::PdmField<cvf::Color3f> m_customColor; caf::PdmField<cvf::Color3f> m_customColor;
caf::PdmChildField<RimPlotCellFilterCollection*> m_plotCellFilterCollection;;
}; };

View File

@ -18,11 +18,18 @@
#include "RimSaturationPressurePlot.h" #include "RimSaturationPressurePlot.h"
#include "RigEclipseCaseData.h"
#include "RigEquil.h"
#include "RimEclipseResultCase.h" #include "RimEclipseResultCase.h"
#include "RimEclipseResultDefinition.h"
#include "RimGridCrossPlotCurveSet.h" #include "RimGridCrossPlotCurveSet.h"
#include "RimPlotAxisAnnotation.h" #include "RimPlotAxisAnnotation.h"
#include "RimPlotAxisProperties.h" #include "RimPlotAxisProperties.h"
#include "CellFilters/RimPlotCellPropertyFilter.h"
#include "RigCaseCellResultsData.h"
CAF_PDM_SOURCE_INIT(RimSaturationPressurePlot, "RimSaturationPressurePlot"); CAF_PDM_SOURCE_INIT(RimSaturationPressurePlot, "RimSaturationPressurePlot");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -36,29 +43,144 @@ RimSaturationPressurePlot::RimSaturationPressurePlot()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSaturationPressurePlot::assignCaseAndEquilibriumRegion(RimEclipseResultCase* eclipseResultCase, int equilibriumRegion) void RimSaturationPressurePlot::assignCaseAndEquilibriumRegion(RiaDefines::PorosityModelType porosityType,
RimEclipseResultCase* eclipseResultCase,
int zeroBasedEquilRegionIndex)
{ {
nameConfig()->addDataSetNames = false; nameConfig()->addDataSetNames = false;
QString caseName = eclipseResultCase->caseUserDescription(); QString caseName = eclipseResultCase->caseUserDescription();
QString plotTitle = QString("%1 - EQLNUM %2").arg(caseName).arg(equilibriumRegion); QString plotTitle = QString("%1 - EQLNUM %2").arg(caseName).arg(zeroBasedEquilRegionIndex + 1);
nameConfig()->setCustomName(plotTitle); nameConfig()->setCustomName(plotTitle);
auto equilData = eclipseResultCase->eclipseCaseData()->equilData();
auto eq = equilData[zeroBasedEquilRegionIndex];
double gasOilContactDepth = eq.gasOilContactDepth();
double waterOilContactDepth = eq.waterOilContactDepth();
{ {
RimGridCrossPlotCurveSet* curveSet = createCurveSet(); RimGridCrossPlotCurveSet* curveSet = createCurveSet();
curveSet->setFromCaseAndEquilibriumRegion(eclipseResultCase, "PRESSURE"); curveSet->setFromCaseAndEquilibriumRegion(eclipseResultCase, "PRESSURE");
curveSet->setCustomColor(cvf::Color3::BLUE); curveSet->setCustomColor(cvf::Color3::BLUE);
RimPlotCellPropertyFilter* cellFilter = new RimPlotCellPropertyFilter();
{
RimEclipseResultDefinition* resultDefinition = new RimEclipseResultDefinition();
resultDefinition->setEclipseCase(eclipseResultCase);
resultDefinition->setResultType(RiaDefines::STATIC_NATIVE);
resultDefinition->setResultVariable("EQLNUM");
cellFilter->setResultDefinition(resultDefinition);
}
cellFilter->setValueRange(zeroBasedEquilRegionIndex + 1, zeroBasedEquilRegionIndex + 1);
curveSet->addCellFilter(cellFilter);
} }
{ {
RimGridCrossPlotCurveSet* curveSet = createCurveSet(); RimGridCrossPlotCurveSet* curveSet = createCurveSet();
curveSet->setFromCaseAndEquilibriumRegion(eclipseResultCase, "PDEW"); curveSet->setFromCaseAndEquilibriumRegion(eclipseResultCase, "PDEW");
curveSet->setCustomColor(cvf::Color3::RED); curveSet->setCustomColor(cvf::Color3::RED);
{
RimPlotCellPropertyFilter* cellFilter = new RimPlotCellPropertyFilter();
{
RimEclipseResultDefinition* resultDefinition = new RimEclipseResultDefinition();
resultDefinition->setEclipseCase(eclipseResultCase);
resultDefinition->setResultType(RiaDefines::STATIC_NATIVE);
resultDefinition->setResultVariable("EQLNUM");
cellFilter->setResultDefinition(resultDefinition);
}
cellFilter->setValueRange(zeroBasedEquilRegionIndex + 1, zeroBasedEquilRegionIndex + 1);
curveSet->addCellFilter(cellFilter);
}
{
RigCaseCellResultsData* caseCellResultsData = eclipseResultCase->eclipseCaseData()->results(porosityType);
if (caseCellResultsData)
{
RigEclipseResultAddress depthResultAddress(RiaDefines::STATIC_NATIVE, "DEPTH");
double minDepth = 0.0;
double maxDepth = 0.0;
caseCellResultsData->minMaxCellScalarValues(depthResultAddress, minDepth, maxDepth);
maxDepth = gasOilContactDepth;
RimPlotCellPropertyFilter* depthCellFilter = new RimPlotCellPropertyFilter();
{
RimEclipseResultDefinition* resultDefinition = new RimEclipseResultDefinition();
resultDefinition->setPorosityModel(porosityType);
resultDefinition->setEclipseCase(eclipseResultCase);
resultDefinition->setResultType(depthResultAddress.m_resultCatType);
resultDefinition->setResultVariable(depthResultAddress.m_resultName);
depthCellFilter->setResultDefinition(resultDefinition);
}
depthCellFilter->setValueRange(minDepth, maxDepth);
curveSet->addCellFilter(depthCellFilter);
}
}
} }
{ {
RimGridCrossPlotCurveSet* curveSet = createCurveSet(); RimGridCrossPlotCurveSet* curveSet = createCurveSet();
curveSet->setFromCaseAndEquilibriumRegion(eclipseResultCase, "PBUB"); curveSet->setFromCaseAndEquilibriumRegion(eclipseResultCase, "PBUB");
curveSet->setCustomColor(cvf::Color3::GREEN); curveSet->setCustomColor(cvf::Color3::GREEN);
{
RimPlotCellPropertyFilter* cellFilter = new RimPlotCellPropertyFilter();
{
RimEclipseResultDefinition* resultDefinition = new RimEclipseResultDefinition();
resultDefinition->setEclipseCase(eclipseResultCase);
resultDefinition->setResultType(RiaDefines::STATIC_NATIVE);
resultDefinition->setResultVariable("EQLNUM");
cellFilter->setResultDefinition(resultDefinition);
}
cellFilter->setValueRange(zeroBasedEquilRegionIndex + 1, zeroBasedEquilRegionIndex + 1);
curveSet->addCellFilter(cellFilter);
}
{
RigCaseCellResultsData* caseCellResultsData = eclipseResultCase->eclipseCaseData()->results(porosityType);
if (caseCellResultsData)
{
RigEclipseResultAddress depthResultAddress(RiaDefines::STATIC_NATIVE, "DEPTH");
double minDepth = 0.0;
double maxDepth = 0.0;
caseCellResultsData->minMaxCellScalarValues(depthResultAddress, minDepth, maxDepth);
minDepth = gasOilContactDepth;
maxDepth = waterOilContactDepth;
RimPlotCellPropertyFilter* depthCellFilter = new RimPlotCellPropertyFilter();
{
RimEclipseResultDefinition* resultDefinition = new RimEclipseResultDefinition();
resultDefinition->setPorosityModel(porosityType);
resultDefinition->setEclipseCase(eclipseResultCase);
resultDefinition->setResultType(depthResultAddress.m_resultCatType);
resultDefinition->setResultVariable(depthResultAddress.m_resultName);
depthCellFilter->setResultDefinition(resultDefinition);
}
depthCellFilter->setValueRange(minDepth, maxDepth);
curveSet->addCellFilter(depthCellFilter);
}
}
} }
RimPlotAxisProperties* yAxisProps = yAxisProperties(); RimPlotAxisProperties* yAxisProps = yAxisProperties();
@ -67,13 +189,15 @@ void RimSaturationPressurePlot::assignCaseAndEquilibriumRegion(RimEclipseResultC
{ {
RimPlotAxisAnnotation* annotation = new RimPlotAxisAnnotation; RimPlotAxisAnnotation* annotation = new RimPlotAxisAnnotation;
annotation->setEquilibriumData(eclipseResultCase, equilibriumRegion, RimPlotAxisAnnotation::PL_EQUIL_GAS_OIL_CONTACT); annotation->setEquilibriumData(
eclipseResultCase, zeroBasedEquilRegionIndex, RimPlotAxisAnnotation::PL_EQUIL_GAS_OIL_CONTACT);
yAxisProps->appendAnnotation(annotation); yAxisProps->appendAnnotation(annotation);
} }
{ {
RimPlotAxisAnnotation* annotation = new RimPlotAxisAnnotation; RimPlotAxisAnnotation* annotation = new RimPlotAxisAnnotation;
annotation->setEquilibriumData(eclipseResultCase, equilibriumRegion, RimPlotAxisAnnotation::PL_EQUIL_WATER_OIL_CONTACT); annotation->setEquilibriumData(
eclipseResultCase, zeroBasedEquilRegionIndex, RimPlotAxisAnnotation::PL_EQUIL_WATER_OIL_CONTACT);
yAxisProps->appendAnnotation(annotation); yAxisProps->appendAnnotation(annotation);
} }

View File

@ -19,6 +19,7 @@
#pragma once #pragma once
#include "RimGridCrossPlot.h" #include "RimGridCrossPlot.h"
#include "RiaPorosityModel.h"
class RimEclipseResultCase; class RimEclipseResultCase;
@ -32,7 +33,9 @@ class RimSaturationPressurePlot : public RimGridCrossPlot
public: public:
RimSaturationPressurePlot(); RimSaturationPressurePlot();
void assignCaseAndEquilibriumRegion(RimEclipseResultCase* eclipseResultCase, int equilibriumRegion); void assignCaseAndEquilibriumRegion(RiaDefines::PorosityModelType porosityType,
RimEclipseResultCase* eclipseResultCase,
int zeroBasedEquilRegionIndex);
protected: protected:
void initAfterRead() override; void initAfterRead() override;

View File

@ -58,8 +58,8 @@ void RimSaturationPressurePlotCollection::createSaturationPressurePlots(RimEclip
RimSaturationPressurePlot* plot = new RimSaturationPressurePlot(); RimSaturationPressurePlot* plot = new RimSaturationPressurePlot();
plot->setAsPlotMdiWindow(); plot->setAsPlotMdiWindow();
int equilibriumRegion = static_cast<int>(i) + 1; int equilibriumRegion = static_cast<int>(i);
plot->assignCaseAndEquilibriumRegion(eclipseResultCase, equilibriumRegion); plot->assignCaseAndEquilibriumRegion(RiaDefines::MATRIX_MODEL, eclipseResultCase, equilibriumRegion);
m_saturationPressurePlots.push_back(plot); m_saturationPressurePlots.push_back(plot);
} }

View File

@ -186,6 +186,14 @@ void RimEclipseResultDefinition::setEclipseCase(RimEclipseCase* eclipseCase)
assignFlowSolutionFromCase(); assignFlowSolutionFromCase();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RimEclipseResultDefinition::eclipseCase()
{
return m_eclipseCase;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -76,6 +76,7 @@ public:
void simpleCopy(const RimEclipseResultDefinition* other); void simpleCopy(const RimEclipseResultDefinition* other);
void setEclipseCase(RimEclipseCase* eclipseCase); void setEclipseCase(RimEclipseCase* eclipseCase);
RimEclipseCase* eclipseCase();
RiaDefines::ResultCatType resultType() const { return m_resultType(); } RiaDefines::ResultCatType resultType() const { return m_resultType(); }
void setResultType(RiaDefines::ResultCatType val); void setResultType(RiaDefines::ResultCatType val);

View File

@ -0,0 +1,13 @@
@startuml
package Rim {
PdmObject <|-- RimPlotCellFilter
RimPlotCellFilter <|-- RimPlotCellRangeFilter
RimPlotCellFilter <|-- RimPlotCellPropertyFilter
RimPlotCellFilter <|-- RimPlotCellRegionFilter
class RimPlotCellFilter
{
bool isCellAcceptedByFilter(size_t reservoirCellIndex);
}
@enduml