Tulip  5.1.0
Large graphs analysis and drawing
GlAbstractPolygon.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
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 #include <tulip/OpenGlIncludes.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  * Sets if the y texture coordinates have to be inversed
166  */
167  void setInvertYTexture(bool invertYTexture);
168 
169  /**
170  * Draw the polygon
171  */
172  virtual void draw(float lod,Camera *camera);
173 
174  /**
175  * Translate entity
176  */
177  virtual void translate(const Coord& mouvement);
178 
179  /**
180  * Scale entity
181  */
182  virtual void scale(const tlp::Size& factor);
183 
184  /**
185  * Function to export data and type in outString (in XML format)
186  */
187  virtual void getXML(std::string &outString);
188 
189  /**
190  * Function to export data in outString (in XML format)
191  */
192  virtual void getXMLOnlyData(std::string &outString);
193 
194  /**
195  * Function to set data with inString (in XML format)
196  */
197  virtual void setWithXML(const std::string &outString, unsigned int &currentPosition);
198 
199  ///@endcond
200 
201 protected:
202 
203  ///@cond DOXYGEN_HIDDEN
204 
205  /**
206  * set Coords of the polygon
207  */
208  virtual void setPoints(const std::vector<Coord> &points);
209 
210  /**
211  * set ith Coord of the polygon
212  */
213  virtual void setPoint(unsigned int index, const Coord &point);
214 
215  /**
216  * set fill colors of the polygon
217  */
218  virtual void setFillColors(const std::vector<Color> &colors);
219 
220  /**
221  * set outline colors of the polygon
222  */
223  virtual void setOutlineColors(const std::vector<Color> &colors);
224 
225  /**
226  * Clear previous bounding box and expand bounding box with polygons' points
227  */
228  virtual void recomputeBoundingBox();
229 
230  /**
231  * Clear previously generated VBO
232  */
233  virtual void clearGenerated();
234 
235  ///@endcond
236 
237  PolygonMode polygonMode;
238  std::vector<Coord> points;
239  std::vector<Color> fillColors;
240  std::vector<Color> outlineColors;
241  bool filled;
242  bool outlined;
243  bool lighting;
244  bool invertYTexture;
245  std::string textureName;
246  float outlineSize;
247  float hideOutlineLod;
248 
249  std::vector<Coord> normalArray;
250  GLubyte *indices;
251  GLubyte *auxIndices;
252  GLfloat *texArray;
253 
254  bool generated;
255  GLuint buffers[7];
256 };
257 
258 }
259 #endif
260 
Base class for all Tulip OpenGL entities.
Tulip OpenGL camera object.
Definition: Camera.h:45
class to create a abstract polygon