Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
GlSimpleEntity.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_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
30namespace tlp {
31
32class GlComposite;
33class 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 */
62class TLP_GL_SCOPE GlSimpleEntity : public GlEntity {
63
64public:
65 /**
66 * @brief Constructor
67 */
68 GlSimpleEntity() : visible(true), stencil(0xFFFF) {}
69
70 /**
71 * @brief Destructor
72 */
73 ~GlSimpleEntity() override;
74
75 /**
76 * @brief Set if entity is visible
77 */
78 virtual void setVisible(bool visible);
79 /**
80 * @brief Return if entity is visible
81 */
82 bool isVisible() const {
83 return visible;
84 }
85 /**
86 * @brief Set stencil number of the entity
87 *
88 * Stencil is an OpenGl system to ensure that other entity can't be displayed above this entity;
89 * it's a "guaranteed visibility" system.
90 * A small number causes a guaranteed 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 */
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 void acceptVisitor(GlSceneVisitor *visitor) override {
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 function : Translate entity of vector translation
157 */
158 virtual void translate(const Coord &) {}
159
160 GlComposite *getParent() const {
161 if (parents.empty())
162 return nullptr;
163
164 return parents[0];
165 }
166
167 ///@endcond
168
169protected:
170 bool visible;
171 int stencil;
172
173 BoundingBox boundingBox;
174
175 std::vector<GlComposite *> parents;
176};
177} // namespace tlp
178
179#endif // Tulip_GLSIMPLEENTITY_H
Tulip OpenGL camera object.
Definition: Camera.h:47
GlSimpleEntity used to aggregate other GlEntity.
Definition: GlComposite.h:39
Base class for all Tulip OpenGL entities.
~GlSimpleEntity() override
Destructor.
bool isVisible() const
Return if entity is visible.
virtual void setVisible(bool visible)
Set if entity is visible.
virtual void setStencil(int stencil)
Set stencil number of the entity.
virtual void getXML(std::string &outString)=0
Save the entity in outString (in XML format)
virtual void setWithXML(const std::string &inString, unsigned int &currentPosition)=0
Load entity with inString (in XML format)
int getStencil()
Return stencil number of entity.
GlSimpleEntity()
Constructor.
virtual BoundingBox getBoundingBox()
Return the entity boundingbox.
virtual void draw(float lod, Camera *camera)=0
Draw function.
This class represents the 3D bounding box of an object. It is mostly used to determine whether or not...
Definition: BoundingBox.h:67