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