forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkBillboardTextActor3D.h
141 lines (112 loc) · 3.78 KB
/
vtkBillboardTextActor3D.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
/*=========================================================================
Program: Visualization Toolkit
Module: vtkBillboardTextActor3D.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.
=========================================================================*/
/**
* @class vtkBillboardTextActor3D
* @brief Renders pixel-aligned text, facing the camera, anchored at a 3D point.
*/
#ifndef vtkBillboardTextActor3D_h
#define vtkBillboardTextActor3D_h
#include "vtkRenderingCoreModule.h" // For export macro
#include "vtkProp3D.h"
#include "vtkNew.h" // For.... vtkNew!
class vtkActor;
class vtkImageData;
class vtkPolyData;
class vtkPolyDataMapper;
class vtkRenderer;
class vtkTextProperty;
class vtkTextRenderer;
class vtkTexture;
class VTKRENDERINGCORE_EXPORT vtkBillboardTextActor3D: public vtkProp3D
{
public:
static vtkBillboardTextActor3D* New();
vtkTypeMacro(vtkBillboardTextActor3D, vtkProp3D)
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE;
/**
* The UTF-8 encoded string to display.
* @{
*/
void SetInput(const char *in);
vtkGetStringMacro(Input)
/** @} */
/**
* Can be used to set a fixed offset from the anchor point.
* Use display coordinates.
* @{
*/
vtkGetVector2Macro(DisplayOffset, int)
vtkSetVector2Macro(DisplayOffset, int)
/** @} */
/**
* The vtkTextProperty object that controls the rendered text.
* @{
*/
void SetTextProperty(vtkTextProperty *tprop);
vtkGetObjectMacro(TextProperty, vtkTextProperty)
/** @} */
/**
* Always returns true, as we're rendering an RGBA texture.
*/
int HasTranslucentPolygonalGeometry() VTK_OVERRIDE { return 1; }
/**
* Check/update geometry/texture in opaque pass, since it only happens once.
*/
int RenderOpaqueGeometry(vtkViewport *vp) VTK_OVERRIDE;
/**
* Just render in translucent pass, since it can execute multiple times
* (depth peeling, for instance).
*/
int RenderTranslucentPolygonalGeometry(vtkViewport *vp) VTK_OVERRIDE;
void ReleaseGraphicsResources(vtkWindow *win) VTK_OVERRIDE;
double *GetBounds() VTK_OVERRIDE;
using Superclass::GetBounds;
/**
* Returns the anchor position in display coordinates, with depth in NDC.
* Valid after calling RenderOpaqueGeometry.
*/
vtkGetVector3Macro(AnchorDC, double)
protected:
vtkBillboardTextActor3D();
~vtkBillboardTextActor3D();
bool InputIsValid();
bool TextureIsStale(vtkRenderer *ren);
void GenerateTexture(vtkRenderer *ren);
bool QuadIsStale(vtkRenderer *ren);
void GenerateQuad(vtkRenderer *ren);
// Used by the opaque pass to tell the translucent pass not to render.
void Invalidate();
bool IsValid();
// Used to sync the internal actor's state.
void PreRender();
// Text specification:
char *Input;
vtkTextProperty *TextProperty;
// Offset in display coordinates.
int DisplayOffset[2];
// Cached metadata to determine if things need rebuildin'
int RenderedDPI;
vtkTimeStamp InputMTime;
// Rendering stuffies
vtkNew<vtkTextRenderer> TextRenderer;
vtkNew<vtkImageData> Image;
vtkNew<vtkTexture> Texture;
vtkNew<vtkPolyData> Quad;
vtkNew<vtkPolyDataMapper> QuadMapper;
vtkNew<vtkActor> QuadActor;
// Display coordinate for anchor position. Z value is in NDC.
// Cached for GL2PS export on OpenGL2:
double AnchorDC[3];
private:
vtkBillboardTextActor3D(const vtkBillboardTextActor3D&) VTK_DELETE_FUNCTION;
void operator=(const vtkBillboardTextActor3D&) VTK_DELETE_FUNCTION;
};
#endif // vtkBillboardTextActor3D_h