VTK  9.3.0
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
38 #ifndef vtkTextActor_h
39 #define vtkTextActor_h
40 
41 #include "vtkRenderingCoreModule.h" // For export macro
42 #include "vtkTexturedActor2D.h"
43 
44 VTK_ABI_NAMESPACE_BEGIN
45 class vtkImageData;
46 class vtkPoints;
47 class vtkPolyData;
49 class vtkProperty2D;
50 class vtkTextProperty;
51 class vtkTextRenderer;
52 class vtkTransform;
53 
54 class VTKRENDERINGCORE_EXPORT vtkTextActor : public vtkTexturedActor2D
55 {
56 public:
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
64  static vtkTextActor* New();
65 
70  void ShallowCopy(vtkProp* prop) override;
71 
73 
79  void SetInput(const char* inputString);
80  char* GetInput();
82 
84 
89  vtkSetVector2Macro(MinimumSize, int);
90  vtkGetVector2Macro(MinimumSize, int);
92 
94 
100  vtkSetMacro(MaximumLineHeight, float);
101  vtkGetMacro(MaximumLineHeight, float);
103 
105 
114  vtkSetClampMacro(TextScaleMode, int, TEXT_SCALE_MODE_NONE, TEXT_SCALE_MODE_VIEWPORT);
115  vtkGetMacro(TextScaleMode, int);
116  void SetTextScaleModeToNone() { this->SetTextScaleMode(TEXT_SCALE_MODE_NONE); }
117  void SetTextScaleModeToProp() { this->SetTextScaleMode(TEXT_SCALE_MODE_PROP); }
118  void SetTextScaleModeToViewport() { this->SetTextScaleMode(TEXT_SCALE_MODE_VIEWPORT); }
120 
121  enum
122  {
123  TEXT_SCALE_MODE_NONE = 0,
125  TEXT_SCALE_MODE_VIEWPORT
126  };
127 
129 
134  vtkSetMacro(UseBorderAlign, vtkTypeBool);
135  vtkGetMacro(UseBorderAlign, vtkTypeBool);
136  vtkBooleanMacro(UseBorderAlign, vtkTypeBool);
138 
140 
158 
160 
168  vtkGetMacro(Orientation, float);
170 
172 
176  vtkGetObjectMacro(TextProperty, vtkTextProperty);
178 
184  virtual void GetBoundingBox(vtkViewport* vport, double bbox[4]);
185 
189  virtual void GetSize(vtkViewport* vport, double size[2]);
190 
192 
197  virtual int SetConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight);
198  static int SetConstrainedFontSize(vtkTextActor*, vtkViewport*, int targetWidth, int targetHeight);
200 
207  static int SetMultipleConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight,
208  vtkTextActor** actors, int nbOfActors, int* maxResultingSize);
209 
219  virtual void SetNonLinearFontScale(double exponent, int target);
220 
225  void SpecifiedToDisplay(double* pos, vtkViewport* vport, int specified);
226 
231  void DisplayToSpecified(double* pos, vtkViewport* vport, int specified);
232 
237  virtual void ComputeScaledFont(vtkViewport* viewport);
238 
240 
244  vtkGetObjectMacro(ScaledTextProperty, vtkTextProperty);
246 
254  static float GetFontScale(vtkViewport* viewport);
255 
264 
266 
271  int RenderOpaqueGeometry(vtkViewport* viewport) override;
272  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
273  int RenderOverlay(vtkViewport* viewport) override;
275 
280 
281 protected:
285  virtual bool RenderImage(vtkTextProperty* tprop, vtkViewport* viewport);
286 
290  virtual bool GetImageBoundingBox(vtkTextProperty* tprop, vtkViewport* viewport, int bbox[4]);
291 
293  ~vtkTextActor() override;
294 
295  int MinimumSize[2];
299  float Orientation;
301 
307  int LastSize[2];
308  int LastOrigin[2];
309  char* Input;
313 
315 
316  // Stuff needed to display the image text as a texture map.
319 
320  virtual void ComputeRectangle(vtkViewport* viewport);
321 
335  virtual int UpdateRectangle(vtkViewport* viewport);
336 
337 private:
338  vtkTextActor(const vtkTextActor&) = delete;
339  void operator=(const vtkTextActor&) = delete;
340 };
341 
342 VTK_ABI_NAMESPACE_END
343 #endif
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
a simple class to control print indentation
Definition: vtkIndent.h:38
represent and manipulate 3D points
Definition: vtkPoints.h:38
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:55
represent surface properties of a 2D image
Definition: vtkProperty2D.h:39
An actor that displays text.
Definition: vtkTextActor.h:55
vtkTextProperty * TextProperty
Definition: vtkTextActor.h:302
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
static int SetConstrainedFontSize(vtkTextActor *, vtkViewport *, int targetWidth, int targetHeight)
Set and return the font size required to make this mapper fit in a given target rectangle (width x he...
int GetAlignmentPoint()
This method is being deprecated.
double FormerOrientation
Definition: vtkTextActor.h:311
void SetOrientation(float orientation)
Counterclockwise rotation around the Alignment point.
float MaximumLineHeight
Definition: vtkTextActor.h:296
void ShallowCopy(vtkProp *prop) override
Shallow copy of this text actor.
int RenderOverlay(vtkViewport *viewport) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
virtual bool RenderImage(vtkTextProperty *tprop, vtkViewport *viewport)
Render Input to Image using the supplied font property.
vtkTransform * Transform
Definition: vtkTextActor.h:306
vtkTextProperty * ScaledTextProperty
Definition: vtkTextActor.h:314
int RenderOpaqueGeometry(vtkViewport *viewport) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
void SetInput(const char *inputString)
Set the text string to be displayed.
virtual int UpdateRectangle(vtkViewport *viewport)
Ensure that Rectangle and RectanglePoints are valid and up-to-date.
void SetAlignmentPoint(int point)
This method is being deprecated.
char * GetInput()
Set the text string to be displayed.
virtual bool GetImageBoundingBox(vtkTextProperty *tprop, vtkViewport *viewport, int bbox[4])
Get the bounding box for Input using the supplied font property.
~vtkTextActor() override
vtkImageData * ImageData
Definition: vtkTextActor.h:303
vtkTextRenderer * TextRenderer
Definition: vtkTextActor.h:304
static vtkTextActor * New()
Instantiate object with a rectangle in normaled view coordinates of (0.2,0.85, 0.8,...
vtkPolyData * Rectangle
Definition: vtkTextActor.h:317
vtkTimeStamp BuildTime
Definition: vtkTextActor.h:305
virtual void ComputeRectangle(vtkViewport *viewport)
double FontScaleExponent
Definition: vtkTextActor.h:297
bool InputRendered
Definition: vtkTextActor.h:310
void SetTextScaleModeToProp()
Set how text should be scaled.
Definition: vtkTextActor.h:117
virtual void SetNonLinearFontScale(double exponent, int target)
Enable non-linear scaling of font sizes.
virtual void GetSize(vtkViewport *vport, double size[2])
Syntactic sugar to get the size of text instead of the entire bounding box.
void SetTextScaleModeToViewport()
Set how text should be scaled.
Definition: vtkTextActor.h:118
vtkPoints * RectanglePoints
Definition: vtkTextActor.h:318
static float GetFontScale(vtkViewport *viewport)
Provide a font scaling based on a viewport.
virtual void SetTextProperty(vtkTextProperty *p)
Set/Get the text property.
vtkTypeBool UseBorderAlign
Definition: vtkTextActor.h:300
virtual int SetConstrainedFontSize(vtkViewport *, int targetWidth, int targetHeight)
Set and return the font size required to make this mapper fit in a given target rectangle (width x he...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
float Orientation
Definition: vtkTextActor.h:299
void SetTextScaleModeToNone()
Set how text should be scaled.
Definition: vtkTextActor.h:116
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkTextActor.h:272
static int SetMultipleConstrainedFontSize(vtkViewport *, int targetWidth, int targetHeight, vtkTextActor **actors, int nbOfActors, int *maxResultingSize)
Set and return the font size required to make each element of an array of mappers fit in a given rect...
void SpecifiedToDisplay(double *pos, vtkViewport *vport, int specified)
This is just a simple coordinate conversion method used in the render process.
void DisplayToSpecified(double *pos, vtkViewport *vport, int specified)
This is just a simple coordinate conversion method used in the render process.
virtual void ComputeScaledFont(vtkViewport *viewport)
Compute the scale the font should be given the viewport.
virtual void GetBoundingBox(vtkViewport *vport, double bbox[4])
Return the bounding box coordinates of the text in pixels.
represent text properties.
Interface for generating images and path data from string data, using multiple backends.
actor that draws 2D data with texture support
record modification and/or execution time
Definition: vtkTimeStamp.h:34
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
abstract specification for Viewports
Definition: vtkViewport.h:54
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
@ point
Definition: vtkX3D.h:236
@ orientation
Definition: vtkX3D.h:262
@ size
Definition: vtkX3D.h:253
int vtkTypeBool
Definition: vtkABI.h:64
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)