Tulip  4.6.0
Better Visualization Through Research
library/tulip-ogl/include/tulip/GlSimpleEntity.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 
00020 #ifndef Tulip_GLSIMPLEENTITY_H
00021 #define Tulip_GLSIMPLEENTITY_H
00022 
00023 #include <vector>
00024 
00025 #include <tulip/GlEntity.h>
00026 #include <tulip/Coord.h>
00027 #include <tulip/GlSceneVisitor.h>
00028 #include <tulip/BoundingBox.h>
00029 
00030 namespace tlp {
00031 
00032 class GlComposite;
00033 class Camera;
00034 
00035 /**
00036  * @ingroup OpenGL
00037  * @brief Base class for all Tulip OpenGL entities
00038  *
00039  * Other Tulip entities inherit for this class.
00040  *
00041  * You don't have to create a GlSimpleEntity, you have to use GlLine, GlRect or GlSphere for example
00042  * @see Gl2DRect
00043  * @see GlPolygon
00044  * @see GlAxis
00045  * @see GlBezierCurve
00046  * @see GlBox
00047  * @see GlCatmullRomCurve
00048  * @see GlCircle
00049  * @see GlComplexPolygon
00050  * @see GlGrid
00051  * @see GlHexagon
00052  * @see GlLabel
00053  * @see GlSphere
00054  * @see GlPentagon
00055  * @see GlTriangle
00056  * @see GlOpenUniformCubicBSpline
00057  *
00058  * To GlSimpleEntity manipulation :
00059  * @see GlLayer
00060  * @see GlScene
00061  */
00062 class TLP_GL_SCOPE GlSimpleEntity : public GlEntity {
00063 
00064 public:
00065 
00066   /**
00067    * @brief Constructor
00068    */
00069   GlSimpleEntity():visible(true),stencil(0xFFFF) {}
00070 
00071   /**
00072    * @brief Destructor
00073    */
00074   virtual ~GlSimpleEntity();
00075 
00076   /**
00077    * @brief Set if entity is visible
00078    */
00079   virtual void setVisible(bool visible);
00080   /**
00081    * @brief Return if entity is visible
00082    */
00083   bool isVisible() const {
00084     return visible;
00085   }
00086   /**
00087    * @brief Set stencil number of the entity
00088    *
00089    * Stencil is an OpenGl system to ensure that other entity can't be displayed above this entity; it's a "guaranted visibility" system.
00090    * A small number causes a guaranted visibility
00091    * Default value in Tulip is 0xFFFF (greater integer)
00092    * And when we have stencil on entity value is 0x2
00093    */
00094   virtual void setStencil(int stencil) {
00095     this->stencil=stencil;
00096   }
00097   /**
00098    * @brief Return stencil number of entity
00099    *
00100    * @see setStencil()
00101    */
00102   int getStencil() {
00103     return stencil;
00104   }
00105 
00106   /**
00107    * @brief Draw function
00108    *
00109    * @warning You don't have to call this function, the Tulip OpenGL engine call it.
00110    */
00111   virtual void draw(float lod,Camera* camera) = 0;
00112 
00113   /**
00114    * @brief Return the entity boundingbox
00115    *
00116    * @warning You don't have to call this function, the Tulip OpenGL engine call it.
00117    */
00118   virtual BoundingBox getBoundingBox() {
00119     return boundingBox;
00120   }
00121 
00122   /**
00123    * @brief Save the entity in outString (in XML format)
00124    *
00125    * @warning You don't have to call this function, the Tulip OpenGL engine call it.
00126    */
00127   virtual void getXML(std::string &outString) =0;
00128 
00129   /**
00130    * @brief Load entity with inString (in XML format)
00131    *
00132    * @warning You don't have to call this function, the Tulip OpenGL engine call it.
00133    */
00134   virtual void setWithXML(const std::string &inString, unsigned int &currentPosition) =0;
00135 
00136 ///@cond DOXYGEN_HIDDEN
00137 
00138   /**
00139    * @brief Accept visitor function
00140    */
00141   virtual void acceptVisitor(GlSceneVisitor *visitor) {
00142     visitor->visit(this);
00143   }
00144 
00145   /**
00146    * Add a parent to this entity
00147    */
00148   void addParent(GlComposite *composite);
00149 
00150   /**
00151    * remove a parent to this entity
00152    */
00153   void removeParent(GlComposite *composite);
00154 
00155   /**
00156    * virtual fucntion : Translate entity of vector translation
00157    */
00158   virtual void translate(const Coord &) {}
00159 
00160   GlComposite* getParent() const {
00161     if (parents.empty())
00162       return NULL;
00163 
00164     return parents[0];
00165   }
00166 
00167 ///@endcond
00168 
00169 protected:
00170 
00171   bool visible;
00172   int stencil;
00173 
00174   BoundingBox boundingBox;
00175 
00176   std::vector<GlComposite*> parents;
00177 
00178 };
00179 
00180 }
00181 
00182 #endif // Tulip_GLSIMPLEENTITY_H
00183 
 All Classes Files Functions Variables Enumerations Enumerator Properties