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 -------------------------------------------------------------------------*/
26 #ifndef vtkRenderedGraphRepresentation_h
27 #define vtkRenderedGraphRepresentation_h
28 
29 #include "vtkViewsInfovisModule.h" // For export macro
31 #include "vtkSmartPointer.h" // for SP ivars
32 
33 class vtkActor;
34 class vtkApplyColors;
35 class vtkApplyIcons;
36 class vtkEdgeCenters;
37 class vtkEdgeLayout;
39 class vtkGraphLayout;
41 class vtkGraphToGlyphs;
42 class vtkGraphToPoints;
43 class vtkGraphToPolyData;
44 class vtkIconGlyphFilter;
45 class vtkInformation;
47 class vtkLookupTable;
50 class vtkPolyData;
51 class vtkPolyDataMapper;
54 class vtkRenderView;
55 class vtkScalarBarWidget;
56 class vtkScalarsToColors;
57 class vtkTextProperty;
58 class vtkTexturedActor2D;
60 class vtkVertexDegree;
61 class vtkView;
62 class vtkViewTheme;
63 
64 class VTKVIEWSINFOVIS_EXPORT vtkRenderedGraphRepresentation : public vtkRenderedRepresentation
65 {
66 public:
69  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
70 
71  // ------------------------------------------------------------------------
72  // Vertex labels
73 
74  virtual void SetVertexLabelArrayName(const char* name);
75  virtual const char* GetVertexLabelArrayName();
76  virtual void SetVertexLabelPriorityArrayName(const char* name);
77  virtual const char* GetVertexLabelPriorityArrayName();
78  virtual void SetVertexLabelVisibility(bool b);
79  virtual bool GetVertexLabelVisibility();
80  vtkBooleanMacro(VertexLabelVisibility, bool);
81  virtual void SetVertexLabelTextProperty(vtkTextProperty* p);
82  virtual vtkTextProperty* GetVertexLabelTextProperty();
83  vtkSetStringMacro(VertexHoverArrayName);
84  vtkGetStringMacro(VertexHoverArrayName);
86 
89  vtkSetMacro(HideVertexLabelsOnInteraction, bool)
90  vtkGetMacro(HideVertexLabelsOnInteraction, bool)
91  vtkBooleanMacro(HideVertexLabelsOnInteraction, bool)
93 
94  // ------------------------------------------------------------------------
95  // Edge labels
96 
97  virtual void SetEdgeLabelArrayName(const char* name);
98  virtual const char* GetEdgeLabelArrayName();
99  virtual void SetEdgeLabelPriorityArrayName(const char* name);
100  virtual const char* GetEdgeLabelPriorityArrayName();
101  virtual void SetEdgeLabelVisibility(bool b);
102  virtual bool GetEdgeLabelVisibility();
103  vtkBooleanMacro(EdgeLabelVisibility, bool);
104  virtual void SetEdgeLabelTextProperty(vtkTextProperty* p);
105  virtual vtkTextProperty* GetEdgeLabelTextProperty();
106  vtkSetStringMacro(EdgeHoverArrayName);
107  vtkGetStringMacro(EdgeHoverArrayName);
109 
112  vtkSetMacro(HideEdgeLabelsOnInteraction, bool)
113  vtkGetMacro(HideEdgeLabelsOnInteraction, bool)
114  vtkBooleanMacro(HideEdgeLabelsOnInteraction, bool)
116 
117  // ------------------------------------------------------------------------
118  // Vertex icons
119 
120  virtual void SetVertexIconArrayName(const char* name);
121  virtual const char* GetVertexIconArrayName();
122  virtual void SetVertexIconPriorityArrayName(const char* name);
123  virtual const char* GetVertexIconPriorityArrayName();
124  virtual void SetVertexIconVisibility(bool b);
125  virtual bool GetVertexIconVisibility();
126  vtkBooleanMacro(VertexIconVisibility, bool);
127  virtual void AddVertexIconType(const char* name, int type);
128  virtual void ClearVertexIconTypes();
129  virtual void SetUseVertexIconTypeMap(bool b);
130  virtual bool GetUseVertexIconTypeMap();
131  vtkBooleanMacro(UseVertexIconTypeMap, bool);
132  virtual void SetVertexIconAlignment(int align);
133  virtual int GetVertexIconAlignment();
134  virtual void SetVertexSelectedIcon(int icon);
135  virtual int GetVertexSelectedIcon();
136  virtual void SetVertexDefaultIcon(int icon);
137  virtual int GetVertexDefaultIcon();
138 
140 
150  virtual void SetVertexIconSelectionMode(int mode);
151  virtual int GetVertexIconSelectionMode();
152  virtual void SetVertexIconSelectionModeToSelectedIcon()
153  { this->SetVertexIconSelectionMode(0); }
155  { this->SetVertexIconSelectionMode(1); }
157  { this->SetVertexIconSelectionMode(2); }
159  { this->SetVertexIconSelectionMode(3); }
161 
162  // ------------------------------------------------------------------------
163  // Edge icons
164 
165  virtual void SetEdgeIconArrayName(const char* name);
166  virtual const char* GetEdgeIconArrayName();
167  virtual void SetEdgeIconPriorityArrayName(const char* name);
168  virtual const char* GetEdgeIconPriorityArrayName();
169  virtual void SetEdgeIconVisibility(bool b);
170  virtual bool GetEdgeIconVisibility();
171  vtkBooleanMacro(EdgeIconVisibility, bool);
172  virtual void AddEdgeIconType(const char* name, int type);
173  virtual void ClearEdgeIconTypes();
174  virtual void SetUseEdgeIconTypeMap(bool b);
175  virtual bool GetUseEdgeIconTypeMap();
176  vtkBooleanMacro(UseEdgeIconTypeMap, bool);
177  virtual void SetEdgeIconAlignment(int align);
178  virtual int GetEdgeIconAlignment();
179 
180  // ------------------------------------------------------------------------
181  // Vertex colors
182 
183  virtual void SetColorVerticesByArray(bool b);
184  virtual bool GetColorVerticesByArray();
185  vtkBooleanMacro(ColorVerticesByArray, bool);
186  virtual void SetVertexColorArrayName(const char* name);
187  virtual const char* GetVertexColorArrayName();
188 
189  // ------------------------------------------------------------------------
190  // Edge colors
191 
192  virtual void SetColorEdgesByArray(bool b);
193  virtual bool GetColorEdgesByArray();
194  vtkBooleanMacro(ColorEdgesByArray, bool);
195  virtual void SetEdgeColorArrayName(const char* name);
196  virtual const char* GetEdgeColorArrayName();
197 
198  // ------------------------------------------------------------------------
199  // Enabled vertices
200 
201  virtual void SetEnableVerticesByArray(bool b);
202  virtual bool GetEnableVerticesByArray();
203  vtkBooleanMacro(EnableVerticesByArray, bool);
204  virtual void SetEnabledVerticesArrayName(const char* name);
205  virtual const char* GetEnabledVerticesArrayName();
206 
207  // ------------------------------------------------------------------------
208  // Enabled edges
209 
210  virtual void SetEnableEdgesByArray(bool b);
211  virtual bool GetEnableEdgesByArray();
212  vtkBooleanMacro(EnableEdgesByArray, bool);
213  virtual void SetEnabledEdgesArrayName(const char* name);
214  virtual const char* GetEnabledEdgesArrayName();
215 
216  virtual void SetEdgeVisibility(bool b);
217  virtual bool GetEdgeVisibility();
218  vtkBooleanMacro(EdgeVisibility, bool);
219 
220  void SetEdgeSelection(bool b);
221  bool GetEdgeSelection();
222 
223  // ------------------------------------------------------------------------
224  // Vertex layout strategy
225 
227 
230  virtual void SetLayoutStrategy(vtkGraphLayoutStrategy* strategy);
231  virtual vtkGraphLayoutStrategy* GetLayoutStrategy();
233 
235 
238  virtual void SetLayoutStrategy(const char* name);
239  vtkGetStringMacro(LayoutStrategyName);
241 
246  { this->SetLayoutStrategy("Random"); }
248  { this->SetLayoutStrategy("Force Directed"); }
250  { this->SetLayoutStrategy("Simple 2D"); }
252  { this->SetLayoutStrategy("Clustering 2D"); }
254  { this->SetLayoutStrategy("Community 2D"); }
256  { this->SetLayoutStrategy("Fast 2D"); }
258  { this->SetLayoutStrategy("Pass Through"); }
260  { this->SetLayoutStrategy("Circular"); }
262  { this->SetLayoutStrategy("Tree"); }
264  { this->SetLayoutStrategy("Cosmic Tree"); }
266  { this->SetLayoutStrategy("Cone"); }
268  { this->SetLayoutStrategy("Span Tree"); }
269 
274  virtual void SetLayoutStrategyToAssignCoordinates(
275  const char* xarr, const char* yarr = 0, const char* zarr = 0);
276 
287  virtual void SetLayoutStrategyToTree(
288  bool radial,
289  double angle = 90,
290  double leafSpacing = 0.9,
291  double logSpacing = 1.0);
292 
303  virtual void SetLayoutStrategyToCosmicTree(
304  const char* nodeSizeArrayName,
305  bool sizeLeafNodesOnly = true,
306  int layoutDepth = 0,
307  vtkIdType layoutRoot = -1);
308 
309  // ------------------------------------------------------------------------
310  // Edge layout strategy
311 
313 
316  virtual void SetEdgeLayoutStrategy(vtkEdgeLayoutStrategy* strategy);
317  virtual vtkEdgeLayoutStrategy* GetEdgeLayoutStrategy();
319  { this->SetEdgeLayoutStrategy("Arc Parallel"); }
321  { this->SetEdgeLayoutStrategy("Pass Through"); }
323 
328  virtual void SetEdgeLayoutStrategyToGeo(double explodeFactor = 0.2);
329 
331 
334  virtual void SetEdgeLayoutStrategy(const char* name);
335  vtkGetStringMacro(EdgeLayoutStrategyName);
337 
338  // ------------------------------------------------------------------------
339  // Miscellaneous
340 
344  void ApplyViewTheme(vtkViewTheme* theme) VTK_OVERRIDE;
345 
347 
350  virtual void SetGlyphType(int type);
351  virtual int GetGlyphType();
353 
355 
358  virtual void SetScaling(bool b);
359  virtual bool GetScaling();
360  vtkBooleanMacro(Scaling, bool);
362 
364 
367  virtual void SetScalingArrayName(const char* name);
368  virtual const char* GetScalingArrayName();
370 
372 
375  virtual void SetVertexScalarBarVisibility(bool b);
376  virtual bool GetVertexScalarBarVisibility();
377  virtual void SetEdgeScalarBarVisibility(bool b);
378  virtual bool GetEdgeScalarBarVisibility();
380 
382 
385  virtual vtkScalarBarWidget* GetVertexScalarBar();
386  virtual vtkScalarBarWidget* GetEdgeScalarBar();
388 
392  virtual bool IsLayoutComplete();
393 
397  virtual void UpdateLayout();
398 
402  void ComputeSelectedGraphBounds( double bounds[6] );
403 
404 protected:
406  ~vtkRenderedGraphRepresentation() VTK_OVERRIDE;
407 
409 
412  bool AddToView(vtkView* view) VTK_OVERRIDE;
413  bool RemoveFromView(vtkView* view) VTK_OVERRIDE;
415 
416  void PrepareForRendering(vtkRenderView* view) VTK_OVERRIDE;
417 
418  vtkSelection* ConvertSelection(vtkView* view, vtkSelection* sel) VTK_OVERRIDE;
419 
420  vtkUnicodeString GetHoverTextInternal(vtkSelection* sel) VTK_OVERRIDE;
421 
425  int RequestData(
426  vtkInformation* request,
427  vtkInformationVector** inputVector,
428  vtkInformationVector* outputVector) VTK_OVERRIDE;
429 
431 
436  vtkSmartPointer<vtkPolyData> EmptyPolyData;
449  vtkSmartPointer<vtkActor> VertexActor;
452  vtkSmartPointer<vtkActor> OutlineActor;
456  vtkSmartPointer<vtkApplyIcons> ApplyVertexIcons;
463 
464  char* VertexHoverArrayName;
465  char* EdgeHoverArrayName;
466 
467  vtkSetStringMacro(VertexColorArrayNameInternal);
468  vtkGetStringMacro(VertexColorArrayNameInternal);
469  char* VertexColorArrayNameInternal;
470 
471  vtkSetStringMacro(EdgeColorArrayNameInternal);
472  vtkGetStringMacro(EdgeColorArrayNameInternal);
473  char* EdgeColorArrayNameInternal;
474 
475  vtkSetStringMacro(ScalingArrayNameInternal);
476  vtkGetStringMacro(ScalingArrayNameInternal);
477  char* ScalingArrayNameInternal;
478 
479  vtkSetStringMacro(LayoutStrategyName);
480  char* LayoutStrategyName;
481  vtkSetStringMacro(EdgeLayoutStrategyName);
482  char* EdgeLayoutStrategyName;
483  bool HideVertexLabelsOnInteraction;
484  bool HideEdgeLabelsOnInteraction;
485 
486  bool EdgeSelection;
487 
488 private:
490  void operator=(const vtkRenderedGraphRepresentation&) VTK_DELETE_FUNCTION;
491 };
492 
493 #endif
494 
virtual void ApplyViewTheme(vtkViewTheme *vtkNotUsed(theme))
Apply a theme to this representation.
virtual void SetVertexIconSelectionModeToIgnoreSelection()
Set the mode to one of.
void SetEdgeLayoutStrategyToPassThrough()
Set/get the graph layout strategy.
represents an object (geometry &amp; properties) in a rendered scene
Definition: vtkActor.h:45
actor that draws 2D data with texture support
Store vtkAlgorithm input/output information.
Filter that generates a polydata consisting of quads with texture coordinates referring to a set of i...
map scalar values into colors via a lookup table
A node in a selection tree.
Definition: vtkSelection.h:37
Adds an attribute array with the degree of each vertex.
Hold a reference to a vtkObjectBase instance.
int vtkIdType
Definition: vtkType.h:345
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
static vtkRenderedRepresentation * New()
abstract superclass for all graph layout strategies
convert a vtkGraph to vtkPolyData
Superclass for mapping scalar values to colors.
generate points at center of edges
Sets theme colors for a graphical view.
Definition: vtkViewTheme.h:42
The superclass for all views.
Definition: vtkView.h:54
a simple class to control print indentation
Definition: vtkIndent.h:33
layout a graph in 2 or 3 dimensions
void SetLayoutStrategyToRandom()
Set predefined layout strategies.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
Perturbs vertices that are coincident.
represent text properties.
transform points into different coordinate systems
build a label hierarchy for a graph or point set.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
map vtkPolyData to graphics primitives
A view containing a renderer.
Definition: vtkRenderView.h:58
abstract superclass for all edge layout strategies
layout graph edges
Definition: vtkEdgeLayout.h:38
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.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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
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.