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