MeshLib Documentation
Loading...
Searching...
No Matches
MR::Palette Class Reference

Class to hold one dimension texture with value to UV mapping. More...

#include <MRPalette.h>

Classes

struct  Label
 
struct  Parameters
 

Public Member Functions

MRVIEWER_API Palette (const std::vector< Color > &colors)
 
MRVIEWER_API void setBaseColors (const std::vector< Color > &colors)
 Set base palette colors colors.size() should be more or equal 2 for discrete palette using vector of colors calculated by mixing the base colors i.e. base {blue, red} -> discrete 3 {blue, 0.5*blue + 0.5*red, red}.
 
MRVIEWER_API void setRangeMinMax (float min, float max)
 set range limits for palette (need for find color by value) all palette colors are evenly distributed between min and max
 
MRVIEWER_API void setRangeMinMaxNegPos (float minNeg, float maxNeg, float minPos, float maxPos)
 set range limits for palette (need for find color by value) two half palette colors are evenly distributed between MinNeg / MaxNeg and MinPos / MaxPos for values between MaxNeg / MinPos return one color (from center palette)
 
MRVIEWER_API void setDiscretizationNumber (int discretization)
 
MRVIEWER_API void setFilterType (FilterType type)
 
MRVIEWER_API void draw (const std::string &windowName, const ImVec2 &pose, const ImVec2 &size, bool onlyTopHalf=false)
 
MRVIEWER_API void resetLabels ()
 
MRVIEWER_API void setCustomLabels (const std::vector< Label > &labels)
 
MRVIEWER_API void setLabelsVisible (bool visible)
 
MRVIEWER_API bool loadFromJson (const Json::Value &root)
 
MRVIEWER_API void saveCurrentToJson (Json::Value &root) const
 
MRVIEWER_API Color getColor (float val)
 
const MeshTexturegetTexture () const
 
MRVIEWER_API float getRelativePos (float val) const
 
UVCoord getUVcoord (float val, bool valid=true) const
 
MRVIEWER_API VertUVCoords getUVcoords (const VertScalars &values, const VertBitSet &region, const VertPredicate &valids={}) const
 
MRVIEWER_API VertUVCoords getUVcoords (const VertScalars &values, const VertBitSet &region, const VertBitSet *valids) const
 
const ParametersgetParameters () const
 
float getRangeMin () const
 returns minimum value in the palette's range
 
float getRangeMax () const
 returns maximum value in the palette's range
 
float getRangeSq () const
 returns minimum squared value, not smaller than all squared values of palette's range
 
MRVIEWER_API std::string getStringValue (float value)
 
MRVIEWER_API int getMaxLabelCount ()
 
MRVIEWER_API void setMaxLabelCount (int val)
 

Static Public Member Functions

static const std::vector< Color > & BlueGreenRedColors ()
 
static MRVIEWER_API const std::vector< Color > & GreenRedColors ()
 simpler palette colors: from green to red
 

Static Public Attributes

static MRVIEWER_API const std::vector< ColorDefaultColors
 preset palette colors: from blue via green to red
 

Detailed Description

Class to hold one dimension texture with value to UV mapping.

Discrete mode will draw rectangle for each color Continuous mode will draw interpolated color

Constructor & Destructor Documentation

◆ Palette()

MRVIEWER_API MR::Palette::Palette ( const std::vector< Color > & colors)

Member Function Documentation

◆ BlueGreenRedColors()

static const std::vector< Color > & MR::Palette::BlueGreenRedColors ( )
inlinestaticnodiscard

◆ draw()

MRVIEWER_API void MR::Palette::draw ( const std::string & windowName,
const ImVec2 & pose,
const ImVec2 & size,
bool onlyTopHalf = false )

Draws vertical legend with labels in ImGui window with given name Discrete: bar consists of single colored rectangles for each initial color Linear (default): color is changing from one to another during initial color list

Parameters
onlyTopHalfif true, draws only top half of the palette and labels stretched to whole window

◆ getColor()

MRVIEWER_API Color MR::Palette::getColor ( float val)

◆ getMaxLabelCount()

MRVIEWER_API int MR::Palette::getMaxLabelCount ( )

◆ getParameters()

const Parameters & MR::Palette::getParameters ( ) const
inlinenodiscard

◆ getRangeMax()

float MR::Palette::getRangeMax ( ) const
inlinenodiscard

returns maximum value in the palette's range

◆ getRangeMin()

float MR::Palette::getRangeMin ( ) const
inlinenodiscard

returns minimum value in the palette's range

◆ getRangeSq()

float MR::Palette::getRangeSq ( ) const
inlinenodiscard

returns minimum squared value, not smaller than all squared values of palette's range

◆ getRelativePos()

MRVIEWER_API float MR::Palette::getRelativePos ( float val) const

◆ getStringValue()

MRVIEWER_API std::string MR::Palette::getStringValue ( float value)

◆ getTexture()

const MeshTexture & MR::Palette::getTexture ( ) const
inline

◆ getUVcoord()

UVCoord MR::Palette::getUVcoord ( float val,
bool valid = true ) const
inline

get UV coordinate in palette for given value

Parameters
validtrue - return coordinate of palette's color, false - return coordinate of gray

◆ getUVcoords() [1/2]

MRVIEWER_API VertUVCoords MR::Palette::getUVcoords ( const VertScalars & values,
const VertBitSet & region,
const VertBitSet * valids ) const

◆ getUVcoords() [2/2]

MRVIEWER_API VertUVCoords MR::Palette::getUVcoords ( const VertScalars & values,
const VertBitSet & region,
const VertPredicate & valids = {} ) const

get UV coordinates in palette for given values

Parameters
regiononly these vertices will be processed
validsif given then defines subregion with valid values, and invalid values will get gray color

◆ GreenRedColors()

static MRVIEWER_API const std::vector< Color > & MR::Palette::GreenRedColors ( )
staticnodiscard

simpler palette colors: from green to red

◆ loadFromJson()

MRVIEWER_API bool MR::Palette::loadFromJson ( const Json::Value & root)

◆ resetLabels()

MRVIEWER_API void MR::Palette::resetLabels ( )

◆ saveCurrentToJson()

MRVIEWER_API void MR::Palette::saveCurrentToJson ( Json::Value & root) const

◆ setBaseColors()

MRVIEWER_API void MR::Palette::setBaseColors ( const std::vector< Color > & colors)

Set base palette colors colors.size() should be more or equal 2 for discrete palette using vector of colors calculated by mixing the base colors i.e. base {blue, red} -> discrete 3 {blue, 0.5*blue + 0.5*red, red}.

◆ setCustomLabels()

MRVIEWER_API void MR::Palette::setCustomLabels ( const std::vector< Label > & labels)

◆ setDiscretizationNumber()

MRVIEWER_API void MR::Palette::setDiscretizationNumber ( int discretization)

◆ setFilterType()

MRVIEWER_API void MR::Palette::setFilterType ( FilterType type)

◆ setLabelsVisible()

MRVIEWER_API void MR::Palette::setLabelsVisible ( bool visible)

◆ setMaxLabelCount()

MRVIEWER_API void MR::Palette::setMaxLabelCount ( int val)

◆ setRangeMinMax()

MRVIEWER_API void MR::Palette::setRangeMinMax ( float min,
float max )

set range limits for palette (need for find color by value) all palette colors are evenly distributed between min and max

◆ setRangeMinMaxNegPos()

MRVIEWER_API void MR::Palette::setRangeMinMaxNegPos ( float minNeg,
float maxNeg,
float minPos,
float maxPos )

set range limits for palette (need for find color by value) two half palette colors are evenly distributed between MinNeg / MaxNeg and MinPos / MaxPos for values between MaxNeg / MinPos return one color (from center palette)

Member Data Documentation

◆ DefaultColors

MRVIEWER_API const std::vector<Color> MR::Palette::DefaultColors
static

preset palette colors: from blue via green to red


The documentation for this class was generated from the following file: