VTK
vtkRenderedGraphRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkRenderedGraphRepresentation.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
32 #ifndef vtkRenderedGraphRepresentation_h
33 #define vtkRenderedGraphRepresentation_h
34 
35 #include "vtkViewsInfovisModule.h" // For export macro
37 #include "vtkSmartPointer.h" // for SP ivars
38 
39 class vtkActor;
40 class vtkApplyColors;
41 class vtkApplyIcons;
42 class vtkEdgeCenters;
43 class vtkEdgeLayout;
45 class vtkGraphLayout;
47 class vtkGraphToGlyphs;
48 class vtkGraphToPoints;
49 class vtkGraphToPolyData;
50 class vtkIconGlyphFilter;
51 class vtkInformation;
53 class vtkLookupTable;
56 class vtkPolyData;
57 class vtkPolyDataMapper;
60 class vtkRenderView;
61 class vtkScalarBarWidget;
62 class vtkScalarsToColors;
63 class vtkTextProperty;
64 class vtkTexturedActor2D;
66 class vtkVertexDegree;
67 class vtkView;
68 class vtkViewTheme;
69 
70 class VTKVIEWSINFOVIS_EXPORT vtkRenderedGraphRepresentation : public vtkRenderedRepresentation
71 {
72 public:
75  void PrintSelf(ostream& os, vtkIndent indent) override;
76 
77  // ------------------------------------------------------------------------
78  // Vertex labels
79 
80  virtual void SetVertexLabelArrayName(const char* name);
81  virtual const char* GetVertexLabelArrayName();
82  virtual void SetVertexLabelPriorityArrayName(const char* name);
83  virtual const char* GetVertexLabelPriorityArrayName();
84  virtual void SetVertexLabelVisibility(bool b);
85  virtual bool GetVertexLabelVisibility();
86  vtkBooleanMacro(VertexLabelVisibility, bool);
87  virtual void SetVertexLabelTextProperty(vtkTextProperty* p);
88  virtual vtkTextProperty* GetVertexLabelTextProperty();
89  vtkSetStringMacro(VertexHoverArrayName);
90  vtkGetStringMacro(VertexHoverArrayName);
92 
95  vtkSetMacro(HideVertexLabelsOnInteraction, bool)
96  vtkGetMacro(HideVertexLabelsOnInteraction, bool)
97  vtkBooleanMacro(HideVertexLabelsOnInteraction, bool)
99 
100  // ------------------------------------------------------------------------
101  // Edge labels
102 
103  virtual void SetEdgeLabelArrayName(const char* name);
104  virtual const char* GetEdgeLabelArrayName();
105  virtual void SetEdgeLabelPriorityArrayName(const char* name);
106  virtual const char* GetEdgeLabelPriorityArrayName();
107  virtual void SetEdgeLabelVisibility(bool b);
108  virtual bool GetEdgeLabelVisibility();
109  vtkBooleanMacro(EdgeLabelVisibility, bool);
110  virtual void SetEdgeLabelTextProperty(vtkTextProperty* p);
111  virtual vtkTextProperty* GetEdgeLabelTextProperty();
112  vtkSetStringMacro(EdgeHoverArrayName);
113  vtkGetStringMacro(EdgeHoverArrayName);
115 
118  vtkSetMacro(HideEdgeLabelsOnInteraction, bool)
119  vtkGetMacro(HideEdgeLabelsOnInteraction, bool)
120  vtkBooleanMacro(HideEdgeLabelsOnInteraction, bool)
122 
123  // ------------------------------------------------------------------------
124  // Vertex icons
125 
126  virtual void SetVertexIconArrayName(const char* name);
127  virtual const char* GetVertexIconArrayName();
128  virtual void SetVertexIconPriorityArrayName(const char* name);
129  virtual const char* GetVertexIconPriorityArrayName();
130  virtual void SetVertexIconVisibility(bool b);
131  virtual bool GetVertexIconVisibility();
132  vtkBooleanMacro(VertexIconVisibility, bool);
133  virtual void AddVertexIconType(const char* name, int type);
134  virtual void ClearVertexIconTypes();
135  virtual void SetUseVertexIconTypeMap(bool b);
136  virtual bool GetUseVertexIconTypeMap();
137  vtkBooleanMacro(UseVertexIconTypeMap, bool);
138  virtual void SetVertexIconAlignment(int align);
139  virtual int GetVertexIconAlignment();
140  virtual void SetVertexSelectedIcon(int icon);
141  virtual int GetVertexSelectedIcon();
142  virtual void SetVertexDefaultIcon(int icon);
143  virtual int GetVertexDefaultIcon();
144 
146 
156  virtual void SetVertexIconSelectionMode(int mode);
157  virtual int GetVertexIconSelectionMode();
158  virtual void SetVertexIconSelectionModeToSelectedIcon()
159  { this->SetVertexIconSelectionMode(0); }
161  { this->SetVertexIconSelectionMode(1); }
163  { this->SetVertexIconSelectionMode(2); }
165  { this->SetVertexIconSelectionMode(3); }
167 
168  // ------------------------------------------------------------------------
169  // Edge icons
170 
171  virtual void SetEdgeIconArrayName(const char* name);
172  virtual const char* GetEdgeIconArrayName();
173  virtual void SetEdgeIconPriorityArrayName(const char* name);
174  virtual const char* GetEdgeIconPriorityArrayName();
175  virtual void SetEdgeIconVisibility(bool b);
176  virtual bool GetEdgeIconVisibility();
177  vtkBooleanMacro(EdgeIconVisibility, bool);
178  virtual void AddEdgeIconType(const char* name, int type);
179  virtual void ClearEdgeIconTypes();
180  virtual void SetUseEdgeIconTypeMap(bool b);
181  virtual bool GetUseEdgeIconTypeMap();
182  vtkBooleanMacro(UseEdgeIconTypeMap, bool);
183  virtual void SetEdgeIconAlignment(int align);
184  virtual int GetEdgeIconAlignment();
185 
186  // ------------------------------------------------------------------------
187  // Vertex colors
188 
189  virtual void SetColorVerticesByArray(bool b);
190  virtual bool GetColorVerticesByArray();
191  vtkBooleanMacro(ColorVerticesByArray, bool);
192  virtual void SetVertexColorArrayName(const char* name);
193  virtual const char* GetVertexColorArrayName();
194 
195  // ------------------------------------------------------------------------
196  // Edge colors
197 
198  virtual void SetColorEdgesByArray(bool b);
199  virtual bool GetColorEdgesByArray();
200  vtkBooleanMacro(ColorEdgesByArray, bool);
201  virtual void SetEdgeColorArrayName(const char* name);
202  virtual const char* GetEdgeColorArrayName();
203 
204  // ------------------------------------------------------------------------
205  // Enabled vertices
206 
207  virtual void SetEnableVerticesByArray(bool b);
208  virtual bool GetEnableVerticesByArray();
209  vtkBooleanMacro(EnableVerticesByArray, bool);
210  virtual void SetEnabledVerticesArrayName(const char* name);
211  virtual const char* GetEnabledVerticesArrayName();
212 
213  // ------------------------------------------------------------------------
214  // Enabled edges
215 
216  virtual void SetEnableEdgesByArray(bool b);
217  virtual bool GetEnableEdgesByArray();
218  vtkBooleanMacro(EnableEdgesByArray, bool);
219  virtual void SetEnabledEdgesArrayName(const char* name);
220  virtual const char* GetEnabledEdgesArrayName();
221 
222  virtual void SetEdgeVisibility(bool b);
223  virtual bool GetEdgeVisibility();
224  vtkBooleanMacro(EdgeVisibility, bool);
225 
226  void SetEdgeSelection(bool b);
227  bool GetEdgeSelection();
228 
229  // ------------------------------------------------------------------------
230  // Vertex layout strategy
231 
233 
236  virtual void SetLayoutStrategy(vtkGraphLayoutStrategy* strategy);
237  virtual vtkGraphLayoutStrategy* GetLayoutStrategy();
239 
241 
244  virtual void SetLayoutStrategy(const char* name);
245  vtkGetStringMacro(LayoutStrategyName);
247 
252  { this->SetLayoutStrategy("Random"); }
254  { this->SetLayoutStrategy("Force Directed"); }
256  { this->SetLayoutStrategy("Simple 2D"); }
258  { this->SetLayoutStrategy("Clustering 2D"); }
260  { this->SetLayoutStrategy("Community 2D"); }
262  { this->SetLayoutStrategy("Fast 2D"); }
264  { this->SetLayoutStrategy("Pass Through"); }
266  { this->SetLayoutStrategy("Circular"); }
268  { this->SetLayoutStrategy("Tree"); }
270  { this->SetLayoutStrategy("Cosmic Tree"); }
272  { this->SetLayoutStrategy("Cone"); }
274  { this->SetLayoutStrategy("Span Tree"); }
275 
280  virtual void SetLayoutStrategyToAssignCoordinates(
281  const char* xarr, const char* yarr = nullptr, const char* zarr = nullptr);
282 
293  virtual void SetLayoutStrategyToTree(
294  bool radial,
295  double angle = 90,
296  double leafSpacing = 0.9,
297  double logSpacing = 1.0);
298 
309  virtual void SetLayoutStrategyToCosmicTree(
310  const char* nodeSizeArrayName,
311  bool sizeLeafNodesOnly = true,
312  int layoutDepth = 0,
313  vtkIdType layoutRoot = -1);
314 
315  // ------------------------------------------------------------------------
316  // Edge layout strategy
317 
319 
322  virtual void SetEdgeLayoutStrategy(vtkEdgeLayoutStrategy* strategy);
323  virtual vtkEdgeLayoutStrategy* GetEdgeLayoutStrategy();
325  { this->SetEdgeLayoutStrategy("Arc Parallel"); }
327  { this->SetEdgeLayoutStrategy("Pass Through"); }
329 
334  virtual void SetEdgeLayoutStrategyToGeo(double explodeFactor = 0.2);
335 
337 
340  virtual void SetEdgeLayoutStrategy(const char* name);
341  vtkGetStringMacro(EdgeLayoutStrategyName);
343 
344  // ------------------------------------------------------------------------
345  // Miscellaneous
346 
350  void ApplyViewTheme(vtkViewTheme* theme) override;
351 
353 
356  virtual void SetGlyphType(int type);
357  virtual int GetGlyphType();
359 
361 
364  virtual void SetScaling(bool b);
365  virtual bool GetScaling();
366  vtkBooleanMacro(Scaling, bool);
368 
370 
373  virtual void SetScalingArrayName(const char* name);
374  virtual const char* GetScalingArrayName();
376 
378 
381  virtual void SetVertexScalarBarVisibility(bool b);
382  virtual bool GetVertexScalarBarVisibility();
383  virtual void SetEdgeScalarBarVisibility(bool b);
384  virtual bool GetEdgeScalarBarVisibility();
386 
388 
391  virtual vtkScalarBarWidget* GetVertexScalarBar();
392  virtual vtkScalarBarWidget* GetEdgeScalarBar();
394 
398  virtual bool IsLayoutComplete();
399 
403  virtual void UpdateLayout();
404 
408  void ComputeSelectedGraphBounds( double bounds[6] );
409 
410 protected:
412  ~vtkRenderedGraphRepresentation() override;
413 
415 
418  bool AddToView(vtkView* view) override;
419  bool RemoveFromView(vtkView* view) override;
421 
422  void PrepareForRendering(vtkRenderView* view) override;
423 
424  vtkSelection* ConvertSelection(vtkView* view, vtkSelection* sel) override;
425 
427 
431  int RequestData(
432  vtkInformation* request,
433  vtkInformationVector** inputVector,
434  vtkInformationVector* outputVector) override;
435 
437 
469 
472 
473  vtkSetStringMacro(VertexColorArrayNameInternal);
474  vtkGetStringMacro(VertexColorArrayNameInternal);
476 
477  vtkSetStringMacro(EdgeColorArrayNameInternal);
478  vtkGetStringMacro(EdgeColorArrayNameInternal);
480 
481  vtkSetStringMacro(ScalingArrayNameInternal);
482  vtkGetStringMacro(ScalingArrayNameInternal);
484 
485  vtkSetStringMacro(LayoutStrategyName);
486  char* LayoutStrategyName;
487  vtkSetStringMacro(EdgeLayoutStrategyName);
491 
493 
494 private:
496  void operator=(const vtkRenderedGraphRepresentation&) = delete;
497 };
498 
499 #endif
500 
virtual void ApplyViewTheme(vtkViewTheme *vtkNotUsed(theme))
Apply a theme to this representation.
vtkSmartPointer< vtkPolyDataMapper > OutlineMapper
Internal filter classes.
vtkSmartPointer< vtkGraphToPoints > VertexIconPoints
Internal filter classes.
virtual void SetVertexIconSelectionModeToIgnoreSelection()
Set the mode to one of.
virtual vtkSelection * ConvertSelection(vtkView *view, vtkSelection *selection)
Convert the selection to a type appropriate for sharing with other representations through vtkAnnotat...
vtkSmartPointer< vtkGraphToPolyData > GraphToPoly
Internal filter classes.
vtkSmartPointer< vtkScalarBarWidget > VertexScalarBar
Internal filter classes.
void SetEdgeLayoutStrategyToPassThrough()
Set/get the graph layout strategy.
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
actor that draws 2D data with texture support
vtkSmartPointer< vtkApplyIcons > ApplyVertexIcons
Internal filter classes.
vtkSmartPointer< vtkPointSetToLabelHierarchy > VertexLabelHierarchy
Internal filter classes.
Store vtkAlgorithm input/output information.
Filter that generates a polydata consisting of quads with texture coordinates referring to a set of i...
vtkSmartPointer< vtkGraphToGlyphs > VertexGlyph
Internal filter classes.
vtkSmartPointer< vtkActor > VertexActor
Internal filter classes.
map scalar values into colors via a lookup table
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Subclasses should override this to connect inputs to the internal pipeline as necessary.
vtkSmartPointer< vtkIconGlyphFilter > VertexIconGlyph
Internal filter classes.
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:63
Adds an attribute array with the degree of each vertex.
vtkSmartPointer< vtkScalarBarWidget > EdgeScalarBar
Internal filter classes.
int vtkIdType
Definition: vtkType.h:347
virtual bool AddToView(vtkView *vtkNotUsed(view))
Adds the representation to the view.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkSmartPointer< vtkApplyColors > ApplyColors
Internal filter classes.
static vtkRenderedRepresentation * New()
abstract superclass for all graph layout strategies
vtkSmartPointer< vtkPolyDataMapper > EdgeMapper
Internal filter classes.
vtkSmartPointer< vtkVertexDegree > VertexDegree
Internal filter classes.
convert a vtkGraph to vtkPolyData
Superclass for mapping scalar values to colors.
vtkSmartPointer< vtkEdgeLayout > EdgeLayout
Internal filter classes.
generate points at center of edges
Sets theme colors for a graphical view.
Definition: vtkViewTheme.h:48
vtkSmartPointer< vtkTexturedActor2D > VertexIconActor
Internal filter classes.
vtkSmartPointer< vtkTransformCoordinateSystems > VertexIconTransform
Internal filter classes.
The superclass for all views.
Definition: vtkView.h:60
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkSmartPointer< vtkPointSetToLabelHierarchy > EdgeLabelHierarchy
Internal filter classes.
vtkSmartPointer< vtkGraphLayout > Layout
Internal filter classes.
virtual bool RemoveFromView(vtkView *vtkNotUsed(view))
Removes the representation to the view.
layout a graph in 2 or 3 dimensions
virtual void PrepareForRendering(vtkRenderView *view)
The view will call this method before every render.
vtkSmartPointer< vtkPolyData > EmptyPolyData
Internal filter classes.
void SetLayoutStrategyToRandom()
Set predefined layout strategies.
Perturbs vertices that are coincident.
represent text properties.
transform points into different coordinate systems
build a label hierarchy for a graph or point set.
vtkSmartPointer< vtkRemoveHiddenData > RemoveHiddenGraph
Internal filter classes.
map vtkPolyData to graphics primitives
vtkSmartPointer< vtkActor > OutlineActor
Internal filter classes.
vtkSmartPointer< vtkActor > EdgeActor
Internal filter classes.
vtkSmartPointer< vtkGraphToPoints > GraphToPoints
Internal filter classes.
A view containing a renderer.
Definition: vtkRenderView.h:61
abstract superclass for all edge layout strategies
vtkSmartPointer< vtkEdgeCenters > EdgeCenters
Internal filter classes.
layout graph edges
Definition: vtkEdgeLayout.h:41
convert a vtkGraph a set of points.
Store zero or more vtkInformation instances.
apply colors to a data set.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSmartPointer< vtkPolyDataMapper > VertexMapper
Internal filter classes.
vtkSmartPointer< vtkGraphToGlyphs > OutlineGlyph
Internal filter classes.
vtkSmartPointer< vtkPolyDataMapper2D > VertexIconMapper
Internal filter classes.
virtual void SetVertexIconSelectionModeToSelectedOffset()
Set the mode to one of.
create glyphs for graph vertices
virtual vtkUnicodeString GetHoverTextInternal(vtkSelection *)
Subclasses may override this method to generate the hover text.
virtual void SetVertexIconSelectionModeToAnnotationIcon()
Set the mode to one of.
apply icons to a data set.
Definition: vtkApplyIcons.h:70
vtkSmartPointer< vtkPerturbCoincidentVertices > Coincident
Internal filter classes.
draw vtkPolyData onto the image plane
String class that stores Unicode text.
2D widget for manipulating a scalar bar
Removes the rows/edges/vertices of input data flagged by ann.
void SetEdgeLayoutStrategyToArcParallel()
Set/get the graph layout strategy.