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())
|
||||
{
|
||||
std::set<int> vals = results->cellResults()->uniqueCellScalarValues(scalarIndex);
|
||||
|
||||
for (auto val : vals)
|
||||
{
|
||||
m_uniqueCellValues.push_back(val);
|
||||
}
|
||||
m_uniqueCellValues = results->cellResults()->uniqueCellScalarValues(scalarIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -948,16 +948,20 @@ void RimEclipseView::updateLegends()
|
||||
{
|
||||
if(cellEdgeResult()->singleVarEdgeResultColors()->resultType() != RimDefines::FORMATION_NAMES)
|
||||
{
|
||||
cellEdgeResult()->legendConfig()->setCategories(results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex()),
|
||||
results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex(), 0));
|
||||
cellEdgeResult()->legendConfig()->setCategories(results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex()));
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::vector<QString>& fnVector =
|
||||
eclipseCase->activeFormationNames()->formationNames();
|
||||
std::set<int> nameIndices;
|
||||
for(int i = 0; i < fnVector.size(); ++i) nameIndices.insert(i);
|
||||
cellEdgeResult()->legendConfig()->setCategories(nameIndices, nameIndices);
|
||||
const std::vector<QString>& fnVector = eclipseCase->activeFormationNames()->formationNames();
|
||||
std::vector<int> nameIndices;
|
||||
std::vector<cvf::String> names;
|
||||
for (int i = 0; i < fnVector.size(); ++i)
|
||||
{
|
||||
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())
|
||||
{
|
||||
size_t adjustedTimeStep = m_currentTimeStep;
|
||||
if (resultColors->hasStaticResult()) adjustedTimeStep = 0;
|
||||
|
||||
if(resultColors->resultType() != RimDefines::FORMATION_NAMES)
|
||||
{
|
||||
resultColors->legendConfig()->setCategories(cellResultsData->uniqueCellScalarValues(resultColors->scalarResultIndex()),
|
||||
cellResultsData->uniqueCellScalarValues(resultColors->scalarResultIndex(), adjustedTimeStep));
|
||||
resultColors->legendConfig()->setCategories(cellResultsData->uniqueCellScalarValues(resultColors->scalarResultIndex()));
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::vector<QString>& fnVector =
|
||||
eclipseCase()->reservoirData()->activeFormationNames()->formationNames();
|
||||
std::set<int> nameIndices;
|
||||
for(int i = 0; i < fnVector.size(); ++i) nameIndices.insert(i);
|
||||
resultColors->legendConfig()->setCategories(nameIndices, nameIndices);
|
||||
const std::vector<QString>& fnVector = eclipseCase()->reservoirData()->activeFormationNames()->formationNames();
|
||||
std::vector<int> nameIndices;
|
||||
std::vector<cvf::String> names;
|
||||
for (int i = 0; i < fnVector.size(); ++i)
|
||||
{
|
||||
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())
|
||||
{
|
||||
const std::vector<QString>& fnVector =
|
||||
gmCase->femPartResults()->activeFormationNames()->formationNames();
|
||||
std::set<int> nameIndices;
|
||||
for (int i = 0; i < fnVector.size(); ++i) nameIndices.insert(i);
|
||||
const std::vector<QString>& fnVector = gmCase->femPartResults()->activeFormationNames()->formationNames();
|
||||
std::vector<int> nameIndices;
|
||||
std::vector<cvf::String> names;
|
||||
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());
|
||||
|
@ -201,8 +201,6 @@ void RimLegendConfig::updateLegend()
|
||||
|
||||
posClosestToZero = m_globalAutoPosClosestToZero;
|
||||
negClosestToZero = m_globalAutoNegClosestToZero;
|
||||
|
||||
m_categoryMapper->setCategories(m_globalCategories);
|
||||
}
|
||||
else if (m_rangeMode == AUTOMATIC_CURRENT_TIMESTEP)
|
||||
{
|
||||
@ -211,8 +209,6 @@ void RimLegendConfig::updateLegend()
|
||||
|
||||
posClosestToZero = m_localAutoPosClosestToZero;
|
||||
negClosestToZero = m_localAutoNegClosestToZero;
|
||||
|
||||
m_categoryMapper->setCategories(m_localCategories);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -381,7 +377,6 @@ void RimLegendConfig::updateLegend()
|
||||
m_logSmoothScalarMapper->setColors(legendColors);
|
||||
m_linSmoothScalarMapper->setColors(legendColors);
|
||||
|
||||
m_categoryMapper->setCycleColors(legendColors);
|
||||
|
||||
m_linDiscreteScalarMapper->setLevelCount(m_numLevels, true);
|
||||
m_logDiscreteScalarMapper->setLevelCount(m_numLevels, true);
|
||||
@ -403,6 +398,8 @@ void RimLegendConfig::updateLegend()
|
||||
m_currentScalarMapper = m_logDiscreteScalarMapper.p();
|
||||
break;
|
||||
case CATEGORY_INTEGER:
|
||||
m_categoryMapper->setCategoriesWithNames(m_categories, m_categoryNames);
|
||||
m_categoryMapper->setCycleColors(legendColors);
|
||||
m_currentScalarMapper = m_categoryMapper.p();
|
||||
break;
|
||||
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_globalCategories.push_back(val);
|
||||
}
|
||||
m_categories = categories;
|
||||
m_categoryNames.clear();
|
||||
|
||||
for (auto val : localCategories)
|
||||
{
|
||||
m_localCategories.push_back(val);
|
||||
}
|
||||
updateLegend();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimLegendConfig::setCategoriesWithNames(const std::vector<int>& categories, const std::vector<cvf::String>& categoryNames)
|
||||
{
|
||||
m_categories = categories;
|
||||
m_categoryNames = categoryNames;
|
||||
|
||||
updateLegend();
|
||||
}
|
||||
|
@ -105,7 +105,8 @@ public:
|
||||
|
||||
void setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax);
|
||||
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);
|
||||
|
||||
@ -149,8 +150,8 @@ private:
|
||||
double m_localAutoPosClosestToZero;
|
||||
double m_localAutoNegClosestToZero;
|
||||
|
||||
std::vector<int> m_globalCategories;
|
||||
std::vector<int> m_localCategories;
|
||||
std::vector<int> m_categories;
|
||||
std::vector<cvf::String> m_categoryNames;
|
||||
|
||||
// Fields
|
||||
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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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 meanCellScalarValues(size_t scalarResultIndex, double& meanValue);
|
||||
void meanCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& meanValue);
|
||||
const std::set<int>& uniqueCellScalarValues(size_t scalarResultIndex);
|
||||
const std::set<int>& uniqueCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex);
|
||||
const std::vector<int>& uniqueCellScalarValues(size_t scalarResultIndex);
|
||||
void sumCellScalarValues(size_t scalarResultIndex, 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();
|
||||
|
||||
return m_statsAllTimesteps.m_uniqueValues;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::set<int>& RigStatisticsDataCache::uniqueCellScalarValues(size_t timeStepIndex)
|
||||
{
|
||||
computeUniqueValuesIfNeeded(timeStepIndex);
|
||||
|
||||
return m_statsPrTs[timeStepIndex].m_uniqueValues;
|
||||
return 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()
|
||||
{
|
||||
if (m_statsAllTimesteps.m_uniqueValues.size() == 0)
|
||||
if (m_uniqueValues.size() == 0)
|
||||
{
|
||||
for (size_t tIdx = 0; tIdx < m_statisticsCalculator->timeStepCount(); tIdx++)
|
||||
{
|
||||
computeUniqueValuesIfNeeded(tIdx);
|
||||
std::set<int> setValues;
|
||||
m_statisticsCalculator->uniqueValues(0, setValues);
|
||||
|
||||
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(size_t timeStepIndex);
|
||||
|
||||
const std::set<int>& uniqueCellScalarValues();
|
||||
const std::set<int>& uniqueCellScalarValues(size_t timeStepIndex);
|
||||
const std::vector<int>& uniqueCellScalarValues();
|
||||
|
||||
private:
|
||||
void computeHistogramStatisticsIfNeeded();
|
||||
void computeHistogramStatisticsIfNeeded(size_t timeStepIndex);
|
||||
|
||||
void computeUniqueValuesIfNeeded();
|
||||
void computeUniqueValuesIfNeeded(size_t timeStepIndex);
|
||||
|
||||
private:
|
||||
struct StatisticsValues
|
||||
@ -102,11 +100,11 @@ private:
|
||||
bool m_isValueSumCalculated;
|
||||
|
||||
std::vector<size_t> m_histogram;
|
||||
std::set<int> m_uniqueValues;
|
||||
};
|
||||
|
||||
StatisticsValues m_statsAllTimesteps;
|
||||
std::vector<StatisticsValues> m_statsPrTs;
|
||||
StatisticsValues m_statsAllTimesteps;
|
||||
std::vector<StatisticsValues> m_statsPrTs;
|
||||
std::vector<int> m_uniqueValues;
|
||||
|
||||
cvf::ref<RigStatisticsCalculator> m_statisticsCalculator;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user