Tulip  5.3.0
Large graphs analysis and drawing
GlSphere.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 Tulip_GLSPHERE_H
21 #define Tulip_GLSPHERE_H
22 
23 #include <tulip/tulipconf.h>
24 
25 #include <tulip/Coord.h>
26 #include <tulip/Color.h>
27 
28 #include <tulip/GlSimpleEntity.h>
29 
30 namespace tlp {
31 
32 /**
33  * @ingroup OpenGL
34  * @brief Class to create a sphere with GlEntity system
35  */
36 class TLP_GL_SCOPE GlSphere : public GlSimpleEntity {
37 
38 public:
39  /**
40  * @brief Constructor
41  *
42  * @warning Don't use this constructor
43  */
44  GlSphere() {}
45 
46  ~GlSphere() override;
47 
48  /**
49  * @brief Create a sphere with a position, a radius a fill color and multiple rotation (if you
50  * want)
51  */
52  GlSphere(const Coord &position, float radius, const Color &color = Color(0, 0, 0, 255),
53  float rotX = 0, float rotY = 0, float rotZ = 0);
54 
55  /**
56  * @brief Create a sphere with a position, a radius, a texture, an alphe and multiple rotation (if
57  * you want)
58  */
59  GlSphere(const Coord &position, float radius, const std::string &textureFile, int alpha = 255,
60  float rotX = 0, float rotY = 0, float rotZ = 0);
61 
62  /**
63  * @brief Draw the sphere
64  */
65  void draw(float lod, Camera *camera) override;
66 
67  /**
68  * @brief Translate entity
69  */
70  void translate(const Coord &mouvement) override;
71 
72  /**
73  * @brief Get absolute position
74  */
75  const Coord &getPosition() const {
76  return position;
77  }
78 
79  /**
80  * @brief Set absolute position
81  */
82  void setPosition(const Coord &pos) {
83  position = pos;
84  }
85 
86  /**
87  * @brief Set the texture name
88  */
89  virtual void setTexture(const std::string &texture) {
90  textureFile = texture;
91  }
92 
93  /**
94  * @brief Get the color
95  */
96  const Color &getColor() const {
97  return color;
98  }
99 
100  /**
101  * @brief Set the color
102  */
103  void setColor(const Color &newColor) {
104  color = newColor;
105  }
106 
107  /**
108  * @brief Function to export data in outString (in XML format)
109  */
110  void getXML(std::string &outString) override;
111 
112  /**
113  * @brief Function to set data with inString (in XML format)
114  */
115  void setWithXML(const std::string &inString, unsigned int &currentPosition) override;
116 
117 private:
118  void generateBuffers(int space);
119 
120  Coord position;
121  float radius;
122  Color color;
123  std::string textureFile;
124  Coord rot;
125 
126  std::vector<unsigned int> buffers;
127  std::vector<float> vertices;
128  std::vector<float> texturesCoord;
129  std::vector<unsigned short> indices;
130  unsigned int verticesCount;
131 };
132 } // namespace tlp
133 
134 #endif // Tulip_GLSCENE_H
Base class for all Tulip OpenGL entities.
GlSphere()
Constructor.
Definition: GlSphere.h:44
void setColor(const Color &newColor)
Set the color.
Definition: GlSphere.h:103
const Coord & getPosition() const
Get absolute position.
Definition: GlSphere.h:75
virtual void setTexture(const std::string &texture)
Set the texture name.
Definition: GlSphere.h:89
void setPosition(const Coord &pos)
Set absolute position.
Definition: GlSphere.h:82
Tulip OpenGL camera object.
Definition: Camera.h:47
Class to create a sphere with GlEntity system.
Definition: GlSphere.h:36
const Color & getColor() const
Get the color.
Definition: GlSphere.h:96