1 #ifndef GENESIS_UTILS_TOOLS_COLOR_NORM_LINEAR_H_ 2 #define GENESIS_UTILS_TOOLS_COLOR_NORM_LINEAR_H_ 88 autoscale( values.begin(), values.end() );
94 template <
class ForwardIterator>
148 return autoscale( values.begin(), values.end() );
178 template <
class ForwardIterator>
182 auto min = std::numeric_limits<double>::max();
183 auto max = std::numeric_limits<double>::lowest();
187 while( first != last ) {
188 if( ! std::isfinite( *first ) || *first ==
mask_value() ) {
219 template <
class ForwardIterator>
222 auto const max = max_value_;
232 template <
class ForwardIterator>
235 auto const min = min_value_;
271 return min_value_ < max_value_;
281 if( min_value_ >= max_value_ ) {
282 throw std::runtime_error(
"Invalid Color Normalization with min >= max." );
298 if( value < min_value_ ) {
301 if( value > max_value_ ) {
304 assert( min_value_ <= value && value <= max_value_ );
307 auto const pos = ( value - min_value_ ) / ( max_value_ - min_value_ );
328 double min_value_ = 0.0;
329 double max_value_ = 1.0;
336 #endif // include guard virtual double normalize_(double value) const override
Normalization function.
ColorNormalizationLinear & max_value(double value)
Minimum value, that is, where to end the color scale.
ColorNormalizationLinear & min_value(double value)
Minimum value, that is, where to begin the color scale.
virtual ~ColorNormalizationLinear() override=default
Default Color normalization, using a sequential linear scaling in the range [ min, max ].
ColorNormalizationLinear & scale(double min, double max)
ColorNormalizationLinear & autoscale(std::vector< double > const &values)
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
ColorNormalizationLinear(double min, double max)
Constructor that sets min() and max() to the provided values.
virtual bool is_valid_() const override
Return whether the ranges are correct.
ColorNormalizationLinear & autoscale(ForwardIterator first, ForwardIterator last)
Set the min and max of the Palette so that they reflect the min and max valid values that are found i...
double max_value() const
Minimum value, that is, where to end the color scale.
ColorNormalizationLinear & autoscale_min(std::vector< double > const &values)
ColorNormalizationLinear(ForwardIterator first, ForwardIterator last)
Constructor that sets min() and max() to the min and max of the provided range.
ColorNormalizationLinear & autoscale_min(ForwardIterator first, ForwardIterator last)
Same as autoscale(), but only updates the min_value().
double min_value() const
Minimum value, that is, where to begin the color scale.
Provides some commonly used string utility functions.
virtual void update_hook_(double min, double max)
Called whenever the min and max are set automatically. Gives derived classes a chance to update their...
Base class for color normalization.
ColorNormalizationLinear(std::vector< double > const &values)
Constructor that sets min() and max() to the min and max of the provided values.
virtual void is_valid_or_throw_() const
Throw if the ranges are incorrect.
ColorNormalizationLinear & operator=(ColorNormalizationLinear const &)=default
ColorNormalizationLinear()=default
Constructor that sets min == 0.0 and max == 1.0.
double mask_value() const
Mask value that identifies invalid values.
ColorNormalizationLinear & autoscale_max(ForwardIterator first, ForwardIterator last)
Same as autoscale(), but only updates the max_value().
ColorNormalizationLinear & autoscale_max(std::vector< double > const &values)