VTK  9.3.1
vtkRenderedGraphRepresentation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
13 #ifndef vtkRenderedGraphRepresentation_h
14 #define vtkRenderedGraphRepresentation_h
15 
17 #include "vtkSmartPointer.h" // for SP ivars
18 #include "vtkViewsInfovisModule.h" // For export macro
19 
20 VTK_ABI_NAMESPACE_BEGIN
21 class vtkActor;
22 class vtkApplyColors;
23 class vtkApplyIcons;
24 class vtkEdgeCenters;
25 class vtkEdgeLayout;
27 class vtkGraphLayout;
29 class vtkGraphToGlyphs;
30 class vtkGraphToPoints;
31 class vtkGraphToPolyData;
32 class vtkIconGlyphFilter;
33 class vtkInformation;
35 class vtkLookupTable;
38 class vtkPolyData;
39 class vtkPolyDataMapper;
42 class vtkRenderView;
43 class vtkScalarBarWidget;
44 class vtkScalarsToColors;
45 class vtkTextProperty;
46 class vtkTexturedActor2D;
48 class vtkVertexDegree;
49 class vtkView;
50 class vtkViewTheme;
51 
52 class VTKVIEWSINFOVIS_EXPORT vtkRenderedGraphRepresentation : public vtkRenderedRepresentation
53 {
54 public:
57  void PrintSelf(ostream& os, vtkIndent indent) override;
58 
59  // ------------------------------------------------------------------------
60  // Vertex labels
61 
62  virtual void SetVertexLabelArrayName(const char* name);
63  virtual const char* GetVertexLabelArrayName();
64  virtual void SetVertexLabelPriorityArrayName(const char* name);
65  virtual const char* GetVertexLabelPriorityArrayName();
66  virtual void SetVertexLabelVisibility(bool b);
67  virtual bool GetVertexLabelVisibility();
68  vtkBooleanMacro(VertexLabelVisibility, bool);
69  virtual void SetVertexLabelTextProperty(vtkTextProperty* p);
70  virtual vtkTextProperty* GetVertexLabelTextProperty();
71  vtkSetStringMacro(VertexHoverArrayName);
72  vtkGetStringMacro(VertexHoverArrayName);
74 
77  vtkSetMacro(HideVertexLabelsOnInteraction, bool);
78  vtkGetMacro(HideVertexLabelsOnInteraction, bool);
79  vtkBooleanMacro(HideVertexLabelsOnInteraction, bool);
81 
82  // ------------------------------------------------------------------------
83  // Edge labels
84 
85  virtual void SetEdgeLabelArrayName(const char* name);
86  virtual const char* GetEdgeLabelArrayName();
87  virtual void SetEdgeLabelPriorityArrayName(const char* name);
88  virtual const char* GetEdgeLabelPriorityArrayName();
89  virtual void SetEdgeLabelVisibility(bool b);
90  virtual bool GetEdgeLabelVisibility();
91  vtkBooleanMacro(EdgeLabelVisibility, bool);
92  virtual void SetEdgeLabelTextProperty(vtkTextProperty* p);
93  virtual vtkTextProperty* GetEdgeLabelTextProperty();
94  vtkSetStringMacro(EdgeHoverArrayName);
95  vtkGetStringMacro(EdgeHoverArrayName);
97 
100  vtkSetMacro(HideEdgeLabelsOnInteraction, bool);
101  vtkGetMacro(HideEdgeLabelsOnInteraction, bool);
102  vtkBooleanMacro(HideEdgeLabelsOnInteraction, bool);
104 
105  // ------------------------------------------------------------------------
106  // Vertex icons
107 
108  virtual void SetVertexIconArrayName(const char* name);
109  virtual const char* GetVertexIconArrayName();
110  virtual void SetVertexIconPriorityArrayName(const char* name);
111  virtual const char* GetVertexIconPriorityArrayName();
112  virtual void SetVertexIconVisibility(bool b);
113  virtual bool GetVertexIconVisibility();
114  vtkBooleanMacro(VertexIconVisibility, bool);
115  virtual void AddVertexIconType(const char* name, int type);
116  virtual void ClearVertexIconTypes();
117  virtual void SetUseVertexIconTypeMap(bool b);
118  virtual bool GetUseVertexIconTypeMap();
119  vtkBooleanMacro(UseVertexIconTypeMap, bool);
120  virtual void SetVertexIconAlignment(int align);
121  virtual int GetVertexIconAlignment();
122  virtual void SetVertexSelectedIcon(int icon);
123  virtual int GetVertexSelectedIcon();
124  virtual void SetVertexDefaultIcon(int icon);
125  virtual int GetVertexDefaultIcon();
126 
128 
138  virtual void SetVertexIconSelectionMode(int mode);
139  virtual int GetVertexIconSelectionMode();
140  virtual void SetVertexIconSelectionModeToSelectedIcon() { this->SetVertexIconSelectionMode(0); }
141  virtual void SetVertexIconSelectionModeToSelectedOffset() { this->SetVertexIconSelectionMode(1); }
142  virtual void SetVertexIconSelectionModeToAnnotationIcon() { this->SetVertexIconSelectionMode(2); }
144  {
145  this->SetVertexIconSelectionMode(3);
146  }
148 
149  // ------------------------------------------------------------------------
150  // Edge icons
151 
152  virtual void SetEdgeIconArrayName(const char* name);
153  virtual const char* GetEdgeIconArrayName();
154  virtual void SetEdgeIconPriorityArrayName(const char* name);
155  virtual const char* GetEdgeIconPriorityArrayName();
156  virtual void SetEdgeIconVisibility(bool b);
157  virtual bool GetEdgeIconVisibility();
158  vtkBooleanMacro(EdgeIconVisibility, bool);
159  virtual void AddEdgeIconType(const char* name, int type);
160  virtual void ClearEdgeIconTypes();
161  virtual void SetUseEdgeIconTypeMap(bool b);
162  virtual bool GetUseEdgeIconTypeMap();
163  vtkBooleanMacro(UseEdgeIconTypeMap, bool);
164  virtual void SetEdgeIconAlignment(int align);
165  virtual int GetEdgeIconAlignment();
166 
167  // ------------------------------------------------------------------------
168  // Vertex colors
169 
170  virtual void SetColorVerticesByArray(bool b);
171  virtual bool GetColorVerticesByArray();
172  vtkBooleanMacro(ColorVerticesByArray, bool);
173  virtual void SetVertexColorArrayName(const char* name);
174  virtual const char* GetVertexColorArrayName();
175 
176  // ------------------------------------------------------------------------
177  // Edge colors
178 
179  virtual void SetColorEdgesByArray(bool b);
180  virtual bool GetColorEdgesByArray();
181  vtkBooleanMacro(ColorEdgesByArray, bool);
182  virtual void SetEdgeColorArrayName(const char* name);
183  virtual const char* GetEdgeColorArrayName();
184 
185  // ------------------------------------------------------------------------
186  // Enabled vertices
187 
188  virtual void SetEnableVerticesByArray(bool b);
189  virtual bool GetEnableVerticesByArray();
190  vtkBooleanMacro(EnableVerticesByArray, bool);
191  virtual void SetEnabledVerticesArrayName(const char* name);
192  virtual const char* GetEnabledVerticesArrayName();
193 
194  // ------------------------------------------------------------------------
195  // Enabled edges
196 
197  virtual void SetEnableEdgesByArray(bool b);
198  virtual bool GetEnableEdgesByArray();
199  vtkBooleanMacro(EnableEdgesByArray, bool);
200  virtual void SetEnabledEdgesArrayName(const char* name);
201  virtual const char* GetEnabledEdgesArrayName();
202 
203  virtual void SetEdgeVisibility(bool b);
204  virtual bool GetEdgeVisibility();
205  vtkBooleanMacro(EdgeVisibility, bool);
206 
207  void SetEdgeSelection(bool b);
208  bool GetEdgeSelection();
209 
210  // ------------------------------------------------------------------------
211  // Vertex layout strategy
212 
214 
217  virtual void SetLayoutStrategy(vtkGraphLayoutStrategy* strategy);
218  virtual vtkGraphLayoutStrategy* GetLayoutStrategy();
220 
222 
225  virtual void SetLayoutStrategy(const char* name);
226  vtkGetStringMacro(LayoutStrategyName);
228 
232  void SetLayoutStrategyToRandom() { this->SetLayoutStrategy("Random"); }
233  void SetLayoutStrategyToForceDirected() { this->SetLayoutStrategy("Force Directed"); }
234  void SetLayoutStrategyToSimple2D() { this->SetLayoutStrategy("Simple 2D"); }
235  void SetLayoutStrategyToClustering2D() { this->SetLayoutStrategy("Clustering 2D"); }
236  void SetLayoutStrategyToCommunity2D() { this->SetLayoutStrategy("Community 2D"); }
237  void SetLayoutStrategyToFast2D() { this->SetLayoutStrategy("Fast 2D"); }
238  void SetLayoutStrategyToPassThrough() { this->SetLayoutStrategy("Pass Through"); }
239  void SetLayoutStrategyToCircular() { this->SetLayoutStrategy("Circular"); }
240  void SetLayoutStrategyToTree() { this->SetLayoutStrategy("Tree"); }
241  void SetLayoutStrategyToCosmicTree() { this->SetLayoutStrategy("Cosmic Tree"); }
242  void SetLayoutStrategyToCone() { this->SetLayoutStrategy("Cone"); }
243  void SetLayoutStrategyToSpanTree() { this->SetLayoutStrategy("Span Tree"); }
244 
249  virtual void SetLayoutStrategyToAssignCoordinates(
250  const char* xarr, const char* yarr = nullptr, const char* zarr = nullptr);
251 
262  virtual void SetLayoutStrategyToTree(
263  bool radial, double angle = 90, double leafSpacing = 0.9, double logSpacing = 1.0);
264 
275  virtual void SetLayoutStrategyToCosmicTree(const char* nodeSizeArrayName,
276  bool sizeLeafNodesOnly = true, int layoutDepth = 0, vtkIdType layoutRoot = -1);
277 
278  // ------------------------------------------------------------------------
279  // Edge layout strategy
280 
282 
285  virtual void SetEdgeLayoutStrategy(vtkEdgeLayoutStrategy* strategy);
286  virtual vtkEdgeLayoutStrategy* GetEdgeLayoutStrategy();
287  void SetEdgeLayoutStrategyToArcParallel() { this->SetEdgeLayoutStrategy("Arc Parallel"); }
288  void SetEdgeLayoutStrategyToPassThrough() { this->SetEdgeLayoutStrategy("Pass Through"); }
290 
295  virtual void SetEdgeLayoutStrategyToGeo(double explodeFactor = 0.2);
296 
298 
301  virtual void SetEdgeLayoutStrategy(const char* name);
302  vtkGetStringMacro(EdgeLayoutStrategyName);
304 
305  // ------------------------------------------------------------------------
306  // Miscellaneous
307 
311  void ApplyViewTheme(vtkViewTheme* theme) override;
312 
314 
317  virtual void SetGlyphType(int type);
318  virtual int GetGlyphType();
320 
322 
325  virtual void SetScaling(bool b);
326  virtual bool GetScaling();
327  vtkBooleanMacro(Scaling, bool);
329 
331 
334  virtual void SetScalingArrayName(const char* name);
335  virtual const char* GetScalingArrayName();
337 
339 
342  virtual void SetVertexScalarBarVisibility(bool b);
343  virtual bool GetVertexScalarBarVisibility();
344  virtual void SetEdgeScalarBarVisibility(bool b);
345  virtual bool GetEdgeScalarBarVisibility();
347 
349 
352  virtual vtkScalarBarWidget* GetVertexScalarBar();
353  virtual vtkScalarBarWidget* GetEdgeScalarBar();
355 
359  virtual bool IsLayoutComplete();
360 
364  virtual void UpdateLayout();
365 
369  void ComputeSelectedGraphBounds(double bounds[6]);
370 
371 protected:
373  ~vtkRenderedGraphRepresentation() override;
374 
376 
379  bool AddToView(vtkView* view) override;
380  bool RemoveFromView(vtkView* view) override;
382 
383  void PrepareForRendering(vtkRenderView* view) override;
384 
385  vtkSelection* ConvertSelection(vtkView* view, vtkSelection* sel) override;
386 
388 
392  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
393  vtkInformationVector* outputVector) override;
394 
396 
428 
431 
432  vtkSetStringMacro(VertexColorArrayNameInternal);
433  vtkGetStringMacro(VertexColorArrayNameInternal);
435 
436  vtkSetStringMacro(EdgeColorArrayNameInternal);
437  vtkGetStringMacro(EdgeColorArrayNameInternal);
439 
440  vtkSetStringMacro(ScalingArrayNameInternal);
441  vtkGetStringMacro(ScalingArrayNameInternal);
443 
444  vtkSetStringMacro(LayoutStrategyName);
445  char* LayoutStrategyName;
446  vtkSetStringMacro(EdgeLayoutStrategyName);
450 
452 
453 private:
455  void operator=(const vtkRenderedGraphRepresentation&) = delete;
456 };
457 
458 VTK_ABI_NAMESPACE_END
459 #endif
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...
virtual void SetVertexIconSelectionModeToSelectedIcon()
Set the mode to one of.
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:40
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:49
Adds an attribute array with the degree of each vertex.
vtkSmartPointer< vtkScalarBarWidget > EdgeScalarBar
Internal filter classes.
int vtkIdType
Definition: vtkType.h:315
virtual bool AddToView(vtkView *vtkNotUsed(view))
Adds the representation to the view.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
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:33
vtkSmartPointer< vtkTexturedActor2D > VertexIconActor
Internal filter classes.
vtkSmartPointer< vtkTransformCoordinateSystems > VertexIconTransform
Internal filter classes.
The superclass for all views.
Definition: vtkView.h:48
a simple class to control print indentation
Definition: vtkIndent.h:28
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.
virtual std::string GetHoverStringInternal(vtkSelection *)
Subclasses may override this method to generate the hover text.
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:49
abstract superclass for all edge layout strategies
vtkSmartPointer< vtkEdgeCenters > EdgeCenters
Internal filter classes.
layout graph edges
Definition: vtkEdgeLayout.h:27
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 void SetVertexIconSelectionModeToAnnotationIcon()
Set the mode to one of.
apply icons to a data set.
Definition: vtkApplyIcons.h:55
vtkSmartPointer< vtkPerturbCoincidentVertices > Coincident
Internal filter classes.
draw vtkPolyData onto the image plane
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.