Tulip  5.2.0
Large graphs analysis and drawing
GlColorScale.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
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 #ifndef GLCOLORSCALE_H_
22 #define GLCOLORSCALE_H_
23 
24 #include <tulip/Observable.h>
25 #include <tulip/GlSimpleEntity.h>
26 #include <tulip/Color.h>
27 
28 namespace tlp {
29 
30 class ColorScale;
31 class GlPolyQuad;
32 
33 class TLP_GL_SCOPE GlColorScale : public GlSimpleEntity, public Observable {
34 
35 public:
36  enum Orientation { Horizontal, Vertical };
37 
38  GlColorScale(ColorScale *colorScale, const Coord &baseCoord, const float length,
39  const float thickness, Orientation orientation);
40 
41  ~GlColorScale() override;
42 
43  /**
44  * @brief Compute the color corresponding to the position in the color scale.
45  * The orientation of the scale define the coordinate used to compute the color (if the
46  *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) override;
52 
53  void translate(const Coord &move) override;
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 &) override {}
78 
79  void setWithXML(const std::string &, unsigned int &) override {}
80 
81 protected:
82  void treatEvent(const Event &) override;
83 
84 private:
85  void updateDrawing();
86 
87  ColorScale *colorScale;
88  Coord baseCoord;
89  float length, thickness;
90  GlPolyQuad *colorScalePolyQuad;
91  Orientation orientation;
92 };
93 }
94 
95 #endif /* GLCOLORSCALE_H_ */
96 ///@endcond