COPASI API  4.16.103
Public Member Functions | Protected Attributes | List of all members
CColorScaleBiLog Class Reference

#include <CColorScale.h>

Inheritance diagram for CColorScaleBiLog:
Inheritance graph
[legend]
Collaboration diagram for CColorScaleBiLog:
Collaboration graph
[legend]

Public Member Functions

 CColorScaleBiLog ()
 
virtual void finishAutomaticParameterCalculation ()
 
virtual QColor getColor (const C_FLOAT64 &number)
 
virtual void passValue (const C_FLOAT64 &number)
 
void setMaxIntensityPoint (const C_FLOAT64 &n)
 
void setWhitepoint (const C_FLOAT64 &n)
 
virtual void startAutomaticParameterCalculation ()
 
- Public Member Functions inherited from CColorScale
 CColorScale ()
 
bool isUsed () const
 
void setIsUsed (bool f)
 
virtual ~CColorScale ()
 

Protected Attributes

C_FLOAT64 m1
 
C_FLOAT64 m2
 
C_FLOAT64 mFloat
 
C_INT32 mInt
 

Detailed Description

Definition at line 183 of file CColorScale.h.

Constructor & Destructor Documentation

CColorScaleBiLog::CColorScaleBiLog ( )

Definition at line 206 of file CColorScale.cpp.

207  : m1(-6.0),
208  m2(2.0),
209  mFloat(0.0),
210  mInt(0)
211 {}
C_FLOAT64 mFloat
Definition: CColorScale.h:208

Member Function Documentation

void CColorScaleBiLog::finishAutomaticParameterCalculation ( )
virtual

this finishes the calculation of the scaling parameters.

Reimplemented from CColorScale.

Definition at line 287 of file CColorScale.cpp.

References m1, m2, mFloat, and mInt.

288 {
289  if (mInt != 0)
290  m1 = (mFloat / mInt) - 4;
291  else
292  m1 = -4.0;
293 
294  m2 -= 1.0;
295 }
C_FLOAT64 mFloat
Definition: CColorScale.h:208
QColor CColorScaleBiLog::getColor ( const C_FLOAT64 number)
virtual

this method maps a number to a color.

Implements CColorScale.

Definition at line 214 of file CColorScale.cpp.

References C_FLOAT64, m1, and m2.

215 {
216  C_FLOAT64 logtmp = log(fabs(number));
217 
218  C_FLOAT64 tmp = (logtmp - m1) / (m2 - m1); //scale to 0..1
219 
220  if (tmp > 1) tmp = 1;
221 
222  if (tmp < 0) tmp = 0;
223 
224  if (number > 0)
225  tmp = 0.5 + tmp * 0.5;
226  else
227  tmp = 0.5 - tmp * 0.5;
228 
229  int r = 0;
230  int g = 0;
231  int b = 0;
232 
233  if (tmp != tmp)
234  {
235  r = 85;
236  g = 85;
237  b = 135;
238  }
239  else if (tmp < 0.5)
240  {
241  r = 255;
242  g = (int)(255 + (tmp - 0.5) * 260);
243  b = (int)(255 + (tmp - 0.5) * 260);
244  }
245  else
246  {
247  r = (int)(255 - (tmp - 0.5) * 260);
248  g = 255;
249  b = (int)(255 - (tmp - 0.5) * 260);
250  }
251 
252  QColor color(r, g, b);
253  return color;
254 }
#define C_FLOAT64
Definition: copasi.h:92
void CColorScaleBiLog::passValue ( const C_FLOAT64 )
virtual

with this method numbers are passed to the automatic scaling algorithm.

Reimplemented from CColorScale.

Definition at line 266 of file CColorScale.cpp.

References C_FLOAT64, m1, m2, max, mFloat, and mInt.

267 {
268  if (number != number) return; //NaN
269 
270  if (fabs(number) >= std::numeric_limits< C_FLOAT64 >::max()) return; //Inf
271 
272  if (number == 0.0) return;
273 
274  C_FLOAT64 tmp = log(fabs(number));
275 
276  //minmax
277  if (tmp > m2) m2 = tmp;
278 
279  if (tmp < m1) m1 = tmp;
280 
281  //average
282  ++mInt;
283  mFloat += tmp;
284 }
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 mFloat
Definition: CColorScale.h:208
#define max(a, b)
Definition: f2c.h:176
void CColorScaleBiLog::setMaxIntensityPoint ( const C_FLOAT64 n)

Definition at line 299 of file CColorScale.cpp.

References m2.

299 {m2 = log(n);}
void CColorScaleBiLog::setWhitepoint ( const C_FLOAT64 n)

Definition at line 297 of file CColorScale.cpp.

References m1.

297 {m1 = log(n);}
void CColorScaleBiLog::startAutomaticParameterCalculation ( )
virtual

this method starts the calculation of the scaling parameters.

Reimplemented from CColorScale.

Definition at line 257 of file CColorScale.cpp.

References m1, m2, max, mFloat, and mInt.

258 {
261  mFloat = 0.0;
262  mInt = 0;
263 }
C_FLOAT64 mFloat
Definition: CColorScale.h:208
#define max(a, b)
Definition: f2c.h:176

Member Data Documentation

C_FLOAT64 CColorScaleBiLog::m1
protected
C_FLOAT64 CColorScaleBiLog::m2
protected
C_FLOAT64 CColorScaleBiLog::mFloat
protected
C_INT32 CColorScaleBiLog::mInt
protected

The documentation for this class was generated from the following files: