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