Files
ResInsight/Fwk/AppFwk/cafVizExtensions/cafCategoryMapper.h
Gaute Lindkvist 47b93dc0d1 Implement pdf rendering (#5250)
* First PDF creation support

* Reimplement info box

* Set title and make overlay frame margins more unified

* Remove a style sheet that was never meant to be applied to Project Tree

* Update RiuDraggableOverlayFrame when changing content

* Default page layout in Preferences

* undo removal of elision

* Remove friend class assignment in cafCategoryMapper

* the required methods have been made public

* Fix up after review

* Remove spurious const on by-value return

* Fix compile errors on Linux

* Fix size adjustment of legends with plot resizing
2019-12-18 12:25:19 +01:00

60 lines
2.1 KiB
C++

#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfScalarMapper.h"
#include "cvfString.h"
namespace caf {
//==================================================================================================
//
//
//==================================================================================================
class CategoryMapper : public cvf::ScalarMapper
{
public:
CategoryMapper();
void setCategories(const std::vector<int>& categoryValues);
void setCategoriesWithNames(const std::vector<int>& categoryValues, const std::vector<cvf::String>& categoryNames);
// 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);
// Overrides used from legend
cvf::Vec2f mapToTextureCoord(double scalarValue) const override;
bool updateTexture(cvf::TextureImage* image) const override;
cvf::Color3ub mapToColor(double normalizedValue) const override;
void majorTickValues(std::vector<double>* domainValues) const override;
double normalizedValue(double domainValue) const override;
double domainValue(double normalizedValue) const override;
size_t categoryCount() const;
const cvf::String textForCategoryIndex(size_t index) const;
int categoryIndexForCategory(double domainValue) const;
private:
void recomputeMaxTexCoord();
private:
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
std::vector<int> m_categoryValues;
std::vector<cvf::String> m_categoryNames;
};
}