File: vtkGraphLayoutView.h

package info (click to toggle)
paraview 3.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 124,600 kB
  • ctags: 133,728
  • sloc: cpp: 958,817; ansic: 509,658; tcl: 45,787; xml: 23,401; python: 19,574; perl: 3,112; yacc: 1,787; java: 1,517; sh: 665; asm: 471; lex: 400; makefile: 168; objc: 28
file content (276 lines) | stat: -rw-r--r-- 10,365 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    $RCSfile: vtkGraphLayoutView.h,v $

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
/*----------------------------------------------------------------------------
 Copyright (c) Sandia Corporation
 See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
----------------------------------------------------------------------------*/
// .NAME vtkGraphLayoutView - Lays out and displays a graph
//
// .SECTION Description
// vtkGraphLayoutView performs graph layout and displays a vtkGraph.
// You may color and label the vertices and edges using fields in the graph.
// If coordinates are already assigned to the graph vertices in your graph,
// set the layout strategy to PassThrough in this view.
//
// .SECTION Thanks
// Thanks to Brian Wylie from Sandia National Laboratories for implementing
// the first version of this class.

#ifndef __vtkGraphLayoutView_h
#define __vtkGraphLayoutView_h

#include "vtkRenderView.h"

class vtkActor;
class vtkActor2D;
class vtkCircularLayoutStrategy;
class vtkCoordinate;
class vtkDynamic2DLabelMapper;
class vtkExtractSelectedGraph;
class vtkFast2DLayoutStrategy;
class vtkForceDirectedLayoutStrategy;
class vtkGraphLayout;
class vtkGraphToPolyData;
class vtkKdTreeSelector;
class vtkLookupTable;
class vtkPassThroughLayoutStrategy;
class vtkPolyDataMapper;
class vtkRandomLayoutStrategy;
class vtkSelectionLink;
class vtkSimple2DLayoutStrategy;
class vtkClustering2DLayoutStrategy;
class vtkCommunity2DLayoutStrategy;
class vtkVertexDegree;
class vtkCellCenters;
class vtkVertexGlyphFilter;
class vtkViewTheme;
class vtkVisibleCellSelector;

class VTK_VIEWS_EXPORT vtkGraphLayoutView : public vtkRenderView
{
public:
  static vtkGraphLayoutView *New();
  vtkTypeRevisionMacro(vtkGraphLayoutView, vtkRenderView);
  void PrintSelf(ostream& os, vtkIndent indent);
  
  // Description:
  // The array to use for vertex labeling.  Default is "label".
  void SetVertexLabelArrayName(const char* name);
  const char* GetVertexLabelArrayName();
  
  // Description:
  // The array to use for edge labeling.  Default is "label".
  void SetEdgeLabelArrayName(const char* name);
  const char* GetEdgeLabelArrayName();
  
  // Description:
  // Whether to show vertex labels.  Default is off.
  void SetVertexLabelVisibility(bool vis);
  bool GetVertexLabelVisibility();
  void VertexLabelVisibilityOn();
  void VertexLabelVisibilityOff();
  
  // Description:
  // Whether to show edge labels.  Default is off.
  void SetEdgeLabelVisibility(bool vis);
  bool GetEdgeLabelVisibility();
  void EdgeLabelVisibilityOn();
  void EdgeLabelVisibilityOff();
  
  // Description:
  // The array to use for coloring vertices.  Default is "color".
  void SetVertexColorArrayName(const char* name);
  const char* GetVertexColorArrayName();
  
  // Description:
  // Whether to show labels.  Default is off.
  void SetColorVertices(bool vis);
  bool GetColorVertices();
  void ColorVerticesOn();
  void ColorVerticesOff();
  
  // Description:
  // The array to use for coloring edges.  Default is "color".
  void SetEdgeColorArrayName(const char* name);
  const char* GetEdgeColorArrayName();
  
  // Description:
  // Whether to show labels.  Default is off.
  void SetColorEdges(bool vis);
  bool GetColorEdges();
  void ColorEdgesOn();
  void ColorEdgesOff();
  
  // Description:
  // The layout strategy to use when performing the graph layout.
  // The possible strings are:
  //   "Random"         - Randomly places vertices in a box.
  //   "Force Directed" - A layout in 3D or 2D simulating forces on edges.
  //   "Simple 2D"      - A simple 2D force directed layout.
  //   "Clustering 2D"  - A 2D force directed layout that's just like
  //                    - simple 2D but uses some techniques to cluster better.
  //   "Fast 2D"        - A linear-time 2D layout.
  //   "Pass Through"   - Use locations assigned to the input.
  //   "Circular"       - Places vertices uniformly on a circle.
  // Default is "Simple 2D".
  void SetLayoutStrategy(const char* name);
  void SetLayoutStrategyToRandom()        { this->SetLayoutStrategy("Random"); }
  void SetLayoutStrategyToForceDirected() { this->SetLayoutStrategy("Force Directed"); }
  void SetLayoutStrategyToSimple2D()      { this->SetLayoutStrategy("Simple 2D"); }
  void SetLayoutStrategyToClustering2D()  { this->SetLayoutStrategy("Cluster 2D"); }
  void SetLayoutStrategyToCommunity2D()   { this->SetLayoutStrategy("Community 2D"); }
  void SetLayoutStrategyToFast2D()        { this->SetLayoutStrategy("Fast 2D"); }
  void SetLayoutStrategyToPassThrough()   { this->SetLayoutStrategy("Pass Through"); }
  void SetLayoutStrategyToCircular()      { this->SetLayoutStrategy("Circular"); }
  const char* GetLayoutStrategy()         { return this->GetLayoutStrategyInternal(); }

  // Description:
  // Set the number of iterations per refresh (defaults to all)
  // In other words, the default is to do the entire layout
  // and then do a visual refresh. Changing this variable
  // to something like '1', will enable an application to
  // see the layout as it progresses.
  void SetIterationsPerLayout(int iterations);
  
  
  // Description:
  // The array used for populating the selection list
  void SetSelectionArrayName(const char* name);
  const char* GetSelectionArrayName();

  // Description:
  // Sets up interactor style.
  virtual void SetupRenderWindow(vtkRenderWindow* win);
  
  // Description:
  // Apply the theme to this view.
  virtual void ApplyViewTheme(vtkViewTheme* theme);

  // Description:
  // Is the graph layout complete? This method is useful
  // for when the strategy is iterative and the application
  // wants to show the iterative progress of the graph layout
  // See Also: UpdateLayout();
  virtual int IsLayoutComplete();
  
  // Description:
  // This method is useful for when the strategy is iterative 
  // and the application wants to show the iterative progress 
  // of the graph layout. The application would have something like
  // while(!IsLayoutComplete())
  //   {
  //   UpdateLayout();
  //   }
  // See Also: IsLayoutComplete();
  virtual void UpdateLayout();

protected:
  vtkGraphLayoutView();
  ~vtkGraphLayoutView();

  // Description:
  // Called to process the user event from the interactor style.
  virtual void ProcessEvents(vtkObject* caller, unsigned long eventId, 
    void* callData);
  
  // Description:
  // Connects the algorithm output to the internal pipeline.
  // This view only supports a single representation.
  virtual void AddInputConnection(vtkAlgorithmOutput* conn);
  
  // Description:
  // Removes the algorithm output from the internal pipeline.
  virtual void RemoveInputConnection(vtkAlgorithmOutput* conn);
  
  // Description:
  // Connects the selection link to the internal pipeline.
  virtual void SetSelectionLink(vtkSelectionLink* link);
  
  // Decsription:
  // Prepares the view for rendering.
  virtual void PrepareForRendering();

  // Description:
  // May a display coordinate to a world coordinate on the x-y plane.  
  void MapToXYPlane(double displayX, double displayY, double &x, double &y);
  
  // Description:
  // Used to store the vertex and edge color array names
  vtkGetStringMacro(VertexColorArrayNameInternal);
  vtkSetStringMacro(VertexColorArrayNameInternal);
  vtkGetStringMacro(EdgeColorArrayNameInternal);
  vtkSetStringMacro(EdgeColorArrayNameInternal);
  char* VertexColorArrayNameInternal;
  char* EdgeColorArrayNameInternal;

  // Description:
  // Used to store the layout strategy name
  vtkGetStringMacro(LayoutStrategyInternal);
  vtkSetStringMacro(LayoutStrategyInternal);
  char* LayoutStrategyInternal;
  
  // Description:
  // Used to store the selection array name
  vtkGetStringMacro(SelectionArrayNameInternal);
  vtkSetStringMacro(SelectionArrayNameInternal);
  char* SelectionArrayNameInternal;
  
  // Used for coordinate conversion
  vtkCoordinate* Coordinate;

  // Representation objects
  vtkGraphLayout*                  GraphLayout;
  vtkRandomLayoutStrategy*         RandomStrategy;
  vtkForceDirectedLayoutStrategy*  ForceDirectedStrategy;
  vtkSimple2DLayoutStrategy*       Simple2DStrategy;
  vtkClustering2DLayoutStrategy*   Clustering2DStrategy;
  vtkCommunity2DLayoutStrategy*    Community2DStrategy;
  vtkFast2DLayoutStrategy*         Fast2DStrategy;
  vtkPassThroughLayoutStrategy*    PassThroughStrategy;
  vtkCircularLayoutStrategy*       CircularStrategy;
  vtkVertexDegree*                 VertexDegree;
  vtkCellCenters*                  CellCenters;
  vtkGraphToPolyData*              GraphToPolyData;
  vtkVertexGlyphFilter*            VertexGlyph;
  vtkPolyDataMapper*               VertexMapper;
  vtkLookupTable*                  VertexColorLUT;
  vtkActor*                        VertexActor;
  vtkPolyDataMapper*               OutlineMapper;
  vtkActor*                        OutlineActor;
  vtkPolyDataMapper*               EdgeMapper;
  vtkLookupTable*                  EdgeColorLUT;
  vtkActor*                        EdgeActor;
  vtkDynamic2DLabelMapper*         VertexLabelMapper;
  vtkActor2D*                      VertexLabelActor;
  vtkDynamic2DLabelMapper*         EdgeLabelMapper;
  vtkActor2D*                      EdgeLabelActor;
  
  // Selection objects
  vtkKdTreeSelector*        KdTreeSelector;
  vtkVisibleCellSelector*   VisibleCellSelector;
  vtkExtractSelectedGraph*  ExtractSelectedGraph;
  vtkGraphToPolyData*       SelectionToPolyData;
  vtkVertexGlyphFilter*     SelectionVertexGlyph;
  vtkPolyDataMapper*        SelectionVertexMapper;
  vtkActor*                 SelectionVertexActor;
  vtkPolyDataMapper*        SelectionEdgeMapper;
  vtkActor*                 SelectionEdgeActor;

private:
  vtkGraphLayoutView(const vtkGraphLayoutView&);  // Not implemented.
  void operator=(const vtkGraphLayoutView&);  // Not implemented.
};

#endif