COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
coColors.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef COVCOLORS_H
9 #define COVCOLORS_H
10 
11 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12 // ++ (C)2000 RUS ++
13 // ++ Description: Universal Colormap class ++
14 // ++ ++
15 // ++ Author: ++
16 // ++ ++
17 // ++ Andreas Werner ++
18 // ++ Computer Center University of Stuttgart ++
19 // ++ Allmandring 30 ++
20 // ++ 70550 Stuttgart ++
21 // ++ ++
22 // ++ Date: 03.08.2000 V3.0 ++
23 // ++**********************************************************************/
24 
25 #include <do/coDoColormap.h>
26 #include <do/coDoTexture.h>
27 #include <do/coDoSet.h>
28 #include <do/coDoIntArr.h>
29 
30 #include <utility>
31 #include <cfloat>
32 
33 namespace covise
34 {
35 
37 {
38 public:
39  void copyFrom(const AttributeList &attrs);
40  void copyFrom(const coDistributedObject *source);
41  void copyTo(coDistributedObject *dest);
42  const char *getAttribute(const char *word) const;
43 
44 private:
45  std::vector<std::pair<std::string, std::string> > m_attrList;
46 };
47 
49 {
50 public:
51  // RGBAX, [0..1]
52  typedef float FlColor[5];
53  coColor(int num_el, float *data_, const coDoColormap *colorMapIn);
54  coDistributedObject *createColors(const coObjInfo &info);
55  static FlColor *interpolateColormap(FlColor *map, int numColors, int numSteps);
56 
57 private:
58  FlColor *actMap_;
59  int steps_;
60  const char *annotation_;
61  float min_, max_;
62  int numElem;
63  float *data;
64  // color to be used for non-existing data values, nomallx 0x00000000
65  unsigned long d_noDataColor;
67 };
68 
70 {
71 public:
73  void Initialise(const coDistributedObject *);
75  virtual ~ScalarContainer();
76  void OpenList(int size);
77  void CopyAllAttributes(const coDistributedObject *);
78  void DumpAllAttributes(coDistributedObject *);
79  const char *getAttribute(const char *) const;
80  const char *getAttributeRecursive(const char *) const;
81  void AddArray(int size, const float *scalar);
82 
83  const float *ScalarField() const;
84  int SizeField() const;
85 
86  ScalarContainer &operator[](int i);
87  int NoChildren() const;
88 
89  void MinMax(float &min, float &max) const;
90 
91 private:
92  float *_field;
95 
96  vector<ScalarContainer> _children;
97 };
98 
100 {
101 public:
102  // RGBAX, [0..1]
103  typedef float FlColor[5];
104 
105 private:
107  enum
108  {
109  MAX_CMAP_SIZE = 2048
110  };
111 
115 
116  FlColor *actMap_;
117  int steps_;
118  string annotation_;
119  float min_, max_;
121 
122  // color to be used for non-existing data values, nomallx 0x00000000
123  unsigned long d_noDataColor;
124 
125  // color output styles
126  enum Outstyle
127  {
128  RGBA = 1,
129  TEX = 4
130  };
131 
132  // struct captures all info for one data input object
133  struct recObj
134  {
135  const coDistributedObject *obj; // the object itself
137  const coDistributedObject *const *objList; // if object was a set: list of subobj.
138  recObj *subObj; // recurse to subobj
139  int numElem; // number
140  float *data; // otherwise: pointer to data
141  bool doDelete; // whether we have to delete this data
142  // (from vect or int)
144  {
145  obj = 0;
146  objSCont = 0;
147  objList = 0;
148  subObj = 0;
149  numElem = 0;
150  data = 0;
151  doDelete = false;
152  }
154  {
155  if (subObj)
156  delete[] subObj;
157  if (doDelete)
158  delete[] data;
159  }
160  };
161 
162  // Data structure holding one color map
163  struct ColorMap
164  {
165  FlColor *map;
167  } *d_cmap;
168 
169  int openObj(recObj &base, const coDistributedObject *obj, const char *&species);
170  int openObj(recObj &base, const ScalarContainer *obj, const char *&species);
171  coDistributedObject *createColors(recObj &base, const coObjInfo &info, int outStyle, int repeat);
172 
173 public:
174  void addColormapAttrib(const coObjInfo &info, coDistributedObject *outObj);
175 
176  coColors(const coDistributedObject *data, const coDoColormap *colorMapIn, bool transparentTextures);
177  coColors(const ScalarContainer &data, const coDoColormap *colorMapIn, bool transparentTextures, const ScalarContainer *glData);
178  coDistributedObject *getColors(const coObjInfo &outInfo,
179  bool create_texture = false,
180  bool createCMAP = true,
181  int repeat = 1,
182  float *min = NULL,
183  float *max = NULL);
184 };
185 }
186 #endif
GLsizei GLsizei GLchar * source
Definition: khronos-glext.h:6739
GLsizei GLsizei GLuint * obj
Definition: khronos-glext.h:6733
Definition: coColors.h:36
AttributeList _attributes
Definition: coColors.h:114
const coDistributedObject * data_
Definition: coColors.h:112
ScalarContainer * objSCont
Definition: coColors.h:136
float * _field
Definition: coColors.h:92
AttributeList _attributes
Definition: coColors.h:94
float * data
Definition: coColors.h:140
float * data
Definition: coColors.h:63
float min_
Definition: coColors.h:119
const ScalarContainer * _scalar
Definition: coColors.h:113
FlColor * actMap_
Definition: coColors.h:58
int numElem
Definition: coColors.h:62
float min_
Definition: coColors.h:61
int textureComponents_
Definition: coColors.h:120
#define NULL
Definition: covise_list.h:22
Definition: coColors.h:133
Definition: coColors.h:48
FlColor * map
Definition: coColors.h:165
Definition: coObjID.h:230
GLsizeiptr size
Definition: khronos-glext.h:6610
string annotation_
Definition: coColors.h:118
unsigned long d_noDataColor
Definition: coColors.h:123
#define ALGEXPORT
Definition: coExport.h:313
Definition: coColors.h:163
unsigned long d_noDataColor
Definition: coColors.h:65
std::vector< std::pair< std::string, std::string > > m_attrList
Definition: coColors.h:45
~recObj()
Definition: coColors.h:153
FlColor * actMap_
Definition: coColors.h:116
recObj * subObj
Definition: coColors.h:138
recObj()
Definition: coColors.h:143
const coDistributedObject * obj
Definition: coColors.h:135
int steps_
Definition: coColors.h:117
int _size_field
Definition: coColors.h:93
Definition: coColors.h:99
bool doDelete
Definition: coColors.h:141
Outstyle
Definition: coColors.h:126
Definition: coDoColormap.h:38
int numElem
Definition: coColors.h:139
Definition: coDistributedObject.h:295
int numcoColors
Definition: coColors.h:166
vector< ScalarContainer > _children
Definition: coColors.h:96
Definition: coColors.h:69
const char * annotation_
Definition: coColors.h:60
AttributeList _attributes
Definition: coColors.h:66
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: khronos-glext.h:6354
const coDistributedObject *const * objList
Definition: coColors.h:137
int min(int a, int b)
Definition: cutil_math.h:60
int steps_
Definition: coColors.h:59
int max(int a, int b)
Definition: cutil_math.h:55