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