ScalePal.hpp
1 #ifndef OPALS_SCALE_PAL_HPP_INCLUDED
2 #define OPALS_SCALE_PAL_HPP_INCLUDED
3 
4 #pragma once
5 
6 #include "opals/config.hpp"
7 #include "opals/Vector.hpp"
8 
9 namespace opals {
10 
11  /// Class describing different scaling methods for palette entries
12  class OPALS_API ScalePal
13  {
14  public:
15  ScalePal();
16  virtual ~ScalePal();
17 
18  /// scaling of palette nodes
19  struct TypeScalePal {
20  enum Type {
21  autoScale = 0, ///< automatic scaling of palette nodes
22  scaleByFactor, ///< single scaling factor
23  scaleByRange, ///< scaling range
24  scaleByRelRange, ///< scaling relative range
25  scaleByRangeClip, ///< scaling range with clipping
26  scaleByRelRangeClip, ///< scaling relative range with clipping
27  };
28  };
29 
30  bool isAutoScale() const { return type == TypeScalePal::autoScale; };
31  bool isScaleByFactor() const { return type == TypeScalePal::scaleByFactor; };
32  bool isScaleByRange() const { return type >= TypeScalePal::scaleByRange && type <= TypeScalePal::scaleByRelRangeClip; };
33 
34  bool isRelativeRange() const { return type == TypeScalePal::scaleByRelRange || type == TypeScalePal::scaleByRelRangeClip; };
35  bool withClipping() const { return type == TypeScalePal::scaleByRangeClip || type == TypeScalePal::scaleByRelRangeClip; };
36 
37  TypeScalePal::Type getType() const { return type; }
38 
39  void setAutoScale();
40  void setScaleFactor( const double& scalefac );
41  void setScaleRange( const double& rangemin, const double& rangemax, bool relativeValues, bool withClipping );
42  void setScaleRange( const opals::Vector<double>& values, bool relativeValues, bool withClipping );
43 
44  double getScaleFactor() const { return isScaleByFactor() ? scale[0] : 0.; };
45  double getScaleMin() const { return *scale.begin(); };
46  double getScaleMax() const { return *scale.rbegin(); };
47  const opals::Vector<double>& getScaleValues() const { return scale; };
48 
49  private:
50  TypeScalePal::Type type;
52  };
53 }
54 
55 #endif //OPALS_SCALE_PAL_HPP_INCLUDED