1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkStackedTreeLayoutStrategy.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 =========================================================================*/ 15 /*------------------------------------------------------------------------- 16 Copyright 2008 Sandia Corporation. 17 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 18 the U.S. Government retains certain rights in this software. 19 -------------------------------------------------------------------------*/ 20 // .NAME vtkStackedTreeLayoutStrategy - lays out tree in stacked boxes or rings 21 // 22 // .SECTION Description 23 // Performs a tree ring layout or "icicle" layout on a tree. 24 // This involves assigning a sector region to each vertex in the tree, 25 // and placing that information in a data array with four components per 26 // tuple representing (innerRadius, outerRadius, startAngle, endAngle). 27 // 28 // This class may be assigned as the layout strategy to vtkAreaLayout. 29 // 30 // .SECTION Thanks 31 // Thanks to Jason Shepherd from Sandia National Laboratories 32 // for help developing this class. 33 34 #ifndef vtkStackedTreeLayoutStrategy_h 35 #define vtkStackedTreeLayoutStrategy_h 36 37 #include "vtkInfovisLayoutModule.h" // For export macro 38 #include "vtkAreaLayoutStrategy.h" 39 40 class vtkTree; 41 class vtkDataArray; 42 43 class VTKINFOVISLAYOUT_EXPORT vtkStackedTreeLayoutStrategy : 44 public vtkAreaLayoutStrategy 45 { 46 public: 47 static vtkStackedTreeLayoutStrategy* New(); 48 vtkTypeMacro(vtkStackedTreeLayoutStrategy,vtkAreaLayoutStrategy); 49 void PrintSelf(ostream& os, vtkIndent indent); 50 51 // Description: 52 // Perform the layout of the input tree, and store the sector 53 // bounds of each vertex as a tuple 54 // (innerRadius, outerRadius, startAngle, endAngle) 55 // in a data array. 56 virtual void Layout(vtkTree *inputTree, vtkDataArray *sectorArray, 57 vtkDataArray* sizeArray); 58 59 // Description: 60 // Fill edgeRoutingTree with points suitable for routing edges of 61 // an overlaid graph. 62 virtual void LayoutEdgePoints(vtkTree *inputTree, vtkDataArray *sectorArray, 63 vtkDataArray* sizeArray, vtkTree *edgeRoutingTree); 64 65 // Description: 66 // Define the tree ring's interior radius. 67 vtkSetMacro(InteriorRadius, double); 68 vtkGetMacro(InteriorRadius, double); 69 70 // Description: 71 // Define the thickness of each of the tree rings. 72 vtkSetMacro(RingThickness, double); 73 vtkGetMacro(RingThickness, double); 74 75 // Description: 76 // Define the start angle for the root node. 77 // NOTE: It is assumed that the root end angle is greater than the 78 // root start angle and subtends no more than 360 degrees. 79 vtkSetMacro(RootStartAngle, double); 80 vtkGetMacro(RootStartAngle, double); 81 82 // Description: 83 // Define the end angle for the root node. 84 // NOTE: It is assumed that the root end angle is greater than the 85 // root start angle and subtends no more than 360 degrees. 86 vtkSetMacro(RootEndAngle, double); 87 vtkGetMacro(RootEndAngle, double); 88 89 // Description: 90 // Define whether or not rectangular coordinates are being used 91 // (as opposed to polar coordinates). 92 vtkSetMacro(UseRectangularCoordinates, bool); 93 vtkGetMacro(UseRectangularCoordinates, bool); 94 vtkBooleanMacro(UseRectangularCoordinates, bool); 95 96 // Description: 97 // Define whether to reverse the order of the tree stacks from 98 // low to high. 99 vtkSetMacro(Reverse, bool); 100 vtkGetMacro(Reverse, bool); 101 vtkBooleanMacro(Reverse, bool); 102 103 // Description: 104 // The spacing of tree levels in the edge routing tree. 105 // Levels near zero give more space 106 // to levels near the root, while levels near one (the default) 107 // create evenly-spaced levels. Levels above one give more space 108 // to levels near the leaves. 109 vtkSetMacro(InteriorLogSpacingValue, double); 110 vtkGetMacro(InteriorLogSpacingValue, double); 111 112 // Description: 113 // Returns the vertex id that contains pnt (or -1 if no one contains it). 114 virtual vtkIdType FindVertex(vtkTree* tree, vtkDataArray* array, float pnt[2]); 115 116 protected: 117 vtkStackedTreeLayoutStrategy(); 118 ~vtkStackedTreeLayoutStrategy(); 119 120 float InteriorRadius; 121 float RingThickness; 122 float RootStartAngle; 123 float RootEndAngle; 124 bool UseRectangularCoordinates; 125 bool Reverse; 126 double InteriorLogSpacingValue; 127 128 void ComputeEdgeRoutingPoints( 129 vtkTree* inputTree, vtkDataArray* coordsArray, vtkTree* outputTree); 130 131 void LayoutChildren( 132 vtkTree *tree, vtkDataArray *coordsArray, vtkDataArray *sizeArray, 133 vtkIdType nchildren, vtkIdType parent, vtkIdType begin, 134 float parentInnerRad, float parentOuterRad, 135 float parentStartAng, float parentEndAng); 136 137 private: 138 vtkStackedTreeLayoutStrategy(const vtkStackedTreeLayoutStrategy&); // Not implemented. 139 void operator=(const vtkStackedTreeLayoutStrategy&); // Not implemented. 140 }; 141 142 #endif 143