VTK
dox/Rendering/FreeType/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 "vtkRenderingFreeTypeModule.h" // For export macro
00044 #include "vtkActor2D.h"
00045 
00046 class vtkTextProperty;
00047 class vtkPolyDataMapper2D;
00048 class vtkImageData;
00049 class vtkTextRenderer;
00050 class vtkTransform;
00051 class vtkPolyData;
00052 class vtkPoints;
00053 class vtkTexture;
00054 
00055 class VTKRENDERINGFREETYPE_EXPORT vtkTextActor : public vtkActor2D
00056 {
00057 public:
00058   vtkTypeMacro(vtkTextActor,vtkActor2D);
00059   void PrintSelf(ostream& os, vtkIndent indent);
00060 
00063   static vtkTextActor *New();
00064 
00067   void ShallowCopy(vtkProp *prop);
00068 
00071   void SetMapper(vtkPolyDataMapper2D *mapper);
00072 
00074 
00077   void SetInput(const char *inputString);
00078   char *GetInput();
00080 
00082 
00084   vtkSetVector2Macro(MinimumSize,int);
00085   vtkGetVector2Macro(MinimumSize,int);
00087 
00089 
00092   vtkSetMacro(MaximumLineHeight,float);
00093   vtkGetMacro(MaximumLineHeight,float);
00095 
00097 
00104   vtkSetClampMacro(TextScaleMode, int,
00105                      TEXT_SCALE_MODE_NONE, TEXT_SCALE_MODE_VIEWPORT);
00106   vtkGetMacro(TextScaleMode, int);
00107   void SetTextScaleModeToNone()
00108     { this->SetTextScaleMode(TEXT_SCALE_MODE_NONE); }
00109   void SetTextScaleModeToProp()
00110     { this->SetTextScaleMode(TEXT_SCALE_MODE_PROP); }
00111   void SetTextScaleModeToViewport()
00112     { this->SetTextScaleMode(TEXT_SCALE_MODE_VIEWPORT); }
00114 
00115 //BTX
00116   enum {
00117     TEXT_SCALE_MODE_NONE = 0,
00118     TEXT_SCALE_MODE_PROP,
00119     TEXT_SCALE_MODE_VIEWPORT
00120   };
00121 //ETX
00122 
00124 
00127   vtkSetMacro(UseBorderAlign,int);
00128   vtkGetMacro(UseBorderAlign,int);
00129   vtkBooleanMacro(UseBorderAlign,int);
00131 
00133 
00141   void SetAlignmentPoint(int point);
00142   int GetAlignmentPoint();
00144 
00146 
00150   void SetOrientation(float orientation);
00151   vtkGetMacro(Orientation,float);
00153 
00155 
00156   virtual void SetTextProperty(vtkTextProperty *p);
00157   vtkGetObjectMacro(TextProperty,vtkTextProperty);
00159 
00163   virtual void GetBoundingBox(double bbox[4]);
00164 
00167   virtual void GetSize(vtkViewport* vport, double size[2]);
00168 
00170 
00174   virtual int SetConstrainedFontSize(
00175     vtkViewport*, int targetWidth, int targetHeight);
00176   static int SetConstrainedFontSize(
00177     vtkTextActor*, vtkViewport*, int targetWidth, int targetHeight);
00179 
00181 
00185   static int SetMultipleConstrainedFontSize(
00186     vtkViewport*, int targetWidth, int targetHeight,
00187     vtkTextActor** actors, int nbOfActors, int* maxResultingSize);
00189 
00197   virtual void SetNonLinearFontScale(double exponent, int target);
00198 
00201   void SpecifiedToDisplay(double *pos, vtkViewport *vport, int specified);
00202 
00205   void DisplayToSpecified(double *pos, vtkViewport *vport, int specified);
00206 
00209   virtual void ComputeScaledFont(vtkViewport *viewport);
00210 
00212 
00214   vtkGetObjectMacro(ScaledTextProperty, vtkTextProperty);
00216 
00223   static float GetFontScale(vtkViewport *viewport);
00224 
00225 //BTX
00230   virtual void ReleaseGraphicsResources(vtkWindow *);
00231 
00233 
00236   virtual int RenderOpaqueGeometry(vtkViewport* viewport);
00237   virtual int RenderTranslucentPolygonalGeometry(vtkViewport* ) {return 0;};
00238   virtual int RenderOverlay(vtkViewport* viewport);
00240 
00242 
00243   virtual int HasTranslucentPolygonalGeometry();
00244 //ETX
00246 
00247 protected:
00250   void SetMapper(vtkMapper2D *mapper);
00251 
00253   virtual bool RenderImage(vtkTextProperty *tprop, vtkViewport *viewport);
00254 
00256 
00257   virtual bool GetImageBoundingBox(
00258     vtkTextProperty *tprop, vtkViewport *viewport, int bbox[4]);
00260 
00261    vtkTextActor();
00262   ~vtkTextActor();
00263 
00264   int     MinimumSize[2];
00265   float   MaximumLineHeight;
00266   double  FontScaleExponent;
00267   int     TextScaleMode;
00268   float   Orientation;
00269   int     UseBorderAlign;
00270 
00271   vtkTextProperty *TextProperty;
00272   vtkImageData *ImageData;
00273   // This used to be "Mapper" but I changed it to PDMapper because
00274   // Mapper is an ivar in Actor2D (bad form).
00275   vtkPolyDataMapper2D *PDMapper;
00276   vtkTextRenderer *TextRenderer;
00277   vtkTimeStamp  BuildTime;
00278   vtkTransform *Transform;
00279   int LastSize[2];
00280   int LastOrigin[2];
00281   char *Input;
00282   bool InputRendered;
00283   double FormerOrientation;
00284 
00285   vtkTextProperty *ScaledTextProperty;
00286 
00287   // Stuff needed to display the image text as a texture map.
00288   vtkPolyData* Rectangle;
00289   vtkPoints*   RectanglePoints;
00290   vtkTexture *Texture;
00291 
00292   virtual void ComputeRectangle(vtkViewport *viewport);
00293 
00301   virtual int UpdateRectangle(vtkViewport* viewport);
00302 
00303   // Set/Get the texture object to control rendering texture maps.  This will
00304   // be a vtkTexture object. An actor does not need to have an associated
00305   // texture map and multiple actors can share one texture.
00306   // This was added for orienated text which is rendered with a
00307   // vtkPolyDataMaper2D and a texture.
00308   virtual void SetTexture(vtkTexture*);
00309   vtkGetObjectMacro(Texture,vtkTexture);
00310 
00311 private:
00312   vtkTextActor(const vtkTextActor&);  // Not implemented.
00313   void operator=(const vtkTextActor&);  // Not implemented.
00314 };
00315 
00316 
00317 #endif
00318