VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkHeatmapItem.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00028 #ifndef __vtkHeatmapItem_h 00029 #define __vtkHeatmapItem_h 00030 00031 #include "vtkViewsInfovisModule.h" // For export macro 00032 #include "vtkContextItem.h" 00033 00034 #include "vtkNew.h" // For vtkNew ivars 00035 #include "vtkSmartPointer.h" // For vtkSmartPointer ivars 00036 #include "vtkVector.h" // For vtkVector2f ivar 00037 #include <map> // For column ranges 00038 #include <set> // For blank row support 00039 #include <vector> // For row mapping 00040 00041 class vtkBitArray; 00042 class vtkCategoryLegend; 00043 class vtkColorLegend; 00044 class vtkLookupTable; 00045 class vtkStringArray; 00046 class vtkTable; 00047 class vtkTooltipItem; 00048 class vtkVariantArray; 00049 00050 class VTKVIEWSINFOVIS_EXPORT vtkHeatmapItem : public vtkContextItem 00051 { 00052 public: 00053 static vtkHeatmapItem *New(); 00054 vtkTypeMacro(vtkHeatmapItem, vtkContextItem); 00055 virtual void PrintSelf(ostream &os, vtkIndent indent); 00056 00059 virtual void SetTable(vtkTable *table); 00060 00062 vtkTable * GetTable(); 00063 00065 void SetOrientation(int orientation); 00066 00068 int GetOrientation(); 00069 00073 double GetTextAngleForOrientation(int orientation); 00074 00076 00077 vtkSetVector2Macro(Position, float); 00078 void SetPosition(const vtkVector2f &pos); 00080 00082 00083 vtkGetVector2Macro(Position, float); 00084 vtkVector2f GetPositionVector(); 00086 00088 00089 vtkGetMacro(CellHeight, double); 00090 vtkSetMacro(CellHeight, double); 00092 00094 00095 vtkGetMacro(CellWidth, double); 00096 vtkSetMacro(CellWidth, double); 00098 00100 virtual void GetBounds(double bounds[4]); 00101 00104 void MarkRowAsBlank(std::string rowName); 00105 00107 virtual bool Paint(vtkContext2D *painter); 00108 00110 00112 vtkGetMacro(RowLabelWidth, float); 00113 vtkGetMacro(ColumnLabelWidth, float); 00115 00116 //BTX 00117 00119 00120 enum 00121 { 00122 LEFT_TO_RIGHT, 00123 UP_TO_DOWN, 00124 RIGHT_TO_LEFT, 00125 DOWN_TO_UP 00126 }; 00128 00130 virtual bool Hit(const vtkContextMouseEvent &mouse); 00131 00133 virtual bool MouseMoveEvent(const vtkContextMouseEvent &event); 00134 00136 virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &event); 00137 00138 //ETX 00139 00140 protected: 00141 vtkHeatmapItem(); 00142 ~vtkHeatmapItem(); 00143 00144 vtkVector2f PositionVector; 00145 float* Position; 00146 00149 virtual void RebuildBuffers(); 00150 00153 virtual void PaintBuffers(vtkContext2D *painter); 00154 00157 virtual bool IsDirty(); 00158 00160 void InitializeLookupTables(); 00161 00166 void AccumulateProminentCategoricalDataValues(vtkIdType column); 00167 00170 void GenerateContinuousDataLookupTable(); 00171 00174 void GenerateCategoricalDataLookupTable(); 00175 00179 std::string GetTooltipText(float x, float y); 00180 00185 void UpdateVisibleSceneExtent(vtkContext2D *painter); 00186 00190 bool LineIsVisible(double x0, double y0, double x1, double y1); 00191 00194 void ComputeBounds(); 00195 00198 void ComputeLabelWidth(vtkContext2D *painter); 00199 00200 // Setup the position, size, and orientation of this heatmap's color 00201 // legend based on the heatmap's current orientation. 00202 void PositionColorLegend(int orientation); 00203 00204 // Setup the position, size, and orientation of this heatmap's 00205 // legends based on the heatmap's current orientation. 00206 void PositionLegends(int orientation); 00207 00208 vtkSmartPointer<vtkTable> Table; 00209 00210 private: 00211 vtkHeatmapItem(const vtkHeatmapItem&); // Not implemented 00212 void operator=(const vtkHeatmapItem&); // Not implemented 00213 00214 unsigned long HeatmapBuildTime; 00215 vtkNew<vtkCategoryLegend> CategoryLegend; 00216 vtkNew<vtkColorLegend> ColorLegend; 00217 vtkNew<vtkTooltipItem> Tooltip; 00218 vtkNew<vtkLookupTable> ContinuousDataLookupTable; 00219 vtkNew<vtkLookupTable> CategoricalDataLookupTable; 00220 vtkNew<vtkLookupTable> ColorLegendLookupTable; 00221 vtkNew<vtkStringArray> CategoricalDataValues; 00222 vtkNew<vtkVariantArray> CategoryLegendValues; 00223 double CellWidth; 00224 double CellHeight; 00225 00226 std::map< vtkIdType, std::pair< double, double > > ColumnRanges; 00227 std::vector< vtkIdType > SceneRowToTableRowMap; 00228 std::vector< vtkIdType > SceneColumnToTableColumnMap; 00229 std::set<std::string> BlankRows; 00230 00231 double MinX; 00232 double MinY; 00233 double MaxX; 00234 double MaxY; 00235 double SceneBottomLeft[3]; 00236 double SceneTopRight[3]; 00237 float RowLabelWidth; 00238 float ColumnLabelWidth; 00239 00240 vtkBitArray* CollapsedRowsArray; 00241 vtkBitArray* CollapsedColumnsArray; 00242 bool LegendPositionSet; 00243 }; 00244 00245 #endif