Tulip  5.0.0
Large graphs analysis and drawing
GlGraphRenderingParameters.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 
20 #ifndef Tulip_GLGRAPHRENDERINGPARAMETERS_H
21 #define Tulip_GLGRAPHRENDERINGPARAMETERS_H
22 
23 #include <tulip/Color.h>
24 #include <tulip/DataSet.h>
25 #include <tulip/tulipconf.h>
26 
27 namespace tlp {
28 
29 class NumericProperty;
30 class BooleanProperty;
31 
32 /**
33  * @ingroup OpenGL
34  * @brief That class defines all the parameters used by GlGraphComposite to render a graph
35  *
36  * @see GlGraphComposite
37  */
38 class TLP_GL_SCOPE GlGraphRenderingParameters {
39 
40 public:
41  /**
42  * @brief Constructor
43  */
45 
46  /**
47  * @brief Get parameters into a DataSet structure
48  */
49  DataSet getParameters() const;
50 
51  /**
52  * @brief Set parameters with a DataSet structure
53  */
54  void setParameters(const DataSet &);
55 
56  /**
57  * @brief activate or deactivate anlialiasing
58  */
59  void setAntialiasing(const bool state);
60 
61  /**
62  * @brief Return true if antialiasing is activated else false.
63  */
64  bool isAntialiased()const;
65 
66  /**
67  * @brief Activate or deactivate displaying of arrows along the graph's edges.
68  */
69  void setViewArrow(const bool state);
70 
71  /**
72  * @brief Return true if arrows drawing is activated else false.
73  */
74  bool isViewArrow()const;
75 
76  /**
77  * @brief Activate or deactivate displaying of labels on nodes.
78  */
79  void setViewNodeLabel(const bool state);
80 
81  /**
82  * @brief Return true if drawing of nodes' labels is activated.
83  */
84  bool isViewNodeLabel() const;
85  /**
86  * @brief Activate or deactivate displaying of labels on nodes.
87  */
88  void setViewEdgeLabel(const bool state);
89 
90  /**
91  * @brief Return true if drawing of nodes' labels is activated.
92  */
93  bool isViewEdgeLabel() const;
94 
95  /**
96  * @brief Activate or deactivate displaying of labels outside the screen.
97  */
98  void setViewOutScreenLabel(const bool state);
99 
100  /**
101  * @brief Return true if drawing of outscreen labels is activated.
102  */
103  bool isViewOutScreenLabel() const;
104 
105  /**
106  * @brief Activate or deactivate interpolation of nodes colors along edge
107  */
108  void setEdgeColorInterpolate(const bool state);
109 
110  /**
111  * @brief Return true if color interpolation is activated
112  */
113  bool isEdgeColorInterpolate() const;
114 
115  /**
116  * @brief Activate or deactivate interpolation of nodes colors along edge
117  */
118  void setEdgeSizeInterpolate(const bool state);
119 
120  /**
121  * @brief Return true if color interpolation is activated
122  */
123  bool isEdgeSizeInterpolate() const;
124 
125  /**
126  * @brief Return the type of fonts used in the renderer(0=3D,1=bitmap,2=texture)
127  */
128  unsigned int getFontsType() const;
129 
130  /**
131  * @brief Set fonts type used in the renderer (0=3D,1=bitmap,2=texture)
132  */
133  void setFontsType(unsigned int type);
134 
135  /**
136  * @brief Set the path for the texture loading
137  */
138  void setTexturePath(const std::string& path);
139 
140  /**
141  * @brief Return the absolute path used for texture loading
142  */
143  std::string getTexturePath() const;
144 
145  /**
146  * @brief Set the absolute path used for the fonts loading
147  */
148  void setFontsPath(const std::string& path);
149 
150  /**
151  * @brief Return the absolute path used for the fonts loading
152  */
153  std::string getFontsPath() const;
154 
155  /**
156  * @brief If true and if labels are activated label inside meta nodes will be displayed
157  */
158  void setViewMetaLabel(const bool state);
159 
160  /**
161  * @brief Return the true if viewMetaLabels is enable else false
162  */
163  bool isViewMetaLabel() const;
164 
165  /**
166  * @brief If true edges are displayed.
167  */
168  void setDisplayEdges(const bool state);
169 
170  /**
171  * @brief Return true if edges are displayed.
172  */
173  bool isDisplayEdges() const;
174 
175  /**
176  * @brief If true nodes are displayed.
177  */
178  void setDisplayNodes(const bool state);
179 
180  /**
181  * @brief Return true if nodes are displayed.
182  */
183  bool isDisplayNodes() const;
184 
185  /**
186  * @brief If true meta-nodes are displayed.
187  */
188  void setDisplayMetaNodes(const bool state);
189 
190  /**
191  * @brief Return true if meta-nodes are displayed.
192  */
193  bool isDisplayMetaNodes() const;
194 
195  /**
196  * @brief set stencil number for selected nodes
197  *
198  * Stencil is an OpenGl system to ensure that other entity can't be displayed above this entity. It's a "guaranted visibility" system.
199  * A small number causes a guaranted visibility
200  * Default value in Tulip is 0xFFFF (greater integer)
201  * And when we have stencil on entity value is 0x2
202  */
203  void setSelectedNodesStencil(const int stencil);
204 
205  /**
206  * @brief get stencil number for selected nodes
207  */
208  int getSelectedNodesStencil() const;
209 
210  /**
211  * @brief set stencil number for selected meta-nodes
212  *
213  * See setSelectedNodesStencil() documentation for more details on stencil number
214  */
215  void setSelectedMetaNodesStencil(const int stencil);
216 
217  /**
218  * @brief get stencil number for selected meta-nodes
219  */
220  int getSelectedMetaNodesStencil() const;
221 
222  /**
223  * @brief set stencil number for selected edges
224  *
225  * See setSelectedNodesStencil() documentation for more details on stencil number
226  */
227  void setSelectedEdgesStencil(const int stencil);
228 
229  /**
230  * @brief get stencil number for selected edges
231  */
232  int getSelectedEdgesStencil() const;
233 
234  /**
235  * @brief set stencil number for nodes
236  *
237  * See setSelectedNodesStencil() documentation for more details on stencil number
238  */
239  void setNodesStencil(const int stencil);
240 
241  /**
242  * @brief get stencil number for nodes
243  */
244  int getNodesStencil() const;
245 
246  /**
247  * @brief set stencil number for meta-nodes
248  *
249  * See setSelectedNodesStencil() documentation for more details on stencil number
250  */
251  void setMetaNodesStencil(const int stencil);
252 
253  /**
254  * @brief get stencil number for meta-nodes
255  */
256  int getMetaNodesStencil() const;
257 
258  /**
259  * @brief set stencil number for edges
260  *
261  * See setSelectedNodesStencil() documentation for more details on stencil number
262  */
263  void setEdgesStencil(const int stencil);
264 
265  /**
266  * @brief get stencil number for edges
267  */
268  int getEdgesStencil() const;
269 
270  /**
271  * @brief set stencil number for nodes label
272  *
273  * See setSelectedNodesStencil() documentation for more details on stencil number
274  */
275  void setNodesLabelStencil(const int stencil);
276 
277  /**
278  * @brief get stencil number for nodes label
279  */
280  int getNodesLabelStencil() const;
281 
282  /**
283  * @brief set stencil number for meta-nodes label
284  *
285  * See setSelectedNodesStencil() documentation for more details on stencil number
286  */
287  void setMetaNodesLabelStencil(const int stencil);
288 
289  /**
290  * @brief get stencil number for meta-nodes label
291  */
292  int getMetaNodesLabelStencil() const;
293 
294  /**
295  * @brief set stencil number for edges label
296  *
297  * See setSelectedNodesStencil() documentation for more details on stencil number
298  */
299  void setEdgesLabelStencil(const int stencil);
300 
301  /**
302  * @brief get stencil number for edges label
303  */
304  int getEdgesLabelStencil() const;
305 
306  /**
307  * @brief If true node and edges are ordered according to the element ordering property (default to viewMetric)
308  */
309  void setElementOrdered(const bool state);
310 
311  /**
312  * @brief Returns true if element ordering is activated
313  */
314  bool isElementOrdered() const;
315 
316  /**
317  * @brief If true (default value) nodes and edges are sorted in descending order according to the element ordering property (default to viewMetric)
318  *
319  * @since Tulip 4.8
320  */
321  void setElementOrderedDescending(const bool state);
322 
323  /**
324  * @brief Returns true if the nodes and edges are sorted in descending order when the element ordering is activated
325  *
326  * @since Tulip 4.8
327  */
328  bool isElementOrderedDescending() const;
329 
330  /**
331  * @brief Defines which property is used for the element ordering.
332  *
333  * @param property The property to use to order the elements.
334  *
335  **/
336  void setElementOrderingProperty(tlp::NumericProperty* property);
337 
338  /**
339  * @brief Gets the property used for element ordering. Setting it to NULL will use viewMetric if the ordering is enabled.
340  *
341  * @return :NumericProperty* The Property currently used.
342  **/
343  tlp::NumericProperty* getElementOrderingProperty() const;
344 
345  /**
346  * @brief If true node and edges are ordered according to the distance with camera
347  */
348  void setElementZOrdered(const bool state);
349 
350  /**
351  * @brief return true if element Z ordering is activated
352  */
353  bool isElementZOrdered() const;
354 
355  /**
356  * @brief if true use 3D displaying of edges instead of 2D lines on ALL edges
357  */
358  void setEdge3D(const bool state);
359 
360  /**
361  * @brief return true if 3D drawing of edges is activated
362  */
363  bool isEdge3D() const;
364 
365  /**
366  * @brief Get the size of the border that is added to any label when using bitmap fonts.
367  *
368  * @deprecated Use getLabelsDensity instead
369  */
370  unsigned int _DEPRECATED getLabelsBorder() const;
371 
372  /**
373  * @brief Get the size of label border
374  *
375  * Get the size of the border that is added to any label when
376  * using bitmap fonts. Setting this parameter to a high value
377  * enables de reduce the label density in the final drawing.
378  * Default value is set to 2 which enables readable labels.
379  * @deprecated Use setLabelsDensity instead
380  */
381  void _DEPRECATED setLabelsBorder(const unsigned int);
382 
383  /**
384  * @brief set if Edge max size is block to node size
385  */
386  void setEdgesMaxSizeToNodesSize(const bool b);
387 
388  /**
389  * @brief return if Edge max size is block to node size
390  */
391  bool getEdgesMaxSizeToNodesSize() const;
392 
393  /**
394  * @brief if true draw graph with feedback information (very low)
395  */
396  void setFeedbackRender(bool feedback);
397 
398  /**
399  * @brief return true if the graph is draw with feedback information
400  */
401  bool getFeedbackRender() const;
402 
403  /**
404  * @brief Change the selection color
405  */
406  void setSelectionColor(const Color &color);
407 
408  /**
409  * @brief return the selection color
410  */
411  Color getSelectionColor() const;
412 
413  /**
414  * @brief return if labels are scaled to node size
415  */
416  bool isLabelScaled() const;
417 
418  /**
419  * Set if labels are scaled to node size
420  */
421  void setLabelScaled(bool state);
422 
423  /**
424  * @brief return if labels are rendered with a fixed font size (dynamic size otherwise)
425  */
426  bool isLabelFixedFontSize() const;
427 
428  /**
429  * Set if labels must be rendered with a fixed font size (dynamic size otherwise)
430  */
431  void setLabelFixedFontSize(bool state);
432 
433  /**
434  * @brief Return labels -density
435  *
436  * This density must be in interval -100 100
437  * -100 : No labels
438  * 0 : No overlap
439  * 100 : All labels
440  */
441  int getLabelsDensity() const;
442 
443  /**
444  * @brief Set labels density
445  *
446  * This density must be in interval -100 100
447  * -100 : No labels
448  * 0 : No overlap
449  * 100 : All labels
450  */
451  void setLabelsDensity(int density);
452 
453  /**
454  * @brief return min size of label : this min size is only used if labels are not scaled and are not rendered with a fixed font size
455  */
456  int getMinSizeOfLabel() const;
457 
458  /**
459  * @brief Set min size of label : this min size is only used if labels are not scaled and are not rendered with a fixed font size
460  */
461  void setMinSizeOfLabel(int size);
462 
463  /**
464  * @brief return max size of label : this max size is only used if labels are not scaled and are not rendered with a fixed font size
465  */
466  int getMaxSizeOfLabel() const;
467 
468  /**
469  * @brief Set max size of label : this max size is only used if labels are not scaled and are not rendered with a fixed font size
470  */
471  void setMaxSizeOfLabel(int size);
472 
473  /**
474  * @brief return if labels are billboarded
475  */
476  bool getLabelsAreBillboarded() const {
477  return _labelsAreBillboarded;
478  }
479 
480  /**
481  * @brief Set if labels are billboarded
482  */
483  void setLabelsAreBillboarded(bool billboarded) {
484  _labelsAreBillboarded=billboarded;
485  }
486 
487  /**
488  * @brief This property is use to filter nodes/edges display, for a node/edge if this property is false : the node/edge will not be diplayed
489  *
490  * @Warning : this property will not be saved in DataSet
491  */
492  void setDisplayFilteringProperty(BooleanProperty *filteringProperty) {
493  _displayFilteringProperty=filteringProperty;
494  }
495 
496  /**
497  * @brief Get the boolean property use to filtering displaying of nodes/edges
498  */
500  return _displayFilteringProperty;
501  }
502 
503 private:
504 
505  bool _antialiased;
506  bool _viewArrow;
507  bool _viewNodeLabel;
508  bool _viewEdgeLabel;
509  bool _viewMetaLabel;
510  bool _viewOutScreenLabel;
511  bool _elementOrdered;
512  bool _elementOrderedDescending;
513  bool _edgeColorInterpolate;
514  bool _edge3D;
515  bool _edgeSizeInterpolate;
516  bool _displayEdges;
517  bool _displayNodes;
518  bool _displayMetaNodes;
519  bool _elementZOrdered;
520  int _selectedNodesStencil;
521  int _selectedMetaNodesStencil;
522  int _selectedEdgesStencil;
523  int _nodesStencil;
524  int _metaNodesStencil;
525  int _edgesStencil;
526  int _nodesLabelStencil;
527  int _metaNodesLabelStencil;
528  int _edgesLabelStencil;
529  bool _labelScaled;
530  bool _labelFixedFontSize;
531  int _labelMinSize;
532  int _labelMaxSize;
533  int _labelsDensity;
534  bool _labelsAreBillboarded;
535  std::string _fontsPath;
536  std::string _texturePath;
537  bool _edgesMaxSizeToNodesSize;
538  bool _feedbackRender;
539  Color _selectionColor;
540  BooleanProperty *_displayFilteringProperty;
541  NumericProperty* _elementOrderingProperty;
542 };
543 
544 /** \brief Class to get the default selection color
545  */
546 class TLP_GL_SCOPE GlDefaultSelectionColorManager {
547 public:
548  static void setManager(GlDefaultSelectionColorManager *);
549  static tlp::Color getDefaultSelectionColor();
550  virtual tlp::Color defaultSelectionColor(bool tulipDefault = false)=0;
551 
552 private:
553  static GlDefaultSelectionColorManager* manager;
554 };
555 }
556 
557 #endif // Tulip_GLGRAPH_H
A graph property that maps a boolean value to graph elements.
void setLabelsAreBillboarded(bool billboarded)
Set if labels are billboarded.
A container that can store data from any type.
Definition: DataSet.h:190
BooleanProperty * getDisplayFilteringProperty() const
Get the boolean property use to filtering displaying of nodes/edges.
That class defines all the parameters used by GlGraphComposite to render a graph. ...
Class to get the default selection color.
Interface all numerical properties. Property values are always returned as double.
bool getLabelsAreBillboarded() const
return if labels are billboarded
void setDisplayFilteringProperty(BooleanProperty *filteringProperty)
This property is use to filter nodes/edges display, for a node/edge if this property is false : the n...