Skip to content
Snippets Groups Projects
Commit 2ae1912b authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Add overloads of set_vmin/max/limits() for std::vector<float>

(not necessary for demo)
parent d67a4fb5
No related branches found
No related tags found
No related merge requests found
#pragma once
#include <algorithm>
#include <initializer_list>
#include <map>
#include <string>
......@@ -70,10 +71,13 @@ namespace simox::color
/// The value corresponding to the bottom color.
float vmin() const { return _vmin ? *_vmin : original_vmin(); }
void set_vmin(float vmin) { this->_vmin = vmin; }
/// The value corresponding to the top color.
float vmax() const { return _vmax ? *_vmax : original_vmax(); }
void set_vmin(float vmin) { this->_vmin = vmin; }
void set_vmax(float vmax) { this->_vmax = vmax; }
void set_vmin(const std::vector<float>& values) { set_vmin(*std::max_element(values.begin(), values.end())); }
void set_vmax(const std::vector<float>& values) { set_vmax(*std::max_element(values.begin(), values.end())); }
/// Sets the value limits, i.e. scales the color map to the range [vmin, vmax].
void set_vlimits(float vmin, float vmax)
......@@ -81,6 +85,12 @@ namespace simox::color
set_vmin(vmin);
set_vmax(vmax);
}
void set_vlimits(const std::vector<float>& values)
{
const auto [min, max] = std::minmax_element(values.begin(), values.end());
set_vmin(*min);
set_vmax(*max);
}
/// Get this colormap reversed (but defined in the same value range as this).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment