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 =========================================================================*/
29 #ifndef vtkHeatmapItem_h
30 #define vtkHeatmapItem_h
31 
32 #include "vtkViewsInfovisModule.h" // For export macro
33 #include "vtkContextItem.h"
34 
35 #include "vtkNew.h" // For vtkNew ivars
36 #include "vtkSmartPointer.h" // For vtkSmartPointer ivars
37 #include "vtkStdString.h" // For get/set ivars
38 #include "vtkVector.h" // For vtkVector2f ivar
39 #include <map> // For column ranges
40 #include <set> // For blank row support
41 #include <vector> // For row mapping
42 
43 class vtkBitArray;
44 class vtkCategoryLegend;
45 class vtkColorLegend;
46 class vtkLookupTable;
47 class vtkStringArray;
48 class vtkTable;
49 class vtkTooltipItem;
50 class vtkVariantArray;
51 
52 class VTKVIEWSINFOVIS_EXPORT vtkHeatmapItem : public vtkContextItem
53 {
54 public:
55  static vtkHeatmapItem *New();
57  virtual void PrintSelf(ostream &os, vtkIndent indent);
58 
63  virtual void SetTable(vtkTable *table);
64 
68  vtkTable * GetTable();
69 
73  vtkStringArray * GetRowNames();
74 
76 
83  vtkGetMacro(NameColumn, vtkStdString);
84  vtkSetMacro(NameColumn, vtkStdString);
86 
90  void SetOrientation(int orientation);
91 
95  int GetOrientation();
96 
102  double GetTextAngleForOrientation(int orientation);
103 
105 
108  vtkSetVector2Macro(Position, float);
109  void SetPosition(const vtkVector2f &pos);
111 
113 
116  vtkGetVector2Macro(Position, float);
117  vtkVector2f GetPositionVector();
119 
121 
125  vtkGetMacro(CellHeight, double);
126  vtkSetMacro(CellHeight, double);
128 
130 
134  vtkGetMacro(CellWidth, double);
135  vtkSetMacro(CellWidth, double);
137 
141  virtual void GetBounds(double bounds[4]);
142 
147  void MarkRowAsBlank(std::string rowName);
148 
152  virtual bool Paint(vtkContext2D *painter);
153 
155 
159  vtkGetMacro(RowLabelWidth, float);
160  vtkGetMacro(ColumnLabelWidth, float);
162 
166  enum
167  {
171  DOWN_TO_UP
172  };
173 
177  virtual bool Hit(const vtkContextMouseEvent &mouse);
178 
182  virtual bool MouseMoveEvent(const vtkContextMouseEvent &event);
183 
187  virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &event);
188 
189 protected:
190  vtkHeatmapItem();
191  ~vtkHeatmapItem();
192 
194  float* Position;
195 
200  virtual void RebuildBuffers();
201 
205  virtual void PaintBuffers(vtkContext2D *painter);
206 
211  virtual bool IsDirty();
212 
216  void InitializeLookupTables();
217 
224  void AccumulateProminentCategoricalDataValues(vtkIdType column);
225 
230  void GenerateContinuousDataLookupTable();
231 
236  void GenerateCategoricalDataLookupTable();
237 
243  std::string GetTooltipText(float x, float y);
244 
251  void UpdateVisibleSceneExtent(vtkContext2D *painter);
252 
258  bool LineIsVisible(double x0, double y0, double x1, double y1);
259 
264  void ComputeBounds();
265 
270  void ComputeLabelWidth(vtkContext2D *painter);
271 
272  // Setup the position, size, and orientation of this heatmap's color
273  // legend based on the heatmap's current orientation.
274  void PositionColorLegend(int orientation);
275 
276  // Setup the position, size, and orientation of this heatmap's
277  // legends based on the heatmap's current orientation.
278  void PositionLegends(int orientation);
279 
283 
284 private:
285  vtkHeatmapItem(const vtkHeatmapItem&) VTK_DELETE_FUNCTION;
286  void operator=(const vtkHeatmapItem&) VTK_DELETE_FUNCTION;
287 
288  unsigned long HeatmapBuildTime;
289  vtkNew<vtkCategoryLegend> CategoryLegend;
290  vtkNew<vtkColorLegend> ColorLegend;
291  vtkNew<vtkTooltipItem> Tooltip;
292  vtkNew<vtkLookupTable> ContinuousDataLookupTable;
293  vtkNew<vtkLookupTable> CategoricalDataLookupTable;
294  vtkNew<vtkLookupTable> ColorLegendLookupTable;
295  vtkNew<vtkStringArray> CategoricalDataValues;
296  vtkNew<vtkVariantArray> CategoryLegendValues;
297  double CellWidth;
298  double CellHeight;
299 
300  std::map< vtkIdType, std::pair< double, double > > ColumnRanges;
301  std::vector< vtkIdType > SceneRowToTableRowMap;
302  std::vector< vtkIdType > SceneColumnToTableColumnMap;
303  std::set<std::string> BlankRows;
304 
305  double MinX;
306  double MinY;
307  double MaxX;
308  double MaxY;
309  double SceneBottomLeft[3];
310  double SceneTopRight[3];
311  float RowLabelWidth;
312  float ColumnLabelWidth;
313 
314  vtkBitArray* CollapsedRowsArray;
315  vtkBitArray* CollapsedColumnsArray;
316  bool LegendPositionSet;
317 };
318 
319 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:47
An array holding vtkVariants.
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
Legend item to display vtkScalarsToColors.
a vtkAbstractArray subclass for strings
A 2D graphics item for rendering a heatmap.
int vtkIdType
Definition: vtkType.h:287
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:57
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkVector2f PositionVector
vtkStringArray * RowNames
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
Legend item to display categorical data.
vtkSmartPointer< vtkTable > Table
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:68
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:36
Allocate and hold a VTK object.
Definition: vtkNew.h:67
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
Mouse move event.
virtual bool Hit(const vtkContextMouseEvent &mouse)
Return true if the supplied x, y coordinate is inside the item.
vtkStdString NameColumn
takes care of drawing 2D axes
virtual void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse)
Mouse button double click event.