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 "vtkStdString.h" // For get/set ivars
37 #include "vtkVector.h" // For vtkVector2f ivar
38 #include <map> // For column ranges
39 #include <set> // For blank row support
40 #include <vector> // For row mapping
41 
42 class vtkBitArray;
43 class vtkCategoryLegend;
44 class vtkColorLegend;
45 class vtkLookupTable;
46 class vtkStringArray;
47 class vtkTable;
48 class vtkTooltipItem;
49 class vtkVariantArray;
50 
52 {
53 public:
54  static vtkHeatmapItem *New();
56  virtual void PrintSelf(ostream &os, vtkIndent indent);
57 
60  virtual void SetTable(vtkTable *table);
61 
63  vtkTable * GetTable();
64 
66  vtkStringArray * GetRowNames();
67 
69 
73  vtkGetMacro(NameColumn, vtkStdString);
74  vtkSetMacro(NameColumn, vtkStdString);
76 
78  void SetOrientation(int orientation);
79 
81  int GetOrientation();
82 
86  double GetTextAngleForOrientation(int orientation);
87 
89 
90  vtkSetVector2Macro(Position, float);
91  void SetPosition(const vtkVector2f &pos);
93 
95 
96  vtkGetVector2Macro(Position, float);
97  vtkVector2f GetPositionVector();
99 
101 
102  vtkGetMacro(CellHeight, double);
103  vtkSetMacro(CellHeight, double);
105 
107 
108  vtkGetMacro(CellWidth, double);
109  vtkSetMacro(CellWidth, double);
111 
113  virtual void GetBounds(double bounds[4]);
114 
117  void MarkRowAsBlank(std::string rowName);
118 
120  virtual bool Paint(vtkContext2D *painter);
121 
123 
125  vtkGetMacro(RowLabelWidth, float);
126  vtkGetMacro(ColumnLabelWidth, float);
128 
129  //BTX
130 
132 
133  enum
134  {
138  DOWN_TO_UP
139  };
141 
143  virtual bool Hit(const vtkContextMouseEvent &mouse);
144 
146  virtual bool MouseMoveEvent(const vtkContextMouseEvent &event);
147 
149  virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &event);
150 
151  //ETX
152 
153 protected:
154  vtkHeatmapItem();
155  ~vtkHeatmapItem();
156 
158  float* Position;
159 
162  virtual void RebuildBuffers();
163 
166  virtual void PaintBuffers(vtkContext2D *painter);
167 
170  virtual bool IsDirty();
171 
173  void InitializeLookupTables();
174 
179  void AccumulateProminentCategoricalDataValues(vtkIdType column);
180 
183  void GenerateContinuousDataLookupTable();
184 
187  void GenerateCategoricalDataLookupTable();
188 
192  std::string GetTooltipText(float x, float y);
193 
198  void UpdateVisibleSceneExtent(vtkContext2D *painter);
199 
203  bool LineIsVisible(double x0, double y0, double x1, double y1);
204 
207  void ComputeBounds();
208 
211  void ComputeLabelWidth(vtkContext2D *painter);
212 
213  // Setup the position, size, and orientation of this heatmap's color
214  // legend based on the heatmap's current orientation.
215  void PositionColorLegend(int orientation);
216 
217  // Setup the position, size, and orientation of this heatmap's
218  // legends based on the heatmap's current orientation.
219  void PositionLegends(int orientation);
220 
224 
225 private:
226  vtkHeatmapItem(const vtkHeatmapItem&); // Not implemented
227  void operator=(const vtkHeatmapItem&); // Not implemented
228 
229  unsigned long HeatmapBuildTime;
230  vtkNew<vtkCategoryLegend> CategoryLegend;
231  vtkNew<vtkColorLegend> ColorLegend;
232  vtkNew<vtkTooltipItem> Tooltip;
233  vtkNew<vtkLookupTable> ContinuousDataLookupTable;
234  vtkNew<vtkLookupTable> CategoricalDataLookupTable;
235  vtkNew<vtkLookupTable> ColorLegendLookupTable;
236  vtkNew<vtkStringArray> CategoricalDataValues;
237  vtkNew<vtkVariantArray> CategoryLegendValues;
238  double CellWidth;
239  double CellHeight;
240 
241  std::map< vtkIdType, std::pair< double, double > > ColumnRanges;
242  std::vector< vtkIdType > SceneRowToTableRowMap;
243  std::vector< vtkIdType > SceneColumnToTableColumnMap;
244  std::set<std::string> BlankRows;
245 
246  double MinX;
247  double MinY;
248  double MaxX;
249  double MaxY;
250  double SceneBottomLeft[3];
251  double SceneTopRight[3];
252  float RowLabelWidth;
253  float ColumnLabelWidth;
254 
255  vtkBitArray* CollapsedRowsArray;
256  vtkBitArray* CollapsedColumnsArray;
257  bool LegendPositionSet;
258 };
259 
260 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
An array holding vtkVariants.
base class for items that are part of a vtkContextScene.
virtual bool Paint(vtkContext2D *painter)
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:247
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:56
data structure to represent mouse events.
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkVector2f PositionVector
vtkStringArray * RowNames
Legend item to display categorical data.
vtkSmartPointer< vtkTable > Table
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:67
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:35
virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse)
virtual bool Hit(const vtkContextMouseEvent &mouse)
vtkStdString NameColumn
takes care of drawing 2D axes
virtual void PrintSelf(ostream &os, vtkIndent indent)
static vtkObject * New()
virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse)
#define VTKVIEWSINFOVIS_EXPORT