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