VTK
dox/Views/Infovis/vtkTreeHeatmapItem.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    TestDiagram.cxx
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 =========================================================================*/
00038 #ifndef __vtkTreeHeatmapItem_h
00039 #define __vtkTreeHeatmapItem_h
00040 
00041 #include "vtkViewsInfovisModule.h" // For export macro
00042 #include "vtkContextItem.h"
00043 
00044 #include "vtkNew.h" // For vtkNew ivars
00045 #include "vtkSmartPointer.h" // For vtkSmartPointer ivars
00046 #include <vector>   // For lookup tables
00047 #include <map>      // For string lookup tables
00048 
00049 class vtkDoubleArray;
00050 class vtkGraphLayout;
00051 class vtkLookupTable;
00052 class vtkTable;
00053 class vtkTooltipItem;
00054 class vtkTree;
00055 class vtkPruneTreeFilter;
00056 
00057 class VTKVIEWSINFOVIS_EXPORT vtkTreeHeatmapItem : public vtkContextItem
00058 {
00059 public:
00060   static vtkTreeHeatmapItem *New();
00061   vtkTypeMacro(vtkTreeHeatmapItem, vtkContextItem);
00062   virtual void PrintSelf(ostream &os, vtkIndent indent);
00063 
00069   virtual void SetTree(vtkTree *tree);
00070 
00072   vtkTree * GetTree();
00073 
00078   virtual void SetTable(vtkTable *table);
00079 
00081   vtkTable * GetTable();
00082 
00087   void CollapseToNumberOfLeafNodes(unsigned int n);
00088 
00089   // Get the collapsed tree
00090   vtkTree * GetPrunedTree();
00091 
00095   void SetTreeColorArray(const char *arrayName);
00096 
00097   //BTX
00099   virtual bool Hit(const vtkContextMouseEvent &mouse);
00100 
00102   virtual bool MouseMoveEvent(const vtkContextMouseEvent &event);
00103 
00105 
00107   virtual bool MouseDoubleClickEvent( const vtkContextMouseEvent &event);
00108   //ETX
00110 
00111 protected:
00112   vtkTreeHeatmapItem();
00113   ~vtkTreeHeatmapItem();
00114 
00117   virtual void RebuildBuffers();
00118 
00121   virtual void PaintBuffers(vtkContext2D *painter);
00122 
00125   virtual bool IsDirty();
00126 
00130   void ComputeMultipliers();
00131 
00133   void ComputeTreeBounds();
00134 
00136   void InitializeLookupTables();
00137 
00139   virtual bool Paint(vtkContext2D *painter);
00140 
00144   void GenerateLookupTableForStringColumn(vtkIdType column);
00145 
00147   void PaintHeatmapWithoutTree(vtkContext2D *painter);
00148 
00153   bool SetupTextProperty(vtkContext2D *painter);
00154 
00158   std::string GetTooltipText(float x, float y);
00159 
00161   void CountLeafNodes();
00162 
00164   int CountLeafNodes(vtkIdType vertex);
00165 
00167   vtkIdType GetClosestVertex(double x, double y);
00168 
00170   void CollapseSubTree(vtkIdType vertex);
00171 
00173   void ExpandSubTree(vtkIdType vertex);
00174 
00176   vtkIdType GetOriginalId(vtkIdType vertex);
00177 
00180   vtkIdType GetPrunedIdForOriginalId(vtkIdType originalId);
00181 
00185   vtkIdType GetClickedCollapsedSubTree(double x, double y);
00186 
00191   void UpdateVisibleSceneExtent(vtkContext2D *painter);
00192 
00196   bool LineIsVisible(double x0, double y0, double x1, double y1);
00197 
00198 private:
00199   vtkTreeHeatmapItem(const vtkTreeHeatmapItem&); // Not implemented
00200   void operator=(const vtkTreeHeatmapItem&); // Not implemented
00201 
00202   vtkSmartPointer<vtkTree> Tree;
00203   vtkSmartPointer<vtkTable> Table;
00204   vtkSmartPointer<vtkTree> PrunedTree;
00205   vtkSmartPointer<vtkTree> LayoutTree;
00206   unsigned long TreeHeatmapBuildTime;
00207   vtkNew<vtkGraphLayout> Layout;
00208   vtkNew<vtkTooltipItem> Tooltip;
00209   vtkNew<vtkPruneTreeFilter> PruneFilter;
00210   vtkNew<vtkLookupTable> TriangleLookupTable;
00211   vtkNew<vtkLookupTable> TreeLookupTable;
00212   vtkDoubleArray* TreeColorArray;
00213   std::vector< vtkLookupTable * > LookupTables;
00214   std::vector< vtkIdType > RowMap;
00215   double MultiplierX;
00216   double MultiplierY;
00217   int NumberOfLeafNodes;
00218   double CellWidth;
00219   double CellHeight;
00220 
00221   std::map< int, std::map< std::string, double> > StringToDoubleMaps;
00222 
00223   double HeatmapMinX;
00224   double HeatmapMinY;
00225   double HeatmapMaxX;
00226   double HeatmapMaxY;
00227   double TreeMinX;
00228   double TreeMinY;
00229   double TreeMaxX;
00230   double TreeMaxY;
00231   double SceneBottomLeft[3];
00232   double SceneTopRight[3];
00233   bool JustCollapsedOrExpanded;
00234   bool ColorTree;
00235 };
00236 
00237 #endif