1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkTextActor.h,v $
6 Date: $Date: 2002/08/28 16:44:22 $
7 Version: $Revision: 1.4 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
18 // .NAME vtkTextActor - An actor that displays text. Scaled or unscaled
19 // .SECTION Description
20 // vtkTextActor can be used to place text annotation into a window.
21 // When ScaledText is false, the text is fixed font and operation is
22 // the same as a vtkTextMapper/vtkActor2D pair.
23 // When ScaledText is true, the font resizes such that the text fits inside the
24 // box defined by the position 1 & 2 coordinates. This class replaces the
25 // deprecated vtkScaledTextActor and acts as a convenient wrapper for
26 // a vtkTextMapper/vtkActor2D pair.
27 // Set the text property/attributes through the vtkTextProperty associated to
31 // vtkActor2D vtkTextMapper vtkTextProperty
33 #ifndef __vtkTextActor_h
34 #define __vtkTextActor_h
36 #include "vtkActor2D.h"
38 // We need to include vtkTextMapper here otherwise we have an ambiguous
39 // case of vtkMapper2D or vtkTextMapper in SetMapper(vtkTextMapper *mapper);
40 // - two members with identical prototypes!
41 class vtkTextProperty;
44 class VTK_RENDERING_EXPORT vtkTextActor : public vtkActor2D
47 vtkTypeRevisionMacro(vtkTextActor,vtkActor2D);
48 void PrintSelf(ostream& os, vtkIndent indent);
51 // Instantiate object with a rectangle in normaled view coordinates
52 // of (0.2,0.85, 0.8, 0.95).
53 static vtkTextActor *New();
56 // Shallow copy of this text actor. Overloads the virtual
58 void ShallowCopy(vtkProp *prop);
61 // Override the vtkTextMapper that defines the text to be drawn.
62 // One will be created by default if none is supplied
63 void SetMapper(vtkTextMapper *mapper);
66 // Set the text string to be displayed. "\n" is recognized
67 // as a carriage return/linefeed (line separator).
68 // Convenience method to the underlying mapper
69 void SetInput(const char *inputString);
73 // Set/Get the minimum size in pixels for this actor.
75 // Not valid when ScaledText = false
76 vtkSetVector2Macro(MinimumSize,int);
77 vtkGetVector2Macro(MinimumSize,int);
80 // Set/Get the maximum height of a line of text as a
81 // percentage of the vertical area allocated to this
82 // scaled text actor. Defaults to 1.0.
83 // Not valid when ScaledText = false
84 vtkSetMacro(MaximumLineHeight,float);
85 vtkGetMacro(MaximumLineHeight,float);
88 // Turn on or off the ScaledText option.
89 // When text is scaled, the bounding rectangle is used to fit the text
90 // When ScaledText is off, the text is rendered at a fixed font size
91 vtkSetMacro(ScaledText,int);
92 vtkGetMacro(ScaledText,int);
93 vtkBooleanMacro(ScaledText,int);
96 // Set/Get the Alignment point for unscaled (fixed fontsize) text
97 // if zero (default), the text aligns itself to the bottom left corner
98 // (which is defined by the PositionCoordinate)
99 // otherwise the text aligns itself to corner/midpoint or centre
100 // 6 7 8 of the box defined by the position 1 & 2 coordinates
101 // 3 4 5 according to the diagram on the left.
103 vtkSetClampMacro(AlignmentPoint,int,0,8)
104 vtkGetMacro(AlignmentPoint,int);
107 // Return the actual vtkCoordinate reference that the mapper should use
108 // to position the actor. This is used internally by the mappers and should
109 // be overridden in specialized subclasses and otherwise ignored.
110 vtkCoordinate *GetActualPositionCoordinate(void)
111 { return this->AdjustedPositionCoordinate; }
114 // Set/Get the text property.
115 virtual void SetTextProperty(vtkTextProperty *p);
116 vtkGetObjectMacro(TextProperty,vtkTextProperty);
120 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
121 // DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS.
122 // Release any graphics resources that are being consumed by this actor.
123 // The parameter window could be used to determine which graphic
124 // resources to release.
125 virtual void ReleaseGraphicsResources(vtkWindow *);
128 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
129 // DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS.
130 // Draw the text actor to the screen.
131 int RenderOpaqueGeometry(vtkViewport* viewport);
132 int RenderTranslucentGeometry(vtkViewport* ) {return 0;};
133 int RenderOverlay(vtkViewport* viewport);
138 // Hide access methods which use superclass vtkMapper2D and not vtkTextMapper
139 void SetMapper(vtkMapper2D *mapper);
145 float MaximumLineHeight;
149 vtkCoordinate *AdjustedPositionCoordinate;
150 vtkTextProperty *TextProperty;
152 vtkTimeStamp BuildTime;
157 vtkTextActor(const vtkTextActor&); // Not implemented.
158 void operator=(const vtkTextActor&); // Not implemented.