VTK  9.3.0
vtkTextMapper.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 vtkTextMapper_h
30 #define vtkTextMapper_h
31 
32 #include "vtkMapper2D.h"
33 #include "vtkRenderingCoreModule.h" // For export macro
34 
35 #include "vtkNew.h" // For vtkNew
36 
37 VTK_ABI_NAMESPACE_BEGIN
38 class vtkActor2D;
39 class vtkImageData;
40 class vtkPoints;
41 class vtkPolyData;
43 class vtkTextProperty;
44 class vtkTexture;
45 class vtkTimeStamp;
46 class vtkViewport;
47 
48 class VTKRENDERINGCORE_EXPORT vtkTextMapper : public vtkMapper2D
49 {
50 public:
51  vtkTypeMacro(vtkTextMapper, vtkMapper2D);
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
57  static vtkTextMapper* New();
58 
60 
64  virtual void GetSize(vtkViewport*, int size[2]);
65  virtual int GetWidth(vtkViewport* v);
66  virtual int GetHeight(vtkViewport* v);
68 
70 
73  vtkSetStringMacro(Input);
74  vtkGetStringMacro(Input);
76 
78 
81  virtual void SetTextProperty(vtkTextProperty* p);
82  vtkGetObjectMacro(TextProperty, vtkTextProperty);
84 
88  void ShallowCopy(vtkAbstractMapper* m) override;
89 
91 
97  virtual int SetConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight);
99  vtkTextMapper*, vtkViewport*, int targetWidth, int targetHeight);
101 
109  static int SetMultipleConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight,
110  vtkTextMapper** mappers, int nbOfMappers, int* maxResultingSize);
111 
113 
118  vtkTextMapper*, vtkViewport*, const int* winSize, int* stringSize, float sizeFactor = 0.0);
119  static int SetMultipleRelativeFontSize(vtkViewport* viewport, vtkTextMapper** textMappers,
120  int nbOfMappers, int* winSize, int* stringSize, float sizeFactor);
122 
125  vtkMTimeType GetMTime() override;
126 
127 protected:
129  ~vtkTextMapper() override;
130 
131  char* Input;
133 
134 private:
135  vtkTextMapper(const vtkTextMapper&) = delete;
136  void operator=(const vtkTextMapper&) = delete;
137 
138  void UpdateQuad(vtkActor2D* actor, int dpi);
139  void UpdateImage(int dpi);
140 
141  int TextDims[2];
142 
143  int RenderedDPI;
144  vtkTimeStamp CoordsTime;
145  vtkTimeStamp TCoordsTime;
146  vtkNew<vtkImageData> Image;
147  vtkNew<vtkPoints> Points;
148  vtkNew<vtkPolyData> PolyData;
150  vtkNew<vtkTexture> Texture;
151 };
152 
153 VTK_ABI_NAMESPACE_END
154 #endif
abstract class specifies interface to map data
a actor that draws 2D data
Definition: vtkActor2D.h:44
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
a simple class to control print indentation
Definition: vtkIndent.h:38
abstract class specifies interface for objects which render 2D actors
Definition: vtkMapper2D.h:25
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
2D text annotation
Definition: vtkTextMapper.h:49
static int SetMultipleConstrainedFontSize(vtkViewport *, int targetWidth, int targetHeight, vtkTextMapper **mappers, int nbOfMappers, int *maxResultingSize)
Set and return the font size (in points) required to make each element of an array of mappers fit in ...
static int SetRelativeFontSize(vtkTextMapper *, vtkViewport *, const int *winSize, int *stringSize, float sizeFactor=0.0)
Use these methods when setting font size relative to the renderer's size.
void RenderOverlay(vtkViewport *, vtkActor2D *) override
virtual int GetHeight(vtkViewport *v)
Return the size[2]/width/height of the rectangle required to draw this mapper (in pixels).
vtkMTimeType GetMTime() override
Override Modifiedtime as we have added Clipping planes.
static int SetMultipleRelativeFontSize(vtkViewport *viewport, vtkTextMapper **textMappers, int nbOfMappers, int *winSize, int *stringSize, float sizeFactor)
Use these methods when setting font size relative to the renderer's size.
virtual void SetTextProperty(vtkTextProperty *p)
Set/Get the text property.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void GetSize(vtkViewport *, int size[2])
Return the size[2]/width/height of the rectangle required to draw this mapper (in pixels).
virtual int SetConstrainedFontSize(vtkViewport *, int targetWidth, int targetHeight)
Set and return the font size (in points) required to make this mapper fit in a given target rectangle...
static vtkTextMapper * New()
Creates a new text mapper.
static int SetConstrainedFontSize(vtkTextMapper *, vtkViewport *, int targetWidth, int targetHeight)
Set and return the font size (in points) required to make this mapper fit in a given target rectangle...
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this mapper.
void ShallowCopy(vtkAbstractMapper *m) override
Shallow copy of an actor.
virtual int GetWidth(vtkViewport *v)
Return the size[2]/width/height of the rectangle required to draw this mapper (in pixels).
vtkTextProperty * TextProperty
~vtkTextMapper() override
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:67
record modification and/or execution time
Definition: vtkTimeStamp.h:34
abstract specification for Viewports
Definition: vtkViewport.h:54
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
@ size
Definition: vtkX3D.h:253
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270