17#include <imgui_internal.h>
56 void addColor(
double value, ImColor color);
66 [[nodiscard]] ImColor
getColor(
double value,
const ImColor& defaultColor)
const;
69 [[nodiscard]] int64_t
getId()
const;
72 [[nodiscard]]
const std::vector<std::pair<double, ImColor>>&
getColormap()
const;
74 std::string
name =
"Colormap";
82 std::vector<std::pair<double, ImColor>>
colormap = { { 0.0, ImColor(1.0F, 1.0F, 1.0F, 1.0F) } };
91 void render(
const ImRect& bounds)
const;
nlohmann::json json
json namespace
Defines how to save certain datatypes to json.
friend void to_json(json &j, const Colormap &cmap)
Converts the provided object into a json object.
const std::vector< std::pair< double, ImColor > > & getColormap() const
Return the map.
ImColor getColor(double value, const ImColor &defaultColor) const
Gets the color for the given value.
void removeColor(size_t idx)
Remove the entry at the index (if past the last index or empty, NoOp)
int64_t id
Unique id of the colormap.
bool discrete
Whether to have discrete changes of the colors or continuous.
std::string name
Name of the Colormap.
int64_t getId() const
Return the id of the colormap.
std::vector< std::pair< double, ImColor > > colormap
Sorted list of value/color combinations (value is active if lookup is greater or equal)
size_t version
Version, to tell nodes that the colormap was updated.
friend void from_json(const json &j, Colormap &cmap)
Converts the provided json object into a struct.
void render() const
Renders the colormap.
void addColor(double value, ImColor color)
Add a color with value.
void to_json(json &j, const Node &node)
Converts the provided node into a json object.
ColormapMaskType
Type of the Colormap mask.
@ Global
Use the global colormap.
@ Flow
Use the flow colormap.
@ None
Ionosphere model turned off.
std::vector< Colormap > ColormapsGlobal
Global colormaps.
bool ShowColormapSelector(ColormapMaskType &type, int64_t &id, const char *label)
Shows a combobox to select a colormap.
void from_json(const json &j, Node &node)
Converts the provided json object into a node object.
std::vector< Colormap > ColormapsFlow
Flow colormaps.
bool ColormapButton(const char *label, Colormap &cmap, const ImVec2 &size_arg)
Display a colormap button.
std::optional< std::reference_wrapper< const Colormap > > ColormapSearch(const ColormapMaskType &type, const int64_t &id)
Searches for the colormap in the Global and Flow colormaps.