Tulip  5.3.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 #ifndef GLABSTRACTPOLYGON_H
21 #define GLABSTRACTPOLYGON_H
22 
23 #include <vector>
24 
25 #include <tulip/Color.h>
26 #include <tulip/Coord.h>
27 #include <tulip/Size.h>
28 #include <tulip/GlSimpleEntity.h>
29 
30 #include <tulip/OpenGlIncludes.h>
31 
32 namespace tlp {
33 
34 /**
35  * @ingroup OpenGL
36  * @brief class to create a abstract polygon
37  * @warning You don't have to use this class, it's only a base class for some others entities
38  */
39 class TLP_GL_SCOPE GlAbstractPolygon : public GlSimpleEntity {
40 public:
41  ///@cond DOXYGEN_HIDDEN
42 
43  /**
44  * Constructor
45  */
47  /**
48  * Default empty destructor
49  */
50  ~GlAbstractPolygon() override;
51 
52  enum PolygonMode { POLYGON = 0, QUAD_STRIP = 1 };
53 
54  /**
55  * Get the polygon mode (see PolygonMode enum)
56  */
57  PolygonMode getPolygonMode();
58 
59  /**
60  * Set the polygon mode (see PolygonMode enum)
61  */
62  void setPolygonMode(PolygonMode mode);
63 
64  /**
65  * Get if the polygon is filled or not
66  */
67  bool getFillMode();
68 
69  /**
70  * Set if the polygon is filled or not
71  */
72  void setFillMode(const bool);
73 
74  /**
75  * Get if the polygon is outlined or not
76  */
77  bool getOutlineMode();
78 
79  /**
80  * Set if the polygon is outlined or not
81  */
82  void setOutlineMode(const bool);
83 
84  /**
85  * Get if the polygon use light or not
86  */
87  bool getLightingMode();
88 
89  /**
90  * Set if the polygon use light or not
91  */
92  void setLightingMode(const bool);
93 
94  /**
95  * Get the ith color used to filling the polygon
96  */
97  Color getFillColor(unsigned int i);
98 
99  /**
100  * Set the ith color used to filling the polygon
101  */
102  void setFillColor(unsigned int i, const Color &color);
103 
104  ///@endcond
105 
106  /**
107  * @brief Set color used to filling the whole polygon
108  */
109  void setFillColor(const Color &color);
110 
111  ///@cond DOXYGEN_HIDDEN
112 
113  /**
114  * Get the ith color used to outlining the polygon
115  */
116  Color getOutlineColor(unsigned int i);
117 
118  /**
119  * Set the ith color used to outlining the polygon
120  */
121  void setOutlineColor(unsigned int i, const Color &color);
122 
123  ///@endcond
124 
125  /**
126  * @brief Set the color used to outlining the whole polygon
127  */
128  void setOutlineColor(const Color &color);
129 
130  /**
131  * @brief Get the textureName
132  */
133  std::string getTextureName();
134 
135  /**
136  * @brief Set the textureName
137  */
138  void setTextureName(const std::string &name);
139 
140  /**
141  * @brief Get the outline size
142  */
143  float getOutlineSize();
144 
145  /**
146  * @brief Set the outline size
147  */
148  void setOutlineSize(float size);
149 
150  ///@cond DOXYGEN_HIDDEN
151 
152  /**
153  * Get the lod outline value, below this lod value outline will not be displayed
154  */
155  float getHideOutlineLod();
156 
157  /**
158  * Set the lod outline value, below this lod value outline will not be displayed
159  */
160  void setHideOutlineLod(float lod);
161 
162  /**
163  * Sets if the y texture coordinates have to be inversed
164  */
165  void setInvertYTexture(bool invertYTexture);
166 
167  /**
168  * Draw the polygon
169  */
170  void draw(float lod, Camera *camera) override;
171 
172  /**
173  * Translate entity
174  */
175  void translate(const Coord &mouvement) override;
176 
177  /**
178  * Scale entity
179  */
180  virtual void scale(const tlp::Size &factor);
181 
182  /**
183  * Function to export data and type in outString (in XML format)
184  */
185  void getXML(std::string &outString) override;
186 
187  /**
188  * Function to export data in outString (in XML format)
189  */
190  virtual void getXMLOnlyData(std::string &outString);
191 
192  /**
193  * Function to set data with inString (in XML format)
194  */
195  void setWithXML(const std::string &outString, unsigned int &currentPosition) override;
196 
197  ///@endcond
198 
199 protected:
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 } // namespace tlp
255 #endif
Base class for all Tulip OpenGL entities.
Tulip OpenGL camera object.
Definition: Camera.h:47
class to create a abstract polygon