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 -------------------------------------------------------------------------*/
29 #ifndef vtkRenderedGraphRepresentation_h
30 #define vtkRenderedGraphRepresentation_h
31 
33 #include "vtkSmartPointer.h" // for SP ivars
34 #include "vtkViewsInfovisModule.h" // For export macro
35 
36 class vtkActor;
37 class vtkApplyColors;
38 class vtkApplyIcons;
39 class vtkEdgeCenters;
40 class vtkEdgeLayout;
42 class vtkGraphLayout;
44 class vtkGraphToGlyphs;
45 class vtkGraphToPoints;
46 class vtkGraphToPolyData;
47 class vtkIconGlyphFilter;
48 class vtkInformation;
50 class vtkLookupTable;
53 class vtkPolyData;
54 class vtkPolyDataMapper;
57 class vtkRenderView;
58 class vtkScalarBarWidget;
59 class vtkScalarsToColors;
60 class vtkTextProperty;
61 class vtkTexturedActor2D;
63 class vtkVertexDegree;
64 class vtkView;
65 class vtkViewTheme;
66 
67 class VTKVIEWSINFOVIS_EXPORT vtkRenderedGraphRepresentation : public vtkRenderedRepresentation
68 {
69 public:
72  void PrintSelf(ostream& os, vtkIndent indent) override;
73 
74  // ------------------------------------------------------------------------
75  // Vertex labels
76 
77  virtual void SetVertexLabelArrayName(const char* name);
78  virtual const char* GetVertexLabelArrayName();
79  virtual void SetVertexLabelPriorityArrayName(const char* name);
80  virtual const char* GetVertexLabelPriorityArrayName();
81  virtual void SetVertexLabelVisibility(bool b);
82  virtual bool GetVertexLabelVisibility();
83  vtkBooleanMacro(VertexLabelVisibility, bool);
84  virtual void SetVertexLabelTextProperty(vtkTextProperty* p);
85  virtual vtkTextProperty* GetVertexLabelTextProperty();
86  vtkSetStringMacro(VertexHoverArrayName);
87  vtkGetStringMacro(VertexHoverArrayName);
89 
92  vtkSetMacro(HideVertexLabelsOnInteraction, bool);
93  vtkGetMacro(HideVertexLabelsOnInteraction, bool);
94  vtkBooleanMacro(HideVertexLabelsOnInteraction, bool);
96 
97  // ------------------------------------------------------------------------
98  // Edge labels
99 
100  virtual void SetEdgeLabelArrayName(const char* name);
101  virtual const char* GetEdgeLabelArrayName();
102  virtual void SetEdgeLabelPriorityArrayName(const char* name);
103  virtual const char* GetEdgeLabelPriorityArrayName();
104  virtual void SetEdgeLabelVisibility(bool b);
105  virtual bool GetEdgeLabelVisibility();
106  vtkBooleanMacro(EdgeLabelVisibility, bool);
107  virtual void SetEdgeLabelTextProperty(vtkTextProperty* p);
108  virtual vtkTextProperty* GetEdgeLabelTextProperty();
109  vtkSetStringMacro(EdgeHoverArrayName);
110  vtkGetStringMacro(EdgeHoverArrayName);
112 
115  vtkSetMacro(HideEdgeLabelsOnInteraction, bool);
116  vtkGetMacro(HideEdgeLabelsOnInteraction, bool);
117  vtkBooleanMacro(HideEdgeLabelsOnInteraction, bool);
119 
120  // ------------------------------------------------------------------------
121  // Vertex icons
122 
123  virtual void SetVertexIconArrayName(const char* name);
124  virtual const char* GetVertexIconArrayName();
125  virtual void SetVertexIconPriorityArrayName(const char* name);
126  virtual const char* GetVertexIconPriorityArrayName();
127  virtual void SetVertexIconVisibility(bool b);
128  virtual bool GetVertexIconVisibility();
129  vtkBooleanMacro(VertexIconVisibility, bool);
130  virtual void AddVertexIconType(const char* name, int type);
131  virtual void ClearVertexIconTypes();
132  virtual void SetUseVertexIconTypeMap(bool b);
133  virtual bool GetUseVertexIconTypeMap();
134  vtkBooleanMacro(UseVertexIconTypeMap, bool);
135  virtual void SetVertexIconAlignment(int align);
136  virtual int GetVertexIconAlignment();
137  virtual void SetVertexSelectedIcon(int icon);
138  virtual int GetVertexSelectedIcon();
139  virtual void SetVertexDefaultIcon(int icon);
140  virtual int GetVertexDefaultIcon();
141 
143 
153  virtual void SetVertexIconSelectionMode(int mode);
154  virtual int GetVertexIconSelectionMode();
155  virtual void SetVertexIconSelectionModeToSelectedIcon() { this->SetVertexIconSelectionMode(0); }
156  virtual void SetVertexIconSelectionModeToSelectedOffset() { this->SetVertexIconSelectionMode(1); }
157  virtual void SetVertexIconSelectionModeToAnnotationIcon() { this->SetVertexIconSelectionMode(2); }
159  {
160  this->SetVertexIconSelectionMode(3);
161  }
163 
164  // ------------------------------------------------------------------------
165  // Edge icons
166 
167  virtual void SetEdgeIconArrayName(const char* name);
168  virtual const char* GetEdgeIconArrayName();
169  virtual void SetEdgeIconPriorityArrayName(const char* name);
170  virtual const char* GetEdgeIconPriorityArrayName();
171  virtual void SetEdgeIconVisibility(bool b);
172  virtual bool GetEdgeIconVisibility();
173  vtkBooleanMacro(EdgeIconVisibility, bool);
174  virtual void AddEdgeIconType(const char* name, int type);
175  virtual void ClearEdgeIconTypes();
176  virtual void SetUseEdgeIconTypeMap(bool b);
177  virtual bool GetUseEdgeIconTypeMap();
178  vtkBooleanMacro(UseEdgeIconTypeMap, bool);
179  virtual void SetEdgeIconAlignment(int align);
180  virtual int GetEdgeIconAlignment();
181 
182  // ------------------------------------------------------------------------
183  // Vertex colors
184 
185  virtual void SetColorVerticesByArray(bool b);
186  virtual bool GetColorVerticesByArray();
187  vtkBooleanMacro(ColorVerticesByArray, bool);
188  virtual void SetVertexColorArrayName(const char* name);
189  virtual const char* GetVertexColorArrayName();
190 
191  // ------------------------------------------------------------------------
192  // Edge colors
193 
194  virtual void SetColorEdgesByArray(bool b);
195  virtual bool GetColorEdgesByArray();
196  vtkBooleanMacro(ColorEdgesByArray, bool);
197  virtual void SetEdgeColorArrayName(const char* name);
198  virtual const char* GetEdgeColorArrayName();
199 
200  // ------------------------------------------------------------------------
201  // Enabled vertices
202 
203  virtual void SetEnableVerticesByArray(bool b);
204  virtual bool GetEnableVerticesByArray();
205  vtkBooleanMacro(EnableVerticesByArray, bool);
206  virtual void SetEnabledVerticesArrayName(const char* name);
207  virtual const char* GetEnabledVerticesArrayName();
208 
209  // ------------------------------------------------------------------------
210  // Enabled edges
211 
212  virtual void SetEnableEdgesByArray(bool b);
213  virtual bool GetEnableEdgesByArray();
214  vtkBooleanMacro(EnableEdgesByArray, bool);
215  virtual void SetEnabledEdgesArrayName(const char* name);
216  virtual const char* GetEnabledEdgesArrayName();
217 
218  virtual void SetEdgeVisibility(bool b);
219  virtual bool GetEdgeVisibility();
220  vtkBooleanMacro(EdgeVisibility, bool);
221 
222  void SetEdgeSelection(bool b);
223  bool GetEdgeSelection();
224 
225  // ------------------------------------------------------------------------
226  // Vertex layout strategy
227 
229 
232  virtual void SetLayoutStrategy(vtkGraphLayoutStrategy* strategy);
233  virtual vtkGraphLayoutStrategy* GetLayoutStrategy();
235 
237 
240  virtual void SetLayoutStrategy(const char* name);
241  vtkGetStringMacro(LayoutStrategyName);
243 
247  void SetLayoutStrategyToRandom() { this->SetLayoutStrategy("Random"); }
248  void SetLayoutStrategyToForceDirected() { this->SetLayoutStrategy("Force Directed"); }
249  void SetLayoutStrategyToSimple2D() { this->SetLayoutStrategy("Simple 2D"); }
250  void SetLayoutStrategyToClustering2D() { this->SetLayoutStrategy("Clustering 2D"); }
251  void SetLayoutStrategyToCommunity2D() { this->SetLayoutStrategy("Community 2D"); }
252  void SetLayoutStrategyToFast2D() { this->SetLayoutStrategy("Fast 2D"); }
253  void SetLayoutStrategyToPassThrough() { this->SetLayoutStrategy("Pass Through"); }
254  void SetLayoutStrategyToCircular() { this->SetLayoutStrategy("Circular"); }
255  void SetLayoutStrategyToTree() { this->SetLayoutStrategy("Tree"); }
256  void SetLayoutStrategyToCosmicTree() { this->SetLayoutStrategy("Cosmic Tree"); }
257  void SetLayoutStrategyToCone() { this->SetLayoutStrategy("Cone"); }
258  void SetLayoutStrategyToSpanTree() { this->SetLayoutStrategy("Span Tree"); }
259 
264  virtual void SetLayoutStrategyToAssignCoordinates(
265  const char* xarr, const char* yarr = nullptr, const char* zarr = nullptr);
266 
277  virtual void SetLayoutStrategyToTree(
278  bool radial, double angle = 90, double leafSpacing = 0.9, double logSpacing = 1.0);
279 
290  virtual void SetLayoutStrategyToCosmicTree(const char* nodeSizeArrayName,
291  bool sizeLeafNodesOnly = true, int layoutDepth = 0, vtkIdType layoutRoot = -1);
292 
293  // ------------------------------------------------------------------------
294  // Edge layout strategy
295 
297 
300  virtual void SetEdgeLayoutStrategy(vtkEdgeLayoutStrategy* strategy);
301  virtual vtkEdgeLayoutStrategy* GetEdgeLayoutStrategy();
302  void SetEdgeLayoutStrategyToArcParallel() { this->SetEdgeLayoutStrategy("Arc Parallel"); }
303  void SetEdgeLayoutStrategyToPassThrough() { this->SetEdgeLayoutStrategy("Pass Through"); }
305 
310  virtual void SetEdgeLayoutStrategyToGeo(double explodeFactor = 0.2);
311 
313 
316  virtual void SetEdgeLayoutStrategy(const char* name);
317  vtkGetStringMacro(EdgeLayoutStrategyName);
319 
320  // ------------------------------------------------------------------------
321  // Miscellaneous
322 
326  void ApplyViewTheme(vtkViewTheme* theme) override;
327 
329 
332  virtual void SetGlyphType(int type);
333  virtual int GetGlyphType();
335 
337 
340  virtual void SetScaling(bool b);
341  virtual bool GetScaling();
342  vtkBooleanMacro(Scaling, bool);
344 
346 
349  virtual void SetScalingArrayName(const char* name);
350  virtual const char* GetScalingArrayName();
352 
354 
357  virtual void SetVertexScalarBarVisibility(bool b);
358  virtual bool GetVertexScalarBarVisibility();
359  virtual void SetEdgeScalarBarVisibility(bool b);
360  virtual bool GetEdgeScalarBarVisibility();
362 
364 
367  virtual vtkScalarBarWidget* GetVertexScalarBar();
368  virtual vtkScalarBarWidget* GetEdgeScalarBar();
370 
374  virtual bool IsLayoutComplete();
375 
379  virtual void UpdateLayout();
380 
384  void ComputeSelectedGraphBounds(double bounds[6]);
385 
386 protected:
388  ~vtkRenderedGraphRepresentation() override;
389 
391 
394  bool AddToView(vtkView* view) override;
395  bool RemoveFromView(vtkView* view) override;
397 
398  void PrepareForRendering(vtkRenderView* view) override;
399 
400  vtkSelection* ConvertSelection(vtkView* view, vtkSelection* sel) override;
401 
403 
407  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
408  vtkInformationVector* outputVector) override;
409 
411 
443 
446 
447  vtkSetStringMacro(VertexColorArrayNameInternal);
448  vtkGetStringMacro(VertexColorArrayNameInternal);
450 
451  vtkSetStringMacro(EdgeColorArrayNameInternal);
452  vtkGetStringMacro(EdgeColorArrayNameInternal);
454 
455  vtkSetStringMacro(ScalingArrayNameInternal);
456  vtkGetStringMacro(ScalingArrayNameInternal);
458 
459  vtkSetStringMacro(LayoutStrategyName);
460  char* LayoutStrategyName;
461  vtkSetStringMacro(EdgeLayoutStrategyName);
465 
467 
468 private:
470  void operator=(const vtkRenderedGraphRepresentation&) = delete;
471 };
472 
473 #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: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:59
Adds an attribute array with the degree of each vertex.
vtkSmartPointer< vtkScalarBarWidget > EdgeScalarBar
Internal filter classes.
int vtkIdType
Definition: vtkType.h:332
virtual bool AddToView(vtkView *vtkNotUsed(view))
Adds the representation to the view.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
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:63
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.
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:64
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 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
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.