iridescence
Loading...
Searching...
No Matches
glk::GridMap Class Reference

GridMap is a drawable that represents a 2D grid map with color values. It assumes that pixel values are stored in row-major order (values[y * width + x]), starting from the (-x, -y) corner (i.e., the first row lies at -y). The grid map lies on the XY plane, and the center is at the origin (0, 0, 0), thus it extends from (-resolution * width / 2, -resolution * height / 2) to (resolution * width / 2, resolution * height / 2). Use guik::TextureColor as shader setting. More...

#include <gridmap.hpp>

Inheritance diagram for glk::GridMap:
Collaboration diagram for glk::GridMap:

Public Types

enum class  ColorMode {
  RAW = 0 , TURBO , PROB , PROB_TURBO ,
  RGBA
}
 ColorMode defines how the color values are interpreted. More...
Public Types inherited from glk::Drawable
using Ptr = std::shared_ptr<Drawable>
using ConstPtr = std::shared_ptr<const Drawable>

Public Member Functions

 GridMap (double resolution, int width, int height, const unsigned char *values, int alpha=255, ColorMode mode=ColorMode::PROB)
 Constructor.
 GridMap (double resolution, int width, int height, float scale, const float *values, float alpha=1.0f, ColorMode mode=ColorMode::PROB)
 Constructor.
virtual ~GridMap ()
virtual void draw (glk::GLSLShader &shader) const override
void update_color (int width, int height, const unsigned char *values, int alpha=255, ColorMode mode=ColorMode::PROB)
void update_color (const unsigned char *values, int alpha=255, ColorMode mode=ColorMode::PROB)
void update_color (int width, int height, float scale, const float *values, float alpha=1.0f, ColorMode mode=ColorMode::PROB)
void update_color (float scale, const float *values, float alpha=1.0f, ColorMode mode=ColorMode::PROB)
Public Member Functions inherited from glk::Drawable
virtual ~Drawable ()

Detailed Description

GridMap is a drawable that represents a 2D grid map with color values. It assumes that pixel values are stored in row-major order (values[y * width + x]), starting from the (-x, -y) corner (i.e., the first row lies at -y). The grid map lies on the XY plane, and the center is at the origin (0, 0, 0), thus it extends from (-resolution * width / 2, -resolution * height / 2) to (resolution * width / 2, resolution * height / 2). Use guik::TextureColor as shader setting.

Member Enumeration Documentation

◆ ColorMode

enum class glk::GridMap::ColorMode
strong

ColorMode defines how the color values are interpreted.

Assuming N=width*height For uint8 values: RAW: expects |values|=N, and rgb[i] = values[i] TURBO: expects |values|=N, and rgb[i] = colormap(TURBO, values[i]) PROB: expects |values|=N, and rgb[i] = 100 - values[i] PROB_TURBO: expects |values|=N, and rgb[i] = colormap(TURBO, (100 - values[i]) * 255.0 / 100.0) RGBA: expects |values|=4*N, and rgba[i] = values[i*4:i*4+4] For float values: RAW: expects |values|=N, and rgb[i] = scale * values[i] TURBO: expects |values|=N, and rgb[i] = colormapf(TURBO, scale * values[i]) PROB: expects |values|=N, and rgb[i] = 1.0 - scale * values[i] PROB_TURBO: expects |values|=N, and rgb[i] = colormapf(TURBO, 1.0 - scale * values[i]) RGBA: expects |values|=4*N, and rgba[i] = values[i*4:i*4+4] (scale is not applied)

Enumerator
RAW 
TURBO 
PROB 
PROB_TURBO 
RGBA 

Constructor & Destructor Documentation

◆ GridMap() [1/2]

glk::GridMap::GridMap ( double resolution,
int width,
int height,
const unsigned char * values,
int alpha = 255,
ColorMode mode = ColorMode::PROB )

Constructor.

Parameters
resolutionResolution of each grid cell in world units.
widthWidth [cells]
heightHeight [cells]
valuesPointer to the color values.
alphaAlpha value for the entire map. Ignored if ColorMode is RGBA.
modeColor mode for interpreting the values.

◆ GridMap() [2/2]

glk::GridMap::GridMap ( double resolution,
int width,
int height,
float scale,
const float * values,
float alpha = 1.0f,
ColorMode mode = ColorMode::PROB )

Constructor.

Parameters
resolutionResolution of each grid cell in world units.
widthWidth [cells]
heightHeight [cells]
scaleScale factor for the color values. Ignored if ColorMode is RGBA.
valuesPointer to the color values.
alphaAlpha value for the entire map. Ignored if ColorMode is RGBA.
modeColor mode for interpreting the values.

◆ ~GridMap()

virtual glk::GridMap::~GridMap ( )
virtual

Member Function Documentation

◆ draw()

virtual void glk::GridMap::draw ( glk::GLSLShader & shader) const
overridevirtual

Reimplemented from glk::Drawable.

◆ update_color() [1/4]

void glk::GridMap::update_color ( const unsigned char * values,
int alpha = 255,
ColorMode mode = ColorMode::PROB )

◆ update_color() [2/4]

void glk::GridMap::update_color ( float scale,
const float * values,
float alpha = 1.0f,
ColorMode mode = ColorMode::PROB )

◆ update_color() [3/4]

void glk::GridMap::update_color ( int width,
int height,
const unsigned char * values,
int alpha = 255,
ColorMode mode = ColorMode::PROB )

◆ update_color() [4/4]

void glk::GridMap::update_color ( int width,
int height,
float scale,
const float * values,
float alpha = 1.0f,
ColorMode mode = ColorMode::PROB )

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