TComposedColorGradient.h
Go to the documentation of this file.
1 #ifndef icmm_TComposedColorGradient_included
2 #define icmm_TComposedColorGradient_included
3 
4 
5 // Qt includes
6 #include <QtCore/QPair>
7 
8 // ACF includes
9 #include <istd/TRange.h>
10 #include <icmm/TColorGradient.h>
11 
12 
13 namespace icmm
14 {
15 
16 
21 template <class Gradient>
23 {
24 public:
25  void AddGradient(const istd::CRange& intervall, const Gradient& gradient);
26 
27  // reimplemented (icmm::IColorTransformation)
28  virtual bool GetValueAt(const Argument& argument, Result& result) const;
29  virtual Result GetValueAt(const Argument& argument) const;
30 
31 private:
32  typedef QPair<istd::CRange, Gradient> IntervallGradient;
33  typedef QVector<IntervallGradient> Gradients;
34 
35  Gradients m_gradients;
36 };
37 
38 
39 // public methods
40 
41 template <class GradientFunction>
42 void TColorGradient<GradientFunction>::AddGradient(const istd::CRange& intervall, const Gradient& gradient)
43 {
44  m_gradients.push_back(std::make_pair<istd::CRange, Gradient>(intervall, gradient));
45 }
46 
47 
48 // reimplemented (icmm::IColorTransformation)
49 
50 template <class GradientFunction>
51 bool TColorGradient<GradientFunction>::GetValueAt(const Argument& argument, Result& result) const
52 {
53  for (int gradientIndex = 0; gradientIndex < int(m_gradients.size()); gradientIndex++){
54  IntervallGradient gradient = m_gradients[gradientIndex];
55 
56  if (gradient.first.Contains(argument)){
57  return gradient.second.GetValueAt(argument, result);
58  }
59  }
60 
61  return false;
62 }
63 
64 
65 template <class GradientFunction>
66 TColorGradient<GradientFunction>::Result TColorGradient<GradientFunction>::GetValueAt(const Argument& argument) const
67 {
68  ResultType result;
69 
70  GetValueAt(argument, result);
71 
72  return result;
73 }
74 
75 
77 
78 
79 } // namespace icmm
80 
81 
82 #endif // !icmm_TComposedColorGradient_included
83 
84 
TComposedColorGradient< CLinearGradient > CComposedLinearGradient
void AddGradient(const istd::CRange &intervall, const Gradient &gradient)
Simple implementation of gradient based on interpolation beetween the start und end colors...
Implementation of color gradient based on set of defined gradients for each subintervall of the full ...
Basic interface for a color transformation.
virtual bool GetValueAt(const Argument &argument, Result &result) const
virtual bool GetValueAt(const ArgumentType &argument, ResultType &result) const
Get function value for specified argument value.

© 2007-2017 Witold Gantzke and Kirill Lepskiy