VTK
vtkTextMapper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTextMapper.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 =========================================================================*/
35 #ifndef vtkTextMapper_h
36 #define vtkTextMapper_h
37 
38 #include "vtkRenderingCoreModule.h" // For export macro
39 #include "vtkMapper2D.h"
40 
41 #include "vtkNew.h" // For vtkNew
42 
43 class vtkActor2D;
44 class vtkImageData;
45 class vtkPoints;
46 class vtkPolyData;
48 class vtkTextProperty;
49 class vtkTexture;
50 class vtkTimeStamp;
51 class vtkViewport;
52 
53 class VTKRENDERINGCORE_EXPORT vtkTextMapper : public vtkMapper2D
54 {
55 public:
56  vtkTypeMacro(vtkTextMapper,vtkMapper2D);
57  void PrintSelf(ostream& os, vtkIndent indent) override;
58 
62  static vtkTextMapper *New();
63 
65 
69  virtual void GetSize(vtkViewport*, int size[2]);
70  virtual int GetWidth(vtkViewport*v);
71  virtual int GetHeight(vtkViewport*v);
73 
75 
78  vtkSetStringMacro(Input)
79  vtkGetStringMacro(Input)
81 
83 
86  virtual void SetTextProperty(vtkTextProperty *p);
87  vtkGetObjectMacro(TextProperty,vtkTextProperty);
89 
93  void ShallowCopy(vtkAbstractMapper *m) override;
94 
96 
102  virtual int SetConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight);
103  static int SetConstrainedFontSize(vtkTextMapper*, vtkViewport*, int targetWidth, int targetHeight);
105 
113  static int SetMultipleConstrainedFontSize(vtkViewport*,
114  int targetWidth, int targetHeight,
115  vtkTextMapper** mappers,
116  int nbOfMappers,
117  int* maxResultingSize);
118 
120 
124  static int SetRelativeFontSize(vtkTextMapper*, vtkViewport*, int *winSize,
125  int *stringSize, float sizeFactor=0.0);
126  static int SetMultipleRelativeFontSize(vtkViewport *viewport,
127  vtkTextMapper **textMappers,
128  int nbOfMappers, int *winSize,
129  int *stringSize, float sizeFactor);
131 
132  void RenderOverlay(vtkViewport *, vtkActor2D *) override;
133  void ReleaseGraphicsResources(vtkWindow *) override;
134  vtkMTimeType GetMTime() override;
135 
136 protected:
137  vtkTextMapper();
138  ~vtkTextMapper() override;
139 
140  char* Input;
141  vtkTextProperty *TextProperty;
142 
143 private:
144  vtkTextMapper(const vtkTextMapper&) = delete;
145  void operator=(const vtkTextMapper&) = delete;
146 
147  void UpdateQuad(vtkActor2D *actor, int dpi);
148  void UpdateImage(int dpi);
149 
150  int TextDims[2];
151 
152  int RenderedDPI;
153  vtkTimeStamp CoordsTime;
154  vtkTimeStamp TCoordsTime;
155  vtkNew<vtkImageData> Image;
156  vtkNew<vtkPoints> Points;
157  vtkNew<vtkPolyData> PolyData;
158  vtkNew<vtkPolyDataMapper2D> Mapper;
159  vtkNew<vtkTexture> Texture;
160 };
161 
162 #endif
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
abstract specification for Viewports
Definition: vtkViewport.h:47
a actor that draws 2D data
Definition: vtkActor2D.h:45
record modification and/or execution time
Definition: vtkTimeStamp.h:35
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
2D text annotation
Definition: vtkTextMapper.h:53
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
a simple class to control print indentation
Definition: vtkIndent.h:39
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
handles properties associated with a texture map
Definition: vtkTexture.h:71
represent text properties.
abstract class specifies interface to map data
Allocate and hold a VTK object.
Definition: vtkNew.h:58
static vtkAlgorithm * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
abstract class specifies interface for objects which render 2D actors
Definition: vtkMapper2D.h:35
draw vtkPolyData onto the image plane
represent and manipulate 3D points
Definition: vtkPoints.h:39