GlobeEngine
ColorisationTable.h
Go to the documentation of this file.
1 /*
2  * Colortable.h
3  * GlobeEngine
4  *
5  * Created by Mathias Thöny on 27.12.11.
6  * Copyright (c) 2011 University of Zurich. All rights reserved.
7  */
8 
9 #ifndef GlobeEngine_Colortable_h
10 #define GlobeEngine_Colortable_h
11 
12 #include "OpenGL_Includes.h"
13 #include "Texture.h"
14 #include "VBOVertex.h"
15 #include <vector>
16 #include <string>
17 #include <memory>
18 
19 namespace geData {
21 
22  std::vector<ge::Color4ub> colors;
23  std::vector<float> heights;
24  void clear() {
25  if (heights.size() > 0) { heights.clear(); }
26  if (colors.size() > 0) { colors.clear(); }
27  }
28  };
29 
30  //class ColorisationTable : public ge::Texture
32  {
33  public:
36 
37  void clear();
38  void create(std::string _filename);
39  void create(const std::shared_ptr<HeightColorTable>& _entries);
40  void create(float _min, float _max);
41  void readColorTable(std::string _filename);
42 
43  unsigned int size();
44  unsigned char* getByteDataRGB();
45  unsigned char* getByteDataRGBA();
46  unsigned char* getByteDataRGBALinear();
47  unsigned char* getByteDataRGBAStaircase();
48  float getTexCoord1DForHeightValue(float _height);
49 
50  void setPixelCount(unsigned int _in);
51  unsigned int getPixelCount() const;
52  ge::Color4ub getColorForValue(double _value) const;
53 
54  void setName(std::string _name);
55  std::string getName() const;
56 
57  void addPairToColorTable(ge::Color4ub _color, float _value);
58 
59  int getTableSize() const;
60  float getValueAtIndex(int _idx) const;
61  ge::Color4ub getColorAtIndex(int _idx) const;
62  void setMinMax(float _min, float _max);
63  float getMinValue() const;
64  float getMaxValue() const;
65  float getValueRange() const;
66  void print();
67 
68  private:
69  void create();
70  void checkForMinMax(float _value);
71  void calculateMinMaxDiff();
72 
73  void addHeightValue(float _height);
74  ge::Color4ub addColorFromString(std::string _colorString);
75 
76  unsigned char interpolate(GLubyte a, GLubyte b, float t);
77 
78  // file operation
79  void determineExtension(std::string _filename);
80  void checkForCommaSeparation(std::string _example);
81 
82  std::string objectName;
83  HeightColorTable data;
84 
85  float maxValue;
86  float minValue;
87  float diffMinMax;
88  unsigned int pixelCount;
89 
90  std::string ext;
91  char csvSeparationChar;
92 
93  };
94 }
95 
96 #endif
float getMaxValue() const
Definition: ColorisationTable.cpp:379
std::string getName() const
Definition: ColorisationTable.cpp:388
void clear()
Definition: ColorisationTable.h:24
unsigned char * getByteDataRGBA()
Definition: ColorisationTable.cpp:255
ge::Color4ub getColorForValue(double _value) const
Definition: ColorisationTable.cpp:198
void print()
Definition: ColorisationTable.cpp:397
Definition: AvalancheTrainingSimulationEngine.h:39
ge::Color4ub getColorAtIndex(int _idx) const
Definition: ColorisationTable.cpp:343
float getMinValue() const
Definition: ColorisationTable.cpp:374
Definition: ColorisationTable.h:31
float getValueAtIndex(int _idx) const
Definition: ColorisationTable.cpp:338
unsigned char * getByteDataRGB()
Definition: ColorisationTable.cpp:226
float getValueRange() const
Definition: ColorisationTable.cpp:359
std::vector< float > heights
Definition: ColorisationTable.h:23
void addPairToColorTable(ge::Color4ub _color, float _value)
Definition: ColorisationTable.cpp:79
Definition: Texture.h:376
void clear()
Definition: ColorisationTable.cpp:19
Definition: ColorisationTable.h:20
ColorisationTable()
Definition: ColorisationTable.cpp:10
unsigned char * getByteDataRGBAStaircase()
Definition: ColorisationTable.cpp:267
void create(std::string _filename)
Definition: ColorisationTable.cpp:31
unsigned int getPixelCount() const
Definition: ColorisationTable.cpp:369
~ColorisationTable()
Definition: ColorisationTable.cpp:15
int getTableSize() const
Definition: ColorisationTable.cpp:333
float getTexCoord1DForHeightValue(float _height)
Definition: ColorisationTable.cpp:184
unsigned int size()
Definition: ColorisationTable.cpp:392
void setName(std::string _name)
Definition: ColorisationTable.cpp:384
std::vector< ge::Color4ub > colors
Definition: ColorisationTable.h:22
Definition: VBOVertex.h:228
unsigned char * getByteDataRGBALinear()
Definition: ColorisationTable.cpp:291
void setPixelCount(unsigned int _in)
Definition: ColorisationTable.cpp:364
void setMinMax(float _min, float _max)
Definition: ColorisationTable.cpp:66
void readColorTable(std::string _filename)
Definition: ColorisationTable.cpp:99