mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4117 Implement formation categorisation
This commit is contained in:
parent
aa5935d5db
commit
41b6cd55f2
@ -49,7 +49,7 @@ void RimGridCrossPlotCurve::determineColorAndSymbol(int curveSetIndex, int categ
|
||||
{
|
||||
if (contrastColors)
|
||||
{
|
||||
const caf::ColorTable& colors = RiaColorTables::contrastCategoryPaletteColors();
|
||||
const caf::ColorTable& colors = RiaColorTables::categoryPaletteColors();
|
||||
int colorIndex = categoryIndex + curveSetIndex; // Offset cycle for each curve set
|
||||
setColor(colors.cycledColor3f(colorIndex));
|
||||
int numColors = (int)colors.size();
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RigActiveCellsResultAccessor.h"
|
||||
#include "RigCaseCellResultCalculator.h"
|
||||
#include "RigFormationNames.h"
|
||||
#include "RigMainGrid.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
@ -37,6 +38,20 @@
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimGridCrossPlotCurveSet, "GridCrossPlotCurveSet");
|
||||
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template<>
|
||||
void AppEnum<RimGridCrossPlotCurveSet::CurveCategorization>::setUp()
|
||||
{
|
||||
addItem(RimGridCrossPlotCurveSet::NO_CATEGORIZATION, "NONE", "None");
|
||||
addItem(RimGridCrossPlotCurveSet::TIME_CATEGORIZATION, "TIME", "Time");
|
||||
addItem(RimGridCrossPlotCurveSet::FORMATION_CATEGORIZATION, "FORMATION", "Formations");
|
||||
setDefault(RimGridCrossPlotCurveSet::TIME_CATEGORIZATION);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -49,6 +64,8 @@ RimGridCrossPlotCurveSet::RimGridCrossPlotCurveSet()
|
||||
CAF_PDM_InitField(&m_timeStep, "TimeStep", -1, "Time Step", "", "", "");
|
||||
m_timeStep.uiCapability()->setUiEditorTypeName(caf::PdmUiComboBoxEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_categorization, "Categorization", "Data Categorization", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_xAxisProperty, "XAxisProperty", "X-Axis Property", "", "", "");
|
||||
m_xAxisProperty = new RimEclipseResultDefinition;
|
||||
m_xAxisProperty.uiCapability()->setUiHidden(true);
|
||||
@ -204,6 +221,7 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
||||
if (m_case())
|
||||
{
|
||||
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
|
||||
|
||||
if (eclipseCase)
|
||||
{
|
||||
if (!eclipseCase->ensureReservoirCaseIsOpen())
|
||||
@ -214,6 +232,7 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
||||
}
|
||||
|
||||
RigCaseCellResultsData* resultData = eclipseCase->results(RiaDefines::MATRIX_MODEL);
|
||||
RigFormationNames* activeFormationNames = resultData->activeFormationNames();
|
||||
|
||||
RigEclipseResultAddress xAddress(m_xAxisProperty->resultType(), m_xAxisProperty->resultVariable());
|
||||
RigEclipseResultAddress yAddress(m_yAxisProperty->resultType(), m_yAxisProperty->resultVariable());
|
||||
@ -252,47 +271,61 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
||||
|
||||
RigActiveCellsResultAccessor xAccessor(mainGrid, &xValuesForAllSteps[xIndex], activeCellInfo);
|
||||
RigActiveCellsResultAccessor yAccessor(mainGrid, &yValuesForAllSteps[yIndex], activeCellInfo);
|
||||
for (size_t j = 0; j < activeCellInfo->reservoirCellCount(); ++j)
|
||||
for (size_t globalCellIdx = 0; globalCellIdx < activeCellInfo->reservoirCellCount(); ++globalCellIdx)
|
||||
{
|
||||
double xValue = xAccessor.cellScalarGlobIdx(j);
|
||||
double yValue = yAccessor.cellScalarGlobIdx(j);
|
||||
int category = 0;
|
||||
if (m_categorization() == TIME_CATEGORIZATION)
|
||||
{
|
||||
category = timeStep;
|
||||
}
|
||||
else if (m_categorization() == FORMATION_CATEGORIZATION && activeFormationNames)
|
||||
{
|
||||
size_t i(cvf::UNDEFINED_SIZE_T), j(cvf::UNDEFINED_SIZE_T), k(cvf::UNDEFINED_SIZE_T);
|
||||
if (mainGrid->ijkFromCellIndex(globalCellIdx, &i, &j, &k))
|
||||
{
|
||||
category = activeFormationNames->formationIndexFromKLayerIdx(k);
|
||||
}
|
||||
}
|
||||
double xValue = xAccessor.cellScalarGlobIdx(globalCellIdx);
|
||||
double yValue = yAccessor.cellScalarGlobIdx(globalCellIdx);
|
||||
if (xValue != HUGE_VAL && yValue != HUGE_VAL)
|
||||
{
|
||||
samples[timeStep].push_back(QPointF(xValue, yValue));
|
||||
}
|
||||
}
|
||||
samples[category].push_back(QPointF(xValue, yValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QStringList timeStepNames;
|
||||
|
||||
if (m_case)
|
||||
{
|
||||
timeStepNames = m_case->timeStepStrings();
|
||||
}
|
||||
QStringList timeStepNames = m_case->timeStepStrings();
|
||||
|
||||
int curveSetIndex = indexInPlot();
|
||||
|
||||
for (const auto& sampleCategory : samples)
|
||||
{
|
||||
RimGridCrossPlotCurve* curve = new RimGridCrossPlotCurve();
|
||||
QString timeStepName = QString::number(sampleCategory.first);
|
||||
if (sampleCategory.first < timeStepNames.size())
|
||||
QString categoryName;
|
||||
if (m_categorization() == TIME_CATEGORIZATION)
|
||||
{
|
||||
timeStepName = timeStepNames[sampleCategory.first];
|
||||
}
|
||||
bool staticResultsOnly = staticResultsOnly = m_xAxisProperty->hasStaticResult() && m_yAxisProperty->hasStaticResult();
|
||||
if (staticResultsOnly)
|
||||
if (!staticResultsOnly && sampleCategory.first < timeStepNames.size())
|
||||
{
|
||||
categoryName = timeStepNames[sampleCategory.first];
|
||||
}
|
||||
}
|
||||
else if (m_categorization() == FORMATION_CATEGORIZATION && activeFormationNames)
|
||||
{
|
||||
categoryName = activeFormationNames->formationNameFromKLayerIdx(sampleCategory.first);
|
||||
}
|
||||
|
||||
if (categoryName.isEmpty())
|
||||
{
|
||||
curve->setCustomName(createAutoName());
|
||||
}
|
||||
else
|
||||
{
|
||||
curve->setCustomName(QString("%1 : %2").arg(createAutoName()).arg(timeStepName));
|
||||
curve->setCustomName(QString("%1 : %2").arg(createAutoName()).arg(categoryName));
|
||||
}
|
||||
curve->determineColorAndSymbol(curveSetIndex, sampleCategory.first, (int) samples.size(), false);
|
||||
curve->determineColorAndSymbol(curveSetIndex, sampleCategory.first, (int)samples.size(), m_categorization() == FORMATION_CATEGORIZATION);
|
||||
curve->setSamples(sampleCategory.second);
|
||||
curve->updateCurveAppearance();
|
||||
curve->updateCurveNameAndUpdatePlotLegendAndTitle();
|
||||
@ -300,6 +333,8 @@ void RimGridCrossPlotCurveSet::onLoadDataAndUpdate(bool updateParentPlot)
|
||||
|
||||
m_crossPlotCurves.push_back(curve);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updateParentPlot)
|
||||
{
|
||||
@ -316,6 +351,7 @@ void RimGridCrossPlotCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUi
|
||||
if (m_case)
|
||||
{
|
||||
uiOrdering.add(&m_timeStep);
|
||||
uiOrdering.add(&m_categorization);
|
||||
|
||||
caf::PdmUiGroup* xAxisGroup = uiOrdering.addNewGroup("X-Axis Property");
|
||||
m_xAxisProperty->uiOrdering(uiConfigName, *xAxisGroup);
|
||||
@ -352,6 +388,10 @@ void RimGridCrossPlotCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* chang
|
||||
{
|
||||
loadDataAndUpdate(true);
|
||||
}
|
||||
else if (changedField == &m_categorization)
|
||||
{
|
||||
loadDataAndUpdate(true);
|
||||
}
|
||||
else if (changedField == &m_isChecked)
|
||||
{
|
||||
triggerReplotAndTreeRebuild();
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "RimCheckableNamedObject.h"
|
||||
#include "RimNameConfig.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmField.h"
|
||||
@ -55,6 +56,15 @@ class RimGridCrossPlotCurveSet : public RimCheckableNamedObject, public RimNameC
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
enum CurveCategorization
|
||||
{
|
||||
NO_CATEGORIZATION,
|
||||
TIME_CATEGORIZATION,
|
||||
FORMATION_CATEGORIZATION
|
||||
};
|
||||
typedef caf::AppEnum<CurveCategorization> CurveCategorizationEnum;
|
||||
|
||||
public:
|
||||
RimGridCrossPlotCurveSet();
|
||||
~RimGridCrossPlotCurveSet() = default;
|
||||
@ -84,6 +94,7 @@ private:
|
||||
|
||||
caf::PdmPtrField<RimCase*> m_case;
|
||||
caf::PdmField<int> m_timeStep;
|
||||
caf::PdmField<CurveCategorizationEnum> m_categorization;
|
||||
caf::PdmChildField<RimEclipseResultDefinition*> m_xAxisProperty;
|
||||
caf::PdmChildField<RimEclipseResultDefinition*> m_yAxisProperty;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user