mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#829) Use std::vector instead of std::set for categories. Added categoryNames to RimLegendConfig
This commit is contained in:
parent
3e40db6ef0
commit
f1c214c1d7
@ -361,12 +361,7 @@ void RimEclipsePropertyFilter::computeResultValueRange()
|
|||||||
|
|
||||||
if (resultDefinition->hasCategoryResult())
|
if (resultDefinition->hasCategoryResult())
|
||||||
{
|
{
|
||||||
std::set<int> vals = results->cellResults()->uniqueCellScalarValues(scalarIndex);
|
m_uniqueCellValues = results->cellResults()->uniqueCellScalarValues(scalarIndex);
|
||||||
|
|
||||||
for (auto val : vals)
|
|
||||||
{
|
|
||||||
m_uniqueCellValues.push_back(val);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -948,16 +948,20 @@ void RimEclipseView::updateLegends()
|
|||||||
{
|
{
|
||||||
if(cellEdgeResult()->singleVarEdgeResultColors()->resultType() != RimDefines::FORMATION_NAMES)
|
if(cellEdgeResult()->singleVarEdgeResultColors()->resultType() != RimDefines::FORMATION_NAMES)
|
||||||
{
|
{
|
||||||
cellEdgeResult()->legendConfig()->setCategories(results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex()),
|
cellEdgeResult()->legendConfig()->setCategories(results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex()));
|
||||||
results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex(), 0));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const std::vector<QString>& fnVector =
|
const std::vector<QString>& fnVector = eclipseCase->activeFormationNames()->formationNames();
|
||||||
eclipseCase->activeFormationNames()->formationNames();
|
std::vector<int> nameIndices;
|
||||||
std::set<int> nameIndices;
|
std::vector<cvf::String> names;
|
||||||
for(int i = 0; i < fnVector.size(); ++i) nameIndices.insert(i);
|
for (int i = 0; i < fnVector.size(); ++i)
|
||||||
cellEdgeResult()->legendConfig()->setCategories(nameIndices, nameIndices);
|
{
|
||||||
|
nameIndices.push_back(i);
|
||||||
|
names.push_back(cvfqt::Utils::toString(fnVector[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
cellEdgeResult()->legendConfig()->setCategoriesWithNames(nameIndices, names);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1006,21 +1010,22 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, R
|
|||||||
|
|
||||||
if (resultColors->hasCategoryResult())
|
if (resultColors->hasCategoryResult())
|
||||||
{
|
{
|
||||||
size_t adjustedTimeStep = m_currentTimeStep;
|
|
||||||
if (resultColors->hasStaticResult()) adjustedTimeStep = 0;
|
|
||||||
|
|
||||||
if(resultColors->resultType() != RimDefines::FORMATION_NAMES)
|
if(resultColors->resultType() != RimDefines::FORMATION_NAMES)
|
||||||
{
|
{
|
||||||
resultColors->legendConfig()->setCategories(cellResultsData->uniqueCellScalarValues(resultColors->scalarResultIndex()),
|
resultColors->legendConfig()->setCategories(cellResultsData->uniqueCellScalarValues(resultColors->scalarResultIndex()));
|
||||||
cellResultsData->uniqueCellScalarValues(resultColors->scalarResultIndex(), adjustedTimeStep));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const std::vector<QString>& fnVector =
|
const std::vector<QString>& fnVector = eclipseCase()->reservoirData()->activeFormationNames()->formationNames();
|
||||||
eclipseCase()->reservoirData()->activeFormationNames()->formationNames();
|
std::vector<int> nameIndices;
|
||||||
std::set<int> nameIndices;
|
std::vector<cvf::String> names;
|
||||||
for(int i = 0; i < fnVector.size(); ++i) nameIndices.insert(i);
|
for (int i = 0; i < fnVector.size(); ++i)
|
||||||
resultColors->legendConfig()->setCategories(nameIndices, nameIndices);
|
{
|
||||||
|
nameIndices.push_back(i);
|
||||||
|
names.push_back(cvfqt::Utils::toString(fnVector[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
resultColors->legendConfig()->setCategoriesWithNames(nameIndices, names);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,12 +422,16 @@ void RimGeoMechView::updateLegends()
|
|||||||
|
|
||||||
if (cellResult()->hasCategoryResult())
|
if (cellResult()->hasCategoryResult())
|
||||||
{
|
{
|
||||||
const std::vector<QString>& fnVector =
|
const std::vector<QString>& fnVector = gmCase->femPartResults()->activeFormationNames()->formationNames();
|
||||||
gmCase->femPartResults()->activeFormationNames()->formationNames();
|
std::vector<int> nameIndices;
|
||||||
std::set<int> nameIndices;
|
std::vector<cvf::String> names;
|
||||||
for (int i = 0; i < fnVector.size(); ++i) nameIndices.insert(i);
|
for (int i = 0; i < fnVector.size(); ++i)
|
||||||
|
{
|
||||||
|
nameIndices.push_back(i);
|
||||||
|
names.push_back(cvfqt::Utils::toString(fnVector[i]));
|
||||||
|
}
|
||||||
|
|
||||||
cellResult()->legendConfig->setCategories(nameIndices, nameIndices);
|
cellResult()->legendConfig->setCategoriesWithNames(nameIndices, names);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend());
|
m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend());
|
||||||
|
@ -201,8 +201,6 @@ void RimLegendConfig::updateLegend()
|
|||||||
|
|
||||||
posClosestToZero = m_globalAutoPosClosestToZero;
|
posClosestToZero = m_globalAutoPosClosestToZero;
|
||||||
negClosestToZero = m_globalAutoNegClosestToZero;
|
negClosestToZero = m_globalAutoNegClosestToZero;
|
||||||
|
|
||||||
m_categoryMapper->setCategories(m_globalCategories);
|
|
||||||
}
|
}
|
||||||
else if (m_rangeMode == AUTOMATIC_CURRENT_TIMESTEP)
|
else if (m_rangeMode == AUTOMATIC_CURRENT_TIMESTEP)
|
||||||
{
|
{
|
||||||
@ -211,8 +209,6 @@ void RimLegendConfig::updateLegend()
|
|||||||
|
|
||||||
posClosestToZero = m_localAutoPosClosestToZero;
|
posClosestToZero = m_localAutoPosClosestToZero;
|
||||||
negClosestToZero = m_localAutoNegClosestToZero;
|
negClosestToZero = m_localAutoNegClosestToZero;
|
||||||
|
|
||||||
m_categoryMapper->setCategories(m_localCategories);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -381,7 +377,6 @@ void RimLegendConfig::updateLegend()
|
|||||||
m_logSmoothScalarMapper->setColors(legendColors);
|
m_logSmoothScalarMapper->setColors(legendColors);
|
||||||
m_linSmoothScalarMapper->setColors(legendColors);
|
m_linSmoothScalarMapper->setColors(legendColors);
|
||||||
|
|
||||||
m_categoryMapper->setCycleColors(legendColors);
|
|
||||||
|
|
||||||
m_linDiscreteScalarMapper->setLevelCount(m_numLevels, true);
|
m_linDiscreteScalarMapper->setLevelCount(m_numLevels, true);
|
||||||
m_logDiscreteScalarMapper->setLevelCount(m_numLevels, true);
|
m_logDiscreteScalarMapper->setLevelCount(m_numLevels, true);
|
||||||
@ -403,6 +398,8 @@ void RimLegendConfig::updateLegend()
|
|||||||
m_currentScalarMapper = m_logDiscreteScalarMapper.p();
|
m_currentScalarMapper = m_logDiscreteScalarMapper.p();
|
||||||
break;
|
break;
|
||||||
case CATEGORY_INTEGER:
|
case CATEGORY_INTEGER:
|
||||||
|
m_categoryMapper->setCategoriesWithNames(m_categories, m_categoryNames);
|
||||||
|
m_categoryMapper->setCycleColors(legendColors);
|
||||||
m_currentScalarMapper = m_categoryMapper.p();
|
m_currentScalarMapper = m_categoryMapper.p();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -694,17 +691,21 @@ void RimLegendConfig::setClosestToZeroValues(double globalPosClosestToZero, doub
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimLegendConfig::setCategories(const std::set<int>& globalCategories, const std::set<int>& localCategories)
|
void RimLegendConfig::setCategories(const std::vector<int>& categories)
|
||||||
{
|
{
|
||||||
for (auto val : globalCategories)
|
m_categories = categories;
|
||||||
{
|
m_categoryNames.clear();
|
||||||
m_globalCategories.push_back(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto val : localCategories)
|
updateLegend();
|
||||||
{
|
}
|
||||||
m_localCategories.push_back(val);
|
|
||||||
}
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimLegendConfig::setCategoriesWithNames(const std::vector<int>& categories, const std::vector<cvf::String>& categoryNames)
|
||||||
|
{
|
||||||
|
m_categories = categories;
|
||||||
|
m_categoryNames = categoryNames;
|
||||||
|
|
||||||
updateLegend();
|
updateLegend();
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,8 @@ public:
|
|||||||
|
|
||||||
void setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax);
|
void setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax);
|
||||||
void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero);
|
void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero);
|
||||||
void setCategories(const std::set<int>& globalCategories, const std::set<int>& localCategories);
|
void setCategories(const std::vector<int>& categories);
|
||||||
|
void setCategoriesWithNames(const std::vector<int>& categories, const std::vector<cvf::String>& categoryNames);
|
||||||
|
|
||||||
void setTitle(const cvf::String& title);
|
void setTitle(const cvf::String& title);
|
||||||
|
|
||||||
@ -149,8 +150,8 @@ private:
|
|||||||
double m_localAutoPosClosestToZero;
|
double m_localAutoPosClosestToZero;
|
||||||
double m_localAutoNegClosestToZero;
|
double m_localAutoNegClosestToZero;
|
||||||
|
|
||||||
std::vector<int> m_globalCategories;
|
std::vector<int> m_categories;
|
||||||
std::vector<int> m_localCategories;
|
std::vector<cvf::String> m_categoryNames;
|
||||||
|
|
||||||
// Fields
|
// Fields
|
||||||
caf::PdmField<int> m_numLevels;
|
caf::PdmField<int> m_numLevels;
|
||||||
|
@ -130,19 +130,11 @@ void RigCaseCellResultsData::meanCellScalarValues(size_t scalarResultIndex, size
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
const std::set<int>& RigCaseCellResultsData::uniqueCellScalarValues(size_t scalarResultIndex)
|
const std::vector<int>& RigCaseCellResultsData::uniqueCellScalarValues(size_t scalarResultIndex)
|
||||||
{
|
{
|
||||||
return m_statisticsDataCache[scalarResultIndex]->uniqueCellScalarValues();
|
return m_statisticsDataCache[scalarResultIndex]->uniqueCellScalarValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
const std::set<int>& RigCaseCellResultsData::uniqueCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex)
|
|
||||||
{
|
|
||||||
return m_statisticsDataCache[scalarResultIndex]->uniqueCellScalarValues(timeStepIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -59,8 +59,7 @@ public:
|
|||||||
void p10p90CellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& p10, double& p90);
|
void p10p90CellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& p10, double& p90);
|
||||||
void meanCellScalarValues(size_t scalarResultIndex, double& meanValue);
|
void meanCellScalarValues(size_t scalarResultIndex, double& meanValue);
|
||||||
void meanCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& meanValue);
|
void meanCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& meanValue);
|
||||||
const std::set<int>& uniqueCellScalarValues(size_t scalarResultIndex);
|
const std::vector<int>& uniqueCellScalarValues(size_t scalarResultIndex);
|
||||||
const std::set<int>& uniqueCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex);
|
|
||||||
void sumCellScalarValues(size_t scalarResultIndex, double& sumValue);
|
void sumCellScalarValues(size_t scalarResultIndex, double& sumValue);
|
||||||
void sumCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& sumValue);
|
void sumCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& sumValue);
|
||||||
|
|
||||||
|
@ -258,21 +258,11 @@ const std::vector<size_t>& RigStatisticsDataCache::cellScalarValuesHistogram(siz
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
const std::set<int>& RigStatisticsDataCache::uniqueCellScalarValues()
|
const std::vector<int>& RigStatisticsDataCache::uniqueCellScalarValues()
|
||||||
{
|
{
|
||||||
computeUniqueValuesIfNeeded();
|
computeUniqueValuesIfNeeded();
|
||||||
|
|
||||||
return m_statsAllTimesteps.m_uniqueValues;
|
return m_uniqueValues;
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
const std::set<int>& RigStatisticsDataCache::uniqueCellScalarValues(size_t timeStepIndex)
|
|
||||||
{
|
|
||||||
computeUniqueValuesIfNeeded(timeStepIndex);
|
|
||||||
|
|
||||||
return m_statsPrTs[timeStepIndex].m_uniqueValues;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -339,34 +329,19 @@ void RigStatisticsDataCache::computeHistogramStatisticsIfNeeded(size_t timeStepI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RigStatisticsDataCache::computeUniqueValuesIfNeeded(size_t timeStepIndex)
|
|
||||||
{
|
|
||||||
if (timeStepIndex >= m_statsPrTs.size())
|
|
||||||
{
|
|
||||||
m_statsPrTs.resize(timeStepIndex + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_statsPrTs[timeStepIndex].m_uniqueValues.size() == 0)
|
|
||||||
{
|
|
||||||
m_statisticsCalculator->uniqueValues(timeStepIndex, m_statsPrTs[timeStepIndex].m_uniqueValues);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RigStatisticsDataCache::computeUniqueValuesIfNeeded()
|
void RigStatisticsDataCache::computeUniqueValuesIfNeeded()
|
||||||
{
|
{
|
||||||
if (m_statsAllTimesteps.m_uniqueValues.size() == 0)
|
if (m_uniqueValues.size() == 0)
|
||||||
{
|
{
|
||||||
for (size_t tIdx = 0; tIdx < m_statisticsCalculator->timeStepCount(); tIdx++)
|
std::set<int> setValues;
|
||||||
{
|
m_statisticsCalculator->uniqueValues(0, setValues);
|
||||||
computeUniqueValuesIfNeeded(tIdx);
|
|
||||||
|
|
||||||
m_statsAllTimesteps.m_uniqueValues.insert(m_statsPrTs[tIdx].m_uniqueValues.begin(), m_statsPrTs[tIdx].m_uniqueValues.end());
|
for (auto val : setValues)
|
||||||
|
{
|
||||||
|
m_uniqueValues.push_back(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,15 +55,13 @@ public:
|
|||||||
const std::vector<size_t>& cellScalarValuesHistogram();
|
const std::vector<size_t>& cellScalarValuesHistogram();
|
||||||
const std::vector<size_t>& cellScalarValuesHistogram(size_t timeStepIndex);
|
const std::vector<size_t>& cellScalarValuesHistogram(size_t timeStepIndex);
|
||||||
|
|
||||||
const std::set<int>& uniqueCellScalarValues();
|
const std::vector<int>& uniqueCellScalarValues();
|
||||||
const std::set<int>& uniqueCellScalarValues(size_t timeStepIndex);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void computeHistogramStatisticsIfNeeded();
|
void computeHistogramStatisticsIfNeeded();
|
||||||
void computeHistogramStatisticsIfNeeded(size_t timeStepIndex);
|
void computeHistogramStatisticsIfNeeded(size_t timeStepIndex);
|
||||||
|
|
||||||
void computeUniqueValuesIfNeeded();
|
void computeUniqueValuesIfNeeded();
|
||||||
void computeUniqueValuesIfNeeded(size_t timeStepIndex);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct StatisticsValues
|
struct StatisticsValues
|
||||||
@ -102,11 +100,11 @@ private:
|
|||||||
bool m_isValueSumCalculated;
|
bool m_isValueSumCalculated;
|
||||||
|
|
||||||
std::vector<size_t> m_histogram;
|
std::vector<size_t> m_histogram;
|
||||||
std::set<int> m_uniqueValues;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
StatisticsValues m_statsAllTimesteps;
|
StatisticsValues m_statsAllTimesteps;
|
||||||
std::vector<StatisticsValues> m_statsPrTs;
|
std::vector<StatisticsValues> m_statsPrTs;
|
||||||
|
std::vector<int> m_uniqueValues;
|
||||||
|
|
||||||
cvf::ref<RigStatisticsCalculator> m_statisticsCalculator;
|
cvf::ref<RigStatisticsCalculator> m_statisticsCalculator;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user