1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkHierarchicalGraphPipeline.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 -------------------------------------------------------------------------*/
20 /**
21  * @class   vtkHierarchicalGraphPipeline
22  * @brief   helper class for rendering graphs superimposed on a tree.
23  *
24  *
25  * vtkHierarchicalGraphPipeline renders bundled edges that are meant to be
26  * viewed as an overlay on a tree. This class is not for general use, but
27  * is used in the internals of vtkRenderedHierarchyRepresentation and
28  * vtkRenderedTreeAreaRepresentation.
29  */
30 
31 #ifndef vtkHierarchicalGraphPipeline_h
32 #define vtkHierarchicalGraphPipeline_h
33 
34 #include "vtkObject.h"
35 #include "vtkViewsInfovisModule.h" // For export macro
36 
37 class vtkActor;
38 class vtkActor2D;
39 class vtkAlgorithmOutput;
40 class vtkApplyColors;
41 class vtkDataRepresentation;
42 class vtkDynamic2DLabelMapper;
43 class vtkEdgeCenters;
44 class vtkGraphHierarchicalBundleEdges;
45 class vtkGraphToPolyData;
46 class vtkPolyDataMapper;
47 class vtkRenderView;
48 class vtkSplineGraphEdges;
49 class vtkSelection;
50 class vtkTextProperty;
51 class vtkViewTheme;
52 
53 class VTKVIEWSINFOVIS_EXPORT vtkHierarchicalGraphPipeline : public vtkObject
54 {
55 public:
56   static vtkHierarchicalGraphPipeline* New();
57   vtkTypeMacro(vtkHierarchicalGraphPipeline, vtkObject);
58   void PrintSelf(ostream& os, vtkIndent indent) override;
59 
60   ///@{
61   /**
62    * The actor associated with the hierarchical graph.
63    */
64   vtkGetObjectMacro(Actor, vtkActor);
65   ///@}
66 
67   ///@{
68   /**
69    * The actor associated with the hierarchical graph.
70    */
71   vtkGetObjectMacro(LabelActor, vtkActor2D);
72   ///@}
73 
74   ///@{
75   /**
76    * The bundling strength for the bundled edges.
77    */
78   virtual void SetBundlingStrength(double strength);
79   virtual double GetBundlingStrength();
80   ///@}
81 
82   ///@{
83   /**
84    * The edge label array name.
85    */
86   virtual void SetLabelArrayName(const char* name);
87   virtual const char* GetLabelArrayName();
88   ///@}
89 
90   ///@{
91   /**
92    * The edge label visibility.
93    */
94   virtual void SetLabelVisibility(bool vis);
95   virtual bool GetLabelVisibility();
96   vtkBooleanMacro(LabelVisibility, bool);
97   ///@}
98 
99   ///@{
100   /**
101    * The edge label text property.
102    */
103   virtual void SetLabelTextProperty(vtkTextProperty* prop);
104   virtual vtkTextProperty* GetLabelTextProperty();
105   ///@}
106 
107   ///@{
108   /**
109    * The edge color array.
110    */
111   virtual void SetColorArrayName(const char* name);
112   virtual const char* GetColorArrayName();
113   ///@}
114 
115   ///@{
116   /**
117    * Whether to color the edges by an array.
118    */
119   virtual void SetColorEdgesByArray(bool vis);
120   virtual bool GetColorEdgesByArray();
121   vtkBooleanMacro(ColorEdgesByArray, bool);
122   ///@}
123 
124   ///@{
125   /**
126    * The visibility of this graph.
127    */
128   virtual void SetVisibility(bool vis);
129   virtual bool GetVisibility();
130   vtkBooleanMacro(Visibility, bool);
131   ///@}
132 
133   /**
134    * Returns a new selection relevant to this graph based on an input
135    * selection and the view that this graph is contained in.
136    */
137   virtual vtkSelection* ConvertSelection(vtkDataRepresentation* rep, vtkSelection* sel);
138 
139   /**
140    * Sets the input connections for this graph.
141    * graphConn is the input graph connection.
142    * treeConn is the input tree connection.
143    * annConn is the annotation link connection.
144    */
145   virtual void PrepareInputConnections(
146     vtkAlgorithmOutput* graphConn, vtkAlgorithmOutput* treeConn, vtkAlgorithmOutput* annConn);
147 
148   /**
149    * Applies the view theme to this graph.
150    */
151   virtual void ApplyViewTheme(vtkViewTheme* theme);
152 
153   ///@{
154   /**
155    * The array to use while hovering over an edge.
156    */
157   vtkSetStringMacro(HoverArrayName);
158   vtkGetStringMacro(HoverArrayName);
159   ///@}
160 
161   ///@{
162   /**
163    * The spline mode to use in vtkSplineGraphEdges.
164    * vtkSplineGraphEdges::CUSTOM uses a vtkCardinalSpline.
165    * vtkSplineGraphEdges::BSPLINE uses a b-spline.
166    * The default is BSPLINE.
167    */
168   virtual void SetSplineType(int type);
169   virtual int GetSplineType();
170   ///@}
171 
172   /**
173    * Register progress with a view.
174    */
175   void RegisterProgress(vtkRenderView* view);
176 
177 protected:
178   vtkHierarchicalGraphPipeline();
179   ~vtkHierarchicalGraphPipeline() override;
180 
181   vtkApplyColors* ApplyColors;
182   vtkGraphHierarchicalBundleEdges* Bundle;
183   vtkGraphToPolyData* GraphToPoly;
184   vtkSplineGraphEdges* Spline;
185   vtkPolyDataMapper* Mapper;
186   vtkActor* Actor;
187   vtkTextProperty* TextProperty;
188   vtkEdgeCenters* EdgeCenters;
189   vtkDynamic2DLabelMapper* LabelMapper;
190   vtkActor2D* LabelActor;
191 
192   char* HoverArrayName;
193 
194   vtkSetStringMacro(ColorArrayNameInternal);
195   vtkGetStringMacro(ColorArrayNameInternal);
196   char* ColorArrayNameInternal;
197 
198   vtkSetStringMacro(LabelArrayNameInternal);
199   vtkGetStringMacro(LabelArrayNameInternal);
200   char* LabelArrayNameInternal;
201 
202 private:
203   vtkHierarchicalGraphPipeline(const vtkHierarchicalGraphPipeline&) = delete;
204   void operator=(const vtkHierarchicalGraphPipeline&) = delete;
205 };
206 
207 #endif
208