Tulip
4.6.0
Better Visualization Through Research
|
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 00021 #ifndef GLABSTRACTPOLYGON_H 00022 #define GLABSTRACTPOLYGON_H 00023 00024 #include <vector> 00025 00026 #include <tulip/Color.h> 00027 #include <tulip/Coord.h> 00028 #include <tulip/Size.h> 00029 #include <tulip/GlSimpleEntity.h> 00030 00031 #if defined(_MSC_VER) 00032 #include <Windows.h> 00033 #endif 00034 00035 #if defined(__APPLE__) 00036 #include <OpenGL/gl.h> 00037 #else 00038 #include <GL/gl.h> 00039 #endif 00040 00041 namespace tlp { 00042 00043 /** 00044 * @ingroup OpenGL 00045 * @brief class to create a abstract polygon 00046 * @warning You don't have to use this class, it's only a base class for some others entities 00047 */ 00048 class TLP_GL_SCOPE GlAbstractPolygon : public GlSimpleEntity { 00049 public: 00050 00051 ///@cond DOXYGEN_HIDDEN 00052 00053 /** 00054 * Constructor 00055 */ 00056 GlAbstractPolygon(); 00057 /** 00058 * Default empty destructor 00059 */ 00060 virtual ~GlAbstractPolygon(); 00061 00062 enum PolygonMode {POLYGON = 0, QUAD_STRIP = 1}; 00063 00064 /** 00065 * Get the polygon mode (see PolygonMode enum) 00066 */ 00067 PolygonMode getPolygonMode(); 00068 00069 /** 00070 * Set the polygon mode (see PolygonMode enum) 00071 */ 00072 void setPolygonMode(PolygonMode mode); 00073 00074 /** 00075 * Get if the polygon is filled or not 00076 */ 00077 bool getFillMode(); 00078 00079 /** 00080 * Set if the polygon is filled or not 00081 */ 00082 void setFillMode(const bool); 00083 00084 /** 00085 * Get if the polygon is outlined or not 00086 */ 00087 bool getOutlineMode(); 00088 00089 /** 00090 * Set if the polygon is outlined or not 00091 */ 00092 void setOutlineMode(const bool); 00093 00094 /** 00095 * Get if the polygon use light or not 00096 */ 00097 bool getLightingMode(); 00098 00099 /** 00100 * Set if the polygon use light or not 00101 */ 00102 void setLightingMode(const bool); 00103 00104 /** 00105 * Get the ith color used to filling the polygon 00106 */ 00107 Color getFillColor(unsigned int i); 00108 00109 /** 00110 * Set the ith color used to filling the polygon 00111 */ 00112 void setFillColor(unsigned int i, const Color &color); 00113 00114 ///@endcond 00115 00116 /** 00117 * @brief Set color used to filling the whole polygon 00118 */ 00119 void setFillColor(const Color &color); 00120 00121 ///@cond DOXYGEN_HIDDEN 00122 00123 /** 00124 * Get the ith color used to outlining the polygon 00125 */ 00126 Color getOutlineColor(unsigned int i); 00127 00128 /** 00129 * Set the ith color used to outlining the polygon 00130 */ 00131 void setOutlineColor(unsigned int i, const Color &color); 00132 00133 ///@endcond 00134 00135 /** 00136 * @brief Set the color used to outlining the whole polygon 00137 */ 00138 void setOutlineColor(const Color &color); 00139 00140 /** 00141 * @brief Get the textureName 00142 */ 00143 std::string getTextureName(); 00144 00145 /** 00146 * @brief Set the textureName 00147 */ 00148 void setTextureName(const std::string &name); 00149 00150 /** 00151 * @brief Get the outline size 00152 */ 00153 float getOutlineSize(); 00154 00155 /** 00156 * @brief Set the outline size 00157 */ 00158 void setOutlineSize(float size); 00159 00160 ///@cond DOXYGEN_HIDDEN 00161 00162 /** 00163 * Get the lod outline value, below this lod value outline will not be displayed 00164 */ 00165 float getHideOutlineLod(); 00166 00167 /** 00168 * Set the lod outline value, below this lod value outline will not be displayed 00169 */ 00170 void setHideOutlineLod(float lod); 00171 00172 /** 00173 * Sets if the y texture coordinates have to be inversed 00174 */ 00175 void setInvertYTexture(bool invertYTexture); 00176 00177 /** 00178 * Draw the polygon 00179 */ 00180 virtual void draw(float lod,Camera *camera); 00181 00182 /** 00183 * Translate entity 00184 */ 00185 virtual void translate(const Coord& mouvement); 00186 00187 /** 00188 * Scale entity 00189 */ 00190 virtual void scale(const tlp::Size& factor); 00191 00192 /** 00193 * Function to export data and type in outString (in XML format) 00194 */ 00195 virtual void getXML(std::string &outString); 00196 00197 /** 00198 * Function to export data in outString (in XML format) 00199 */ 00200 virtual void getXMLOnlyData(std::string &outString); 00201 00202 /** 00203 * Function to set data with inString (in XML format) 00204 */ 00205 virtual void setWithXML(const std::string &outString, unsigned int ¤tPosition); 00206 00207 ///@endcond 00208 00209 protected: 00210 00211 ///@cond DOXYGEN_HIDDEN 00212 00213 /** 00214 * set Coords of the polygon 00215 */ 00216 virtual void setPoints(const std::vector<Coord> &points); 00217 00218 /** 00219 * set ith Coord of the polygon 00220 */ 00221 virtual void setPoint(unsigned int index, const Coord &point); 00222 00223 /** 00224 * set fill colors of the polygon 00225 */ 00226 virtual void setFillColors(const std::vector<Color> &colors); 00227 00228 /** 00229 * set outline colors of the polygon 00230 */ 00231 virtual void setOutlineColors(const std::vector<Color> &colors); 00232 00233 /** 00234 * Clear previous bounding box and expand bounding box with polygons' points 00235 */ 00236 virtual void recomputeBoundingBox(); 00237 00238 /** 00239 * Clear previously generated VBO 00240 */ 00241 virtual void clearGenerated(); 00242 00243 ///@endcond 00244 00245 PolygonMode polygonMode; 00246 std::vector<Coord> points; 00247 std::vector<Color> fillColors; 00248 std::vector<Color> outlineColors; 00249 bool filled; 00250 bool outlined; 00251 bool lighting; 00252 bool invertYTexture; 00253 std::string textureName; 00254 float outlineSize; 00255 float hideOutlineLod; 00256 00257 std::vector<Coord> normalArray; 00258 GLubyte *indices; 00259 GLubyte *auxIndices; 00260 GLfloat *texArray; 00261 00262 bool generated; 00263 GLuint buffers[7]; 00264 }; 00265 00266 } 00267 #endif 00268