-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
vtkLabeledTreeMapDataMapper.h
179 lines (156 loc) · 5.53 KB
/
vtkLabeledTreeMapDataMapper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*=========================================================================
Program: Visualization Toolkit
Module: vtkLabeledTreeMapDataMapper.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/
/**
* @class vtkLabeledTreeMapDataMapper
* @brief draw text labels on a tree map
*
*
* vtkLabeledTreeMapDataMapper is a mapper that renders text on a tree map.
* A tree map is a vtkTree with an associated 4-tuple array
* used for storing the boundary rectangle for each vertex in the tree.
* The user must specify the array name used for storing the rectangles.
*
* The mapper iterates through the tree and attempts and renders a label
* inside the vertex's rectangle as long as the following conditions hold:
* 1. The vertex level is within the range of levels specified for labeling.
* 2. The label can fully fit inside its box.
* 3. The label does not overlap an ancestor's label.
*
* @sa
* vtkLabeledDataMapper
*
* @par Thanks:
* Thanks to Patricia Crossno, Ken Moreland, Andrew Wilson and Brian Wylie from
* Sandia National Laboratories for their help in developing this class.
*/
#ifndef vtkLabeledTreeMapDataMapper_h
#define vtkLabeledTreeMapDataMapper_h
#include "vtkRenderingLabelModule.h" // For export macro
#include "vtkLabeledDataMapper.h"
class vtkTree;
class vtkPoints;
class vtkCoordinate;
class vtkFloatArray;
class vtkStringArray;
class vtkIdList;
class VTKRENDERINGLABEL_EXPORT vtkLabeledTreeMapDataMapper : public vtkLabeledDataMapper
{
public:
static vtkLabeledTreeMapDataMapper *New();
vtkTypeMacro(vtkLabeledTreeMapDataMapper,vtkLabeledDataMapper);
void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
//@{
/**
* Draw the text to the screen at each input point.
*/
void RenderOpaqueGeometry(vtkViewport* viewport, vtkActor2D* actor) VTK_OVERRIDE;
void RenderOverlay(vtkViewport *viewport, vtkActor2D *actor) VTK_OVERRIDE;
//@}
/**
* The input to this filter.
*/
virtual vtkTree *GetInputTree();
/**
* The name of the 4-tuple array used for
*/
virtual void SetRectanglesArrayName(const char* name);
//@{
/**
* Indicates if the label can be displayed clipped by the Window
* mode = 0 - ok to clip labels
* 1 - auto center labels w/r to the area of the vertex's clipped region
*/
vtkGetMacro(ClipTextMode, int);
vtkSetMacro(ClipTextMode, int);
//@}
//@{
/**
* Indicates if the label can be moved by its ancestors
*/
vtkGetMacro(ChildMotion, int);
vtkSetMacro(ChildMotion, int);
//@}
//@{
/**
* Indicates at which level labeling should be dynamic
*/
vtkGetMacro(DynamicLevel, int);
vtkSetMacro(DynamicLevel, int);
//@}
/**
* Release any graphics resources that are being consumed by this actor.
*/
void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE;
//@{
/**
* The range of font sizes to use when rendering the labels.
*/
void SetFontSizeRange(int maxSize, int minSize, int delta=4);
void GetFontSizeRange(int range[3]);
//@}
//@{
/**
* The range of levels to attempt to label.
* The level of a vertex is the length of the path to the root
* (the root has level 0).
*/
void SetLevelRange(int startLevel, int endLevel);
void GetLevelRange(int range[2]);
//@}
protected:
vtkLabeledTreeMapDataMapper();
~vtkLabeledTreeMapDataMapper() VTK_OVERRIDE;
void LabelTree(vtkTree *tree, vtkFloatArray *boxInfo,
vtkDataArray *numericData, vtkStringArray *stringData,
int activeComp, int numComps);
void GetVertexLabel(vtkIdType vertex, vtkDataArray *numericData,
vtkStringArray *stringData, int activeComp, int numComps,
char *string, size_t stringSize);
void UpdateFontSizes();
int UpdateWindowInfo(vtkViewport *viewport);
int GetStringSize(char *string, int level);
// Returns 1 if the transformed box is off screen
int ConvertToDC(float *origBoxInfo, float *newBoxInfo);
// Returns 1 if the label will not fit in box - 2 if the text could
// not be placed due to other labels
int AnalyseLabel(char * string, int level, float *blimitsDC,
float *textPosWC,
vtkTextProperty **tprop);
int ApplyMasks(int level, float flimits[4], float blimits[4]);
vtkViewport *CurrentViewPort;
int *FontHeights;
int **FontWidths;
int MaxFontLevel;
int *ChildrenCount;
int MaxTreeLevels;
double BoxTrans[2][2];
double WindowLimits[2][2];
float (*LabelMasks)[4];
vtkIdList *VertexList;
vtkPoints *TextPoints;
vtkCoordinate *VCoord;
int ClipTextMode;
int ChildMotion;
int StartLevel;
int EndLevel;
int DynamicLevel;
vtkTextProperty *VerticalLabelProperty;
vtkTextProperty **HLabelProperties;
private:
vtkLabeledTreeMapDataMapper(const vtkLabeledTreeMapDataMapper&) VTK_DELETE_FUNCTION;
void operator=(const vtkLabeledTreeMapDataMapper&) VTK_DELETE_FUNCTION;
};
#endif