VTK
dox/Rendering/vtkTextActor.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkTextActor.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00040 #ifndef __vtkTextActor_h
00041 #define __vtkTextActor_h
00042 
00043 #include "vtkActor2D.h"
00044 
00045 class vtkTextProperty;
00046 class vtkPolyDataMapper2D;
00047 class vtkImageData;
00048 class vtkFreeTypeUtilities;
00049 class vtkTransform;
00050 class vtkPolyData;
00051 class vtkPoints;
00052 class vtkTexture;
00053 
00054 class VTK_RENDERING_EXPORT vtkTextActor : public vtkActor2D
00055 {
00056 public:
00057   vtkTypeMacro(vtkTextActor,vtkActor2D);
00058   void PrintSelf(ostream& os, vtkIndent indent);
00059 
00062   static vtkTextActor *New();
00063 
00066   void ShallowCopy(vtkProp *prop);
00067 
00070   void SetMapper(vtkPolyDataMapper2D *mapper);
00071 
00073 
00076   void SetInput(const char *inputString);
00077   char *GetInput();
00079 
00081 
00083   vtkSetVector2Macro(MinimumSize,int);
00084   vtkGetVector2Macro(MinimumSize,int);
00086 
00088 
00091   vtkSetMacro(MaximumLineHeight,float);
00092   vtkGetMacro(MaximumLineHeight,float);
00094 
00096 
00103   vtkSetClampMacro(TextScaleMode, int,
00104                      TEXT_SCALE_MODE_NONE, TEXT_SCALE_MODE_VIEWPORT);
00105   vtkGetMacro(TextScaleMode, int);
00106   void SetTextScaleModeToNone()
00107     { this->SetTextScaleMode(TEXT_SCALE_MODE_NONE); }
00108   void SetTextScaleModeToProp()
00109     { this->SetTextScaleMode(TEXT_SCALE_MODE_PROP); }
00110   void SetTextScaleModeToViewport()
00111     { this->SetTextScaleMode(TEXT_SCALE_MODE_VIEWPORT); }
00113 
00114 //BTX
00115   enum {
00116     TEXT_SCALE_MODE_NONE = 0,
00117     TEXT_SCALE_MODE_PROP,
00118     TEXT_SCALE_MODE_VIEWPORT
00119   };
00120 //ETX
00121 
00123 
00125   VTK_LEGACY(void SetScaledText(int));
00126   VTK_LEGACY(int GetScaledText());
00127   VTK_LEGACY(void ScaledTextOn());
00128   VTK_LEGACY(void ScaledTextOff());
00130 
00132 
00135   vtkSetMacro(UseBorderAlign,int);
00136   vtkGetMacro(UseBorderAlign,int);
00137   vtkBooleanMacro(UseBorderAlign,int);
00139 
00141 
00149   void SetAlignmentPoint(int point);
00150   int GetAlignmentPoint();
00152   
00154 
00158   void SetOrientation(float orientation);
00159   vtkGetMacro(Orientation,float);
00161 
00163 
00164   virtual void SetTextProperty(vtkTextProperty *p);
00165   vtkGetObjectMacro(TextProperty,vtkTextProperty);
00167   
00175   virtual void SetNonLinearFontScale(double exponent, int target);
00176 
00179   void SpecifiedToDisplay(double *pos, vtkViewport *vport, int specified);
00180 
00183   void DisplayToSpecified(double *pos, vtkViewport *vport, int specified);
00184 
00187   virtual void ComputeScaledFont(vtkViewport *viewport);
00188 
00190 
00192   vtkGetObjectMacro(ScaledTextProperty, vtkTextProperty);
00194 
00201   static float GetFontScale(vtkViewport *viewport);
00202 
00203 //BTX
00208   virtual void ReleaseGraphicsResources(vtkWindow *);
00209 
00211 
00214   virtual int RenderOpaqueGeometry(vtkViewport* viewport);
00215   virtual int RenderTranslucentPolygonalGeometry(vtkViewport* ) {return 0;};
00216   virtual int RenderOverlay(vtkViewport* viewport);
00218   
00220 
00221   virtual int HasTranslucentPolygonalGeometry();
00222 //ETX
00224 
00225 protected:
00228   void SetMapper(vtkMapper2D *mapper);
00229 
00230    vtkTextActor();
00231   ~vtkTextActor();
00232 
00233   int     MinimumSize[2];
00234   float   MaximumLineHeight;
00235   double  FontScaleExponent;
00236   int     TextScaleMode;
00237   float   Orientation;
00238   int     UseBorderAlign;
00239 
00240   vtkTextProperty *TextProperty;
00241   vtkImageData *ImageData;
00242   // This used to be "Mapper" but I changed it to PDMapper because
00243   // Mapper is an ivar in Actor2D (bad form).
00244   vtkPolyDataMapper2D *PDMapper;
00245   vtkFreeTypeUtilities *FreeTypeUtilities;
00246   vtkTimeStamp  BuildTime;
00247   vtkTransform *Transform;
00248   int LastSize[2];
00249   int LastOrigin[2];
00250   char *Input;
00251   bool InputRendered;
00252   double FormerOrientation;
00253 
00254   vtkTextProperty *ScaledTextProperty;
00255 
00256   // Stuff needed to display the image text as a texture map.
00257   vtkPolyData* Rectangle;
00258   vtkPoints*   RectanglePoints;
00259   vtkTexture *Texture; 
00260   
00261   virtual void ComputeRectangle(vtkViewport *viewport); 
00262 
00263   // Set/Get the texture object to control rendering texture maps.  This will
00264   // be a vtkTexture object. An actor does not need to have an associated
00265   // texture map and multiple actors can share one texture.
00266   // This was added for orienated text which is rendered with a 
00267   // vtkPolyDataMaper2D and a texture.
00268   virtual void SetTexture(vtkTexture*);
00269   vtkGetObjectMacro(Texture,vtkTexture);
00270 
00271 private:
00272   vtkTextActor(const vtkTextActor&);  // Not implemented.
00273   void operator=(const vtkTextActor&);  // Not implemented.
00274 };
00275 
00276 
00277 #endif
00278