Tulip  4.6.0
Better Visualization Through Research
library/tulip-ogl/include/tulip/GlPolyQuad.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 ///@cond DOXYGEN_HIDDEN
00020 
00021 
00022 #ifndef GLPOLYQUAD_H_
00023 #define GLPOLYQUAD_H_
00024 
00025 #include <tulip/tulipconf.h>
00026 #include <tulip/Coord.h>
00027 #include <tulip/Color.h>
00028 #include <tulip/GlSimpleEntity.h>
00029 
00030 #include <vector>
00031 #include <string>
00032 
00033 namespace tlp {
00034 
00035 /**
00036  * @ingroup OpenGL
00037  * \brief General class used to render a connected group of quadrilaterals (textured or not) that shares edges as GlEntity
00038  *
00039  * This generic class is used  to render a connected group of quadrilaterals (textured or not) that shares edges as GlEntity
00040  */
00041 class TLP_GL_SCOPE GlPolyQuad : public GlSimpleEntity {
00042 
00043 public :
00044 
00045   /**
00046    * Default Constructor for initializing an empty polyquad
00047    * Use the addQuadEdge method to set the quads edges
00048    *
00049    * \param textureName The absolute path of the texture image file to use
00050    *
00051    *
00052    */
00053   GlPolyQuad(const std::string &textureName = "", const bool outlined = false, const int outlineWidth = 1, const Color &outlineColor = Color(0,0,0));
00054 
00055   /**
00056    * Constructor for building a polyquad with spefific colors for each edges
00057    *
00058    * Pay attention to the order of the edges point in the polyQuadEdges vector. Indeed, to draw the following polyquad
00059    *
00060    *                    v2
00061    *          v0+--------+--------+ v4
00062    *            |        |        |
00063    *            |        |        |
00064    *            |        |        |
00065    *          v1+--------+--------+ v5
00066    *                    v3
00067    *
00068    * The content of the polyQuadEdges vector should be {v0, v1, v2, v3, v4, v5} or {v1, v0, v3, v2, v5, v4}
00069    *
00070    * \param polyQuadEdges A vector containing the coordinates of the quad edges, its size must be  a multiple of 2 because an edge is defined by 2 points
00071    * \param polyQuadEdgesColor A vector containing the edges's colors, its size must be equal to the number of edges defined by the polyQuadEdges vector
00072    * \param  textureName The absolute path of the texture image file to use
00073    */
00074   GlPolyQuad(const std::vector<Coord> &polyQuadEdges, const std::vector<Color> &polyQuadEdgesColor, const std::string &textureName = "",
00075              const bool outlined = false, const int outlineWidth = 1, const Color &outlineColor = Color(0,0,0));
00076 
00077   /**
00078    * Constructor for building a polyquad with a single color
00079    *
00080    * \param polyQuadEdges A vector containing the coordinates of the quad edges, its size must be  a multiple of 2 because an edge is defined by 2 points
00081    * \param polyQuadColor The polyquad color
00082    * \param  textureName The absolute path of the texture image file to use
00083    */
00084   GlPolyQuad(const std::vector<Coord> &polyQuadEdges, const Color &polyQuadColor, const std::string &textureName = "",
00085              const bool outlined = false, const int outlineWidth = 1, const Color &outlineColor = Color(0,0,0));
00086 
00087   /**
00088    * Method to add a polyquad edge
00089    *
00090    * \param edgeStart The first end of the edge
00091    * \param edgeEnd The other end of the edge
00092    * \param edgeColor The edge's color
00093    *
00094    */
00095   void addQuadEdge(const Coord &edgeStart, const Coord &edgeEnd, const Color &edgeColor);
00096 
00097   /**
00098    * Virtual function used to draw the polyquad.
00099    */
00100   void draw(float lod,Camera *camera);
00101 
00102   /**
00103    * Method to set the polyquad color (all edges share the same color)
00104    */
00105   void setColor(const Color &color);
00106 
00107   /**
00108    * Method to set the polyquad outline color
00109    */
00110   void setOutlineColor(const Color &color) {
00111     outlineColor = color;
00112   }
00113 
00114   /**
00115    * Method to toggle polyquad outline
00116    */
00117   void setOutlined(const bool outline) {
00118     outlined = outline;
00119   }
00120 
00121   /**
00122    * Method to set the polyquad outline width
00123    */
00124   void setOutlineWidth(const int width) {
00125     outlineWidth = width;
00126   }
00127 
00128   /**
00129    *  Method to translate entity
00130    */
00131   void translate(const Coord &move);
00132 
00133   /**
00134    * Function to export data in outString (in XML format)
00135    */
00136   void getXML(std::string &outString);
00137 
00138   /**
00139    * Function to set data with inString (in XML format)
00140    */
00141   void setWithXML(const std::string &inString,unsigned int &currentPosition);
00142 
00143 private :
00144   std::vector<Coord> polyQuadEdges; // vector which contains polyquad edges, an edge being defined by a pair of Coord
00145   std::vector<Color> polyQuadEdgesColors; // vector which contains polyquad edges colors
00146   std::string textureName;
00147   bool outlined;
00148   int outlineWidth;
00149   Color outlineColor;
00150 };
00151 
00152 
00153 }
00154 #endif /* GLPOLYQUAD_H_ */
00155 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties