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 
64 
67 
69 
73  vtkGetMacro(NameColumn, vtkStdString);
74  vtkSetMacro(NameColumn, vtkStdString);
76 
79 
82 
87 
89 
90  vtkSetVector2Macro(Position, float);
91  void SetPosition(const vtkVector2f &pos);
93 
95 
96  vtkGetVector2Macro(Position, float);
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 
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 
147 
150 
151  //ETX
152 
153 protected:
156 
158  float* Position;
159 
162  virtual void RebuildBuffers();
163 
166  virtual void PaintBuffers(vtkContext2D *painter);
167 
170  virtual bool IsDirty();
171 
174 
180 
184 
188 
192  std::string GetTooltipText(float x, float y);
193 
199 
203  bool LineIsVisible(double x0, double y0, double x1, double y1);
204 
208 
212 
213  // Setup the position, size, and orientation of this heatmap's color
214  // legend based on the heatmap's current orientation.
216 
217  // Setup the position, size, and orientation of this heatmap's
218  // legends based on the heatmap's current 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
vtkHeatmapItem::GetOrientation
int GetOrientation()
vtkStdString.h
vtkContextMouseEvent
data structure to represent mouse events.
Definition: vtkContextMouseEvent.h:40
vtkViewsInfovisModule.h
vtkHeatmapItem::GetTooltipText
std::string GetTooltipText(float x, float y)
vtkSetVector2Macro
#define vtkSetVector2Macro(name, type)
Definition: vtkSetGet.h:254
vtkHeatmapItem::RIGHT_TO_LEFT
@ RIGHT_TO_LEFT
Definition: vtkHeatmapItem.h:137
vtkHeatmapItem::NameColumn
vtkStdString NameColumn
Definition: vtkHeatmapItem.h:223
vtkHeatmapItem::PositionLegends
void PositionLegends(int orientation)
vtkGetVector2Macro
#define vtkGetVector2Macro(name, type)
Definition: vtkSetGet.h:270
vtkHeatmapItem::GenerateContinuousDataLookupTable
void GenerateContinuousDataLookupTable()
vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkHeatmapItem::MarkRowAsBlank
void MarkRowAsBlank(std::string rowName)
vtkHeatmapItem::GetRowNames
vtkStringArray * GetRowNames()
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:68
vtkHeatmapItem::PositionVector
vtkVector2f PositionVector
Definition: vtkHeatmapItem.h:157
VTKVIEWSINFOVIS_EXPORT
#define VTKVIEWSINFOVIS_EXPORT
Definition: vtkViewsInfovisModule.h:15
vtkHeatmapItem::~vtkHeatmapItem
~vtkHeatmapItem()
vtkHeatmapItem::New
static vtkHeatmapItem * New()
vtkHeatmapItem::UP_TO_DOWN
@ UP_TO_DOWN
Definition: vtkHeatmapItem.h:136
vtkHeatmapItem::SetTable
virtual void SetTable(vtkTable *table)
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkSmartPointer< vtkTable >
vtkVector.h
vtkHeatmapItem::GenerateCategoricalDataLookupTable
void GenerateCategoricalDataLookupTable()
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkTooltipItem
takes care of drawing 2D axes
Definition: vtkTooltipItem.h:39
vtkVariantArray
An array holding vtkVariants.
Definition: vtkVariantArray.h:48
vtkgl::table
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: vtkgl.h:11332
vtkContext2D
Class for drawing 2D primitives to a graphical context.
Definition: vtkContext2D.h:57
vtkContextItem.h
vtkHeatmapItem::ComputeLabelWidth
void ComputeLabelWidth(vtkContext2D *painter)
vtkgl::event
struct _cl_event * event
Definition: vtkgl.h:14387
vtkHeatmapItem::GetBounds
virtual void GetBounds(double bounds[4])
vtkHeatmapItem::UpdateVisibleSceneExtent
void UpdateVisibleSceneExtent(vtkContext2D *painter)
vtkHeatmapItem::SetOrientation
void SetOrientation(int orientation)
vtkHeatmapItem::IsDirty
virtual bool IsDirty()
vtkHeatmapItem::LEFT_TO_RIGHT
@ LEFT_TO_RIGHT
Definition: vtkHeatmapItem.h:135
vtkHeatmapItem::RowNames
vtkStringArray * RowNames
Definition: vtkHeatmapItem.h:222
vtkHeatmapItem::PrintSelf
virtual void PrintSelf(ostream &os, vtkIndent indent)
vtkgl::column
GLenum GLenum GLvoid GLvoid * column
Definition: vtkgl.h:11352
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkHeatmapItem::PaintBuffers
virtual void PaintBuffers(vtkContext2D *painter)
vtkHeatmapItem::MouseMoveEvent
virtual bool MouseMoveEvent(const vtkContextMouseEvent &event)
vtkSmartPointer.h
vtkNew< vtkCategoryLegend >
vtkHeatmapItem::InitializeLookupTables
void InitializeLookupTables()
vtkGetMacro
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
vtkHeatmapItem::Hit
virtual bool Hit(const vtkContextMouseEvent &mouse)
vtkHeatmapItem::GetTextAngleForOrientation
double GetTextAngleForOrientation(int orientation)
vtkHeatmapItem::Paint
virtual bool Paint(vtkContext2D *painter)
vtkHeatmapItem::Position
float * Position
Definition: vtkHeatmapItem.h:158
vtkContextItem
base class for items that are part of a vtkContextScene.
Definition: vtkContextItem.h:34
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
vtkLookupTable
map scalar values into colors via a lookup table
Definition: vtkLookupTable.h:74
vtkColorLegend
Legend item to display vtkScalarsToColors.
Definition: vtkColorLegend.h:38
vtkX3D::orientation
@ orientation
Definition: vtkX3D.h:262
vtkgl::y
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
vtkNew.h
vtkHeatmapItem::MouseDoubleClickEvent
virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &event)
vtkHeatmapItem::GetTable
vtkTable * GetTable()
vtkHeatmapItem::GetPositionVector
vtkVector2f GetPositionVector()
vtkHeatmapItem::AccumulateProminentCategoricalDataValues
void AccumulateProminentCategoricalDataValues(vtkIdType column)
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:45
vtkCategoryLegend
Legend item to display categorical data.
Definition: vtkCategoryLegend.h:44
vtkHeatmapItem::Table
vtkSmartPointer< vtkTable > Table
Definition: vtkHeatmapItem.h:221
vtkBitArray
dynamic, self-adjusting array of bits
Definition: vtkBitArray.h:36
vtkHeatmapItem
A 2D graphics item for rendering a heatmap.
Definition: vtkHeatmapItem.h:52
vtkHeatmapItem::SetPosition
void SetPosition(const vtkVector2f &pos)
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:48
vtkHeatmapItem::ComputeBounds
void ComputeBounds()
vtkHeatmapItem::RebuildBuffers
virtual void RebuildBuffers()
vtkHeatmapItem::PositionColorLegend
void PositionColorLegend(int orientation)
vtkHeatmapItem::LineIsVisible
bool LineIsVisible(double x0, double y0, double x1, double y1)
vtkHeatmapItem::vtkHeatmapItem
vtkHeatmapItem()
vtkgl::string
GLsizei const GLchar ** string
Definition: vtkgl.h:12011
vtkVector2f
Definition: vtkVector.h:277