Tulip  5.7.4
Large graphs analysis and drawing
GlBox.h
1 /*
2  *
3  * This file is part of Tulip (https://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_GLBOX_H
21 #define Tulip_GLBOX_H
22 
23 #include <tulip/OpenGlIncludes.h>
24 
25 #include <tulip/Color.h>
26 #include <tulip/Size.h>
27 #include <tulip/GlSimpleEntity.h>
28 
29 namespace tlp {
30 
31 /**
32  * @ingroup OpenGL
33  * @brief General class used to render boxes as GlSimpleEntity.
34  */
35 class TLP_GL_SCOPE GlBox : public GlSimpleEntity {
36 
37 public:
38  /**
39  * @brief Don't use this constructor
40  */
41  GlBox();
42 
43  /**
44  * @brief Constructor
45  *
46  * @param position The center of the box.
47  * @param size The length of each dimension of the box.
48  * @param fillColor The fill color of the box.
49  * @param outlineColor The outline color of the box
50  * @param filled Fill the box ?
51  * @param outlined outline the box ?
52  * @param outlineSize The size of the outline
53  */
54  GlBox(const Coord &position, const Size &size, const Color &fillColor, const Color &outlineColor,
55  bool filled = true, bool outlined = true, const std::string &textureName = "",
56  float outlineSize = 1.);
57 
58  /**
59  * @brief Destructor.
60  */
61  ~GlBox() override;
62 
63  void draw(float lod, Camera *camera) override;
64 
65  /**
66  * @brief Draw a GlBox
67  */
68  static void draw(const Color &fillColor, const Color &outlineColor, float outlineWidth,
69  const std::string &textureName, float lod);
70 
71  static Coord getAnchor(const Coord &vector);
72 
73  /**
74  * @brief Accessor in reading to the size.
75  */
76  Size getSize() const;
77 
78  /**
79  * @brief Accessor in writing to the size of the box
80  */
81  void setSize(const Size &size);
82 
83  /**
84  * @brief Accessor in reading to the position.
85  */
86  Coord *getPosition() const;
87 
88  /**
89  * @brief Accessor in writing to the position.
90  */
91  void setPosition(const Coord &position);
92 
93  /**
94  * @brief Accessor in reading to the fill color.
95  */
96  Color getFillColor() const;
97 
98  /**
99  * @brief Accessor in writing to the fill color of the box
100  */
101  void setFillColor(const Color &color);
102 
103  /**
104  * @brief Accessor in reading to the outline color.
105  */
106  Color getOutlineColor() const;
107 
108  /**
109  * @brief Accessor in writing to the outline color of the box
110  */
111  void setOutlineColor(const Color &color);
112 
113  /**
114  * @brief Accessor in reading to the outline size.
115  */
116  float getOutlineSize() const;
117 
118  /**
119  * @brief Accessor in writing to the outline size of the box
120  */
121  void setOutlineSize(float size);
122 
123  /**
124  * @brief Accessor in reading to the texture name.
125  */
126  std::string getTextureName() const;
127 
128  /**
129  * @brief Accessor in writing to the texture name of the box
130  */
131  void setTextureName(const std::string &textureName);
132 
133  /**
134  * @brief Translate entity
135  */
136  void translate(const Coord &mouvement) override;
137 
138  /**
139  * @brief Function to export data in outString (in XML format)
140  */
141  void getXML(std::string &outString) override;
142 
143  /**
144  * @brief Function to set data with inString (in XML format)
145  */
146  void setWithXML(const std::string &inString, unsigned int &currentPosition) override;
147 
148 protected:
149  virtual void clearGenerated();
150 
151  Coord position; /**< The position of the center of the box*/
152  Size size; /**< size is the "radius" of the box */
153  std::vector<Color> fillColors; /**< fillColor of the box */
154  std::vector<Color> outlineColors; /**< outlineColor of the box */
155  bool filled; /**< the box is filled ? */
156  bool outlined; /**< the box is outlined ? */
157  std::string textureName;
158  float outlineSize; /**< size of the ouline */
159 
160  float *newCubeCoordArrays;
161  bool generated;
162  GLuint buffers[5];
163 };
164 } // namespace tlp
165 #endif
Tulip OpenGL camera object.
Definition: Camera.h:47
General class used to render boxes as GlSimpleEntity.
Definition: GlBox.h:35
GlBox()
Don't use this constructor.
void setTextureName(const std::string &textureName)
Accessor in writing to the texture name of the box.
std::string getTextureName() const
Accessor in reading to the texture name.
float outlineSize
Definition: GlBox.h:158
float getOutlineSize() const
Accessor in reading to the outline size.
static void draw(const Color &fillColor, const Color &outlineColor, float outlineWidth, const std::string &textureName, float lod)
Draw a GlBox.
void setOutlineSize(float size)
Accessor in writing to the outline size of the box.
Coord * getPosition() const
Accessor in reading to the position.
Color getOutlineColor() const
Accessor in reading to the outline color.
Color getFillColor() const
Accessor in reading to the fill color.
std::vector< Color > outlineColors
Definition: GlBox.h:154
void setOutlineColor(const Color &color)
Accessor in writing to the outline color of the box.
void getXML(std::string &outString) override
Function to export data in outString (in XML format)
Size getSize() const
Accessor in reading to the size.
GlBox(const Coord &position, const Size &size, const Color &fillColor, const Color &outlineColor, bool filled=true, bool outlined=true, const std::string &textureName="", float outlineSize=1.)
Constructor.
std::vector< Color > fillColors
Definition: GlBox.h:153
void setFillColor(const Color &color)
Accessor in writing to the fill color of the box.
void draw(float lod, Camera *camera) override
Draw function.
bool outlined
Definition: GlBox.h:156
void setSize(const Size &size)
Accessor in writing to the size of the box.
bool filled
Definition: GlBox.h:155
Size size
Definition: GlBox.h:152
void translate(const Coord &mouvement) override
Translate entity.
~GlBox() override
Destructor.
void setWithXML(const std::string &inString, unsigned int &currentPosition) override
Function to set data with inString (in XML format)
Coord position
Definition: GlBox.h:151
void setPosition(const Coord &position)
Accessor in writing to the position.
Base class for all Tulip OpenGL entities.