Tulip  4.3.0
Better Visualization Through Research
 All Classes Namespaces 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/GlSimpleEntity.h>
27 #include <tulip/Color.h>
28 
29 namespace tlp {
30 
31 class ColorScale;
32 class GlPolyQuad;
33 
34 class TLP_GL_SCOPE GlColorScale : public GlSimpleEntity, public Observable {
35 
36 public:
37 
38  enum Orientation {
39  Horizontal, Vertical
40  };
41 
42  GlColorScale(ColorScale *colorScale, const Coord &baseCoord, const float length,
43  const float thickness, Orientation orientation);
44 
45  ~GlColorScale();
46 
47  /**
48  * @brief Compute the color corresponding to the position in the color scale.
49  * The orientation of the scale define the coordinate used to compute the color (if the orientation is horizontal use only the X coordinate).
50  * If the position is outside of the entity coordinates returns the nearest extremity value.
51  **/
52  Color getColorAtPos(Coord pos);
53 
54  void draw(float lod, Camera* camera);
55 
56  void translate(const Coord &move);
57 
58  Coord getBaseCoord() const {
59  return baseCoord;
60  }
61 
62  float getThickness() const {
63  return thickness;
64  }
65 
66  float getLength() const {
67  return length;
68  }
69 
70  GlPolyQuad *getColorScalePolyQuad() const {
71  return colorScalePolyQuad;
72  }
73 
74  void setColorScale(ColorScale * scale);
75 
76  ColorScale *getColorScale() {
77  return colorScale;
78  }
79 
80  void getXML(std::string &) {}
81 
82  void setWithXML(const std::string &,unsigned int &) {}
83 
84 protected :
85 
86  void treatEvent(const Event &);
87 
88 private:
89 
90  void updateDrawing();
91 
92  ColorScale *colorScale;
93  Coord baseCoord;
94  float length, thickness;
95  GlPolyQuad *colorScalePolyQuad;
96  Orientation orientation;
97 };
98 
99 }
100 
101 #endif /* GLCOLORSCALE_H_ */
102 ///@endcond