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 =========================================================================*/
34 #ifndef __vtkTextMapper_h
35 #define __vtkTextMapper_h
36 
37 #include "vtkRenderingCoreModule.h" // For export macro
38 #include "vtkMapper2D.h"
39 
40 class vtkActor2D;
41 class vtkTextProperty;
42 class vtkViewport;
43 
44 class VTKRENDERINGCORE_EXPORT vtkTextMapper : public vtkMapper2D
45 {
46 public:
47  vtkTypeMacro(vtkTextMapper,vtkMapper2D);
48  void PrintSelf(ostream& os, vtkIndent indent);
49 
51  static vtkTextMapper *New();
52 
54 
56  virtual void GetSize(vtkViewport*, int size[2]) {size[0]=size[0];}
57  virtual int GetWidth(vtkViewport*v);
58  virtual int GetHeight(vtkViewport*v);
60 
62 
64  virtual void SetInput(const char *inputString);
65  vtkGetStringMacro(Input);
67 
69 
70  virtual void SetTextProperty(vtkTextProperty *p);
71  vtkGetObjectMacro(TextProperty,vtkTextProperty);
73 
75  void ShallowCopy(vtkTextMapper *tm);
76 
79  int GetNumberOfLines(const char *input);
80 
82 
85  vtkGetMacro(NumberOfLines,int);
87 
89 
93  virtual int SetConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight);
94  static int SetConstrainedFontSize(vtkTextMapper*, vtkViewport*, int targetWidth, int targetHeight);
96 
98 
102  static int SetMultipleConstrainedFontSize(vtkViewport*,
103  int targetWidth, int targetHeight,
104  vtkTextMapper** mappers,
105  int nbOfMappers,
106  int* maxResultingSize);
108 
110 
113  static int SetRelativeFontSize(vtkTextMapper*, vtkViewport*, int *winSize,
114  int *stringSize, float sizeFactor=0.0);
115  static int SetMultipleRelativeFontSize(vtkViewport *viewport,
116  vtkTextMapper **textMappers,
117  int nbOfMappers, int *winSize,
118  int *stringSize, float sizeFactor);
120 
122 
123  virtual int GetSystemFontSize(int size)
124  { return size; }
126 
127 protected:
128  vtkTextMapper();
129  ~vtkTextMapper();
130 
131  char* Input;
133 
134  int LineSize;
137 
139 
140  // These functions are used to parse, process, and render multiple lines
141  char *NextLine(const char *input, int lineNum);
142  void GetMultiLineSize(vtkViewport* viewport, int size[2]);
143  void RenderOverlayMultipleLines(vtkViewport *viewport, vtkActor2D *actor);
144 
145 private:
146  vtkTextMapper(const vtkTextMapper&); // Not implemented.
147  void operator=(const vtkTextMapper&); // Not implemented.
148 };
149 
150 #endif
151