VTK
vtkBillboardTextActor3D.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkBillboardTextActor3D.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 =========================================================================*/
20 #ifndef vtkBillboardTextActor3D_h
21 #define vtkBillboardTextActor3D_h
22 
23 #include "vtkRenderingCoreModule.h" // For export macro
24 #include "vtkProp3D.h"
25 #include "vtkNew.h" // For.... vtkNew!
26 #include "vtkSmartPointer.h" // For.... vtkSmartPointer!
27 
28 class vtkActor;
29 class vtkImageData;
30 class vtkPolyData;
31 class vtkPolyDataMapper;
32 class vtkRenderer;
33 class vtkTextProperty;
34 class vtkTextRenderer;
35 class vtkTexture;
36 
37 class VTKRENDERINGCORE_EXPORT vtkBillboardTextActor3D: public vtkProp3D
38 {
39 public:
40  static vtkBillboardTextActor3D* New();
42  void PrintSelf(ostream &os, vtkIndent indent) override;
43 
48  void SetInput(const char *in);
49  vtkGetStringMacro(Input)
57  vtkGetVector2Macro(DisplayOffset, int)
58  vtkSetVector2Macro(DisplayOffset, int)
65  void SetTextProperty(vtkTextProperty *tprop);
66  vtkGetObjectMacro(TextProperty, vtkTextProperty)
73  virtual void SetForceOpaque(bool opaque);
74  virtual bool GetForceOpaque();
75  virtual void ForceOpaqueOn();
76  virtual void ForceOpaqueOff();
77  virtual void SetForceTranslucent(bool trans);
78  virtual bool GetForceTranslucent();
79  virtual void ForceTranslucentOn();
80  virtual void ForceTranslucentOff();
86  vtkTypeBool HasTranslucentPolygonalGeometry() override;
87 
91  int RenderOpaqueGeometry(vtkViewport *vp) override;
92 
97  int RenderTranslucentPolygonalGeometry(vtkViewport *vp) override;
98 
99  void ReleaseGraphicsResources(vtkWindow *win) override;
100  double *GetBounds() override;
101  using Superclass::GetBounds;
102 
107  vtkGetVector3Macro(AnchorDC, double)
108 
109 protected:
111  ~vtkBillboardTextActor3D() override;
112 
113  bool InputIsValid();
114 
115  void UpdateInternals(vtkRenderer *ren);
116 
117  bool TextureIsStale(vtkRenderer *ren);
118  void GenerateTexture(vtkRenderer *ren);
119 
120  bool QuadIsStale(vtkRenderer *ren);
121  void GenerateQuad(vtkRenderer *ren);
122 
123  // Used by the opaque pass to tell the translucent pass not to render.
124  void Invalidate();
125  bool IsValid();
126 
127  // Used to sync the internal actor's state.
128  void PreRender();
129 
130  // Text specification:
131  char *Input;
132  vtkTextProperty *TextProperty;
133 
134  // Offset in display coordinates.
135  int DisplayOffset[2];
136 
137  // Cached metadata to determine if things need rebuildin'
138  int RenderedDPI;
139  vtkTimeStamp InputMTime;
140 
141  // We cache this so we can recompute the bounds between renders, if needed.
142  vtkSmartPointer<vtkRenderer> RenderedRenderer;
143 
144  // Rendering stuffies
145  vtkNew<vtkTextRenderer> TextRenderer;
147  vtkNew<vtkTexture> Texture;
150  vtkNew<vtkActor> QuadActor;
151 
152  // Display coordinate for anchor position. Z value is in NDC.
153  // Cached for GL2PS export on OpenGL2:
154  double AnchorDC[3];
155 
156 private:
157  vtkBillboardTextActor3D(const vtkBillboardTextActor3D&) = delete;
158  void operator=(const vtkBillboardTextActor3D&) = delete;
159 };
160 
161 #endif // vtkBillboardTextActor3D_h
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
abstract specification for Viewports
Definition: vtkViewport.h:47
Renders pixel-aligned text, facing the camera, anchored at a 3D point.
record modification and/or execution time
Definition: vtkTimeStamp.h:35
abstract specification for renderers
Definition: vtkRenderer.h:63
Hold a reference to a vtkObjectBase instance.
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:46
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
int vtkTypeBool
Definition: vtkABI.h:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
a simple class to control print indentation
Definition: vtkIndent.h:39
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
handles properties associated with a texture map
Definition: vtkTexture.h:71
represent text properties.
map vtkPolyData to graphics primitives
Interface for generating images and path data from string data, using multiple backends.
Allocate and hold a VTK object.
Definition: vtkNew.h:58
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...