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 "vtkStdString.h" // For get/set ivars 00037 #include "vtkVector.h" // For vtkVector2f ivar 00038 #include <map> // For column ranges 00039 #include <set> // For blank row support 00040 #include <vector> // For row mapping 00041 00042 class vtkBitArray; 00043 class vtkCategoryLegend; 00044 class vtkColorLegend; 00045 class vtkLookupTable; 00046 class vtkStringArray; 00047 class vtkTable; 00048 class vtkTooltipItem; 00049 class vtkVariantArray; 00050 00051 class VTKVIEWSINFOVIS_EXPORT vtkHeatmapItem : public vtkContextItem 00052 { 00053 public: 00054 static vtkHeatmapItem *New(); 00055 vtkTypeMacro(vtkHeatmapItem, vtkContextItem); 00056 virtual void PrintSelf(ostream &os, vtkIndent indent); 00057 00060 virtual void SetTable(vtkTable *table); 00061 00063 vtkTable * GetTable(); 00064 00066 vtkStringArray * GetRowNames(); 00067 00069 00073 vtkGetMacro(NameColumn, vtkStdString); 00074 vtkSetMacro(NameColumn, vtkStdString); 00076 00078 void SetOrientation(int orientation); 00079 00081 int GetOrientation(); 00082 00086 double GetTextAngleForOrientation(int orientation); 00087 00089 00090 vtkSetVector2Macro(Position, float); 00091 void SetPosition(const vtkVector2f &pos); 00093 00095 00096 vtkGetVector2Macro(Position, float); 00097 vtkVector2f GetPositionVector(); 00099 00101 00102 vtkGetMacro(CellHeight, double); 00103 vtkSetMacro(CellHeight, double); 00105 00107 00108 vtkGetMacro(CellWidth, double); 00109 vtkSetMacro(CellWidth, double); 00111 00113 virtual void GetBounds(double bounds[4]); 00114 00117 void MarkRowAsBlank(std::string rowName); 00118 00120 virtual bool Paint(vtkContext2D *painter); 00121 00123 00125 vtkGetMacro(RowLabelWidth, float); 00126 vtkGetMacro(ColumnLabelWidth, float); 00128 00129 //BTX 00130 00132 00133 enum 00134 { 00135 LEFT_TO_RIGHT, 00136 UP_TO_DOWN, 00137 RIGHT_TO_LEFT, 00138 DOWN_TO_UP 00139 }; 00141 00143 virtual bool Hit(const vtkContextMouseEvent &mouse); 00144 00146 virtual bool MouseMoveEvent(const vtkContextMouseEvent &event); 00147 00149 virtual bool MouseDoubleClickEvent(const vtkContextMouseEvent &event); 00150 00151 //ETX 00152 00153 protected: 00154 vtkHeatmapItem(); 00155 ~vtkHeatmapItem(); 00156 00157 vtkVector2f PositionVector; 00158 float* Position; 00159 00162 virtual void RebuildBuffers(); 00163 00166 virtual void PaintBuffers(vtkContext2D *painter); 00167 00170 virtual bool IsDirty(); 00171 00173 void InitializeLookupTables(); 00174 00179 void AccumulateProminentCategoricalDataValues(vtkIdType column); 00180 00183 void GenerateContinuousDataLookupTable(); 00184 00187 void GenerateCategoricalDataLookupTable(); 00188 00192 std::string GetTooltipText(float x, float y); 00193 00198 void UpdateVisibleSceneExtent(vtkContext2D *painter); 00199 00203 bool LineIsVisible(double x0, double y0, double x1, double y1); 00204 00207 void ComputeBounds(); 00208 00211 void ComputeLabelWidth(vtkContext2D *painter); 00212 00213 // Setup the position, size, and orientation of this heatmap's color 00214 // legend based on the heatmap's current orientation. 00215 void PositionColorLegend(int orientation); 00216 00217 // Setup the position, size, and orientation of this heatmap's 00218 // legends based on the heatmap's current orientation. 00219 void PositionLegends(int orientation); 00220 00221 vtkSmartPointer<vtkTable> Table; 00222 vtkStringArray * RowNames; 00223 vtkStdString NameColumn; 00224 00225 private: 00226 vtkHeatmapItem(const vtkHeatmapItem&); // Not implemented 00227 void operator=(const vtkHeatmapItem&); // Not implemented 00228 00229 unsigned long HeatmapBuildTime; 00230 vtkNew<vtkCategoryLegend> CategoryLegend; 00231 vtkNew<vtkColorLegend> ColorLegend; 00232 vtkNew<vtkTooltipItem> Tooltip; 00233 vtkNew<vtkLookupTable> ContinuousDataLookupTable; 00234 vtkNew<vtkLookupTable> CategoricalDataLookupTable; 00235 vtkNew<vtkLookupTable> ColorLegendLookupTable; 00236 vtkNew<vtkStringArray> CategoricalDataValues; 00237 vtkNew<vtkVariantArray> CategoryLegendValues; 00238 double CellWidth; 00239 double CellHeight; 00240 00241 std::map< vtkIdType, std::pair< double, double > > ColumnRanges; 00242 std::vector< vtkIdType > SceneRowToTableRowMap; 00243 std::vector< vtkIdType > SceneColumnToTableColumnMap; 00244 std::set<std::string> BlankRows; 00245 00246 double MinX; 00247 double MinY; 00248 double MaxX; 00249 double MaxY; 00250 double SceneBottomLeft[3]; 00251 double SceneTopRight[3]; 00252 float RowLabelWidth; 00253 float ColumnLabelWidth; 00254 00255 vtkBitArray* CollapsedRowsArray; 00256 vtkBitArray* CollapsedColumnsArray; 00257 bool LegendPositionSet; 00258 }; 00259 00260 #endif