VTK  9.2.5
vtkTextActor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTextActor.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 =========================================================================*/
150 #ifndef vtkTextActor_h
151 #define vtkTextActor_h
152 
153 #include "vtkRenderingCoreModule.h" // For export macro
154 #include "vtkTexturedActor2D.h"
155 
156 class vtkImageData;
157 class vtkPoints;
158 class vtkPolyData;
159 class vtkPolyDataMapper2D;
160 class vtkProperty2D;
161 class vtkTextProperty;
162 class vtkTextRenderer;
163 class vtkTransform;
164 
165 class VTKRENDERINGCORE_EXPORT vtkTextActor : public vtkTexturedActor2D
166 {
167 public:
169  void PrintSelf(ostream& os, vtkIndent indent) override;
170 
175  static vtkTextActor* New();
176 
181  void ShallowCopy(vtkProp* prop) override;
182 
184 
190  void SetInput(const char* inputString);
191  char* GetInput();
193 
195 
200  vtkSetVector2Macro(MinimumSize, int);
201  vtkGetVector2Macro(MinimumSize, int);
203 
205 
211  vtkSetMacro(MaximumLineHeight, float);
212  vtkGetMacro(MaximumLineHeight, float);
214 
216 
225  vtkSetClampMacro(TextScaleMode, int, TEXT_SCALE_MODE_NONE, TEXT_SCALE_MODE_VIEWPORT);
226  vtkGetMacro(TextScaleMode, int);
227  void SetTextScaleModeToNone() { this->SetTextScaleMode(TEXT_SCALE_MODE_NONE); }
228  void SetTextScaleModeToProp() { this->SetTextScaleMode(TEXT_SCALE_MODE_PROP); }
229  void SetTextScaleModeToViewport() { this->SetTextScaleMode(TEXT_SCALE_MODE_VIEWPORT); }
231 
232  enum
233  {
234  TEXT_SCALE_MODE_NONE = 0,
236  TEXT_SCALE_MODE_VIEWPORT
237  };
238 
240 
245  vtkSetMacro(UseBorderAlign, vtkTypeBool);
246  vtkGetMacro(UseBorderAlign, vtkTypeBool);
247  vtkBooleanMacro(UseBorderAlign, vtkTypeBool);
249 
251 
269 
271 
279  vtkGetMacro(Orientation, float);
281 
283 
287  vtkGetObjectMacro(TextProperty, vtkTextProperty);
289 
295  virtual void GetBoundingBox(vtkViewport* vport, double bbox[4]);
296 
300  virtual void GetSize(vtkViewport* vport, double size[2]);
301 
303 
308  virtual int SetConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight);
309  static int SetConstrainedFontSize(vtkTextActor*, vtkViewport*, int targetWidth, int targetHeight);
311 
318  static int SetMultipleConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight,
319  vtkTextActor** actors, int nbOfActors, int* maxResultingSize);
320 
330  virtual void SetNonLinearFontScale(double exponent, int target);
331 
336  void SpecifiedToDisplay(double* pos, vtkViewport* vport, int specified);
337 
342  void DisplayToSpecified(double* pos, vtkViewport* vport, int specified);
343 
348  virtual void ComputeScaledFont(vtkViewport* viewport);
349 
351 
355  vtkGetObjectMacro(ScaledTextProperty, vtkTextProperty);
357 
365  static float GetFontScale(vtkViewport* viewport);
366 
375 
377 
382  int RenderOpaqueGeometry(vtkViewport* viewport) override;
383  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
384  int RenderOverlay(vtkViewport* viewport) override;
386 
391 
392 protected:
396  virtual bool RenderImage(vtkTextProperty* tprop, vtkViewport* viewport);
397 
401  virtual bool GetImageBoundingBox(vtkTextProperty* tprop, vtkViewport* viewport, int bbox[4]);
402 
404  ~vtkTextActor() override;
405 
406  int MinimumSize[2];
410  float Orientation;
412 
418  int LastSize[2];
419  int LastOrigin[2];
420  char* Input;
424 
426 
427  // Stuff needed to display the image text as a texture map.
430 
431  virtual void ComputeRectangle(vtkViewport* viewport);
432 
446  virtual int UpdateRectangle(vtkViewport* viewport);
447 
448 private:
449  vtkTextActor(const vtkTextActor&) = delete;
450  void operator=(const vtkTextActor&) = delete;
451 };
452 
453 #endif
topologically and geometrically regular array of data
Definition: vtkImageData.h:163
a simple class to control print indentation
Definition: vtkIndent.h:119
represent and manipulate 3D points
Definition: vtkPoints.h:149
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:200
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:76
represent surface properties of a 2D image
An actor that displays text.
Definition: vtkTextActor.h:166
vtkTextProperty * TextProperty
Definition: vtkTextActor.h:413
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:422
void SetOrientation(float orientation)
Counterclockwise rotation around the Alignment point.
float MaximumLineHeight
Definition: vtkTextActor.h:407
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:417
vtkTextProperty * ScaledTextProperty
Definition: vtkTextActor.h:425
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:414
vtkTextRenderer * TextRenderer
Definition: vtkTextActor.h:415
static vtkTextActor * New()
Instantiate object with a rectangle in normaled view coordinates of (0.2,0.85, 0.8,...
vtkPolyData * Rectangle
Definition: vtkTextActor.h:428
vtkTimeStamp BuildTime
Definition: vtkTextActor.h:416
virtual void ComputeRectangle(vtkViewport *viewport)
double FontScaleExponent
Definition: vtkTextActor.h:408
bool InputRendered
Definition: vtkTextActor.h:421
void SetTextScaleModeToProp()
Set how text should be scaled.
Definition: vtkTextActor.h:228
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:229
vtkPoints * RectanglePoints
Definition: vtkTextActor.h:429
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:411
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:410
void SetTextScaleModeToNone()
Set how text should be scaled.
Definition: vtkTextActor.h:227
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkTextActor.h:383
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:55
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:170
abstract specification for Viewports
Definition: vtkViewport.h:56
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
@ point
Definition: vtkX3D.h:242
@ orientation
Definition: vtkX3D.h:268
@ size
Definition: vtkX3D.h:259
int vtkTypeBool
Definition: vtkABI.h:69
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)