#1208 Use category text instead of category index

This commit is contained in:
Magne Sjaastad
2017-02-14 09:18:00 +01:00
parent 61e82c37b5
commit e43f531a0f
3 changed files with 35 additions and 1 deletions

View File

@@ -636,6 +636,25 @@ void RimLegendConfig::setCategoryColors(const std::vector<cvf::Color3ub>& catego
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimLegendConfig::categoryNameFromCategoryValue(size_t categoryValue) const
{
if (m_categoryNames.size() > 0)
{
for (size_t categoryIndex = 0; categoryIndex < m_categories.size(); categoryIndex++)
{
if (categoryValue == m_categories[categoryIndex])
{
return cvfqt::Utils::toQString(m_categoryNames[categoryIndex]);
}
}
}
return QString("%1").arg(categoryValue);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -105,10 +105,12 @@ public:
void setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax);
void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero);
void setIntegerCategories(const std::vector<int>& categories);
void setNamedCategoriesInverse(const std::vector<QString>& categoryNames);
void setNamedCategories(const std::vector<QString>& categoryNames);
void setCategoryColors(const std::vector<cvf::Color3ub>& categoryColors);
QString categoryNameFromCategoryValue(size_t categoryValue) const;
void setTitle(const cvf::String& title);