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

#include <CColorScale.h>

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

Public Member Functions

 CColorScaleSimple ()
 
virtual void finishAutomaticParameterCalculation ()
 
virtual QColor getColor (const C_FLOAT64 &number)
 
virtual void passValue (const C_FLOAT64 &number)
 
void setLog (bool l)
 
void setMinMax (const C_FLOAT64 &min, const C_FLOAT64 &max)
 
void setSymmetric (bool s)
 
virtual void startAutomaticParameterCalculation ()
 
- Public Member Functions inherited from CColorScale
 CColorScale ()
 
bool isUsed () const
 
void setIsUsed (bool f)
 
virtual ~CColorScale ()
 

Protected Attributes

bool mLog
 
C_FLOAT64 mMax
 
C_FLOAT64 mMin
 
bool mSym
 

Detailed Description

This maps a range of numbers to a range of colors. Automatic scaling looks for minimum and maximum of the provided numbers

Definition at line 100 of file CColorScale.h.

Constructor & Destructor Documentation

CColorScaleSimple::CColorScaleSimple ( )

Definition at line 44 of file CColorScale.cpp.

45  : mMin(0.0),
46  mMax(1.0),
47  mLog(false),
48  mSym(false)
49 {}

Member Function Documentation

void CColorScaleSimple::finishAutomaticParameterCalculation ( )
virtual

this finishes the calculation of the scaling parameters.

Reimplemented from CColorScale.

Reimplemented in CColorScaleAverage.

Definition at line 103 of file CColorScale.cpp.

References C_FLOAT64, mMax, mMin, and mSym.

104 {
105  if (mSym)
106  {
107  C_FLOAT64 tmp;
108 
109  if (fabs(mMax) > fabs(mMin))
110  tmp = fabs(mMax);
111  else
112  tmp = fabs(mMin);
113 
114  mMin = - tmp;
115  mMax = tmp;
116  }
117 
118  if (mMin == mMax)
119  {
120  mMin -= 1e-5;
121  mMax += 1e-5;
122  }
123 }
#define C_FLOAT64
Definition: copasi.h:92
QColor CColorScaleSimple::getColor ( const C_FLOAT64 number)
virtual

this method maps a number to a color.

Implements CColorScale.

Reimplemented in CColorScaleAdvanced.

Definition at line 52 of file CColorScale.cpp.

References C_FLOAT64, mMax, and mMin.

53 {
54  C_FLOAT64 tmp = (number - mMin) / (mMax - mMin); //scale to 0..1
55 
56  if (tmp > 1) tmp = 1;
57 
58  if (tmp < 0) tmp = 0;
59 
60  int r = 0;
61  int g = 0;
62  int b = 0;
63 
64  if (tmp != tmp)
65  {
66  r = 85;
67  g = 85;
68  b = 135;
69  }
70  else if (tmp < 0.5)
71  {
72  r = 255;
73  g = (int)(255 + (tmp - 0.5) * 260);
74  b = (int)(255 + (tmp - 0.5) * 260);
75  }
76  else
77  {
78  r = (int)(255 - (tmp - 0.5) * 260);
79  g = 255;
80  b = (int)(255 - (tmp - 0.5) * 260);
81  }
82 
83  QColor color(r, g, b);
84  return color;
85 }
#define C_FLOAT64
Definition: copasi.h:92
void CColorScaleSimple::passValue ( const C_FLOAT64 )
virtual

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

Reimplemented from CColorScale.

Reimplemented in CColorScaleAverage.

Definition at line 95 of file CColorScale.cpp.

References mMax, and mMin.

96 {
97  if (number > mMax) mMax = number;
98 
99  if (number < mMin) mMin = number;
100 }
void CColorScaleSimple::setLog ( bool  l)
inline

Log scaling is not yet implemented

Definition at line 114 of file CColorScale.h.

References mLog.

114 {mLog = l;} ; //log not implemented yet!
void CColorScaleSimple::setMinMax ( const C_FLOAT64 min,
const C_FLOAT64 max 
)
inline

Set minimum and maximum of number range

Definition at line 108 of file CColorScale.h.

References max, min, mMax, and mMin.

Referenced by CQMathMatrixWidget::CQMathMatrixWidget().

109  {mMin = min; mMax = max;};
#define min(a, b)
Definition: f2c.h:175
#define max(a, b)
Definition: f2c.h:176
void CColorScaleSimple::setSymmetric ( bool  s)
inline

If this is true, the number range (if automatically determined) is centered around 0.0.

Definition at line 120 of file CColorScale.h.

References mSym.

Referenced by CQTSSAResultSubWidget::slotTableChanged().

120 {mSym = s;};
void CColorScaleSimple::startAutomaticParameterCalculation ( )
virtual

this method starts the calculation of the scaling parameters.

Reimplemented from CColorScale.

Reimplemented in CColorScaleAverage.

Definition at line 88 of file CColorScale.cpp.

References max, mMax, and mMin.

89 {
92 }
#define max(a, b)
Definition: f2c.h:176

Member Data Documentation

bool CColorScaleSimple::mLog
protected

Definition at line 131 of file CColorScale.h.

Referenced by setLog().

C_FLOAT64 CColorScaleSimple::mMax
protected
C_FLOAT64 CColorScaleSimple::mMin
protected
bool CColorScaleSimple::mSym
protected

Definition at line 132 of file CColorScale.h.

Referenced by finishAutomaticParameterCalculation(), and setSymmetric().


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