VTK
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 =========================================================================*/
41 #ifndef vtkTextActor_h
42 #define vtkTextActor_h
43 
44 #include "vtkRenderingCoreModule.h" // For export macro
45 #include "vtkTexturedActor2D.h"
46 
47 class vtkImageData;
48 class vtkPoints;
49 class vtkPolyData;
51 class vtkProperty2D;
52 class vtkTextProperty;
53 class vtkTextRenderer;
54 class vtkTransform;
55 
56 class VTKRENDERINGCORE_EXPORT vtkTextActor : public vtkTexturedActor2D
57 {
58 public:
60  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
61 
66  static vtkTextActor *New();
67 
72  void ShallowCopy(vtkProp *prop) VTK_OVERRIDE;
73 
75 
81  void SetInput(const char *inputString);
82  char *GetInput();
84 
86 
91  vtkSetVector2Macro(MinimumSize,int);
92  vtkGetVector2Macro(MinimumSize,int);
94 
96 
102  vtkSetMacro(MaximumLineHeight,float);
103  vtkGetMacro(MaximumLineHeight,float);
105 
107 
116  vtkSetClampMacro(TextScaleMode, int,
117  TEXT_SCALE_MODE_NONE, TEXT_SCALE_MODE_VIEWPORT);
118  vtkGetMacro(TextScaleMode, int);
120  { this->SetTextScaleMode(TEXT_SCALE_MODE_NONE); }
122  { this->SetTextScaleMode(TEXT_SCALE_MODE_PROP); }
124  { this->SetTextScaleMode(TEXT_SCALE_MODE_VIEWPORT); }
126 
127  enum {
128  TEXT_SCALE_MODE_NONE = 0,
130  TEXT_SCALE_MODE_VIEWPORT
131  };
132 
134 
139  vtkSetMacro(UseBorderAlign,int);
140  vtkGetMacro(UseBorderAlign,int);
141  vtkBooleanMacro(UseBorderAlign,int);
143 
145 
163 
165 
173  vtkGetMacro(Orientation,float);
175 
177 
181  vtkGetObjectMacro(TextProperty,vtkTextProperty);
183 
189  virtual void GetBoundingBox(vtkViewport* vport, double bbox[4]);
190 
194  virtual void GetSize(vtkViewport* vport, double size[2]);
195 
197 
203  vtkViewport*, int targetWidth, int targetHeight);
205  vtkTextActor*, vtkViewport*, int targetWidth, int targetHeight);
207 
215  vtkViewport*, int targetWidth, int targetHeight,
216  vtkTextActor** actors, int nbOfActors, int* maxResultingSize);
217 
227  virtual void SetNonLinearFontScale(double exponent, int target);
228 
233  void SpecifiedToDisplay(double *pos, vtkViewport *vport, int specified);
234 
239  void DisplayToSpecified(double *pos, vtkViewport *vport, int specified);
240 
245  virtual void ComputeScaledFont(vtkViewport *viewport);
246 
248 
252  vtkGetObjectMacro(ScaledTextProperty, vtkTextProperty);
254 
262  static float GetFontScale(vtkViewport *viewport);
263 
271  virtual void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE;
272 
274 
279  virtual int RenderOpaqueGeometry(vtkViewport* viewport) VTK_OVERRIDE;
280  virtual int RenderTranslucentPolygonalGeometry(vtkViewport* ) VTK_OVERRIDE {return 0;};
281  virtual int RenderOverlay(vtkViewport* viewport) VTK_OVERRIDE;
283 
287  virtual int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
288 
289 protected:
293  virtual bool RenderImage(vtkTextProperty *tprop, vtkViewport *viewport);
294 
298  virtual bool GetImageBoundingBox(
299  vtkTextProperty *tprop, vtkViewport *viewport, int bbox[4]);
300 
303 
304  int MinimumSize[2];
305  float MaximumLineHeight;
306  double FontScaleExponent;
307  int TextScaleMode;
308  float Orientation;
309  int UseBorderAlign;
310 
311  vtkTextProperty *TextProperty;
312  vtkImageData *ImageData;
313  vtkTextRenderer *TextRenderer;
316  int LastSize[2];
317  int LastOrigin[2];
318  char *Input;
319  bool InputRendered;
320  double FormerOrientation;
321  int RenderedDPI;
322 
323  vtkTextProperty *ScaledTextProperty;
324 
325  // Stuff needed to display the image text as a texture map.
326  vtkPolyData* Rectangle;
327  vtkPoints* RectanglePoints;
328 
329  virtual void ComputeRectangle(vtkViewport *viewport);
330 
344  virtual int UpdateRectangle(vtkViewport* viewport);
345 
346 private:
347  vtkTextActor(const vtkTextActor&) VTK_DELETE_FUNCTION;
348  void operator=(const vtkTextActor&) VTK_DELETE_FUNCTION;
349 };
350 
351 
352 #endif
topologically and geometrically regular array of data
Definition: vtkImageData.h:46
a simple class to control print indentation
Definition: vtkIndent.h:40
represent and manipulate 3D points
Definition: vtkPoints.h:40
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
represent surface properties of a 2D image
Definition: vtkProperty2D.h:41
An actor that displays text.
Definition: vtkTextActor.h:57
static int SetConstrainedFontSize(vtkTextActor *, vtkViewport *, int targetWidth, int targetHeight)
int GetAlignmentPoint()
void SetOrientation(float orientation)
Counterclockwise rotation around the Alignment point.
void ShallowCopy(vtkProp *prop) override
Shallow copy of this text actor.
virtual void ReleaseGraphicsResources(vtkWindow *) 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.
void SetAlignmentPoint(int point)
This method is being depricated.
char * GetInput()
static vtkTextActor * New()
Instantiate object with a rectangle in normaled view coordinates of (0.2,0.85, 0.8,...
virtual int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
virtual int HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
void SetTextScaleModeToProp()
Definition: vtkTextActor.h:121
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()
Definition: vtkTextActor.h:123
virtual int RenderOpaqueGeometry(vtkViewport *viewport) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
static float GetFontScale(vtkViewport *viewport)
Provide a font scaling based on a viewport.
virtual void SetTextProperty(vtkTextProperty *p)
Set/Get the text property.
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.
void SetTextScaleModeToNone()
Definition: vtkTextActor.h:119
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.
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Definition: vtkTextActor.h:280
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 viewport coordinates.
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:36
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
abstract specification for Viewports
Definition: vtkViewport.h:48
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
Transform
Definition: ADIOSDefs.h:40
@ point
Definition: vtkX3D.h:236
@ orientation
Definition: vtkX3D.h:262
@ size
Definition: vtkX3D.h:253
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkTimeStamp BuildTime
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.