VTK
vtkHeatmapItem.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkHeatmapItem.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 =========================================================================*/
28 #ifndef __vtkHeatmapItem_h
29 #define __vtkHeatmapItem_h
30 
31 #include "vtkViewsInfovisModule.h" // For export macro
32 #include "vtkContextItem.h"
33 
34 #include "vtkNew.h" // For vtkNew ivars
35 #include "vtkSmartPointer.h" // For vtkSmartPointer ivars
36 #include "vtkVector.h" // For vtkVector2f ivar
37 #include <map> // For column ranges
38 #include <set> // For blank row support
39 #include <vector> // For row mapping
40 
41 class vtkBitArray;
42 class vtkCategoryLegend;
43 class vtkColorLegend;
44 class vtkLookupTable;
45 class vtkStringArray;
46 class vtkTable;
47 class vtkTooltipItem;
48 class vtkVariantArray;
49 
51 {
52 public:
53  static vtkHeatmapItem *New();
55  virtual void PrintSelf(ostream &os, vtkIndent indent);
56 
59  virtual void SetTable(vtkTable *table);
60 
62  vtkTable * GetTable();
63 
65  void SetOrientation(int orientation);
66 
68  int GetOrientation();
69 
73  double GetTextAngleForOrientation(int orientation);
74 
76 
77  vtkSetVector2Macro(Position, float);
78  void SetPosition(const vtkVector2f &pos);
80 
82 
83  vtkGetVector2Macro(Position, float);
84  vtkVector2f GetPositionVector();
86 
88 
89  vtkGetMacro(CellHeight, double);
90  vtkSetMacro(CellHeight, double);
92 
94 
95  vtkGetMacro(CellWidth, double);
96  vtkSetMacro(CellWidth, double);
98 
100  virtual void GetBounds(double bounds[4]);
101 
104  void MarkRowAsBlank(std::string rowName);
105 
107  virtual bool Paint(vtkContext2D *painter);
108 
110 
112  vtkGetMacro(RowLabelWidth, float);
113  vtkGetMacro(ColumnLabelWidth, float);
115 
116  //BTX
117 
119 
120  enum
121  {
125  DOWN_TO_UP
126  };
128 
130  virtual bool Hit(const vtkContextMouseEvent &mouse);
131 
133  virtual bool MouseMoveEvent(const vtkContextMouseEvent &event);
134 
136  virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &event);
137 
138  //ETX
139 
140 protected:
141  vtkHeatmapItem();
142  ~vtkHeatmapItem();
143 
145  float* Position;
146 
149  virtual void RebuildBuffers();
150 
153  virtual void PaintBuffers(vtkContext2D *painter);
154 
157  virtual bool IsDirty();
158 
160  void InitializeLookupTables();
161 
166  void AccumulateProminentCategoricalDataValues(vtkIdType column);
167 
170  void GenerateContinuousDataLookupTable();
171 
174  void GenerateCategoricalDataLookupTable();
175 
179  std::string GetTooltipText(float x, float y);
180 
185  void UpdateVisibleSceneExtent(vtkContext2D *painter);
186 
190  bool LineIsVisible(double x0, double y0, double x1, double y1);
191 
194  void ComputeBounds();
195 
198  void ComputeLabelWidth(vtkContext2D *painter);
199 
200  // Setup the position, size, and orientation of this heatmap's color
201  // legend based on the heatmap's current orientation.
202  void PositionColorLegend(int orientation);
203 
204  // Setup the position, size, and orientation of this heatmap's
205  // legends based on the heatmap's current orientation.
206  void PositionLegends(int orientation);
207 
209 
210 private:
211  vtkHeatmapItem(const vtkHeatmapItem&); // Not implemented
212  void operator=(const vtkHeatmapItem&); // Not implemented
213 
214  unsigned long HeatmapBuildTime;
215  vtkNew<vtkCategoryLegend> CategoryLegend;
216  vtkNew<vtkColorLegend> ColorLegend;
217  vtkNew<vtkTooltipItem> Tooltip;
218  vtkNew<vtkLookupTable> ContinuousDataLookupTable;
219  vtkNew<vtkLookupTable> CategoricalDataLookupTable;
220  vtkNew<vtkLookupTable> ColorLegendLookupTable;
221  vtkNew<vtkStringArray> CategoricalDataValues;
222  vtkNew<vtkVariantArray> CategoryLegendValues;
223  double CellWidth;
224  double CellHeight;
225 
226  std::map< vtkIdType, std::pair< double, double > > ColumnRanges;
227  std::vector< vtkIdType > SceneRowToTableRowMap;
228  std::vector< vtkIdType > SceneColumnToTableColumnMap;
229  std::set<std::string> BlankRows;
230 
231  double MinX;
232  double MinY;
233  double MaxX;
234  double MaxY;
235  double SceneBottomLeft[3];
236  double SceneTopRight[3];
237  float RowLabelWidth;
238  float ColumnLabelWidth;
239 
240  vtkBitArray* CollapsedRowsArray;
241  vtkBitArray* CollapsedColumnsArray;
242  bool LegendPositionSet;
243 };
244 
245 #endif
GLenum GLenum GLvoid GLvoid * column
Definition: vtkgl.h:11352
An array holding vtkVariants.
base class for items that are part of a vtkContextScene.
virtual bool Paint(vtkContext2D *painter)
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
map scalar values into colors via a lookup table
Legend item to display vtkScalarsToColors.
a vtkAbstractArray subclass for strings
A 2D graphics item for rendering a heatmap.
int vtkIdType
Definition: vtkType.h:268
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: vtkgl.h:11332
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:619
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:56
data structure to represent mouse events.
struct _cl_event * event
Definition: vtkgl.h:14387
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkVector2f PositionVector
Legend item to display categorical data.
vtkSmartPointer< vtkTable > Table
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:67
#define vtkGetVector2Macro(name, type)
Definition: vtkSetGet.h:260
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:35
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
virtual bool Hit(const vtkContextMouseEvent &mouse)
takes care of drawing 2D axes
virtual void PrintSelf(ostream &os, vtkIndent indent)
static vtkObject * New()
virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse)
GLsizei const GLchar ** string
Definition: vtkgl.h:12011
#define vtkSetVector2Macro(name, type)
Definition: vtkSetGet.h:244
#define VTKVIEWSINFOVIS_EXPORT
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69