COPASI API  4.16.103
CLGradientStops.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/layout/CLGradientStops.h,v $
3 // $Revision: 1.2 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/09/30 16:35:20 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 #ifndef CLGradientStops_H__
15 #define CLGradientStops_H__
16 
17 #include <list>
18 #include <map>
19 #include <string>
20 
21 #include "CLRGBAColor.h"
22 
24 
26 {
27 protected:
29 
30  // an array of numStops RGBA values
31  unsigned char* mColorData;
32 
33  // a list of stops, each stops has a relative value between 0 and 1
34  // associated with an index into the color data
35  std::list<std::pair<double, unsigned int> > mStops;
36 
37  // some iterators that are needed to calculate the color value
38  std::list<std::pair<double, unsigned int> >::const_iterator mBegin;
39  std::list<std::pair<double, unsigned int> >::const_iterator mEnd;
40  std::list<std::pair<double, unsigned int> >::const_iterator mCurrentPosition;
41  std::list<std::pair<double, unsigned int> >::const_iterator mTmp;
42 
43  // an index variable that saves us from instantiating one millions of times
44  unsigned int mIndex;
45 
46  // a color object that allows us to return a reference to a color value
47  // rather than having to copy a color millions of times
49 
50  // a double value that we need for each of the many calls to color
51  // this way we don't need to reserve memory every time
52  double mHelp;
53 
54 public:
55  // Construktor that creates a CLGradientStops object from
56  // a gradient base object and a color map.
57  CLGradientStops(const CLGradientBase* pGradient, const std::map<std::string, CLRGBAColor>& colormap);
58 
59  // Destructor
61 
62  void update_color(double val);
63 
64  const CLRGBAColor& color() const;
65 
66 protected:
67  /**
68  * This method takes the given offset value and adjust it
69  * if it is outside the rangr from 0.0 to 1.0 depending on
70  * the spread method that has been set from the gradient.
71  */
72  void adjust_value(double& value) const;
73 };
74 
75 #endif /* CLGradientStops_H__ */
unsigned int mIndex
std::list< std::pair< double, unsigned int > >::const_iterator mEnd
void adjust_value(double &value) const
void update_color(double val)
std::list< std::pair< double, unsigned int > > mStops
CLRGBAColor mColor
CLGradientBase::SPREADMETHOD mSpreadMethod
unsigned char * mColorData
CLGradientStops(const CLGradientBase *pGradient, const std::map< std::string, CLRGBAColor > &colormap)
std::list< std::pair< double, unsigned int > >::const_iterator mCurrentPosition
const CLRGBAColor & color() const
std::list< std::pair< double, unsigned int > >::const_iterator mBegin
std::list< std::pair< double, unsigned int > >::const_iterator mTmp