0.4.1
Loading...
Searching...
No Matches
NAV::Colormap Class Reference

Colormap class. More...

Public Member Functions

void addColor (double value, ImColor color)
 Add a color with value.
 
 Colormap ()
 Constructor.
 
ImColor getColor (double value, const ImColor &defaultColor) const
 Gets the color for the given value.
 
const std::vector< std::pair< double, ImColor > > & getColormap () const
 Return the map.
 
int64_t getId () const
 Return the id of the colormap.
 
void removeColor (size_t idx)
 Remove the entry at the index (if past the last index or empty, NoOp)
 

Data Fields

bool discrete
 Whether to have discrete changes of the colors or continuous.
 
std::string name
 Name of the Colormap.
 
size_t version
 Version, to tell nodes that the colormap was updated.
 

Private Member Functions

void render () const
 Renders the colormap.
 
void render (const ImRect &bounds) const
 Renders the colormap.
 

Private Attributes

std::vector< std::pair< double, ImColor > > colormap
 Sorted list of value/color combinations (value is active if lookup is greater or equal)
 
int64_t id
 Unique id of the colormap.
 

Friends

void from_json (const json &j, Colormap &cmap)
 Converts the provided json object into a struct.
 
bool NAV::ColormapButton (const char *label, Colormap &cmap, const ImVec2 &size_arg)
 Display a colormap button.
 
void to_json (json &j, const Colormap &cmap)
 Converts the provided object into a json object.
 

Detailed Description

Colormap class.

Definition at line 47 of file Colormap.hpp.

Constructor & Destructor Documentation

◆ Colormap()

NAV::Colormap::Colormap ( )

Constructor.

Definition at line 29 of file Colormap.cpp.

Member Function Documentation

◆ addColor()

void NAV::Colormap::addColor ( double value,
ImColor color )

Add a color with value.

Parameters
valueValue
colorColor

Definition at line 36 of file Colormap.cpp.

◆ getColor()

ImColor NAV::Colormap::getColor ( double value,
const ImColor & defaultColor ) const
nodiscard

Gets the color for the given value.

Parameters
[in]valueValue to look for
[in]defaultColorDefault color to display if no enty in the colormap matches
Returns
The color for the value or the given defaultColor if nothing matches

Definition at line 51 of file Colormap.cpp.

◆ getColormap()

const std::vector< std::pair< double, ImColor > > & NAV::Colormap::getColormap ( ) const
nodiscard

Return the map.

Definition at line 78 of file Colormap.cpp.

◆ getId()

int64_t NAV::Colormap::getId ( ) const
nodiscard

Return the id of the colormap.

Definition at line 73 of file Colormap.cpp.

◆ removeColor()

void NAV::Colormap::removeColor ( size_t idx)

Remove the entry at the index (if past the last index or empty, NoOp)

Parameters
idxIndex to remove

Definition at line 44 of file Colormap.cpp.

◆ render() [1/2]

void NAV::Colormap::render ( ) const
private

Renders the colormap.

Note
Code from Implot library

Definition at line 83 of file Colormap.cpp.

◆ render() [2/2]

void NAV::Colormap::render ( const ImRect & bounds) const
private

Renders the colormap.

Parameters
[in]boundsBounds where to draw the rect
Note
Code from Implot library

Definition at line 93 of file Colormap.cpp.

Friends And Related Symbol Documentation

◆ from_json

void from_json ( const json & j,
Colormap & cmap )
friend

Converts the provided json object into a struct.

Parameters
[in]jJson object with the vector values
[out]cmapStruct to return

Definition at line 225 of file Colormap.cpp.

◆ NAV::ColormapButton

bool NAV::ColormapButton ( const char * label,
Colormap & cmap,
const ImVec2 & size_arg )
friend

Display a colormap button.

Parameters
[in]labelLabel to display on the button (unique id for ImGui)
[in,out]cmapColormap to show on the button and edit in the popup
[in]size_argSize of the button
Returns
True if clicked
Note
Code from Implot library

◆ to_json

void to_json ( json & j,
const Colormap & cmap )
friend

Converts the provided object into a json object.

Parameters
[out]jReturn Json object
[in]cmapColormap to convert

Definition at line 215 of file Colormap.cpp.

Field Documentation

◆ colormap

std::vector<std::pair<double, ImColor> > NAV::Colormap::colormap
private

Sorted list of value/color combinations (value is active if lookup is greater or equal)

Definition at line 82 of file Colormap.hpp.

◆ discrete

bool NAV::Colormap::discrete

Whether to have discrete changes of the colors or continuous.

Definition at line 75 of file Colormap.hpp.

◆ id

int64_t NAV::Colormap::id
private

Unique id of the colormap.

Definition at line 80 of file Colormap.hpp.

◆ name

std::string NAV::Colormap::name

Name of the Colormap.

Definition at line 74 of file Colormap.hpp.

◆ version

size_t NAV::Colormap::version

Version, to tell nodes that the colormap was updated.

Definition at line 76 of file Colormap.hpp.


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