|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_COLOR_NORM_LINEAR_H_
2 #define GENESIS_UTILS_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>
188 template <
class ForwardIterator>
198 template <
class ForwardIterator>
231 template <
class ForwardIterator>
233 ForwardIterator first, ForwardIterator last,
234 bool set_min,
bool set_max
237 auto min = std::numeric_limits<double>::max();
238 auto max = std::numeric_limits<double>::lowest();
241 while( first != last ) {
242 if( ! std::isfinite( *first ) || *first ==
mask_value() ) {
285 return min_value_ < max_value_;
293 if( min_value_ >= max_value_ ) {
294 throw std::runtime_error(
"Invalid Color Normalization with min >= max." );
310 if( value < min_value_ ) {
313 if( value > max_value_ ) {
316 assert( min_value_ <= value && value <= max_value_ );
319 auto const pos = ( value - min_value_ ) / ( max_value_ - min_value_ );
340 double min_value_ = 0.0;
341 double max_value_ = 1.0;
348 #endif // include guard
ColorNormalizationLinear & autoscale_(ForwardIterator first, ForwardIterator last, bool set_min, bool set_max)
virtual double normalize_(double value) const override
Normalization function.
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...
Base class for color normalization.
ColorNormalizationLinear & max_value(double value)
Minimum value, that is, where to end the color scale.
ColorNormalizationLinear()=default
Constructor that sets min == 0.0 and max == 1.0.
double mask_value() const
Mask value that identifies invalid values.
virtual ~ColorNormalizationLinear() override=default
ColorNormalizationLinear(std::vector< double > const &values)
Constructor that sets min() and max() to the min and max of the provided values.
ColorNormalizationLinear & autoscale_min(std::vector< double > const &values)
virtual bool is_valid_() const override
Return whether the ranges are correct.
Provides some commonly used string utility functions.
ColorNormalizationLinear(ForwardIterator first, ForwardIterator last)
Constructor that sets min() and max() to the min and max of the provided range.
double min_value() const
Minimum value, that is, where to begin the color scale.
Default Color normalization, using a sequential linear scaling in the range [ min,...
virtual void is_valid_or_throw_() const
Throw if the ranges are incorrect.
ColorNormalizationLinear(double min, double max)
Constructor that sets min() and max() to the provided values.
ColorNormalizationLinear & min_value(double value)
Minimum value, that is, where to begin the color scale.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
ColorNormalizationLinear & autoscale_min(ForwardIterator first, ForwardIterator last)
Same as autoscale(), but only updates the min_value().
ColorNormalizationLinear & autoscale_max(std::vector< double > const &values)
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...
double max_value() const
Minimum value, that is, where to end the color scale.
ColorNormalizationLinear & autoscale(std::vector< double > const &values)
ColorNormalizationLinear & scale(double min, double max)
ColorNormalizationLinear & autoscale_max(ForwardIterator first, ForwardIterator last)
Same as autoscale(), but only updates the max_value().
ColorNormalizationLinear & operator=(ColorNormalizationLinear const &)=default