Tulip  5.3.0
Large graphs analysis and drawing
GlLine.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 GLLINE_H
22 #define GLLINE_H
23 
24 #ifndef DOXYGEN_NOTFOR_DEVEL
25 
26 #include <tulip/Color.h>
27 #include <tulip/Coord.h>
28 #include <tulip/tulipconf.h>
29 #include <tulip/GlSimpleEntity.h>
30 
31 namespace tlp {
32 
33 /**
34  * @ingroup OpenGL
35  * \brief This is a general class to render an OpenGL laine
36  * This class is use to render an OpenGl line
37  */
38 class TLP_GL_SCOPE GlLine : public GlSimpleEntity {
39 public:
40  /**
41  * Enpty constructor
42  */
43  GlLine() : width(1.0), factor(1), pattern(0) {}
44  /**
45  * Constructor with a list of coord and a list of color
46  */
47  GlLine(const std::vector<Coord> &points, const std::vector<Color> &colors);
48 
49  ~GlLine() override;
50 
51  /**
52  * Render the line
53  */
54  void draw(float lod, Camera *camera) override;
55 
56  /**
57  * Change number of points
58  */
59  virtual void resizePoints(const unsigned int nbPoints);
60  /**
61  * Change number of colors
62  */
63  virtual void resizeColors(const unsigned int nbColors);
64 
65  virtual const Coord &point(const unsigned int i) const;
66  /**
67  * Return the coord of point with given id
68  */
69  virtual Coord &point(const unsigned int i);
70  /**
71  * Add a new point with given coord and given color
72  */
73  virtual void addPoint(const Coord &point, const Color &color);
74 
75  /**
76  * return the ith color used for draw the line
77  */
78  virtual const Color &color(const unsigned int i) const;
79  /**
80  * return the ith color used for draw the line
81  */
82  virtual Color &color(const unsigned int i);
83  /**
84  * Set line width
85  */
86  virtual void setLineWidth(float width);
87  /**
88  * Set the style of the line (documentation can be found in OpenGL manuel of fuction
89  * glLineStipple)
90  */
91  virtual void setLineStipple(unsigned char factor, unsigned int pattern);
92 
93  /**
94  * Translate entity
95  */
96  void translate(const Coord &vec) override;
97 
98  /**
99  * Function to export data in outString (in XML format)
100  */
101  void getXML(std::string &outString) override;
102 
103  /**
104  * Function to set data with inString (in XML format)
105  */
106  void setWithXML(const std::string &inString, unsigned int &currentPosition) override;
107 
108 protected:
109  std::vector<Coord> _points;
110  std::vector<Color> _colors;
111  float width;
112  unsigned char factor;
113  unsigned int pattern;
114 };
115 } // namespace tlp
116 
117 #endif // DOXYGEN_NOTFOR_DEVEL
118 
119 #endif
120 ///@endcond