COPASI API  4.16.103
CColorScale.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 #ifndef CCOLORSCALE_H
12 #define CCOLORSCALE_H
13 
14 #include <QtGui/QColor>
15 
16 #ifdef SunOS
17 # include <ieeefp.h>
18 #endif
19 
20 #include "copasi.h"
21 
22 /**
23  * Base class for color scales. The derived classes provide algorithms
24  * to map a double number to a QColor.
25  * The scaling parameters can either be set automatically (by using methods
26  * provided by the derived classes) or be determined automatically.
27  * For automatic scaling all numbers that are to be displayed (or at least
28  * a typical sample) have to be passed to the passValue() method before the
29  * getColor() method is used.
30  * This class is used by ArrayAnnotationWidget.
31  */
33 {
34 public:
35  CColorScale(): mIsUsed(false) {};
36 
37  virtual ~CColorScale() {};
38 
39  /**
40  * this method maps a number to a color.
41  */
42  virtual QColor getColor(const C_FLOAT64 & number) = 0;
43 
44  /**
45  * this method starts the calculation of the scaling parameters.
46  */
48 
49  /**
50  * with this method numbers are passed to the automatic scaling algorithm.
51  */
52  virtual void passValue(const C_FLOAT64 & /*number*/) {};
53 
54  /**
55  * this finishes the calculation of the scaling parameters.
56  */
58 
59  /**
60  * this is called by the array annotation widget to indicate that the scaler is in use
61  */
62  void setIsUsed(bool f) {mIsUsed = f;};
63 
64  /**
65  * if setIsUsed() was used isUsed() can be called to find out if the scaler is
66  * already in use. One scaler must not be used in several widgets.
67  */
68  bool isUsed() const {return mIsUsed;};
69 
70 private:
71  /**
72  * This flag indicates whether the scaler is in use. The widget using the scaler must
73  * call setIsUsed() to keep this up to date.
74  */
75  bool mIsUsed;
76 };
77 
78 /**
79  * This returns white, if the absolute value of the number is smaller than the
80  * threshold. Otherwise if it is positive, the color is green, if negative red.
81  */
82 class CColorScale1 : public CColorScale
83 {
84 public:
85  CColorScale1();
86 
87  void setThreshold(const C_FLOAT64 & n) {m1 = n;};
88 
89  virtual QColor getColor(const C_FLOAT64 & number);
90 
91 protected:
93 };
94 
95 /**
96  * This maps a range of numbers to a range of colors.
97  * Automatic scaling looks for minimum and maximum of
98  * the provided numbers
99  */
101 {
102 public:
104 
105  /**
106  * Set minimum and maximum of number range
107  */
108  void setMinMax(const C_FLOAT64 & min, const C_FLOAT64 & max)
109  {mMin = min; mMax = max;};
110 
111  /**
112  * Log scaling is not yet implemented
113  */
114  void setLog(bool l) {mLog = l;} ; //log not implemented yet!
115 
116  /**
117  * If this is true, the number range (if automatically determined)
118  * is centered around 0.0.
119  */
120  void setSymmetric(bool s) {mSym = s;};
121 
122  virtual QColor getColor(const C_FLOAT64 & number);
123 
124  virtual void startAutomaticParameterCalculation();
125  virtual void passValue(const C_FLOAT64 & number);
127 
128 protected:
131  bool mLog;
132  bool mSym;
133 };
134 
135 /**
136  * The same mapping as in the base class.
137  * Option to set user defined colors for the min and
138  * max value.
139  */
141 {
142 public:
143 
145 
146  virtual QColor getColor(const C_FLOAT64 & number);
147 
148  void setColorMin(QColor col);
149  void setColorMax(QColor col);
150 
151 protected:
152 
153  QColor mColorMin;
154  QColor mColorMax;
155 };
156 
157 /**
158  * the same mapping as in the base class. However the automatic scaling
159  * is done using the average of the absolute values of the provided numbers.
160  * The average of the absolute values is multiplied by the factor to give the
161  * range.
162  */
164 {
165 public:
167 
168  /**
169  *
170  */
171  void setFactor(C_FLOAT64 f) {mFactor = f;};
172 
173  virtual void startAutomaticParameterCalculation();
174  virtual void passValue(const C_FLOAT64 & number);
176 
177 protected:
181 };
182 
184 {
185 public:
187 
188  /**
189  *
190  */
191  void setWhitepoint(const C_FLOAT64 & n);
192 
193  /**
194  *
195  */
196  void setMaxIntensityPoint(const C_FLOAT64 & n);
197 
198  virtual QColor getColor(const C_FLOAT64 & number);
199 
200  virtual void startAutomaticParameterCalculation();
201  virtual void passValue(const C_FLOAT64 & number);
203 
204 protected:
207 
210 };
211 
212 #endif
void setSymmetric(bool s)
Definition: CColorScale.h:120
void setWhitepoint(const C_FLOAT64 &n)
C_FLOAT64 m1
Definition: CColorScale.h:92
virtual void startAutomaticParameterCalculation()
virtual void finishAutomaticParameterCalculation()
void setColorMax(QColor col)
void setMinMax(const C_FLOAT64 &min, const C_FLOAT64 &max)
Definition: CColorScale.h:108
bool mIsUsed
Definition: CColorScale.h:68
virtual ~CColorScale()
Definition: CColorScale.h:37
#define C_INT32
Definition: copasi.h:90
virtual void passValue(const C_FLOAT64 &number)
Definition: CColorScale.cpp:95
virtual void passValue(const C_FLOAT64 &number)
virtual void startAutomaticParameterCalculation()
Definition: CColorScale.h:47
virtual void finishAutomaticParameterCalculation()
Definition: CColorScale.h:57
virtual void passValue(const C_FLOAT64 &number)
virtual QColor getColor(const C_FLOAT64 &number)
Definition: CColorScale.cpp:52
virtual QColor getColor(const C_FLOAT64 &number)=0
void setColorMin(QColor col)
virtual void finishAutomaticParameterCalculation()
virtual QColor getColor(const C_FLOAT64 &number)
void setThreshold(const C_FLOAT64 &n)
Definition: CColorScale.h:87
virtual QColor getColor(const C_FLOAT64 &number)
Definition: CColorScale.cpp:28
virtual void passValue(const C_FLOAT64 &)
Definition: CColorScale.h:52
void setFactor(C_FLOAT64 f)
Definition: CColorScale.h:171
#define C_FLOAT64
Definition: copasi.h:92
void setMaxIntensityPoint(const C_FLOAT64 &n)
virtual void startAutomaticParameterCalculation()
void setLog(bool l)
Definition: CColorScale.h:114
virtual void finishAutomaticParameterCalculation()
bool isUsed() const
Definition: CColorScale.h:68
void setIsUsed(bool f)
Definition: CColorScale.h:62
#define min(a, b)
Definition: f2c.h:175
virtual void startAutomaticParameterCalculation()
Definition: CColorScale.cpp:88
C_FLOAT64 mFloat
Definition: CColorScale.h:208
virtual QColor getColor(const C_FLOAT64 &number)
#define max(a, b)
Definition: f2c.h:176