17#include <imgui_internal.h>
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;
bool ShowColormapSelector(ColormapMaskType &type, int64_t &id, const char *label="")
Shows a combobox to select a colormap.
std::vector< Colormap > ColormapsGlobal
Global colormaps.
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.
ColormapMaskType
Type of the Colormap mask.
Definition Colormap.hpp:118
@ Global
Use the global colormap.
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
@ None
None.
Definition GlobalActions.hpp:19
Defines how to save certain datatypes to json.
void from_json(const json &j, ImColor &color)
Converts the provided json object into a color.
void to_json(json &j, const ImColor &color)
Converts the provided color into a json object.
Colormap class.
Definition Colormap.hpp:48
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)
bool discrete
Whether to have discrete changes of the colors or continuous.
Definition Colormap.hpp:75
std::string name
Name of the Colormap.
Definition Colormap.hpp:74
int64_t getId() const
Return the id of the colormap.
size_t version
Version, to tell nodes that the colormap was updated.
Definition Colormap.hpp:76
friend void from_json(const json &j, Colormap &cmap)
Converts the provided json object into a struct.
void addColor(double value, ImColor color)
Add a color with value.