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 -------------------------------------------------------------------------*/
31 #ifndef __vtkRenderedGraphRepresentation_h
32 #define __vtkRenderedGraphRepresentation_h
33 
34 #include "vtkViewsInfovisModule.h" // For export macro
36 #include "vtkSmartPointer.h" // for SP ivars
37 
38 class vtkActor;
39 class vtkApplyColors;
40 class vtkApplyIcons;
41 class vtkEdgeCenters;
42 class vtkEdgeLayout;
44 class vtkGraphLayout;
46 class vtkGraphToGlyphs;
47 class vtkGraphToPoints;
48 class vtkGraphToPolyData;
49 class vtkIconGlyphFilter;
50 class vtkInformation;
52 class vtkLookupTable;
55 class vtkPolyData;
56 class vtkPolyDataMapper;
59 class vtkRenderView;
60 class vtkScalarBarWidget;
61 class vtkScalarsToColors;
62 class vtkTextProperty;
63 class vtkTexturedActor2D;
65 class vtkVertexDegree;
66 class vtkView;
67 class vtkViewTheme;
68 
69 class VTKVIEWSINFOVIS_EXPORT vtkRenderedGraphRepresentation : public vtkRenderedRepresentation
70 {
71 public:
74  void PrintSelf(ostream& os, vtkIndent indent);
75 
76  // ------------------------------------------------------------------------
77  // Vertex labels
78 
79  virtual void SetVertexLabelArrayName(const char* name);
80  virtual const char* GetVertexLabelArrayName();
81  virtual void SetVertexLabelPriorityArrayName(const char* name);
82  virtual const char* GetVertexLabelPriorityArrayName();
83  virtual void SetVertexLabelVisibility(bool b);
84  virtual bool GetVertexLabelVisibility();
85  vtkBooleanMacro(VertexLabelVisibility, bool);
86  virtual void SetVertexLabelTextProperty(vtkTextProperty* p);
87  virtual vtkTextProperty* GetVertexLabelTextProperty();
88  vtkSetStringMacro(VertexHoverArrayName);
89  vtkGetStringMacro(VertexHoverArrayName);
91 
93  vtkSetMacro(HideVertexLabelsOnInteraction, bool)
94  vtkGetMacro(HideVertexLabelsOnInteraction, bool)
95  vtkBooleanMacro(HideVertexLabelsOnInteraction, bool)
97 
98  // ------------------------------------------------------------------------
99  // Edge labels
100 
101  virtual void SetEdgeLabelArrayName(const char* name);
102  virtual const char* GetEdgeLabelArrayName();
103  virtual void SetEdgeLabelPriorityArrayName(const char* name);
104  virtual const char* GetEdgeLabelPriorityArrayName();
105  virtual void SetEdgeLabelVisibility(bool b);
106  virtual bool GetEdgeLabelVisibility();
107  vtkBooleanMacro(EdgeLabelVisibility, bool);
108  virtual void SetEdgeLabelTextProperty(vtkTextProperty* p);
109  virtual vtkTextProperty* GetEdgeLabelTextProperty();
110  vtkSetStringMacro(EdgeHoverArrayName);
111  vtkGetStringMacro(EdgeHoverArrayName);
113 
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 
148  virtual void SetVertexIconSelectionMode(int mode);
149  virtual int GetVertexIconSelectionMode();
150  virtual void SetVertexIconSelectionModeToSelectedIcon()
151  { this->SetVertexIconSelectionMode(0); }
152  virtual void SetVertexIconSelectionModeToSelectedOffset()
153  { this->SetVertexIconSelectionMode(1); }
154  virtual void SetVertexIconSelectionModeToAnnotationIcon()
155  { this->SetVertexIconSelectionMode(2); }
156  virtual void SetVertexIconSelectionModeToIgnoreSelection()
157  { this->SetVertexIconSelectionMode(3); }
159 
160  // ------------------------------------------------------------------------
161  // Edge icons
162 
163  virtual void SetEdgeIconArrayName(const char* name);
164  virtual const char* GetEdgeIconArrayName();
165  virtual void SetEdgeIconPriorityArrayName(const char* name);
166  virtual const char* GetEdgeIconPriorityArrayName();
167  virtual void SetEdgeIconVisibility(bool b);
168  virtual bool GetEdgeIconVisibility();
169  vtkBooleanMacro(EdgeIconVisibility, bool);
170  virtual void AddEdgeIconType(const char* name, int type);
171  virtual void ClearEdgeIconTypes();
172  virtual void SetUseEdgeIconTypeMap(bool b);
173  virtual bool GetUseEdgeIconTypeMap();
174  vtkBooleanMacro(UseEdgeIconTypeMap, bool);
175  virtual void SetEdgeIconAlignment(int align);
176  virtual int GetEdgeIconAlignment();
177 
178  // ------------------------------------------------------------------------
179  // Vertex colors
180 
181  virtual void SetColorVerticesByArray(bool b);
182  virtual bool GetColorVerticesByArray();
183  vtkBooleanMacro(ColorVerticesByArray, bool);
184  virtual void SetVertexColorArrayName(const char* name);
185  virtual const char* GetVertexColorArrayName();
186 
187  // ------------------------------------------------------------------------
188  // Edge colors
189 
190  virtual void SetColorEdgesByArray(bool b);
191  virtual bool GetColorEdgesByArray();
192  vtkBooleanMacro(ColorEdgesByArray, bool);
193  virtual void SetEdgeColorArrayName(const char* name);
194  virtual const char* GetEdgeColorArrayName();
195 
196  // ------------------------------------------------------------------------
197  // Enabled vertices
198 
199  virtual void SetEnableVerticesByArray(bool b);
200  virtual bool GetEnableVerticesByArray();
201  vtkBooleanMacro(EnableVerticesByArray, bool);
202  virtual void SetEnabledVerticesArrayName(const char* name);
203  virtual const char* GetEnabledVerticesArrayName();
204 
205  // ------------------------------------------------------------------------
206  // Enabled edges
207 
208  virtual void SetEnableEdgesByArray(bool b);
209  virtual bool GetEnableEdgesByArray();
210  vtkBooleanMacro(EnableEdgesByArray, bool);
211  virtual void SetEnabledEdgesArrayName(const char* name);
212  virtual const char* GetEnabledEdgesArrayName();
213 
214  virtual void SetEdgeVisibility(bool b);
215  virtual bool GetEdgeVisibility();
216  vtkBooleanMacro(EdgeVisibility, bool);
217 
218  void SetEdgeSelection(bool b);
219  bool GetEdgeSelection();
220 
221  // ------------------------------------------------------------------------
222  // Vertex layout strategy
223 
225 
226  virtual void SetLayoutStrategy(vtkGraphLayoutStrategy* strategy);
227  virtual vtkGraphLayoutStrategy* GetLayoutStrategy();
229 
231 
232  virtual void SetLayoutStrategy(const char* name);
233  vtkGetStringMacro(LayoutStrategyName);
235 
237 
238  void SetLayoutStrategyToRandom()
239  { this->SetLayoutStrategy("Random"); }
240  void SetLayoutStrategyToForceDirected()
241  { this->SetLayoutStrategy("Force Directed"); }
242  void SetLayoutStrategyToSimple2D()
243  { this->SetLayoutStrategy("Simple 2D"); }
244  void SetLayoutStrategyToClustering2D()
245  { this->SetLayoutStrategy("Clustering 2D"); }
246  void SetLayoutStrategyToCommunity2D()
247  { this->SetLayoutStrategy("Community 2D"); }
248  void SetLayoutStrategyToFast2D()
249  { this->SetLayoutStrategy("Fast 2D"); }
250  void SetLayoutStrategyToPassThrough()
251  { this->SetLayoutStrategy("Pass Through"); }
252  void SetLayoutStrategyToCircular()
253  { this->SetLayoutStrategy("Circular"); }
254  void SetLayoutStrategyToTree()
255  { this->SetLayoutStrategy("Tree"); }
256  void SetLayoutStrategyToCosmicTree()
257  { this->SetLayoutStrategy("Cosmic Tree"); }
258  void SetLayoutStrategyToCone()
259  { this->SetLayoutStrategy("Cone"); }
260  void SetLayoutStrategyToSpanTree()
261  { this->SetLayoutStrategy("Span Tree"); }
263 
265 
267  virtual void SetLayoutStrategyToAssignCoordinates(
268  const char* xarr, const char* yarr = 0, const char* zarr = 0);
270 
272 
281  virtual void SetLayoutStrategyToTree(
282  bool radial,
283  double angle = 90,
284  double leafSpacing = 0.9,
285  double logSpacing = 1.0);
287 
289 
298  virtual void SetLayoutStrategyToCosmicTree(
299  const char* nodeSizeArrayName,
300  bool sizeLeafNodesOnly = true,
301  int layoutDepth = 0,
302  vtkIdType layoutRoot = -1);
304 
305  // ------------------------------------------------------------------------
306  // Edge layout strategy
307 
309 
310  virtual void SetEdgeLayoutStrategy(vtkEdgeLayoutStrategy* strategy);
311  virtual vtkEdgeLayoutStrategy* GetEdgeLayoutStrategy();
312  void SetEdgeLayoutStrategyToArcParallel()
313  { this->SetEdgeLayoutStrategy("Arc Parallel"); }
314  void SetEdgeLayoutStrategyToPassThrough()
315  { this->SetEdgeLayoutStrategy("Pass Through"); }
317 
320  virtual void SetEdgeLayoutStrategyToGeo(double explodeFactor = 0.2);
321 
323 
324  virtual void SetEdgeLayoutStrategy(const char* name);
325  vtkGetStringMacro(EdgeLayoutStrategyName);
327 
328  // ------------------------------------------------------------------------
329  // Miscellaneous
330 
332  virtual void ApplyViewTheme(vtkViewTheme* theme);
333 
335 
336  virtual void SetGlyphType(int type);
337  virtual int GetGlyphType();
339 
341 
342  virtual void SetScaling(bool b);
343  virtual bool GetScaling();
344  vtkBooleanMacro(Scaling, bool);
346 
348 
349  virtual void SetScalingArrayName(const char* name);
350  virtual const char* GetScalingArrayName();
352 
354 
355  virtual void SetVertexScalarBarVisibility(bool b);
356  virtual bool GetVertexScalarBarVisibility();
357  virtual void SetEdgeScalarBarVisibility(bool b);
358  virtual bool GetEdgeScalarBarVisibility();
360 
362  virtual bool IsLayoutComplete();
363 
365  virtual void UpdateLayout();
366 
368  void ComputeSelectedGraphBounds( double bounds[6] );
369 
370 protected:
373 
375 
376  virtual bool AddToView(vtkView* view);
377  virtual bool RemoveFromView(vtkView* view);
379 
380  virtual void PrepareForRendering(vtkRenderView* view);
381 
382  virtual vtkSelection* ConvertSelection(vtkView* view, vtkSelection* sel);
383 
385 
387 
388  virtual int RequestData(
389  vtkInformation* request,
390  vtkInformationVector** inputVector,
391  vtkInformationVector* outputVector);
393 
394  //BTX
396 
425  //ETX
427 
430 
431  vtkSetStringMacro(VertexColorArrayNameInternal);
432  vtkGetStringMacro(VertexColorArrayNameInternal);
434 
435  vtkSetStringMacro(EdgeColorArrayNameInternal);
436  vtkGetStringMacro(EdgeColorArrayNameInternal);
438 
439  vtkSetStringMacro(ScalingArrayNameInternal);
440  vtkGetStringMacro(ScalingArrayNameInternal);
442 
443  vtkSetStringMacro(LayoutStrategyName);
444  char* LayoutStrategyName;
445  vtkSetStringMacro(EdgeLayoutStrategyName);
449 
451 
452 private:
454  void operator=(const vtkRenderedGraphRepresentation&); // Not implemented
455 };
456 
457 #endif
458