mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#827 Refactored CategoryMapper function names and added comments
This commit is contained in:
@@ -381,7 +381,7 @@ void RimLegendConfig::updateLegend()
|
||||
m_logSmoothScalarMapper->setColors(legendColors);
|
||||
m_linSmoothScalarMapper->setColors(legendColors);
|
||||
|
||||
m_categoryMapper->setColors(legendColors);
|
||||
m_categoryMapper->setCycleColors(legendColors);
|
||||
|
||||
m_linDiscreteScalarMapper->setLevelCount(m_numLevels, true);
|
||||
m_logDiscreteScalarMapper->setLevelCount(m_numLevels, true);
|
||||
@@ -696,24 +696,16 @@ void RimLegendConfig::setClosestToZeroValues(double globalPosClosestToZero, doub
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimLegendConfig::setCategories(const std::set<int>& globalCategories, const std::set<int>& localCategories)
|
||||
{
|
||||
m_globalCategories.resize(globalCategories.size());
|
||||
m_localCategories.resize(localCategories.size());
|
||||
|
||||
for (auto val : globalCategories)
|
||||
{
|
||||
size_t i = 0;
|
||||
for (auto val : globalCategories)
|
||||
{
|
||||
m_globalCategories.set(i++, val);
|
||||
}
|
||||
m_globalCategories.push_back(val);
|
||||
}
|
||||
|
||||
for (auto val : localCategories)
|
||||
{
|
||||
size_t i = 0;
|
||||
for (auto val : localCategories)
|
||||
{
|
||||
m_localCategories.set(i++, val);
|
||||
}
|
||||
m_localCategories.push_back(val);
|
||||
}
|
||||
|
||||
updateLegend();
|
||||
}
|
||||
|
||||
|
||||
@@ -149,8 +149,8 @@ private:
|
||||
double m_localAutoPosClosestToZero;
|
||||
double m_localAutoNegClosestToZero;
|
||||
|
||||
cvf::IntArray m_globalCategories;
|
||||
cvf::IntArray m_localCategories;
|
||||
std::vector<int> m_globalCategories;
|
||||
std::vector<int> m_localCategories;
|
||||
|
||||
// Fields
|
||||
caf::PdmField<int> m_numLevels;
|
||||
|
||||
@@ -22,32 +22,32 @@ CategoryMapper::CategoryMapper()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CategoryMapper::setCategories(const IntArray& categoryValues)
|
||||
void CategoryMapper::setCategories(const std::vector<int>& categoryValues)
|
||||
{
|
||||
m_categoryValues = categoryValues;
|
||||
|
||||
ref<Color3ubArray> colorArr = ScalarMapper::colorTableArray(ColorTable::NORMAL);
|
||||
|
||||
setColors(*(colorArr.p()));
|
||||
setCycleColors(*(colorArr.p()));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CategoryMapper::setCategories(const cvf::IntArray& categoryValues, const std::vector<cvf::String>& categoryNames)
|
||||
void CategoryMapper::setCategoriesWithNames(const std::vector<int>& categoryValues, const std::vector<cvf::String>& categoryNames)
|
||||
{
|
||||
m_categoryValues = categoryValues;
|
||||
m_categoryNames = categoryNames;
|
||||
|
||||
ref<Color3ubArray> colorArr = ScalarMapper::colorTableArray(ColorTable::NORMAL);
|
||||
|
||||
setColors(*(colorArr.p()));
|
||||
setCycleColors(*(colorArr.p()));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CategoryMapper::setColors(const Color3ubArray& colorArray)
|
||||
void CategoryMapper::setCycleColors(const Color3ubArray& colorArray)
|
||||
{
|
||||
m_colors.resize(m_categoryValues.size());
|
||||
|
||||
|
||||
@@ -18,14 +18,17 @@ class CategoryMapper : public cvf::ScalarMapper
|
||||
public:
|
||||
CategoryMapper();
|
||||
|
||||
void setCategories(const cvf::IntArray& categoryValues);
|
||||
void setCategories(const cvf::IntArray& categoryValues, const std::vector<cvf::String>& categoryNames);
|
||||
void setCategories(const std::vector<int>& categoryValues);
|
||||
void setCategoriesWithNames(const std::vector<int>& categoryValues, const std::vector<cvf::String>& categoryNames);
|
||||
|
||||
void setColors(const cvf::Color3ubArray& colorArray);
|
||||
// Colors in color array are cycled, if category count is larger than color count, colors are reused
|
||||
void setCycleColors(const cvf::Color3ubArray& colorArray);
|
||||
|
||||
// Colors are interpolated to make sure all categories get a unique color
|
||||
void setInterpolateColors(const cvf::Color3ubArray& colorArray);
|
||||
|
||||
size_t categoryCount() const;
|
||||
const cvf::String textForCategoryIndex(size_t index) const;
|
||||
|
||||
// Overrides used from legend
|
||||
|
||||
virtual cvf::Vec2f mapToTextureCoord(double scalarValue) const;
|
||||
virtual bool updateTexture(cvf::TextureImage* image) const;
|
||||
@@ -37,13 +40,17 @@ public:
|
||||
virtual double domainValue(double normalizedValue) const;
|
||||
|
||||
private:
|
||||
friend class CategoryLegend;
|
||||
size_t categoryCount() const;
|
||||
const cvf::String textForCategoryIndex(size_t index) const;
|
||||
|
||||
int categoryIndexForCategory(double domainValue) const;
|
||||
|
||||
private:
|
||||
cvf::Color3ubArray m_colors;
|
||||
cvf::uint m_textureSize; // The size of texture that updateTexture() is will produce.
|
||||
|
||||
cvf::IntArray m_categoryValues;
|
||||
std::vector<int> m_categoryValues;
|
||||
std::vector<cvf::String> m_categoryNames;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user