![]() |
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_GLGRAPHINPUTDATA_H 00022 #define Tulip_GLGRAPHINPUTDATA_H 00023 00024 #include <tulip/tulipconf.h> 00025 #include <tulip/Observable.h> 00026 #include <tulip/LayoutProperty.h> 00027 #include <tulip/DoubleProperty.h> 00028 #include <tulip/StringProperty.h> 00029 #include <tulip/BooleanProperty.h> 00030 #include <tulip/SizeProperty.h> 00031 #include <tulip/IntegerProperty.h> 00032 #include <tulip/ColorProperty.h> 00033 00034 namespace tlp { 00035 00036 class PropertyManager; 00037 class Graph; 00038 class Glyph; 00039 class EdgeExtremityGlyph; 00040 class GlVertexArrayManager; 00041 class GlMetaNodeRenderer; 00042 class GlGraphRenderingParameters; 00043 class GlGlyphRenderer; 00044 00045 /** 00046 * Class use to store inputData of the graph 00047 */ 00048 class TLP_GL_SCOPE GlGraphInputData : public Observable { 00049 00050 public: 00051 00052 /** 00053 * GlGraphInputData available properties 00054 */ 00055 enum PropertyName { 00056 VIEW_COLOR=0, /**< color of nodes/edges */ 00057 VIEW_LABELCOLOR, /**< color of labels */ 00058 VIEW_LABELBORDERCOLOR, /**< border color of labels */ 00059 VIEW_LABELBORDERWIDTH, /**< border width of labels */ 00060 VIEW_SIZE, /**< size of nodes/edges */ 00061 VIEW_LABELPOSITION, /**< position of labels */ 00062 VIEW_SHAPE, /**< shape of nodes/edges */ 00063 VIEW_ROTATION, /**< rotation apply on nodes */ 00064 VIEW_SELECTED, /**< nodes/edges selected */ 00065 VIEW_FONT, /**< font name of labels */ 00066 VIEW_FONTSIZE, /**< font size of labels */ 00067 VIEW_LABEL, /**< text of labels */ 00068 VIEW_LAYOUT, /**< position of nodes */ 00069 VIEW_TEXTURE, /**< texture of nodes/edges */ 00070 VIEW_BORDERCOLOR, /**< border color of nodes/edges */ 00071 VIEW_BORDERWIDTH, /**< border width of nodes/edges */ 00072 VIEW_SRCANCHORSHAPE, /**< shape of source arrow edge extremity */ 00073 VIEW_SRCANCHORSIZE, /**< size of source arrow edge extremity */ 00074 VIEW_TGTANCHORSHAPE, /**< shape of target arrow edge extremity */ 00075 VIEW_TGTANCHORSIZE, /**< size of target arrow edge extremity */ 00076 VIEW_ANIMATIONFRAME, /**< animation frame */ 00077 NB_PROPS /** must be the last, give the number of enum props */ 00078 }; 00079 00080 /** 00081 * Create the inputData with Graph : graph and GlGraphRenderingParameters : parameters 00082 */ 00083 GlGraphInputData(Graph* graph, GlGraphRenderingParameters* parameters,GlMetaNodeRenderer *renderer = NULL); 00084 00085 ~GlGraphInputData(); 00086 00087 /** 00088 * Return the graph of this inputData 00089 */ 00090 Graph* getGraph() const { 00091 return graph; 00092 } 00093 00094 void treatEvent(const Event &ev); 00095 00096 /** 00097 * Set metaNode renderer 00098 * If deleteOldMetaNodeRenderer==true : this function delete old meta node renderer 00099 */ 00100 void setMetaNodeRenderer(GlMetaNodeRenderer *renderer,bool deleteOldMetaNodeRenderer=true); 00101 00102 /** 00103 * Return metaNode renderer 00104 */ 00105 GlMetaNodeRenderer *getMetaNodeRenderer() const { 00106 return _metaNodeRenderer; 00107 } 00108 00109 /** 00110 * Return glEdgeDisplayManager 00111 */ 00112 GlVertexArrayManager *getGlVertexArrayManager() const { 00113 return _glVertexArrayManager; 00114 } 00115 00116 GlGlyphRenderer *getGlGlyphRenderer() const { 00117 return _glGlyphRenderer; 00118 } 00119 00120 /** 00121 * Set glEdgeDisplayManager 00122 */ 00123 void setGlVertexArrayManager(GlVertexArrayManager * manager) { 00124 _glVertexArrayManager=manager; 00125 } 00126 00127 /** 00128 * Function to get the PropertyInterface* corresponding 00129 * to a given name 00130 */ 00131 tlp::PropertyInterface* getProperty(const std::string& name) const { 00132 std::map<std::string, PropertyName>::iterator it = 00133 _propertiesNameMap.find(name); 00134 00135 if (it != _propertiesNameMap.end()) 00136 return _propertiesMap[it->second]; 00137 00138 return NULL; 00139 } 00140 00141 /** 00142 * Function to get the typed PropertyInterface* for a given propertyName 00143 * See PropertyName enum for more details on available properties 00144 */ 00145 template<typename T> 00146 T* getProperty(PropertyName propertyName) const { 00147 return static_cast<T*>(_propertiesMap[propertyName]); 00148 } 00149 00150 /** 00151 * Function to set the PropertyInterface* for a given propertyName 00152 * See PropertyName enum for more details on available properties 00153 */ 00154 void setProperty(PropertyName propertyName, PropertyInterface *property) { 00155 _properties.erase(_propertiesMap[propertyName]); 00156 _propertiesMap[propertyName]=property; 00157 _properties.insert(property); 00158 } 00159 00160 /** 00161 * Function to set the PropertyInterface* for a given name 00162 */ 00163 bool setProperty(const std::string& name, PropertyInterface *property); 00164 00165 /** 00166 * Function to set a bunch of named PropertyInterface* 00167 */ 00168 bool installProperties(const std::map<std::string, tlp::PropertyInterface*>& propsMap); 00169 00170 /** 00171 * Return a pointer on the property used to elementColor 00172 */ 00173 ColorProperty * getElementColor() const { 00174 return getProperty<ColorProperty>(VIEW_COLOR); 00175 } 00176 /** 00177 * Set the pointer on the property used to elementColor 00178 */ 00179 void setElementColor(ColorProperty *property) { 00180 setProperty(VIEW_COLOR,property); 00181 } 00182 /** 00183 * Return a pointer on the property used to elementLabelColor 00184 */ 00185 ColorProperty *getElementLabelColor() const { 00186 return getProperty<ColorProperty>(VIEW_LABELCOLOR); 00187 } 00188 /** 00189 * Set the pointer on the property used to elementLabelColor 00190 */ 00191 void setElementLabelColor(ColorProperty *property) { 00192 setProperty(VIEW_LABELCOLOR,property); 00193 } 00194 /** 00195 * Return a pointer on the property used to elementLabelBorderColor 00196 */ 00197 ColorProperty *getElementLabelBorderColor() const { 00198 return getProperty<ColorProperty>(VIEW_LABELBORDERCOLOR); 00199 } 00200 /** 00201 * Set the pointer on the property used to elementLabelBorderColor 00202 */ 00203 void setElementLabelBorderColor(ColorProperty *property) { 00204 setProperty(VIEW_LABELBORDERCOLOR,property); 00205 } 00206 /** 00207 * Return a pointer on the property used to elementLabelBorderWidth 00208 */ 00209 DoubleProperty *getElementLabelBorderWidth() const { 00210 return getProperty<DoubleProperty>(VIEW_LABELBORDERWIDTH); 00211 } 00212 /** 00213 * Set the pointer on the property used to elementLabelBorderColor 00214 */ 00215 void setElementLabelBorderWidth(DoubleProperty *property) { 00216 setProperty(VIEW_LABELBORDERWIDTH,property); 00217 } 00218 /** 00219 * Return a pointer on the property used to elementSize 00220 */ 00221 SizeProperty *getElementSize() const { 00222 return getProperty<SizeProperty>(VIEW_SIZE); 00223 } 00224 /** 00225 * Set the pointer on the property used to elementSize 00226 */ 00227 void setElementSize(SizeProperty *property) { 00228 setProperty(VIEW_SIZE,property); 00229 } 00230 /** 00231 * Return a pointer on the property used to elementLabelPosition 00232 */ 00233 IntegerProperty *getElementLabelPosition() const { 00234 return getProperty<IntegerProperty>(VIEW_LABELPOSITION); 00235 } 00236 /** 00237 * Set the pointer on the property used to elementLabelPosition 00238 */ 00239 void setElementLabelPosition(IntegerProperty *property) { 00240 setProperty(VIEW_LABELPOSITION,property); 00241 } 00242 /** 00243 * Return a pointer on the property used to elementShape 00244 */ 00245 IntegerProperty *getElementShape() const { 00246 return getProperty<IntegerProperty>(VIEW_SHAPE); 00247 } 00248 /** 00249 * Set the pointer on the property used to elementShape 00250 */ 00251 void setElementShape(IntegerProperty *property) { 00252 setProperty(VIEW_SHAPE,property); 00253 } 00254 /** 00255 * Return a pointer on the property used to elementRotation 00256 */ 00257 DoubleProperty *getElementRotation() const { 00258 return getProperty<DoubleProperty>(VIEW_ROTATION); 00259 } 00260 /** 00261 * Set the pointer on the property used to elementRotation 00262 */ 00263 void setElementRotation(DoubleProperty *property) { 00264 setProperty(VIEW_ROTATION,property); 00265 } 00266 /** 00267 * Return a pointer on the property used to elementSelected 00268 */ 00269 BooleanProperty *getElementSelected() const { 00270 return getProperty<BooleanProperty>(VIEW_SELECTED); 00271 } 00272 /** 00273 * Set the pointer on the property used to elementSelected 00274 */ 00275 void setElementSelected(BooleanProperty *property) { 00276 setProperty(VIEW_SELECTED,property); 00277 } 00278 /** 00279 * Return a pointer on the property used to elementFont 00280 */ 00281 StringProperty *getElementFont() const { 00282 return getProperty<StringProperty>(VIEW_FONT); 00283 } 00284 /** 00285 * Set the pointer on the property used to elementFont 00286 */ 00287 void setElementFont(StringProperty *property) { 00288 setProperty(VIEW_FONT,property); 00289 } 00290 /** 00291 * Return a pointer on the property used to elementFontSize 00292 */ 00293 IntegerProperty *getElementFontSize() const { 00294 return getProperty<IntegerProperty>(VIEW_FONTSIZE); 00295 } 00296 /** 00297 * Set the pointer on the property used to elementFontSize 00298 */ 00299 void setElementFontSize(IntegerProperty *property) { 00300 setProperty(VIEW_FONTSIZE,property); 00301 } 00302 /** 00303 * Return a pointer on the property used to elementLabel 00304 */ 00305 StringProperty *getElementLabel() const { 00306 return getProperty<StringProperty>(VIEW_LABEL); 00307 } 00308 /** 00309 * Set the pointer on the property used to elementLabel 00310 */ 00311 void setElementLabel(StringProperty *property) { 00312 setProperty(VIEW_LABEL,property); 00313 } 00314 /** 00315 * Return a pointer on the property used to elementLayout 00316 */ 00317 LayoutProperty *getElementLayout() const { 00318 return getProperty<LayoutProperty>(VIEW_LAYOUT); 00319 } 00320 /** 00321 * Set the pointer on the property used to elementLayout 00322 */ 00323 void setElementLayout(LayoutProperty *property) { 00324 setProperty(VIEW_LAYOUT,property); 00325 } 00326 /** 00327 * Return a pointer on the property used to elementTexture 00328 */ 00329 StringProperty *getElementTexture() const { 00330 return getProperty<StringProperty>(VIEW_TEXTURE); 00331 } 00332 /** 00333 * Set the pointer on the property used to elementTexture 00334 */ 00335 void setElementTexture(StringProperty *property) { 00336 setProperty(VIEW_TEXTURE,property); 00337 } 00338 /** 00339 * Return a pointer on the property used to elementBorderColor 00340 */ 00341 ColorProperty *getElementBorderColor() const { 00342 return getProperty<ColorProperty>(VIEW_BORDERCOLOR); 00343 } 00344 /** 00345 * Set the pointer on the property used to elementBorderColor 00346 */ 00347 void setElementBorderColor(ColorProperty *property) { 00348 setProperty(VIEW_BORDERCOLOR,property); 00349 } 00350 /** 00351 * Return a pointer on the property used to elementBorderWidth 00352 */ 00353 DoubleProperty *getElementBorderWidth() const { 00354 return getProperty<DoubleProperty>(VIEW_BORDERWIDTH); 00355 } 00356 /** 00357 * Set the pointer on the property used to elementBorderWidth 00358 */ 00359 void setElementBorderWidth(DoubleProperty *property) { 00360 setProperty(VIEW_BORDERWIDTH,property); 00361 } 00362 /** 00363 * Return a pointer on the property used to elementSrcAnchorShape 00364 */ 00365 IntegerProperty *getElementSrcAnchorShape() const { 00366 return getProperty<IntegerProperty>(VIEW_SRCANCHORSHAPE); 00367 } 00368 /** 00369 * Set the pointer on the property used to elementSrcAnchorShape 00370 */ 00371 void setElementSrcAnchorShape(IntegerProperty *property) { 00372 setProperty(VIEW_SRCANCHORSHAPE,property); 00373 } 00374 /** 00375 * Return a pointer on the property used to elementSrcAnchorSize 00376 */ 00377 SizeProperty *getElementSrcAnchorSize() const { 00378 return getProperty<SizeProperty>(VIEW_SRCANCHORSIZE); 00379 } 00380 /** 00381 * Set the pointer on the property used to elementSrcAnchorSize 00382 */ 00383 void setElementSrcAnchorSize(SizeProperty *property) { 00384 setProperty(VIEW_SRCANCHORSIZE,property); 00385 } 00386 /** 00387 * Return a pointer on the property used to elementTgtAnchorShape 00388 */ 00389 IntegerProperty *getElementTgtAnchorShape() const { 00390 return getProperty<IntegerProperty>(VIEW_TGTANCHORSHAPE); 00391 } 00392 /** 00393 * Set the pointer on the property used to elementTgtAnchorShape 00394 */ 00395 void setElementTgtAnchorShape(IntegerProperty *property) { 00396 setProperty(VIEW_TGTANCHORSHAPE,property); 00397 } 00398 /** 00399 * Return a pointer on the property used to elementTgtAnchorSize 00400 */ 00401 SizeProperty *getElementTgtAnchorSize() const { 00402 return getProperty<SizeProperty>(VIEW_TGTANCHORSIZE); 00403 } 00404 /** 00405 * Set the property name for elementSourceAnchorSize 00406 */ 00407 void setElementTgtAnchorSize(SizeProperty *property) { 00408 setProperty(VIEW_TGTANCHORSIZE,property); 00409 } 00410 /** 00411 * Return a pointer on the property used to elementAnimationFrame 00412 */ 00413 IntegerProperty *getElementAnimationFrame() const { 00414 return getProperty<IntegerProperty>(VIEW_ANIMATIONFRAME); 00415 } 00416 /** 00417 * Set the pointer on the property used to elementAnimationFrame 00418 */ 00419 void setElementAnimationFrame(IntegerProperty *property) { 00420 setProperty(VIEW_ANIMATIONFRAME,property); 00421 } 00422 00423 std::set<tlp::PropertyInterface*> properties() const { 00424 return _properties; 00425 } 00426 00427 /** 00428 * @brief reloadGraphProperties restore the properties of the GlGraphInputData from the the graph. 00429 */ 00430 void reloadGraphProperties(); 00431 00432 /** 00433 * @brief renderingParameters return a pointer on the rendering parameters. 00434 * @return 00435 */ 00436 GlGraphRenderingParameters* renderingParameters()const { 00437 return parameters; 00438 } 00439 00440 /** 00441 * @brief setRenderingParameters set the pointer on the rendering parameters. 00442 * @param newParameters 00443 */ 00444 void setRenderingParameters(GlGraphRenderingParameters* newParameters) { 00445 parameters = newParameters; 00446 } 00447 00448 public : 00449 00450 Graph* graph; 00451 00452 GlGraphRenderingParameters* parameters; 00453 00454 MutableContainer<Glyph *> glyphs; 00455 MutableContainer<EdgeExtremityGlyph *> extremityGlyphs; 00456 00457 protected: 00458 00459 std::set<PropertyInterface*> _properties; 00460 00461 PropertyInterface* _propertiesMap[NB_PROPS]; 00462 static std::map<std::string,PropertyName> _propertiesNameMap; 00463 00464 GlMetaNodeRenderer *_metaNodeRenderer; 00465 GlVertexArrayManager *_glVertexArrayManager; 00466 GlGlyphRenderer *_glGlyphRenderer; 00467 00468 00469 }; 00470 } 00471 00472 #endif 00473 ///@endcond