Tulip  4.0.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
GlColorScale.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 
22 #ifndef GLCOLORSCALE_H_
23 #define GLCOLORSCALE_H_
24 
25 #include <tulip/Observable.h>
26 #include <tulip/GlPolyQuad.h>
27 #include <tulip/ColorScale.h>
28 
29 namespace tlp {
30 
31 class TLP_GL_SCOPE GlColorScale : public GlSimpleEntity, public Observable {
32 
33 public:
34 
35  enum Orientation {
36  Horizontal, Vertical
37  };
38 
39  GlColorScale(ColorScale *colorScale, const Coord &baseCoord, const float length,
40  const float thickness, Orientation orientation);
41 
42  ~GlColorScale();
43 
44  /**
45  * @brief Compute the color corresponding to the position in the color scale.
46  * The orientation of the scale define the coordinate used to compute the color (if the orientation is horizontal use only the X coordinate).
47  * If the position is outside of the entity coordinates returns the nearest extremity value.
48  **/
49  Color getColorAtPos(Coord pos);
50 
51  void draw(float lod, Camera* camera);
52 
53  void translate(const Coord &move);
54 
55  Coord getBaseCoord() const {
56  return baseCoord;
57  }
58 
59  float getThickness() const {
60  return thickness;
61  }
62 
63  float getLength() const {
64  return length;
65  }
66 
67  GlPolyQuad *getColorScalePolyQuad() const {
68  return colorScalePolyQuad;
69  }
70 
71  void setColorScale(ColorScale * scale);
72 
73  ColorScale *getColorScale() {
74  return colorScale;
75  }
76 
77  void getXML(std::string &) {}
78 
79  void setWithXML(const std::string &,unsigned int &) {}
80 
81 protected :
82 
83  void treatEvent(const Event &);
84 
85 private:
86 
87  void updateDrawing();
88 
89  ColorScale *colorScale;
90  Coord baseCoord;
91  float length, thickness;
92  GlPolyQuad *colorScalePolyQuad;
93  Orientation orientation;
94 };
95 
96 }
97 
98 #endif /* GLCOLORSCALE_H_ */
99 ///@endcond