Tulip  5.2.1
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 "guaranted visibility" system.
210  * A small number causes a guaranted 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 if true draw graph with feedback information (very low)
411  */
412  void setFeedbackRender(bool feedback);
413 
414  /**
415  * @brief return true if the graph is draw with feedback information
416  */
417  bool getFeedbackRender() const;
418 
419  /**
420  * @brief Change the selection color
421  */
422  void setSelectionColor(const Color &color);
423 
424  /**
425  * @brief return the selection color
426  */
427  Color getSelectionColor() const;
428 
429  /**
430  * @brief return if labels are scaled to node size
431  */
432  bool isLabelScaled() const;
433 
434  /**
435  * Set if labels are scaled to node size
436  */
437  void setLabelScaled(bool state);
438 
439  /**
440  * @brief return if labels are rendered with a fixed font size (dynamic size otherwise)
441  */
442  bool isLabelFixedFontSize() const;
443 
444  /**
445  * Set if labels must be rendered with a fixed font size (dynamic size otherwise)
446  */
447  void setLabelFixedFontSize(bool state);
448 
449  /**
450  * @brief Return 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  int getLabelsDensity() const;
458 
459  /**
460  * @brief Set labels density
461  *
462  * This density must be in interval -100 100
463  * -100 : No labels
464  * 0 : No overlap
465  * 100 : All labels
466  */
467  void setLabelsDensity(int density);
468 
469  /**
470  * @brief return min size of label : this min size is only used if labels are not scaled and are
471  * not rendered with a fixed font size
472  */
473  int getMinSizeOfLabel() const;
474 
475  /**
476  * @brief Set min size of label : this min size is only used if labels are not scaled and are not
477  * rendered with a fixed font size
478  */
479  void setMinSizeOfLabel(int size);
480 
481  /**
482  * @brief return max size of label : this max size is only used if labels are not scaled and are
483  * not rendered with a fixed font size
484  */
485  int getMaxSizeOfLabel() const;
486 
487  /**
488  * @brief Set max size of label : this max size is only used if labels are not scaled and are not
489  * rendered with a fixed font size
490  */
491  void setMaxSizeOfLabel(int size);
492 
493  /**
494  * @brief return if labels are billboarded
495  */
496  bool getLabelsAreBillboarded() const {
497  return _labelsAreBillboarded;
498  }
499 
500  /**
501  * @brief Set if labels are billboarded
502  */
503  void setLabelsAreBillboarded(bool billboarded) {
504  _labelsAreBillboarded = billboarded;
505  }
506 
507  /**
508  * @brief This property is use to filter nodes/edges display, for a node/edge if this property is
509  * false : the node/edge will not be diplayed
510  *
511  * @Warning : this property will not be saved in DataSet
512  */
513  void setDisplayFilteringProperty(BooleanProperty *filteringProperty) {
514  _displayFilteringProperty = filteringProperty;
515  }
516 
517  /**
518  * @brief Get the boolean property use to filtering displaying of nodes/edges
519  */
521  return _displayFilteringProperty;
522  }
523 
524 private:
525  bool _antialiased;
526  bool _viewArrow;
527  bool _viewNodeLabel;
528  bool _viewEdgeLabel;
529  bool _viewMetaLabel;
530  bool _viewOutScreenLabel;
531  bool _elementOrdered;
532  bool _elementOrderedDescending;
533  bool _edgeColorInterpolate;
534  bool _edge3D;
535  bool _edgeSizeInterpolate;
536  bool _edgeFrontDisplay;
537  bool _displayEdges;
538  bool _displayNodes;
539  bool _displayMetaNodes;
540  bool _elementZOrdered;
541  int _selectedNodesStencil;
542  int _selectedMetaNodesStencil;
543  int _selectedEdgesStencil;
544  int _nodesStencil;
545  int _metaNodesStencil;
546  int _edgesStencil;
547  int _nodesLabelStencil;
548  int _metaNodesLabelStencil;
549  int _edgesLabelStencil;
550  bool _labelScaled;
551  bool _labelFixedFontSize;
552  int _labelMinSize;
553  int _labelMaxSize;
554  int _labelsDensity;
555  bool _labelsAreBillboarded;
556  std::string _fontsPath;
557  std::string _texturePath;
558  bool _edgesMaxSizeToNodesSize;
559  bool _feedbackRender;
560  Color _selectionColor;
561  BooleanProperty *_displayFilteringProperty;
562  NumericProperty *_elementOrderingProperty;
563 };
564 
565 /** \brief Class to get the default selection color
566  */
567 class TLP_GL_SCOPE GlDefaultSelectionColorManager {
568 public:
569  static void setManager(GlDefaultSelectionColorManager *);
570  static tlp::Color getDefaultSelectionColor();
571  virtual tlp::Color defaultSelectionColor(bool tulipDefault = false) = 0;
572 
573 private:
574  static GlDefaultSelectionColorManager *manager;
575 };
576 } // namespace tlp
577 
578 #endif // Tulip_GLGRAPH_H
A graph property that maps a boolean value to graph elements.
BooleanProperty * getDisplayFilteringProperty() const
Get the boolean property use to filtering displaying 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. ...
Class to get the default selection color.
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