Tulip  5.1.0
Large graphs analysis and drawing
GlSimpleEntity.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_GLSIMPLEENTITY_H
21 #define Tulip_GLSIMPLEENTITY_H
22 
23 #include <vector>
24 
25 #include <tulip/GlEntity.h>
26 #include <tulip/Coord.h>
27 #include <tulip/GlSceneVisitor.h>
28 #include <tulip/BoundingBox.h>
29 
30 namespace tlp {
31 
32 class GlComposite;
33 class Camera;
34 
35 /**
36  * @ingroup OpenGL
37  * @brief Base class for all Tulip OpenGL entities
38  *
39  * Other Tulip entities inherit for this class.
40  *
41  * You don't have to create a GlSimpleEntity, you have to use GlLine, GlRect or GlSphere for example
42  * @see Gl2DRect
43  * @see GlPolygon
44  * @see GlAxis
45  * @see GlBezierCurve
46  * @see GlBox
47  * @see GlCatmullRomCurve
48  * @see GlCircle
49  * @see GlComplexPolygon
50  * @see GlGrid
51  * @see GlHexagon
52  * @see GlLabel
53  * @see GlSphere
54  * @see GlPentagon
55  * @see GlTriangle
56  * @see GlOpenUniformCubicBSpline
57  *
58  * To GlSimpleEntity manipulation :
59  * @see GlLayer
60  * @see GlScene
61  */
62 class TLP_GL_SCOPE GlSimpleEntity : public GlEntity {
63 
64 public:
65 
66  /**
67  * @brief Constructor
68  */
69  GlSimpleEntity():visible(true),stencil(0xFFFF) {}
70 
71  /**
72  * @brief Destructor
73  */
74  virtual ~GlSimpleEntity();
75 
76  /**
77  * @brief Set if entity is visible
78  */
79  virtual void setVisible(bool visible);
80  /**
81  * @brief Return if entity is visible
82  */
83  bool isVisible() const {
84  return visible;
85  }
86  /**
87  * @brief Set stencil number of the entity
88  *
89  * Stencil is an OpenGl system to ensure that other entity can't be displayed above this entity; it's a "guaranted visibility" system.
90  * A small number causes a guaranted visibility
91  * Default value in Tulip is 0xFFFF (greater integer)
92  * And when we have stencil on entity value is 0x2
93  */
94  virtual void setStencil(int stencil) {
95  this->stencil=stencil;
96  }
97  /**
98  * @brief Return stencil number of entity
99  *
100  * @see setStencil()
101  */
102  int getStencil() {
103  return stencil;
104  }
105 
106  /**
107  * @brief Draw function
108  *
109  * @warning You don't have to call this function, the Tulip OpenGL engine call it.
110  */
111  virtual void draw(float lod,Camera* camera) = 0;
112 
113  /**
114  * @brief Return the entity boundingbox
115  *
116  * @warning You don't have to call this function, the Tulip OpenGL engine call it.
117  */
119  return boundingBox;
120  }
121 
122  /**
123  * @brief Save the entity in outString (in XML format)
124  *
125  * @warning You don't have to call this function, the Tulip OpenGL engine call it.
126  */
127  virtual void getXML(std::string &outString) =0;
128 
129  /**
130  * @brief Load entity with inString (in XML format)
131  *
132  * @warning You don't have to call this function, the Tulip OpenGL engine call it.
133  */
134  virtual void setWithXML(const std::string &inString, unsigned int &currentPosition) =0;
135 
136 ///@cond DOXYGEN_HIDDEN
137 
138  /**
139  * @brief Accept visitor function
140  */
141  virtual void acceptVisitor(GlSceneVisitor *visitor) {
142  visitor->visit(this);
143  }
144 
145  /**
146  * Add a parent to this entity
147  */
148  void addParent(GlComposite *composite);
149 
150  /**
151  * remove a parent to this entity
152  */
153  void removeParent(GlComposite *composite);
154 
155  /**
156  * virtual fucntion : Translate entity of vector translation
157  */
158  virtual void translate(const Coord &) {}
159 
160  GlComposite* getParent() const {
161  if (parents.empty())
162  return NULL;
163 
164  return parents[0];
165  }
166 
167 ///@endcond
168 
169 protected:
170 
171  bool visible;
172  int stencil;
173 
174  BoundingBox boundingBox;
175 
176  std::vector<GlComposite*> parents;
177 
178 };
179 
180 }
181 
182 #endif // Tulip_GLSIMPLEENTITY_H
183 
int getStencil()
Return stencil number of entity.
Base class for all Tulip OpenGL entities.
virtual void setStencil(int stencil)
Set stencil number of the entity.
virtual BoundingBox getBoundingBox()
Return the entity boundingbox.
This class represents the 3D bounding box of an object. It is mostly used to determine whether or not...
Definition: BoundingBox.h:63
Tulip OpenGL camera object.
Definition: Camera.h:45
GlSimpleEntity()
Constructor.
bool isVisible() const
Return if entity is visible.
GlSimpleEntity used to agregate other GlEntity.
Definition: GlComposite.h:39