COVISE Core
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
33namespace covise
34{
35
37{
38public:
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
44private:
45 std::vector<std::pair<std::string, std::string> > m_attrList;
46};
47
49{
50public:
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
57private:
58 FlColor *actMap_;
59 int steps_;
60 const char *annotation_;
61 float min_, max_;
63 float *data;
64 // color to be used for non-existing data values, nomallx 0x00000000
65 unsigned long d_noDataColor;
67};
68
70{
71public:
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
91private:
92 float *_field;
95
96 vector<ScalarContainer> _children;
97};
98
100{
101public:
102 // RGBAX, [0..1]
103 typedef float FlColor[5];
104
105private:
107 enum
108 {
109 MAX_CMAP_SIZE = 2048
110 };
111
115
116 FlColor *actMap_;
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
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
173public:
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
#define ALGEXPORT
Definition: coExport.h:337
#define NULL
Definition: covise_list.h:22
GLsizei GLsizei GLuint * obj
Definition: khronos-glext.h:6733
GLsizeiptr size
Definition: khronos-glext.h:6610
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: khronos-glext.h:6354
GLsizei GLsizei GLchar * source
Definition: khronos-glext.h:6739
int min(int a, int b)
Definition: cutil_math.h:60
int max(int a, int b)
Definition: cutil_math.h:55
list of all chemical elements
Definition: coConfig.h:27
Definition: coObjID.h:231
Definition: coDistributedObject.h:296
Definition: coDoColormap.h:39
Definition: coColors.h:37
std::vector< std::pair< std::string, std::string > > m_attrList
Definition: coColors.h:45
Definition: coColors.h:49
const char * annotation_
Definition: coColors.h:60
float * data
Definition: coColors.h:63
unsigned long d_noDataColor
Definition: coColors.h:65
int numElem
Definition: coColors.h:62
float max_
Definition: coColors.h:61
int steps_
Definition: coColors.h:59
FlColor * actMap_
Definition: coColors.h:58
AttributeList _attributes
Definition: coColors.h:66
Definition: coColors.h:70
vector< ScalarContainer > _children
Definition: coColors.h:96
float * _field
Definition: coColors.h:92
int _size_field
Definition: coColors.h:93
AttributeList _attributes
Definition: coColors.h:94
Definition: coColors.h:100
unsigned long d_noDataColor
Definition: coColors.h:123
FlColor * actMap_
Definition: coColors.h:116
Outstyle
Definition: coColors.h:127
const ScalarContainer * _scalar
Definition: coColors.h:113
const coDistributedObject * data_
Definition: coColors.h:112
AttributeList _attributes
Definition: coColors.h:114
int textureComponents_
Definition: coColors.h:120
int steps_
Definition: coColors.h:117
string annotation_
Definition: coColors.h:118
float max_
Definition: coColors.h:119
Definition: coColors.h:134
ScalarContainer * objSCont
Definition: coColors.h:136
recObj()
Definition: coColors.h:143
const coDistributedObject * obj
Definition: coColors.h:135
recObj * subObj
Definition: coColors.h:138
~recObj()
Definition: coColors.h:153
bool doDelete
Definition: coColors.h:141
int numElem
Definition: coColors.h:139
const coDistributedObject *const * objList
Definition: coColors.h:137
float * data
Definition: coColors.h:140
Definition: coColors.h:164
FlColor * map
Definition: coColors.h:165
int numcoColors
Definition: coColors.h:166