VTK  9.3.1
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:
38  static vtkTanglegramItem* New();
40  void PrintSelf(ostream& os, vtkIndent indent) override;
41 
45  virtual void SetTree1(vtkTree* tree);
46 
50  virtual void SetTree2(vtkTree* tree);
51 
53 
62  vtkTable* GetTable();
63  void SetTable(vtkTable* table);
65 
67 
70  vtkGetStringMacro(Tree1Label);
71  vtkSetStringMacro(Tree1Label);
73 
75 
78  vtkGetStringMacro(Tree2Label);
79  vtkSetStringMacro(Tree2Label);
81 
86  void SetOrientation(int orientation);
87 
91  int GetOrientation();
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 
127  float GetTreeLineWidth();
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 
154  void PositionTree2();
155 
159  void PaintCorrespondenceLines(vtkContext2D* painter);
160 
164  void PaintTreeLabels(vtkContext2D* painter);
165 
170  void ReorderTree();
171 
177  void ReorderTreeAtVertex(vtkIdType parent, vtkTree* tree);
178 
185  double GetPositionScoreForVertex(vtkIdType vertex, vtkTree* tree);
186 
191  void GenerateLookupTable();
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
Display two related trees.
A 2D graphics item for rendering a tree as a dendrogram.
base class for items that are part of a vtkContextScene.
virtual bool Paint(vtkContext2D *painter)
Paint event for the item, called whenever the item needs to be drawn.
map scalar values into colors via a lookup table
a vtkAbstractArray subclass for strings
int vtkIdType
Definition: vtkType.h:315
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:49
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:28
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:58
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
A rooted tree data structure.
Definition: vtkTree.h:45
virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse)
Mouse button double click event.