Tulip  4.2.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
GlAbstractPolygon.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 
20 
21 #ifndef GLABSTRACTPOLYGON_H
22 #define GLABSTRACTPOLYGON_H
23 
24 #include <vector>
25 
26 #include <tulip/Color.h>
27 #include <tulip/Coord.h>
28 #include <tulip/tulipconf.h>
29 
30 #include <tulip/GlSimpleEntity.h>
31 #include <tulip/GlTools.h>
32 
33 namespace tlp {
34 
35 /**
36  * @ingroup OpenGL
37  * @brief class to create a abstract polygon
38  * @warning You don't have to use this class, it's only a base class for some others entities
39  */
40 class TLP_GL_SCOPE GlAbstractPolygon : public GlSimpleEntity {
41 public:
42 
43  ///@cond DOXYGEN_HIDDEN
44 
45  /**
46  * Constructor
47  */
49  /**
50  * Default empty destructor
51  */
52  virtual ~GlAbstractPolygon();
53 
54  enum PolygonMode {POLYGON = 0, QUAD_STRIP = 1};
55 
56  /**
57  * Get the polygon mode (see PolygonMode enum)
58  */
59  PolygonMode getPolygonMode();
60 
61  /**
62  * Set the polygon mode (see PolygonMode enum)
63  */
64  void setPolygonMode(PolygonMode mode);
65 
66  /**
67  * Get if the polygon is filled or not
68  */
69  bool getFillMode();
70 
71  /**
72  * Set if the polygon is filled or not
73  */
74  void setFillMode(const bool);
75 
76  /**
77  * Get if the polygon is outlined or not
78  */
79  bool getOutlineMode();
80 
81  /**
82  * Set if the polygon is outlined or not
83  */
84  void setOutlineMode(const bool);
85 
86  /**
87  * Get if the polygon use light or not
88  */
89  bool getLightingMode();
90 
91  /**
92  * Set if the polygon use light or not
93  */
94  void setLightingMode(const bool);
95 
96  /**
97  * Get the ith color used to filling the polygon
98  */
99  Color getFillColor(unsigned int i);
100 
101  /**
102  * Set the ith color used to filling the polygon
103  */
104  void setFillColor(unsigned int i, const Color &color);
105 
106  ///@endcond
107 
108  /**
109  * @brief Set color used to filling the whole polygon
110  */
111  void setFillColor(const Color &color);
112 
113  ///@cond DOXYGEN_HIDDEN
114 
115  /**
116  * Get the ith color used to outlining the polygon
117  */
118  Color getOutlineColor(unsigned int i);
119 
120  /**
121  * Set the ith color used to outlining the polygon
122  */
123  void setOutlineColor(unsigned int i, const Color &color);
124 
125  ///@endcond
126 
127  /**
128  * @brief Set the color used to outlining the whole polygon
129  */
130  void setOutlineColor(const Color &color);
131 
132  /**
133  * @brief Get the textureName
134  */
135  std::string getTextureName();
136 
137  /**
138  * @brief Set the textureName
139  */
140  void setTextureName(const std::string &name);
141 
142  /**
143  * @brief Get the outline size
144  */
145  float getOutlineSize();
146 
147  /**
148  * @brief Set the outline size
149  */
150  void setOutlineSize(float size);
151 
152  ///@cond DOXYGEN_HIDDEN
153 
154  /**
155  * Get the lod outline value, below this lod value outline will not be displayed
156  */
157  float getHideOutlineLod();
158 
159  /**
160  * Set the lod outline value, below this lod value outline will not be displayed
161  */
162  void setHideOutlineLod(float lod);
163 
164  /**
165  * Draw the polygon
166  */
167  virtual void draw(float lod,Camera *camera);
168 
169  /**
170  * Translate entity
171  */
172  virtual void translate(const Coord& mouvement);
173 
174  /**
175  * Function to export data and type in outString (in XML format)
176  */
177  virtual void getXML(std::string &outString);
178 
179  /**
180  * Function to export data in outString (in XML format)
181  */
182  virtual void getXMLOnlyData(std::string &outString);
183 
184  /**
185  * Function to set data with inString (in XML format)
186  */
187  virtual void setWithXML(const std::string &outString, unsigned int &currentPosition);
188 
189  ///@endcond
190 
191 protected:
192 
193  ///@cond DOXYGEN_HIDDEN
194 
195  /**
196  * set Coords of the polygon
197  */
198  virtual void setPoints(const std::vector<Coord> &points);
199 
200  /**
201  * set ith Coord of the polygon
202  */
203  virtual void setPoint(unsigned int index, const Coord &point);
204 
205  /**
206  * set fill colors of the polygon
207  */
208  virtual void setFillColors(const std::vector<Color> &colors);
209 
210  /**
211  * set outline colors of the polygon
212  */
213  virtual void setOutlineColors(const std::vector<Color> &colors);
214 
215  /**
216  * Clear previous bounding box and expand bounding box with polygons' points
217  */
218  virtual void recomputeBoundingBox();
219 
220  /**
221  * Clear previously generated VBO
222  */
223  virtual void clearGenerated();
224 
225  ///@endcond
226 
227  PolygonMode polygonMode;
228  std::vector<Coord> points;
229  std::vector<Color> fillColors;
230  std::vector<Color> outlineColors;
231  bool filled;
232  bool outlined;
233  bool lighting;
234  bool invertYTexture;
235  std::string textureName;
236  float outlineSize;
237  float hideOutlineLod;
238 
239  std::vector<Coord> normalArray;
240  GLubyte *indices;
241  GLubyte *auxIndices;
242  GLfloat *texArray;
243 
244  bool generated;
245  GLuint buffers[7];
246 };
247 
248 }
249 #endif
250