![]() |
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 ///@cond DOXYGEN_HIDDEN 00020 00021 #ifndef Tulip_GLVERTEXARRAYMANAGER_H 00022 #define Tulip_GLVERTEXARRAYMANAGER_H 00023 00024 #if defined(_MSC_VER) 00025 #include <windows.h> 00026 #endif 00027 00028 #if defined(__APPLE__) 00029 #include <OpenGL/gl.h> 00030 #include <OpenGL/glu.h> 00031 #else 00032 #include <GL/gl.h> 00033 #include <GL/glu.h> 00034 #endif 00035 00036 #include <tulip/Coord.h> 00037 #include <tulip/Color.h> 00038 #include <tulip/Observable.h> 00039 #include <tulip/tuliphash.h> 00040 00041 #include <vector> 00042 00043 namespace tlp { 00044 00045 class Graph; 00046 class GlEdge; 00047 class GlNode; 00048 class GlGraphInputData; 00049 class PropertyInterface; 00050 class ColorProperty; 00051 class LayoutProperty; 00052 class SizeProperty; 00053 class IntegerProperty; 00054 class DoubleProperty; 00055 00056 /** \brief Class used to render edges/nodes with vertex array 00057 * 00058 * Class used to render edges/nodes with vertex array 00059 */ 00060 class TLP_GL_SCOPE GlVertexArrayManager : private Observable { 00061 00062 public: 00063 00064 /** 00065 * Constructor 00066 * \param inputData : input data to use for this GlVertexArrayManager 00067 */ 00068 GlVertexArrayManager(GlGraphInputData *inputData); 00069 00070 ~GlVertexArrayManager(); 00071 00072 /** 00073 * Call this function when you want to change input data used by this GlVertexArrayManager 00074 */ 00075 void setInputData(GlGraphInputData *inputData); 00076 00077 /** 00078 * Return if this GlVertexArrayManager is used to render entities of the scene 00079 */ 00080 inline bool renderingIsBegin() { 00081 return isBegin; 00082 } 00083 00084 /** 00085 * Return if this GlVertexArrayManager have to compute its data 00086 */ 00087 bool haveToCompute(); 00088 00089 /** 00090 * Call this function if this GlVertexArrayManager have to compute colors and layout properties 00091 */ 00092 void setHaveToComputeAll(bool compute); 00093 /** 00094 * Call this function if this GlVertexArrayManager have to compute layout propertie 00095 */ 00096 void setHaveToComputeLayout(bool compute); 00097 /** 00098 * Call this function if this GlVertexArrayManager have to compute colors propertie 00099 */ 00100 void setHaveToComputeColor(bool compute); 00101 00102 /** 00103 * Call this function at the begining of the rendering 00104 * This function clear entities to render 00105 */ 00106 void beginRendering(); 00107 /** 00108 * Call this funtion at the end of rendering 00109 * This function draw needed entities 00110 */ 00111 void endRendering(); 00112 00113 /** 00114 * This function is call by GlVertexArraySceneVisitor to inform GlVertexArrayManager that we need to render an edge 00115 */ 00116 void addEdge(GlEdge *edge); 00117 /** 00118 * This function is call by GlVertexArraySceneVisitor to inform GlVertexArrayManager that we need to render a node 00119 */ 00120 void addNode(GlNode *node); 00121 00122 /** 00123 * You can call this function to pause rendering 00124 * For example this function is call in GlMetaNodeTrueRenderer to don't use GlVertexArrayManager 00125 */ 00126 void pauseRendering(bool pause); 00127 00128 /** 00129 * You can call this function to deactivate/activate GlVertexArrayManager 00130 */ 00131 void activate(bool act); 00132 00133 bool isActivated() { 00134 return activated; 00135 } 00136 00137 /** 00138 * This function is call when you want to activate line rendering of a specific edge 00139 */ 00140 void activateLineEdgeDisplay(GlEdge *edge, bool selected); 00141 /** 00142 * This function is call when you want to activate quad rendering of a specific edge 00143 */ 00144 void activateQuadEdgeDisplay(GlEdge *edge, bool selected); 00145 /** 00146 * This function is call when you want to activate point rendering of a specific edge 00147 */ 00148 void activatePointEdgeDisplay(GlEdge *edge, bool selected); 00149 /** 00150 * This function is call when you want to activate point rendering of a specific node 00151 */ 00152 void activatePointNodeDisplay(GlNode *node, bool selected); 00153 00154 protected: 00155 00156 void propertyValueChanged(tlp::PropertyInterface *property); 00157 void treatEvent(const Event&); 00158 00159 void clearLayoutData(); 00160 void clearColorData(); 00161 void clearData(); 00162 void initObservers(); 00163 void clearObservers(PropertyInterface *deletedProperty=NULL); 00164 00165 GlGraphInputData *inputData; 00166 Graph *graph; 00167 //Store properties used to compute the arrays 00168 LayoutProperty* layoutProperty; 00169 SizeProperty* sizeProperty; 00170 IntegerProperty* shapeProperty; 00171 DoubleProperty* rotationProperty; 00172 ColorProperty* colorProperty; 00173 ColorProperty* borderColorProperty; 00174 DoubleProperty* borderWidthProperty; 00175 IntegerProperty *srcAnchorShapeProperty; 00176 IntegerProperty *tgtAnchorShapeProperty; 00177 SizeProperty *srcAnchorSizeProperty; 00178 SizeProperty *tgtAnchorSizeProperty; 00179 bool graphObserverActivated; 00180 bool layoutObserverActivated; 00181 bool colorObserverActivated; 00182 00183 bool activated; 00184 bool isBegin; 00185 bool toComputeAll; 00186 bool toComputeLayout; 00187 bool toComputeColor; 00188 00189 bool vectorLayoutSizeInit; 00190 bool vectorColorSizeInit; 00191 bool vectorIndexSizeInit; 00192 00193 bool edgesModified; 00194 bool colorInterpolate; 00195 bool sizeInterpolate; 00196 bool viewArrow; 00197 00198 00199 std::vector<Coord> linesCoordsArray; 00200 std::vector<Color> linesColorsArray; 00201 std::vector<GLint> linesIndexArray; 00202 std::vector<GLsizei> linesIndexCountArray; 00203 00204 std::vector<GLuint> linesRenderingIndicesArray; 00205 std::vector<GLuint> linesSelectedRenderingIndicesArray; 00206 00207 std::vector<Coord> quadsCoordsArray; 00208 std::vector<Color> quadsColorsArray; 00209 std::vector<Color> quadsOutlineColorsArray; 00210 std::vector<GLuint> quadsIndexArray; 00211 std::vector<GLsizei> quadsIndexCountArray; 00212 std::vector<std::vector<GLuint> > quadsBottomOutlineIndexArray; 00213 std::vector<std::vector<GLuint> > quadsTopOutlineIndexArray; 00214 00215 std::vector<GLuint> quadsRenderingIndicesArray; 00216 std::vector<GLuint> quadsSelectedRenderingIndicesArray; 00217 00218 std::map<float, std::vector<GLuint> > quadsOutlineRenderingIndicesArray; 00219 std::map<float, std::vector<GLuint> > quadsSelectedOutlineRenderingIndicesArray; 00220 00221 std::vector<Coord> pointsCoordsArray; 00222 std::vector<Color> pointsColorsArray; 00223 00224 std::vector<GLuint> pointsNodesRenderingIndexArray; 00225 std::vector<GLuint> pointsNodesSelectedRenderingIndexArray; 00226 std::vector<GLuint> pointsEdgesRenderingIndexArray; 00227 std::vector<GLuint> pointsEdgesSelectedRenderingIndexArray; 00228 00229 TLP_HASH_MAP<unsigned int, std::pair<unsigned int,unsigned int> > edgeToLineIndexVector; 00230 TLP_HASH_MAP<unsigned int, std::pair<unsigned int,unsigned int> > edgeToQuadIndexVector; 00231 TLP_HASH_MAP<unsigned int, unsigned int> edgeToBottomOulineIndexVector; 00232 TLP_HASH_MAP<unsigned int, unsigned int> edgeToTopOutlineIndexVector; 00233 TLP_HASH_MAP<unsigned int, unsigned int> edgeToPointIndexVector; 00234 TLP_HASH_MAP<unsigned int, unsigned int> nodeToPointIndexVector; 00235 00236 GLuint pointsVerticesVBO; 00237 GLuint pointsColorsVBO; 00238 GLuint linesVerticesVBO; 00239 GLuint linesColorsVBO; 00240 GLuint quadsVerticesVBO; 00241 GLuint quadsColorsVBO; 00242 GLuint quadsOutlineColorsVBO; 00243 00244 bool pointsVerticesUploaded; 00245 bool pointsColorsUploaded; 00246 bool linesVerticesUploaded; 00247 bool linesColorsUploaded; 00248 bool quadsVerticesUploaded; 00249 bool quadsColorsUploaded; 00250 bool quadsOutlineColorsUploaded; 00251 00252 bool verticesUploadNeeded; 00253 bool colorsUploadNeeded; 00254 00255 }; 00256 00257 } 00258 00259 #endif 00260 ///@endcond