VTK  9.3.1
vtkTextActor.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
29 #ifndef vtkTextActor_h
30 #define vtkTextActor_h
31 
32 #include "vtkRenderingCoreModule.h" // For export macro
33 #include "vtkTexturedActor2D.h"
34 
35 VTK_ABI_NAMESPACE_BEGIN
36 class vtkImageData;
37 class vtkPoints;
38 class vtkPolyData;
40 class vtkProperty2D;
41 class vtkTextProperty;
42 class vtkTextRenderer;
43 class vtkTransform;
44 
45 class VTKRENDERINGCORE_EXPORT vtkTextActor : public vtkTexturedActor2D
46 {
47 public:
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
55  static vtkTextActor* New();
56 
61  void ShallowCopy(vtkProp* prop) override;
62 
64 
70  void SetInput(const char* inputString);
71  char* GetInput();
73 
75 
80  vtkSetVector2Macro(MinimumSize, int);
81  vtkGetVector2Macro(MinimumSize, int);
83 
85 
91  vtkSetMacro(MaximumLineHeight, float);
92  vtkGetMacro(MaximumLineHeight, float);
94 
96 
105  vtkSetClampMacro(TextScaleMode, int, TEXT_SCALE_MODE_NONE, TEXT_SCALE_MODE_VIEWPORT);
106  vtkGetMacro(TextScaleMode, int);
107  void SetTextScaleModeToNone() { this->SetTextScaleMode(TEXT_SCALE_MODE_NONE); }
108  void SetTextScaleModeToProp() { this->SetTextScaleMode(TEXT_SCALE_MODE_PROP); }
109  void SetTextScaleModeToViewport() { this->SetTextScaleMode(TEXT_SCALE_MODE_VIEWPORT); }
111 
112  enum
113  {
114  TEXT_SCALE_MODE_NONE = 0,
116  TEXT_SCALE_MODE_VIEWPORT
117  };
118 
120 
125  vtkSetMacro(UseBorderAlign, vtkTypeBool);
126  vtkGetMacro(UseBorderAlign, vtkTypeBool);
127  vtkBooleanMacro(UseBorderAlign, vtkTypeBool);
129 
131 
146  void SetAlignmentPoint(int point);
147  int GetAlignmentPoint();
149 
151 
158  void SetOrientation(float orientation);
159  vtkGetMacro(Orientation, float);
161 
163 
166  virtual void SetTextProperty(vtkTextProperty* p);
167  vtkGetObjectMacro(TextProperty, vtkTextProperty);
169 
175  virtual void GetBoundingBox(vtkViewport* vport, double bbox[4]);
176 
180  virtual void GetSize(vtkViewport* vport, double size[2]);
181 
183 
188  virtual int SetConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight);
189  static int SetConstrainedFontSize(vtkTextActor*, vtkViewport*, int targetWidth, int targetHeight);
191 
198  static int SetMultipleConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight,
199  vtkTextActor** actors, int nbOfActors, int* maxResultingSize);
200 
210  virtual void SetNonLinearFontScale(double exponent, int target);
211 
216  void SpecifiedToDisplay(double* pos, vtkViewport* vport, int specified);
217 
222  void DisplayToSpecified(double* pos, vtkViewport* vport, int specified);
223 
228  virtual void ComputeScaledFont(vtkViewport* viewport);
229 
231 
235  vtkGetObjectMacro(ScaledTextProperty, vtkTextProperty);
237 
245  static float GetFontScale(vtkViewport* viewport);
246 
254  void ReleaseGraphicsResources(vtkWindow*) override;
255 
257 
262  int RenderOpaqueGeometry(vtkViewport* viewport) override;
263  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
264  int RenderOverlay(vtkViewport* viewport) override;
266 
271 
272 protected:
276  virtual bool RenderImage(vtkTextProperty* tprop, vtkViewport* viewport);
277 
281  virtual bool GetImageBoundingBox(vtkTextProperty* tprop, vtkViewport* viewport, int bbox[4]);
282 
283  vtkTextActor();
284  ~vtkTextActor() override;
285 
286  int MinimumSize[2];
290  float Orientation;
292 
298  int LastSize[2];
299  int LastOrigin[2];
300  char* Input;
304 
306 
307  // Stuff needed to display the image text as a texture map.
310 
311  virtual void ComputeRectangle(vtkViewport* viewport);
312 
326  virtual int UpdateRectangle(vtkViewport* viewport);
327 
328 private:
329  vtkTextActor(const vtkTextActor&) = delete;
330  void operator=(const vtkTextActor&) = delete;
331 };
332 
333 VTK_ABI_NAMESPACE_END
334 #endif
bool InputRendered
Definition: vtkTextActor.h:301
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
actor that draws 2D data with texture support
vtkPolyData * Rectangle
Definition: vtkTextActor.h:308
void SetTextScaleModeToViewport()
Set how text should be scaled.
Definition: vtkTextActor.h:109
abstract specification for Viewports
Definition: vtkViewport.h:44
record modification and/or execution time
Definition: vtkTimeStamp.h:24
vtkPoints * RectanglePoints
Definition: vtkTextActor.h:309
vtkTextProperty * ScaledTextProperty
Definition: vtkTextActor.h:305
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
vtkImageData * ImageData
Definition: vtkTextActor.h:294
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
An actor that displays text.
Definition: vtkTextActor.h:45
int RenderOpaqueGeometry(vtkViewport *viewport) override
Support the standard render methods.
double FontScaleExponent
Definition: vtkTextActor.h:288
vtkTimeStamp BuildTime
Definition: vtkTextActor.h:296
vtkTransform * Transform
Definition: vtkTextActor.h:297
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:28
void SetTextScaleModeToProp()
Set how text should be scaled.
Definition: vtkTextActor.h:108
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkTextActor.h:263
float Orientation
Definition: vtkTextActor.h:290
vtkTextRenderer * TextRenderer
Definition: vtkTextActor.h:295
represent text properties.
void SetTextScaleModeToNone()
Set how text should be scaled.
Definition: vtkTextActor.h:107
float MaximumLineHeight
Definition: vtkTextActor.h:287
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
Interface for generating images and path data from string data, using multiple backends.
vtkTextProperty * TextProperty
Definition: vtkTextActor.h:293
represent surface properties of a 2D image
Definition: vtkProperty2D.h:29
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
static vtkTexturedActor2D * New()
void ShallowCopy(vtkProp *prop) override
Shallow copy of this vtkTexturedActor2D.
vtkTypeBool UseBorderAlign
Definition: vtkTextActor.h:291
draw vtkPolyData onto the image plane
void ReleaseGraphicsResources(vtkWindow *win) override
Release any graphics resources that are being consumed by this actor.
represent and manipulate 3D points
Definition: vtkPoints.h:28
double FormerOrientation
Definition: vtkTextActor.h:302