2016-08-02 10:25:55 +02:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2016-08-05 17:53:02 +02:00
|
|
|
#include "cvfBase.h"
|
2016-08-02 10:25:55 +02:00
|
|
|
#include "cvfObject.h"
|
|
|
|
|
#include "cvfScalarMapper.h"
|
2016-09-06 11:15:21 +02:00
|
|
|
#include "cvfString.h"
|
2016-08-02 10:25:55 +02:00
|
|
|
|
|
|
|
|
namespace caf {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//==================================================================================================
|
|
|
|
|
class CategoryMapper : public cvf::ScalarMapper
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CategoryMapper();
|
|
|
|
|
|
2016-09-06 15:35:17 +02:00
|
|
|
void setCategories(const std::vector<int>& categoryValues);
|
|
|
|
|
void setCategoriesWithNames(const std::vector<int>& categoryValues, const std::vector<cvf::String>& categoryNames);
|
2016-09-06 11:15:21 +02:00
|
|
|
|
2016-09-06 15:35:17 +02:00
|
|
|
// 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
|
2016-09-06 11:15:21 +02:00
|
|
|
void setInterpolateColors(const cvf::Color3ubArray& colorArray);
|
2016-08-02 10:25:55 +02:00
|
|
|
|
2016-09-06 15:35:17 +02:00
|
|
|
|
|
|
|
|
// Overrides used from legend
|
2016-08-02 10:25:55 +02:00
|
|
|
|
2019-01-10 22:13:19 +01:00
|
|
|
cvf::Vec2f mapToTextureCoord(double scalarValue) const override;
|
|
|
|
|
bool updateTexture(cvf::TextureImage* image) const override;
|
2016-08-02 10:25:55 +02:00
|
|
|
|
2019-01-10 22:13:19 +01:00
|
|
|
cvf::Color3ub mapToColor(double normalizedValue) const override;
|
2016-08-02 10:25:55 +02:00
|
|
|
|
2019-01-10 22:13:19 +01:00
|
|
|
void majorTickValues(std::vector<double>* domainValues) const override;
|
|
|
|
|
double normalizedValue(double domainValue) const override;
|
|
|
|
|
double domainValue(double normalizedValue) const override;
|
2016-09-06 15:35:17 +02:00
|
|
|
size_t categoryCount() const;
|
|
|
|
|
|
2019-12-18 12:25:19 +01:00
|
|
|
const cvf::String textForCategoryIndex(size_t index) const;
|
2016-08-02 10:25:55 +02:00
|
|
|
int categoryIndexForCategory(double domainValue) const;
|
2019-12-18 12:25:19 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
2016-09-14 08:23:50 +02:00
|
|
|
void recomputeMaxTexCoord();
|
2016-08-02 10:25:55 +02:00
|
|
|
|
|
|
|
|
private:
|
2016-09-14 08:23:50 +02:00
|
|
|
cvf::Color3ubArray m_colors;
|
|
|
|
|
cvf::uint m_textureSize; // The size of texture that updateTexture() is will produce.
|
|
|
|
|
double m_maxTexCoord; // The largest allowable s texture coordinate, scalar values >= m_rangeMax will get mapped to this coordinate
|
2016-08-02 10:25:55 +02:00
|
|
|
|
2016-09-06 15:35:17 +02:00
|
|
|
std::vector<int> m_categoryValues;
|
2016-09-06 11:15:21 +02:00
|
|
|
std::vector<cvf::String> m_categoryNames;
|
2016-08-02 10:25:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|