VTK  9.3.20240419
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
138 #ifndef vtkTextActor_h
139 #define vtkTextActor_h
140 
141 #include "vtkRenderingCoreModule.h" // For export macro
142 #include "vtkTexturedActor2D.h"
143 
144 VTK_ABI_NAMESPACE_BEGIN
145 class vtkImageData;
146 class vtkPoints;
147 class vtkPolyData;
148 class vtkPolyDataMapper2D;
149 class vtkProperty2D;
150 class vtkTextProperty;
151 class vtkTextRenderer;
152 class vtkTransform;
153 
154 class VTKRENDERINGCORE_EXPORT vtkTextActor : public vtkTexturedActor2D
155 {
156 public:
158  void PrintSelf(ostream& os, vtkIndent indent) override;
159 
164  static vtkTextActor* New();
165 
170  void ShallowCopy(vtkProp* prop) override;
171 
173 
179  void SetInput(const char* inputString);
180  char* GetInput();
182 
184 
189  vtkSetVector2Macro(MinimumSize, int);
190  vtkGetVector2Macro(MinimumSize, int);
192 
194 
200  vtkSetMacro(MaximumLineHeight, float);
201  vtkGetMacro(MaximumLineHeight, float);
203 
205 
214  vtkSetClampMacro(TextScaleMode, int, TEXT_SCALE_MODE_NONE, TEXT_SCALE_MODE_VIEWPORT);
215  vtkGetMacro(TextScaleMode, int);
216  void SetTextScaleModeToNone() { this->SetTextScaleMode(TEXT_SCALE_MODE_NONE); }
217  void SetTextScaleModeToProp() { this->SetTextScaleMode(TEXT_SCALE_MODE_PROP); }
218  void SetTextScaleModeToViewport() { this->SetTextScaleMode(TEXT_SCALE_MODE_VIEWPORT); }
220 
221  enum
222  {
223  TEXT_SCALE_MODE_NONE = 0,
225  TEXT_SCALE_MODE_VIEWPORT
226  };
227 
229 
234  vtkSetMacro(UseBorderAlign, vtkTypeBool);
235  vtkGetMacro(UseBorderAlign, vtkTypeBool);
236  vtkBooleanMacro(UseBorderAlign, vtkTypeBool);
238 
240 
258 
260 
268  vtkGetMacro(Orientation, float);
270 
272 
276  vtkGetObjectMacro(TextProperty, vtkTextProperty);
278 
284  virtual void GetBoundingBox(vtkViewport* vport, double bbox[4]);
285 
289  virtual void GetSize(vtkViewport* vport, double size[2]);
290 
292 
297  virtual int SetConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight);
298  static int SetConstrainedFontSize(vtkTextActor*, vtkViewport*, int targetWidth, int targetHeight);
300 
307  static int SetMultipleConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight,
308  vtkTextActor** actors, int nbOfActors, int* maxResultingSize);
309 
319  virtual void SetNonLinearFontScale(double exponent, int target);
320 
325  void SpecifiedToDisplay(double* pos, vtkViewport* vport, int specified);
326 
331  void DisplayToSpecified(double* pos, vtkViewport* vport, int specified);
332 
337  virtual void ComputeScaledFont(vtkViewport* viewport);
338 
340 
344  vtkGetObjectMacro(ScaledTextProperty, vtkTextProperty);
346 
354  static float GetFontScale(vtkViewport* viewport);
355 
364 
366 
371  int RenderOpaqueGeometry(vtkViewport* viewport) override;
372  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
373  int RenderOverlay(vtkViewport* viewport) override;
375 
380 
381 protected:
385  virtual bool RenderImage(vtkTextProperty* tprop, vtkViewport* viewport);
386 
390  virtual bool GetImageBoundingBox(vtkTextProperty* tprop, vtkViewport* viewport, int bbox[4]);
391 
393  ~vtkTextActor() override;
394 
395  int MinimumSize[2];
399  float Orientation;
401 
407  int LastSize[2];
408  int LastOrigin[2];
409  char* Input;
413 
415 
416  // Stuff needed to display the image text as a texture map.
419 
420  virtual void ComputeRectangle(vtkViewport* viewport);
421 
435  virtual int UpdateRectangle(vtkViewport* viewport);
436 
437 private:
438  vtkTextActor(const vtkTextActor&) = delete;
439  void operator=(const vtkTextActor&) = delete;
440 };
441 
442 VTK_ABI_NAMESPACE_END
443 #endif
topologically and geometrically regular array of data
Definition: vtkImageData.h:156
a simple class to control print indentation
Definition: vtkIndent.h:108
represent and manipulate 3D points
Definition: vtkPoints.h:139
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:181
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:66
represent surface properties of a 2D image
An actor that displays text.
Definition: vtkTextActor.h:155
vtkTextProperty * TextProperty
Definition: vtkTextActor.h:402
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:411
void SetOrientation(float orientation)
Counterclockwise rotation around the Alignment point.
float MaximumLineHeight
Definition: vtkTextActor.h:396
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:406
vtkTextProperty * ScaledTextProperty
Definition: vtkTextActor.h:414
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:403
vtkTextRenderer * TextRenderer
Definition: vtkTextActor.h:404
static vtkTextActor * New()
Instantiate object with a rectangle in normaled view coordinates of (0.2,0.85, 0.8,...
vtkPolyData * Rectangle
Definition: vtkTextActor.h:417
vtkTimeStamp BuildTime
Definition: vtkTextActor.h:405
virtual void ComputeRectangle(vtkViewport *viewport)
double FontScaleExponent
Definition: vtkTextActor.h:397
bool InputRendered
Definition: vtkTextActor.h:410
void SetTextScaleModeToProp()
Set how text should be scaled.
Definition: vtkTextActor.h:217
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:218
vtkPoints * RectanglePoints
Definition: vtkTextActor.h:418
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:400
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:399
void SetTextScaleModeToNone()
Set how text should be scaled.
Definition: vtkTextActor.h:216
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkTextActor.h:372
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:44
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:160
abstract specification for Viewports
Definition: vtkViewport.h:65
window superclass for vtkRenderWindow
Definition: vtkWindow.h:48
@ 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 *)