Tulip  5.4.0
Large graphs analysis and drawing
GlGraphRenderingParameters.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
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 Activate or deactivate edge display in front of the scene
127  */
128  void setEdgeFrontDisplay(const bool state);
129 
130  /**
131  * @brief Return true if edge display in front of the scene is activated
132  */
133  bool isEdgeFrontDisplay() const;
134 
135  /**
136  * @brief Return the type of fonts used in the renderer(0=3D,1=bitmap,2=texture)
137  */
138  unsigned int getFontsType() const;
139 
140  /**
141  * @brief Set fonts type used in the renderer (0=3D,1=bitmap,2=texture)
142  */
143  void setFontsType(unsigned int type);
144 
145  /**
146  * @brief Set the path for the texture loading
147  */
148  void setTexturePath(const std::string &path);
149 
150  /**
151  * @brief Return the absolute path used for texture loading
152  */
153  std::string getTexturePath() const;
154 
155  /**
156  * @brief Set the absolute path used for the fonts loading
157  */
158  void setFontsPath(const std::string &path);
159 
160  /**
161  * @brief Return the absolute path used for the fonts loading
162  */
163  std::string getFontsPath() const;
164 
165  /**
166  * @brief If true and if labels are activated label inside meta nodes will be displayed
167  */
168  void setViewMetaLabel(const bool state);
169 
170  /**
171  * @brief Return the true if viewMetaLabels is enable else false
172  */
173  bool isViewMetaLabel() const;
174 
175  /**
176  * @brief If true edges are displayed.
177  */
178  void setDisplayEdges(const bool state);
179 
180  /**
181  * @brief Return true if edges are displayed.
182  */
183  bool isDisplayEdges() const;
184 
185  /**
186  * @brief If true nodes are displayed.
187  */
188  void setDisplayNodes(const bool state);
189 
190  /**
191  * @brief Return true if nodes are displayed.
192  */
193  bool isDisplayNodes() const;
194 
195  /**
196  * @brief If true meta-nodes are displayed.
197  */
198  void setDisplayMetaNodes(const bool state);
199 
200  /**
201  * @brief Return true if meta-nodes are displayed.
202  */
203  bool isDisplayMetaNodes() const;
204 
205  /**
206  * @brief set stencil number for selected nodes
207  *
208  * Stencil is an OpenGl system to ensure that other entity can't be displayed above this entity.
209  * It's a "guaranteed visibility" system.
210  * A small number causes a guaranteed visibility
211  * Default value in Tulip is 0xFFFF (greater integer)
212  * And when we have stencil on entity value is 0x2
213  */
214  void setSelectedNodesStencil(const int stencil);
215 
216  /**
217  * @brief get stencil number for selected nodes
218  */
219  int getSelectedNodesStencil() const;
220 
221  /**
222  * @brief set stencil number for selected meta-nodes
223  *
224  * See setSelectedNodesStencil() documentation for more details on stencil number
225  */
226  void setSelectedMetaNodesStencil(const int stencil);
227 
228  /**
229  * @brief get stencil number for selected meta-nodes
230  */
231  int getSelectedMetaNodesStencil() const;
232 
233  /**
234  * @brief set stencil number for selected edges
235  *
236  * See setSelectedNodesStencil() documentation for more details on stencil number
237  */
238  void setSelectedEdgesStencil(const int stencil);
239 
240  /**
241  * @brief get stencil number for selected edges
242  */
243  int getSelectedEdgesStencil() const;
244 
245  /**
246  * @brief set stencil number for nodes
247  *
248  * See setSelectedNodesStencil() documentation for more details on stencil number
249  */
250  void setNodesStencil(const int stencil);
251 
252  /**
253  * @brief get stencil number for nodes
254  */
255  int getNodesStencil() const;
256 
257  /**
258  * @brief set stencil number for meta-nodes
259  *
260  * See setSelectedNodesStencil() documentation for more details on stencil number
261  */
262  void setMetaNodesStencil(const int stencil);
263 
264  /**
265  * @brief get stencil number for meta-nodes
266  */
267  int getMetaNodesStencil() const;
268 
269  /**
270  * @brief set stencil number for edges
271  *
272  * See setSelectedNodesStencil() documentation for more details on stencil number
273  */
274  void setEdgesStencil(const int stencil);
275 
276  /**
277  * @brief get stencil number for edges
278  */
279  int getEdgesStencil() const;
280 
281  /**
282  * @brief set stencil number for nodes label
283  *
284  * See setSelectedNodesStencil() documentation for more details on stencil number
285  */
286  void setNodesLabelStencil(const int stencil);
287 
288  /**
289  * @brief get stencil number for nodes label
290  */
291  int getNodesLabelStencil() const;
292 
293  /**
294  * @brief set stencil number for meta-nodes label
295  *
296  * See setSelectedNodesStencil() documentation for more details on stencil number
297  */
298  void setMetaNodesLabelStencil(const int stencil);
299 
300  /**
301  * @brief get stencil number for meta-nodes label
302  */
303  int getMetaNodesLabelStencil() const;
304 
305  /**
306  * @brief set stencil number for edges label
307  *
308  * See setSelectedNodesStencil() documentation for more details on stencil number
309  */
310  void setEdgesLabelStencil(const int stencil);
311 
312  /**
313  * @brief get stencil number for edges label
314  */
315  int getEdgesLabelStencil() const;
316 
317  /**
318  * @brief If true node and edges are ordered according to the element ordering property (default
319  * to viewMetric)
320  */
321  void setElementOrdered(const bool state);
322 
323  /**
324  * @brief Returns true if element ordering is activated
325  */
326  bool isElementOrdered() const;
327 
328  /**
329  * @brief If true (default value) nodes and edges are sorted in descending order according to the
330  * element ordering property (default to viewMetric)
331  *
332  * @since Tulip 4.8
333  */
334  void setElementOrderedDescending(const bool state);
335 
336  /**
337  * @brief Returns true if the nodes and edges are sorted in descending order when the element
338  * ordering is activated
339  *
340  * @since Tulip 4.8
341  */
342  bool isElementOrderedDescending() const;
343 
344  /**
345  * @brief Defines which property is used for the element ordering.
346  *
347  * @param property The property to use to order the elements.
348  *
349  **/
350  void setElementOrderingProperty(tlp::NumericProperty *property);
351 
352  /**
353  * @brief Gets the property used for element ordering. Setting it to nullptr will use viewMetric
354  *if
355  *the ordering is enabled.
356  *
357  * @return :NumericProperty* The Property currently used.
358  **/
359  tlp::NumericProperty *getElementOrderingProperty() const;
360 
361  /**
362  * @brief If true node and edges are ordered according to the distance with camera
363  */
364  void setElementZOrdered(const bool state);
365 
366  /**
367  * @brief return true if element Z ordering is activated
368  */
369  bool isElementZOrdered() const;
370 
371  /**
372  * @brief if true use 3D displaying of edges instead of 2D lines on ALL edges
373  */
374  void setEdge3D(const bool state);
375 
376  /**
377  * @brief return true if 3D drawing of edges is activated
378  */
379  bool isEdge3D() const;
380 
381  /**
382  * @brief Get the size of the border that is added to any label when using bitmap fonts.
383  *
384  * @deprecated Use getLabelsDensity instead
385  */
386  unsigned int _DEPRECATED getLabelsBorder() const;
387 
388  /**
389  * @brief Get the size of label border
390  *
391  * Get the size of the border that is added to any label when
392  * using bitmap fonts. Setting this parameter to a high value
393  * enables de reduce the label density in the final drawing.
394  * Default value is set to 2 which enables readable labels.
395  * @deprecated Use setLabelsDensity instead
396  */
397  void _DEPRECATED setLabelsBorder(const unsigned int);
398 
399  /**
400  * @brief set if Edge max size is block to node size
401  */
402  void setEdgesMaxSizeToNodesSize(const bool b);
403 
404  /**
405  * @brief return if Edge max size is block to node size
406  */
407  bool getEdgesMaxSizeToNodesSize() const;
408 
409  /**
410  * @brief Change the selection color
411  */
412  void setSelectionColor(const Color &color);
413 
414  /**
415  * @brief return the selection color
416  */
417  Color getSelectionColor() const;
418 
419  /**
420  * @brief return if labels are scaled to node size
421  */
422  bool isLabelScaled() const;
423 
424  /**
425  * Set if labels are scaled to node size
426  */
427  void setLabelScaled(bool state);
428 
429  /**
430  * @brief return if labels are rendered with a fixed font size (dynamic size otherwise)
431  */
432  bool isLabelFixedFontSize() const;
433 
434  /**
435  * Set if labels must be rendered with a fixed font size (dynamic size otherwise)
436  */
437  void setLabelFixedFontSize(bool state);
438 
439  /**
440  * @brief Return labels -density
441  *
442  * This density must be in interval -100 100
443  * -100 : No labels
444  * 0 : No overlap
445  * 100 : All labels
446  */
447  int getLabelsDensity() const;
448 
449  /**
450  * @brief Set labels density
451  *
452  * This density must be in interval -100 100
453  * -100 : No labels
454  * 0 : No overlap
455  * 100 : All labels
456  */
457  void setLabelsDensity(int density);
458 
459  /**
460  * @brief return min size of label : this min size is only used if labels are not scaled and are
461  * not rendered with a fixed font size
462  */
463  int getMinSizeOfLabel() const;
464 
465  /**
466  * @brief Set min size of label : this min size is only used if labels are not scaled and are not
467  * rendered with a fixed font size
468  */
469  void setMinSizeOfLabel(int size);
470 
471  /**
472  * @brief return max size of label : this max size is only used if labels are not scaled and are
473  * not rendered with a fixed font size
474  */
475  int getMaxSizeOfLabel() const;
476 
477  /**
478  * @brief Set max size of label : this max size is only used if labels are not scaled and are not
479  * rendered with a fixed font size
480  */
481  void setMaxSizeOfLabel(int size);
482 
483  /**
484  * @brief return if labels are billboarded
485  */
486  bool getLabelsAreBillboarded() const {
487  return _labelsAreBillboarded;
488  }
489 
490  /**
491  * @brief Set if labels are billboarded
492  */
493  void setLabelsAreBillboarded(bool billboarded) {
494  _labelsAreBillboarded = billboarded;
495  }
496 
497  /**
498  * @brief This property is use to filter nodes/edges display, for a node/edge if this property is
499  * false : the node/edge will not be displayed
500  *
501  * @Warning : this property will not be saved in DataSet
502  */
503  void setDisplayFilteringProperty(BooleanProperty *filteringProperty) {
504  _displayFilteringProperty = filteringProperty;
505  }
506 
507  /**
508  * @brief Get the Boolean property use to filter the rendering of nodes/edges
509  */
511  return _displayFilteringProperty;
512  }
513 
514 private:
515  bool _antialiased;
516  bool _viewArrow;
517  bool _viewNodeLabel;
518  bool _viewEdgeLabel;
519  bool _viewMetaLabel;
520  bool _viewOutScreenLabel;
521  bool _elementOrdered;
522  bool _elementOrderedDescending;
523  bool _edgeColorInterpolate;
524  bool _edge3D;
525  bool _edgeSizeInterpolate;
526  bool _edgeFrontDisplay;
527  bool _displayEdges;
528  bool _displayNodes;
529  bool _displayMetaNodes;
530  bool _elementZOrdered;
531  int _selectedNodesStencil;
532  int _selectedMetaNodesStencil;
533  int _selectedEdgesStencil;
534  int _nodesStencil;
535  int _metaNodesStencil;
536  int _edgesStencil;
537  int _nodesLabelStencil;
538  int _metaNodesLabelStencil;
539  int _edgesLabelStencil;
540  bool _labelScaled;
541  bool _labelFixedFontSize;
542  int _labelMinSize;
543  int _labelMaxSize;
544  int _labelsDensity;
545  bool _labelsAreBillboarded;
546  std::string _fontsPath;
547  std::string _texturePath;
548  bool _edgesMaxSizeToNodesSize;
549  Color _selectionColor;
550  BooleanProperty *_displayFilteringProperty;
551  NumericProperty *_elementOrderingProperty;
552 };
553 
554 ///@cond DOXYGEN_HIDDEN
555 /** \brief Class to get the default selection color
556  */
557 class TLP_GL_SCOPE GlDefaultSelectionColorManager {
558 public:
559  static void setManager(GlDefaultSelectionColorManager *);
560  static tlp::Color getDefaultSelectionColor();
561  virtual tlp::Color defaultSelectionColor(bool tulipDefault = false) = 0;
562 
563 private:
564  static GlDefaultSelectionColorManager *manager;
565 };
566 
567 ///@endcond
568 
569 } // namespace tlp
570 
571 #endif // Tulip_GLGRAPH_H
A graph property that maps a boolean value to graph elements.
BooleanProperty * getDisplayFilteringProperty() const
Get the Boolean property use to filter the rendering of nodes/edges.
void setLabelsAreBillboarded(bool billboarded)
Set if labels are billboarded.
A container that can store data from any type.
Definition: DataSet.h:189
That class defines all the parameters used by GlGraphComposite to render a graph. ...
Interface all numerical properties. Property values are always returned as double.
void setDisplayFilteringProperty(BooleanProperty *filteringProperty)
This property is use to filter nodes/edges display, for a node/edge if this property is false : the n...
bool getLabelsAreBillboarded() const
return if labels are billboarded