VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vtkTreeHeatmapItem.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: TestDiagram.cxx
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 =========================================================================*/
38 #ifndef __vtkTreeHeatmapItem_h
39 #define __vtkTreeHeatmapItem_h
40 
41 #include "vtkViewsInfovisModule.h" // For export macro
42 #include "vtkContextItem.h"
43 
44 #include "vtkNew.h" // For vtkNew ivars
45 #include "vtkSmartPointer.h" // For vtkSmartPointer ivars
46 #include <vector> // For lookup tables
47 #include <map> // For string lookup tables
48 
49 class vtkDoubleArray;
50 class vtkGraphLayout;
51 class vtkLookupTable;
52 class vtkTable;
53 class vtkTooltipItem;
54 class vtkTree;
55 class vtkPruneTreeFilter;
56 
57 class VTKVIEWSINFOVIS_EXPORT vtkTreeHeatmapItem : public vtkContextItem
58 {
59 public:
60  static vtkTreeHeatmapItem *New();
61  vtkTypeMacro(vtkTreeHeatmapItem, vtkContextItem);
62  virtual void PrintSelf(ostream &os, vtkIndent indent);
63 
69  virtual void SetTree(vtkTree *tree);
70 
72  vtkTree * GetTree();
73 
78  virtual void SetTable(vtkTable *table);
79 
81  vtkTable * GetTable();
82 
87  void CollapseToNumberOfLeafNodes(unsigned int n);
88 
89  // Get the collapsed tree
90  vtkTree * GetPrunedTree();
91 
95  void SetTreeColorArray(const char *arrayName);
96 
97  //BTX
99  virtual bool Hit(const vtkContextMouseEvent &mouse);
100 
102  virtual bool MouseMoveEvent(const vtkContextMouseEvent &event);
103 
105 
107  virtual bool MouseDoubleClickEvent( const vtkContextMouseEvent &event);
108  //ETX
110 
111 protected:
114 
117  virtual void RebuildBuffers();
118 
121  virtual void PaintBuffers(vtkContext2D *painter);
122 
125  virtual bool IsDirty();
126 
130  void ComputeMultipliers();
131 
133  void ComputeTreeBounds();
134 
136  void InitializeLookupTables();
137 
139  virtual bool Paint(vtkContext2D *painter);
140 
144  void GenerateLookupTableForStringColumn(vtkIdType column);
145 
147  void PaintHeatmapWithoutTree(vtkContext2D *painter);
148 
153  bool SetupTextProperty(vtkContext2D *painter);
154 
158  std::string GetTooltipText(float x, float y);
159 
161  void CountLeafNodes();
162 
164  int CountLeafNodes(vtkIdType vertex);
165 
167  vtkIdType GetClosestVertex(double x, double y);
168 
170  void CollapseSubTree(vtkIdType vertex);
171 
173  void ExpandSubTree(vtkIdType vertex);
174 
176  vtkIdType GetOriginalId(vtkIdType vertex);
177 
180  vtkIdType GetPrunedIdForOriginalId(vtkIdType originalId);
181 
185  vtkIdType GetClickedCollapsedSubTree(double x, double y);
186 
191  void UpdateVisibleSceneExtent(vtkContext2D *painter);
192 
196  bool LineIsVisible(double x0, double y0, double x1, double y1);
197 
198 private:
199  vtkTreeHeatmapItem(const vtkTreeHeatmapItem&); // Not implemented
200  void operator=(const vtkTreeHeatmapItem&); // Not implemented
201 
202  vtkSmartPointer<vtkTree> Tree;
203  vtkSmartPointer<vtkTable> Table;
204  vtkSmartPointer<vtkTree> PrunedTree;
205  vtkSmartPointer<vtkTree> LayoutTree;
206  unsigned long TreeHeatmapBuildTime;
207  vtkNew<vtkGraphLayout> Layout;
208  vtkNew<vtkTooltipItem> Tooltip;
209  vtkNew<vtkPruneTreeFilter> PruneFilter;
210  vtkNew<vtkLookupTable> TriangleLookupTable;
211  vtkNew<vtkLookupTable> TreeLookupTable;
212  vtkDoubleArray* TreeColorArray;
213  std::vector< vtkLookupTable * > LookupTables;
214  std::vector< vtkIdType > RowMap;
215  double MultiplierX;
216  double MultiplierY;
217  int NumberOfLeafNodes;
218  double CellWidth;
219  double CellHeight;
220 
221  std::map< int, std::map< std::string, double> > StringToDoubleMaps;
222 
223  double HeatmapMinX;
224  double HeatmapMinY;
225  double HeatmapMaxX;
226  double HeatmapMaxY;
227  double TreeMinX;
228  double TreeMinY;
229  double TreeMaxX;
230  double TreeMaxY;
231  double SceneBottomLeft[3];
232  double SceneTopRight[3];
233  bool JustCollapsedOrExpanded;
234  bool ColorTree;
235 };
236 
237 #endif
layout a graph in 2 or 3 dimensions
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:67
prune a subtree out of a vtkTree
A 2D graphics item for rendering a tree and an associated heatmap.