VTK  9.2.6
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 -------------------------------------------------------------------------*/
38 #ifndef vtkRenderedGraphRepresentation_h
39 #define vtkRenderedGraphRepresentation_h
40 
42 #include "vtkSmartPointer.h" // for SP ivars
43 #include "vtkViewsInfovisModule.h" // For export macro
44 
45 class vtkActor;
46 class vtkApplyColors;
47 class vtkApplyIcons;
48 class vtkEdgeCenters;
49 class vtkEdgeLayout;
51 class vtkGraphLayout;
53 class vtkGraphToGlyphs;
54 class vtkGraphToPoints;
55 class vtkGraphToPolyData;
56 class vtkIconGlyphFilter;
57 class vtkInformation;
59 class vtkLookupTable;
62 class vtkPolyData;
63 class vtkPolyDataMapper;
66 class vtkRenderView;
67 class vtkScalarBarWidget;
68 class vtkScalarsToColors;
69 class vtkTextProperty;
70 class vtkTexturedActor2D;
72 class vtkVertexDegree;
73 class vtkView;
74 class vtkViewTheme;
75 
76 class VTKVIEWSINFOVIS_EXPORT vtkRenderedGraphRepresentation : public vtkRenderedRepresentation
77 {
78 public:
81  void PrintSelf(ostream& os, vtkIndent indent) override;
82 
83  // ------------------------------------------------------------------------
84  // Vertex labels
85 
86  virtual void SetVertexLabelArrayName(const char* name);
87  virtual const char* GetVertexLabelArrayName();
88  virtual void SetVertexLabelPriorityArrayName(const char* name);
89  virtual const char* GetVertexLabelPriorityArrayName();
90  virtual void SetVertexLabelVisibility(bool b);
91  virtual bool GetVertexLabelVisibility();
92  vtkBooleanMacro(VertexLabelVisibility, bool);
95  vtkSetStringMacro(VertexHoverArrayName);
96  vtkGetStringMacro(VertexHoverArrayName);
98 
101  vtkSetMacro(HideVertexLabelsOnInteraction, bool);
102  vtkGetMacro(HideVertexLabelsOnInteraction, bool);
103  vtkBooleanMacro(HideVertexLabelsOnInteraction, bool);
105 
106  // ------------------------------------------------------------------------
107  // Edge labels
108 
109  virtual void SetEdgeLabelArrayName(const char* name);
110  virtual const char* GetEdgeLabelArrayName();
111  virtual void SetEdgeLabelPriorityArrayName(const char* name);
112  virtual const char* GetEdgeLabelPriorityArrayName();
113  virtual void SetEdgeLabelVisibility(bool b);
114  virtual bool GetEdgeLabelVisibility();
115  vtkBooleanMacro(EdgeLabelVisibility, bool);
118  vtkSetStringMacro(EdgeHoverArrayName);
119  vtkGetStringMacro(EdgeHoverArrayName);
121 
124  vtkSetMacro(HideEdgeLabelsOnInteraction, bool);
125  vtkGetMacro(HideEdgeLabelsOnInteraction, bool);
126  vtkBooleanMacro(HideEdgeLabelsOnInteraction, bool);
128 
129  // ------------------------------------------------------------------------
130  // Vertex icons
131 
132  virtual void SetVertexIconArrayName(const char* name);
133  virtual const char* GetVertexIconArrayName();
134  virtual void SetVertexIconPriorityArrayName(const char* name);
135  virtual const char* GetVertexIconPriorityArrayName();
136  virtual void SetVertexIconVisibility(bool b);
137  virtual bool GetVertexIconVisibility();
138  vtkBooleanMacro(VertexIconVisibility, bool);
139  virtual void AddVertexIconType(const char* name, int type);
140  virtual void ClearVertexIconTypes();
141  virtual void SetUseVertexIconTypeMap(bool b);
142  virtual bool GetUseVertexIconTypeMap();
143  vtkBooleanMacro(UseVertexIconTypeMap, bool);
144  virtual void SetVertexIconAlignment(int align);
145  virtual int GetVertexIconAlignment();
146  virtual void SetVertexSelectedIcon(int icon);
147  virtual int GetVertexSelectedIcon();
148  virtual void SetVertexDefaultIcon(int icon);
149  virtual int GetVertexDefaultIcon();
150 
152 
162  virtual void SetVertexIconSelectionMode(int mode);
164  virtual void SetVertexIconSelectionModeToSelectedIcon() { this->SetVertexIconSelectionMode(0); }
165  virtual void SetVertexIconSelectionModeToSelectedOffset() { this->SetVertexIconSelectionMode(1); }
166  virtual void SetVertexIconSelectionModeToAnnotationIcon() { this->SetVertexIconSelectionMode(2); }
168  {
169  this->SetVertexIconSelectionMode(3);
170  }
172 
173  // ------------------------------------------------------------------------
174  // Edge icons
175 
176  virtual void SetEdgeIconArrayName(const char* name);
177  virtual const char* GetEdgeIconArrayName();
178  virtual void SetEdgeIconPriorityArrayName(const char* name);
179  virtual const char* GetEdgeIconPriorityArrayName();
180  virtual void SetEdgeIconVisibility(bool b);
181  virtual bool GetEdgeIconVisibility();
182  vtkBooleanMacro(EdgeIconVisibility, bool);
183  virtual void AddEdgeIconType(const char* name, int type);
184  virtual void ClearEdgeIconTypes();
185  virtual void SetUseEdgeIconTypeMap(bool b);
186  virtual bool GetUseEdgeIconTypeMap();
187  vtkBooleanMacro(UseEdgeIconTypeMap, bool);
188  virtual void SetEdgeIconAlignment(int align);
189  virtual int GetEdgeIconAlignment();
190 
191  // ------------------------------------------------------------------------
192  // Vertex colors
193 
194  virtual void SetColorVerticesByArray(bool b);
195  virtual bool GetColorVerticesByArray();
196  vtkBooleanMacro(ColorVerticesByArray, bool);
197  virtual void SetVertexColorArrayName(const char* name);
198  virtual const char* GetVertexColorArrayName();
199 
200  // ------------------------------------------------------------------------
201  // Edge colors
202 
203  virtual void SetColorEdgesByArray(bool b);
204  virtual bool GetColorEdgesByArray();
205  vtkBooleanMacro(ColorEdgesByArray, bool);
206  virtual void SetEdgeColorArrayName(const char* name);
207  virtual const char* GetEdgeColorArrayName();
208 
209  // ------------------------------------------------------------------------
210  // Enabled vertices
211 
212  virtual void SetEnableVerticesByArray(bool b);
213  virtual bool GetEnableVerticesByArray();
214  vtkBooleanMacro(EnableVerticesByArray, bool);
215  virtual void SetEnabledVerticesArrayName(const char* name);
216  virtual const char* GetEnabledVerticesArrayName();
217 
218  // ------------------------------------------------------------------------
219  // Enabled edges
220 
221  virtual void SetEnableEdgesByArray(bool b);
222  virtual bool GetEnableEdgesByArray();
223  vtkBooleanMacro(EnableEdgesByArray, bool);
224  virtual void SetEnabledEdgesArrayName(const char* name);
225  virtual const char* GetEnabledEdgesArrayName();
226 
227  virtual void SetEdgeVisibility(bool b);
228  virtual bool GetEdgeVisibility();
229  vtkBooleanMacro(EdgeVisibility, bool);
230 
231  void SetEdgeSelection(bool b);
233 
234  // ------------------------------------------------------------------------
235  // Vertex layout strategy
236 
238 
241  virtual void SetLayoutStrategy(vtkGraphLayoutStrategy* strategy);
244 
246 
249  virtual void SetLayoutStrategy(const char* name);
250  vtkGetStringMacro(LayoutStrategyName);
252 
256  void SetLayoutStrategyToRandom() { this->SetLayoutStrategy("Random"); }
257  void SetLayoutStrategyToForceDirected() { this->SetLayoutStrategy("Force Directed"); }
258  void SetLayoutStrategyToSimple2D() { this->SetLayoutStrategy("Simple 2D"); }
259  void SetLayoutStrategyToClustering2D() { this->SetLayoutStrategy("Clustering 2D"); }
260  void SetLayoutStrategyToCommunity2D() { this->SetLayoutStrategy("Community 2D"); }
261  void SetLayoutStrategyToFast2D() { this->SetLayoutStrategy("Fast 2D"); }
262  void SetLayoutStrategyToPassThrough() { this->SetLayoutStrategy("Pass Through"); }
263  void SetLayoutStrategyToCircular() { this->SetLayoutStrategy("Circular"); }
264  void SetLayoutStrategyToTree() { this->SetLayoutStrategy("Tree"); }
265  void SetLayoutStrategyToCosmicTree() { this->SetLayoutStrategy("Cosmic Tree"); }
266  void SetLayoutStrategyToCone() { this->SetLayoutStrategy("Cone"); }
267  void SetLayoutStrategyToSpanTree() { this->SetLayoutStrategy("Span Tree"); }
268 
274  const char* xarr, const char* yarr = nullptr, const char* zarr = nullptr);
275 
287  bool radial, double angle = 90, double leafSpacing = 0.9, double logSpacing = 1.0);
288 
299  virtual void SetLayoutStrategyToCosmicTree(const char* nodeSizeArrayName,
300  bool sizeLeafNodesOnly = true, int layoutDepth = 0, vtkIdType layoutRoot = -1);
301 
302  // ------------------------------------------------------------------------
303  // Edge layout strategy
304 
306 
311  void SetEdgeLayoutStrategyToArcParallel() { this->SetEdgeLayoutStrategy("Arc Parallel"); }
312  void SetEdgeLayoutStrategyToPassThrough() { this->SetEdgeLayoutStrategy("Pass Through"); }
314 
319  virtual void SetEdgeLayoutStrategyToGeo(double explodeFactor = 0.2);
320 
322 
325  virtual void SetEdgeLayoutStrategy(const char* name);
326  vtkGetStringMacro(EdgeLayoutStrategyName);
328 
329  // ------------------------------------------------------------------------
330  // Miscellaneous
331 
335  void ApplyViewTheme(vtkViewTheme* theme) override;
336 
338 
341  virtual void SetGlyphType(int type);
342  virtual int GetGlyphType();
344 
346 
349  virtual void SetScaling(bool b);
350  virtual bool GetScaling();
351  vtkBooleanMacro(Scaling, bool);
353 
355 
358  virtual void SetScalingArrayName(const char* name);
359  virtual const char* GetScalingArrayName();
361 
363 
366  virtual void SetVertexScalarBarVisibility(bool b);
368  virtual void SetEdgeScalarBarVisibility(bool b);
371 
373 
379 
383  virtual bool IsLayoutComplete();
384 
388  virtual void UpdateLayout();
389 
393  void ComputeSelectedGraphBounds(double bounds[6]);
394 
395 protected:
398 
400 
403  bool AddToView(vtkView* view) override;
404  bool RemoveFromView(vtkView* view) override;
406 
407  void PrepareForRendering(vtkRenderView* view) override;
408 
410 
412 
416  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
417  vtkInformationVector* outputVector) override;
418 
420 
452 
455 
456  vtkSetStringMacro(VertexColorArrayNameInternal);
457  vtkGetStringMacro(VertexColorArrayNameInternal);
459 
460  vtkSetStringMacro(EdgeColorArrayNameInternal);
461  vtkGetStringMacro(EdgeColorArrayNameInternal);
463 
464  vtkSetStringMacro(ScalingArrayNameInternal);
465  vtkGetStringMacro(ScalingArrayNameInternal);
467 
468  vtkSetStringMacro(LayoutStrategyName);
470  vtkSetStringMacro(EdgeLayoutStrategyName);
474 
476 
477 private:
479  void operator=(const vtkRenderedGraphRepresentation&) = delete;
480 };
481 
482 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:61
apply colors to a data set.
apply icons to a data set.
Definition: vtkApplyIcons.h:71
generate points at center of edges
abstract superclass for all edge layout strategies
layout graph edges
Definition: vtkEdgeLayout.h:42
abstract superclass for all graph layout strategies
layout a graph in 2 or 3 dimensions
create glyphs for graph vertices
convert a vtkGraph a set of points.
convert a vtkGraph to vtkPolyData
Filter that generates a polydata consisting of quads with texture coordinates referring to a set of i...
a simple class to control print indentation
Definition: vtkIndent.h:49
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
map scalar values into colors via a lookup table
Perturbs vertices that are coincident.
build a label hierarchy for a graph or point set.
draw vtkPolyData onto the image plane
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:100
Removes the rows/edges/vertices of input data flagged by ann.
A view containing a renderer.
Definition: vtkRenderView.h:74
bool AddToView(vtkView *view) override
Called by the view to add/remove this representation.
virtual void SetEdgeIconVisibility(bool b)
virtual void SetEnabledEdgesArrayName(const char *name)
virtual void SetEdgeLayoutStrategy(vtkEdgeLayoutStrategy *strategy)
Set/get the graph layout strategy.
virtual void SetLayoutStrategyToTree(bool radial, double angle=90, double leafSpacing=0.9, double logSpacing=1.0)
Set the layout strategy to a tree layout.
virtual const char * GetVertexLabelArrayName()
virtual bool GetScaling()
Set whether to scale vertex glyphs.
virtual void ClearVertexIconTypes()
vtkSmartPointer< vtkActor > OutlineActor
Internal filter classes.
void PrepareForRendering(vtkRenderView *view) override
The view will call this method before every render.
vtkSmartPointer< vtkApplyColors > ApplyColors
Internal filter classes.
virtual void SetScaling(bool b)
Set whether to scale vertex glyphs.
virtual void SetColorEdgesByArray(bool b)
virtual bool GetColorEdgesByArray()
virtual const char * GetVertexColorArrayName()
virtual void SetLayoutStrategyToCosmicTree(const char *nodeSizeArrayName, bool sizeLeafNodesOnly=true, int layoutDepth=0, vtkIdType layoutRoot=-1)
Set the layout strategy to a cosmic tree layout.
virtual void SetLayoutStrategy(const char *name)
Get/set the layout strategy by name.
virtual void SetEdgeLayoutStrategy(const char *name)
Set the edge layout strategy by name.
vtkSmartPointer< vtkActor > VertexActor
Internal filter classes.
virtual void SetVertexLabelTextProperty(vtkTextProperty *p)
virtual vtkTextProperty * GetEdgeLabelTextProperty()
void ApplyViewTheme(vtkViewTheme *theme) override
Apply a theme to this representation.
vtkSmartPointer< vtkTexturedActor2D > VertexIconActor
Internal filter classes.
virtual int GetVertexIconSelectionMode()
Set the mode to one of.
vtkSmartPointer< vtkTransformCoordinateSystems > VertexIconTransform
Internal filter classes.
virtual bool GetColorVerticesByArray()
virtual void SetEnableEdgesByArray(bool b)
virtual void SetVertexLabelArrayName(const char *name)
virtual void SetEdgeVisibility(bool b)
std::string GetHoverStringInternal(vtkSelection *sel) override
Subclasses may override this method to generate the hover text.
vtkSmartPointer< vtkGraphLayout > Layout
Internal filter classes.
virtual const char * GetEdgeIconPriorityArrayName()
virtual bool GetEdgeLabelVisibility()
virtual const char * GetEnabledEdgesArrayName()
vtkSmartPointer< vtkScalarBarWidget > EdgeScalarBar
Internal filter classes.
virtual int GetGlyphType()
Set the graph vertex glyph type.
vtkSmartPointer< vtkGraphToPoints > VertexIconPoints
Internal filter classes.
virtual bool GetEnableEdgesByArray()
vtkSmartPointer< vtkPointSetToLabelHierarchy > EdgeLabelHierarchy
Internal filter classes.
virtual bool GetEdgeIconVisibility()
virtual void SetVertexIconSelectionMode(int mode)
Set the mode to one of.
virtual bool GetEnableVerticesByArray()
virtual int GetVertexIconAlignment()
vtkSmartPointer< vtkApplyIcons > ApplyVertexIcons
Internal filter classes.
virtual void SetEnabledVerticesArrayName(const char *name)
virtual void AddEdgeIconType(const char *name, int type)
virtual void SetVertexDefaultIcon(int icon)
virtual vtkTextProperty * GetVertexLabelTextProperty()
virtual void AddVertexIconType(const char *name, int type)
vtkSmartPointer< vtkPolyData > EmptyPolyData
Internal filter classes.
vtkSmartPointer< vtkPolyDataMapper2D > VertexIconMapper
Internal filter classes.
virtual const char * GetEdgeIconArrayName()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual const char * GetEnabledVerticesArrayName()
vtkSmartPointer< vtkEdgeCenters > EdgeCenters
Internal filter classes.
virtual void UpdateLayout()
Performs another iteration on the graph layout.
vtkSmartPointer< vtkPointSetToLabelHierarchy > VertexLabelHierarchy
Internal filter classes.
virtual const char * GetEdgeLabelPriorityArrayName()
virtual vtkScalarBarWidget * GetVertexScalarBar()
Obtain the scalar bar widget used to draw a legend for the vertices/edges.
virtual void SetVertexIconSelectionModeToAnnotationIcon()
Set the mode to one of.
virtual void SetEdgeLabelTextProperty(vtkTextProperty *p)
virtual void SetScalingArrayName(const char *name)
Set the glyph scaling array name.
void SetEdgeLayoutStrategyToPassThrough()
Set/get the graph layout strategy.
virtual void SetVertexScalarBarVisibility(bool b)
Vertex/edge scalar bar visibility.
void SetLayoutStrategyToRandom()
Set predefined layout strategies.
virtual void SetLayoutStrategy(vtkGraphLayoutStrategy *strategy)
Set/get the graph layout strategy.
virtual const char * GetVertexIconArrayName()
virtual void SetVertexIconSelectionModeToIgnoreSelection()
Set the mode to one of.
virtual bool IsLayoutComplete()
Whether the current graph layout is complete.
virtual const char * GetScalingArrayName()
Set the glyph scaling array name.
virtual void SetEdgeIconAlignment(int align)
virtual void SetVertexIconVisibility(bool b)
virtual void SetVertexSelectedIcon(int icon)
vtkSmartPointer< vtkEdgeLayout > EdgeLayout
Internal filter classes.
bool RemoveFromView(vtkView *view) override
Called by the view to add/remove this representation.
virtual void SetEdgeIconArrayName(const char *name)
virtual const char * GetVertexIconPriorityArrayName()
static vtkRenderedGraphRepresentation * New()
virtual void SetVertexIconSelectionModeToSelectedOffset()
Set the mode to one of.
virtual void SetEdgeColorArrayName(const char *name)
virtual void SetColorVerticesByArray(bool b)
virtual const char * GetVertexLabelPriorityArrayName()
virtual vtkScalarBarWidget * GetEdgeScalarBar()
Obtain the scalar bar widget used to draw a legend for the vertices/edges.
vtkSmartPointer< vtkRemoveHiddenData > RemoveHiddenGraph
Internal filter classes.
virtual void SetUseVertexIconTypeMap(bool b)
virtual void SetVertexIconAlignment(int align)
virtual bool GetVertexLabelVisibility()
vtkSmartPointer< vtkPolyDataMapper > VertexMapper
Internal filter classes.
vtkSmartPointer< vtkGraphToGlyphs > VertexGlyph
Internal filter classes.
virtual bool GetUseVertexIconTypeMap()
vtkSmartPointer< vtkPolyDataMapper > EdgeMapper
Internal filter classes.
virtual void SetEdgeLayoutStrategyToGeo(double explodeFactor=0.2)
Set the edge layout strategy to a geospatial arced strategy appropriate for vtkGeoView.
vtkSmartPointer< vtkPerturbCoincidentVertices > Coincident
Internal filter classes.
virtual void SetVertexColorArrayName(const char *name)
virtual void SetEdgeLabelPriorityArrayName(const char *name)
virtual bool GetUseEdgeIconTypeMap()
virtual void SetEdgeIconPriorityArrayName(const char *name)
virtual void SetVertexIconSelectionModeToSelectedIcon()
Set the mode to one of.
virtual void SetVertexLabelVisibility(bool b)
virtual void SetEnableVerticesByArray(bool b)
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Connect inputs to internal pipeline.
vtkSmartPointer< vtkGraphToPoints > GraphToPoints
Internal filter classes.
virtual void SetUseEdgeIconTypeMap(bool b)
vtkSelection * ConvertSelection(vtkView *view, vtkSelection *sel) override
Convert the selection to a type appropriate for sharing with other representations through vtkAnnotat...
virtual const char * GetEdgeLabelArrayName()
virtual vtkGraphLayoutStrategy * GetLayoutStrategy()
Set/get the graph layout strategy.
virtual void SetVertexIconPriorityArrayName(const char *name)
virtual const char * GetEdgeColorArrayName()
virtual void SetGlyphType(int type)
Set the graph vertex glyph type.
virtual void SetVertexLabelPriorityArrayName(const char *name)
virtual void SetEdgeLabelArrayName(const char *name)
vtkSmartPointer< vtkActor > EdgeActor
Internal filter classes.
vtkSmartPointer< vtkScalarBarWidget > VertexScalarBar
Internal filter classes.
void SetEdgeLayoutStrategyToArcParallel()
Set/get the graph layout strategy.
~vtkRenderedGraphRepresentation() override
vtkSmartPointer< vtkGraphToGlyphs > OutlineGlyph
Internal filter classes.
virtual void SetLayoutStrategyToAssignCoordinates(const char *xarr, const char *yarr=nullptr, const char *zarr=nullptr)
Set the layout strategy to use coordinates from arrays.
vtkSmartPointer< vtkPolyDataMapper > OutlineMapper
Internal filter classes.
virtual void SetVertexIconArrayName(const char *name)
vtkSmartPointer< vtkVertexDegree > VertexDegree
Internal filter classes.
vtkSmartPointer< vtkGraphToPolyData > GraphToPoly
Internal filter classes.
virtual void SetEdgeScalarBarVisibility(bool b)
Vertex/edge scalar bar visibility.
virtual bool GetEdgeScalarBarVisibility()
Vertex/edge scalar bar visibility.
vtkSmartPointer< vtkIconGlyphFilter > VertexIconGlyph
Internal filter classes.
virtual vtkEdgeLayoutStrategy * GetEdgeLayoutStrategy()
Set/get the graph layout strategy.
void ComputeSelectedGraphBounds(double bounds[6])
Compute the bounding box of the selected subgraph.
virtual bool GetVertexScalarBarVisibility()
Vertex/edge scalar bar visibility.
virtual void SetEdgeLabelVisibility(bool b)
virtual bool GetVertexIconVisibility()
2D widget for manipulating a scalar bar
Superclass for mapping scalar values to colors.
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:69
represent text properties.
actor that draws 2D data with texture support
transform points into different coordinate systems
Adds an attribute array with the degree of each vertex.
Sets theme colors for a graphical view.
Definition: vtkViewTheme.h:58
The superclass for all views.
Definition: vtkView.h:64
@ mode
Definition: vtkX3D.h:253
@ type
Definition: vtkX3D.h:522
@ name
Definition: vtkX3D.h:225
@ string
Definition: vtkX3D.h:496
int vtkIdType
Definition: vtkType.h:332