mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4157 Grid Cross Plot: Make categorisation legend more like ensemble legend
This commit is contained in:
@@ -40,12 +40,9 @@ RigEclipseCrossPlotResult RigEclipseCrossPlotDataExtractor::extract(RigEclipseCa
|
||||
const RigEclipseResultAddress& yAddress,
|
||||
RigGridCrossPlotCurveCategorization categorizationType,
|
||||
const RigEclipseResultAddress& catAddress,
|
||||
int categoryBinCount,
|
||||
std::map<int, cvf::UByteArray> timeStepCellVisibilityMap)
|
||||
{
|
||||
RigEclipseCrossPlotResult result;
|
||||
RigEclipseCrossPlotResult::CategorySamplesMap& categorySamplesMap = result.categorySamplesMap;
|
||||
RigEclipseCrossPlotResult::CategoryNameMap& categoryNameMap = result.categoryNameMap;
|
||||
|
||||
RigCaseCellResultsData* resultData = caseData->results(RiaDefines::MATRIX_MODEL);
|
||||
RigFormationNames* activeFormationNames = resultData->activeFormationNames();
|
||||
@@ -68,7 +65,6 @@ RigEclipseCrossPlotResult RigEclipseCrossPlotDataExtractor::extract(RigEclipseCa
|
||||
{
|
||||
resultData->ensureKnownResultLoaded(catAddress);
|
||||
catValuesForAllSteps = &resultData->cellScalarResults(catAddress);
|
||||
catBinSorter.reset(new RigEclipseResultBinSorter(*catValuesForAllSteps, categoryBinCount));
|
||||
}
|
||||
|
||||
std::set<int> timeStepsToInclude;
|
||||
@@ -119,61 +115,38 @@ RigEclipseCrossPlotResult RigEclipseCrossPlotDataExtractor::extract(RigEclipseCa
|
||||
double xValue = xAccessor.cellScalarGlobIdx(globalCellIdx);
|
||||
double yValue = yAccessor.cellScalarGlobIdx(globalCellIdx);
|
||||
|
||||
int category = 0;
|
||||
if (xValue == HUGE_VAL || yValue == HUGE_VAL) continue;
|
||||
|
||||
result.xValues.push_back(xValue);
|
||||
result.yValues.push_back(yValue);
|
||||
|
||||
if (categorizationType == TIME_CATEGORIZATION)
|
||||
{
|
||||
category = timeStep;
|
||||
result.catValuesDiscrete.push_back(timeStep);
|
||||
}
|
||||
else if (categorizationType == FORMATION_CATEGORIZATION && activeFormationNames)
|
||||
else if (categorizationType == FORMATION_CATEGORIZATION)
|
||||
{
|
||||
CVF_ASSERT(activeFormationNames);
|
||||
int category = 0;
|
||||
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);
|
||||
}
|
||||
result.catValuesDiscrete.push_back(category);
|
||||
}
|
||||
else if (catAccessor && catBinSorter)
|
||||
else if (categorizationType == RESULT_CATEGORIZATION)
|
||||
{
|
||||
double catValue = catAccessor->cellScalarGlobIdx(globalCellIdx);
|
||||
category = catBinSorter->binNumber(catValue);
|
||||
}
|
||||
if (xValue != HUGE_VAL && yValue != HUGE_VAL)
|
||||
{
|
||||
categorySamplesMap[category].first.push_back(xValue);
|
||||
categorySamplesMap[category].second.push_back(yValue);
|
||||
double catValue = HUGE_VAL;
|
||||
if (catAccessor)
|
||||
{
|
||||
catValue = catAccessor->cellScalarGlobIdx(globalCellIdx);
|
||||
}
|
||||
result.catValuesContinuous.push_back(catValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<QDateTime> timeStepDates = resultData->timeStepDates();
|
||||
QString timeFormatString = RiaQDateTimeTools::createTimeFormatStringFromDates(timeStepDates);
|
||||
|
||||
for (const auto& sampleCategory : categorySamplesMap)
|
||||
{
|
||||
QString categoryName;
|
||||
if (categorizationType == TIME_CATEGORIZATION && categorySamplesMap.size() > 1u)
|
||||
{
|
||||
if (sampleCategory.first < static_cast<int>(timeStepDates.size()))
|
||||
{
|
||||
categoryName = RiaQDateTimeTools::toStringUsingApplicationLocale(timeStepDates[sampleCategory.first], timeFormatString);
|
||||
}
|
||||
}
|
||||
else if (categorizationType == FORMATION_CATEGORIZATION && activeFormationNames)
|
||||
{
|
||||
categoryName = activeFormationNames->formationNameFromKLayerIdx(sampleCategory.first);
|
||||
}
|
||||
else if (catBinSorter)
|
||||
{
|
||||
std::pair<double, double> binRange = catBinSorter->binRange(sampleCategory.first);
|
||||
|
||||
categoryName = QString("%1 [%2, %3]")
|
||||
.arg(catAddress.m_resultName)
|
||||
.arg(binRange.first)
|
||||
.arg(binRange.second);
|
||||
}
|
||||
categoryNameMap.insert(std::make_pair(sampleCategory.first, categoryName));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user