VTK  9.3.20240418
vtkTanglegramItem.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
20 #ifndef vtkTanglegramItem_h
21 #define vtkTanglegramItem_h
22 
23 #include "vtkViewsInfovisModule.h" // For export macro
24 
25 #include "vtkContextItem.h"
26 #include "vtkSmartPointer.h" // For SmartPointer ivars
27 #include "vtkTable.h" // For get/set
28 
29 VTK_ABI_NAMESPACE_BEGIN
30 class vtkDendrogramItem;
31 class vtkLookupTable;
32 class vtkStringArray;
33 class vtkTree;
34 
35 class VTKVIEWSINFOVIS_EXPORT vtkTanglegramItem : public vtkContextItem
36 {
37 public:
40  void PrintSelf(ostream& os, vtkIndent indent) override;
41 
45  virtual void SetTree1(vtkTree* tree);
46 
50  virtual void SetTree2(vtkTree* tree);
51 
53 
63  void SetTable(vtkTable* table);
65 
67 
70  vtkGetStringMacro(Tree1Label);
71  vtkSetStringMacro(Tree1Label);
73 
75 
78  vtkGetStringMacro(Tree2Label);
79  vtkSetStringMacro(Tree2Label);
81 
87 
92 
94 
100  vtkGetMacro(MinimumVisibleFontSize, int);
101  vtkSetMacro(MinimumVisibleFontSize, int);
103 
105 
111  vtkGetMacro(LabelSizeDifference, int);
112  vtkSetMacro(LabelSizeDifference, int);
114 
116 
119  vtkGetMacro(CorrespondenceLineWidth, float);
120  vtkSetMacro(CorrespondenceLineWidth, float);
122 
124 
128  void SetTreeLineWidth(float width);
130 
134  bool Hit(const vtkContextMouseEvent& mouse) override;
135 
140  bool MouseDoubleClickEvent(const vtkContextMouseEvent& event) override;
141 
142 protected:
144  ~vtkTanglegramItem() override;
145 
149  void RefreshBuffers(vtkContext2D* painter);
150 
155 
160 
165 
170  void ReorderTree();
171 
177  void ReorderTreeAtVertex(vtkIdType parent, vtkTree* tree);
178 
186 
192 
196  bool Paint(vtkContext2D* painter) override;
197 
198 private:
203  vtkStringArray* Tree1Names;
204  vtkStringArray* Tree2Names;
205  vtkStringArray* SourceNames;
206  double Tree1Bounds[4];
207  double Tree2Bounds[4];
208  double Spacing;
209  double LabelWidth1;
210  double LabelWidth2;
211  bool PositionSet;
212  bool TreeReordered;
213  char* Tree1Label;
214  char* Tree2Label;
215  int Orientation;
216  int MinimumVisibleFontSize;
217  int LabelSizeDifference;
218  float CorrespondenceLineWidth;
219 
220  vtkTanglegramItem(const vtkTanglegramItem&) = delete;
221  void operator=(const vtkTanglegramItem&) = delete;
222 };
223 
224 VTK_ABI_NAMESPACE_END
225 #endif
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:69
base class for items that are part of a vtkContextScene.
data structure to represent mouse events.
A 2D graphics item for rendering a tree as a dendrogram.
a simple class to control print indentation
Definition: vtkIndent.h:108
map scalar values into colors via a lookup table
a vtkAbstractArray subclass for strings
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:168
Display two related trees.
void RefreshBuffers(vtkContext2D *painter)
Update the bounds of our two dendrograms.
void ReorderTree()
Reorder the children of tree #2 to minimize the amount of crossings in our tanglegram.
bool MouseDoubleClickEvent(const vtkContextMouseEvent &event) override
Propagate any double click onto the dendrograms to check if any subtrees should be collapsed or expan...
void SetTable(vtkTable *table)
Get/Set the table that describes the correspondences between the two trees.
static vtkTanglegramItem * New()
int GetOrientation()
Get the current orientation.
bool Hit(const vtkContextMouseEvent &mouse) override
Returns true if the transform is interactive, false otherwise.
void PaintTreeLabels(vtkContext2D *painter)
Draw the labels of our two dendrograms.
void ReorderTreeAtVertex(vtkIdType parent, vtkTree *tree)
Helper function used by ReorderTree.
void PositionTree2()
Calculate and set an appropriate position for our second dendrogram.
void SetTreeLineWidth(float width)
Get/Set how wide the edges of the trees should be.
~vtkTanglegramItem() override
vtkTable * GetTable()
Get/Set the table that describes the correspondences between the two trees.
void GenerateLookupTable()
Initialize the lookup table used to color the lines between the two dendrograms.
void PaintCorrespondenceLines(vtkContext2D *painter)
Draw the lines between the corresponding vertices of our two dendrograms.
float GetTreeLineWidth()
Get/Set how wide the edges of the trees should be.
bool Paint(vtkContext2D *painter) override
Paints the tree & associated table as a heatmap.
double GetPositionScoreForVertex(vtkIdType vertex, vtkTree *tree)
Helper function used by ReorderTreeAtVertex.
virtual void SetTree1(vtkTree *tree)
Set the first tree.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetOrientation(int orientation)
Set which way the tanglegram should face within the visualization.
virtual void SetTree2(vtkTree *tree)
Set the second tree.
A rooted tree data structure.
Definition: vtkTree.h:145
@ orientation
Definition: vtkX3D.h:262
int vtkIdType
Definition: vtkType.h:315