VTK
|
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 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 00126 VTK_LEGACY(void SetScaledText(int)); 00127 VTK_LEGACY(int GetScaledText()); 00128 VTK_LEGACY(void ScaledTextOn()); 00129 VTK_LEGACY(void ScaledTextOff()); 00131 00133 00136 vtkSetMacro(UseBorderAlign,int); 00137 vtkGetMacro(UseBorderAlign,int); 00138 vtkBooleanMacro(UseBorderAlign,int); 00140 00142 00150 void SetAlignmentPoint(int point); 00151 int GetAlignmentPoint(); 00153 00155 00159 void SetOrientation(float orientation); 00160 vtkGetMacro(Orientation,float); 00162 00164 00165 virtual void SetTextProperty(vtkTextProperty *p); 00166 vtkGetObjectMacro(TextProperty,vtkTextProperty); 00168 00176 virtual void SetNonLinearFontScale(double exponent, int target); 00177 00180 void SpecifiedToDisplay(double *pos, vtkViewport *vport, int specified); 00181 00184 void DisplayToSpecified(double *pos, vtkViewport *vport, int specified); 00185 00188 virtual void ComputeScaledFont(vtkViewport *viewport); 00189 00191 00193 vtkGetObjectMacro(ScaledTextProperty, vtkTextProperty); 00195 00202 static float GetFontScale(vtkViewport *viewport); 00203 00204 //BTX 00209 virtual void ReleaseGraphicsResources(vtkWindow *); 00210 00212 00215 virtual int RenderOpaqueGeometry(vtkViewport* viewport); 00216 virtual int RenderTranslucentPolygonalGeometry(vtkViewport* ) {return 0;}; 00217 virtual int RenderOverlay(vtkViewport* viewport); 00219 00221 virtual int HasTranslucentPolygonalGeometry(); 00222 //ETX 00223 00224 protected: 00227 void SetMapper(vtkMapper2D *mapper); 00228 00229 vtkTextActor(); 00230 ~vtkTextActor(); 00231 00232 int MinimumSize[2]; 00233 float MaximumLineHeight; 00234 double FontScaleExponent; 00235 int TextScaleMode; 00236 float Orientation; 00237 int UseBorderAlign; 00238 00239 vtkTextProperty *TextProperty; 00240 vtkImageData *ImageData; 00241 // This used to be "Mapper" but I changed it to PDMapper because 00242 // Mapper is an ivar in Actor2D (bad form). 00243 vtkPolyDataMapper2D *PDMapper; 00244 vtkFreeTypeUtilities *FreeTypeUtilities; 00245 vtkTimeStamp BuildTime; 00246 vtkTransform *Transform; 00247 int LastSize[2]; 00248 int LastOrigin[2]; 00249 char *Input; 00250 bool InputRendered; 00251 double FormerOrientation; 00252 00253 vtkTextProperty *ScaledTextProperty; 00254 00255 // Stuff needed to display the image text as a texture map. 00256 vtkPolyData* Rectangle; 00257 vtkPoints* RectanglePoints; 00258 vtkTexture *Texture; 00259 00260 virtual void ComputeRectangle(vtkViewport *viewport); 00261 00262 // Set/Get the texture object to control rendering texture maps. This will 00263 // be a vtkTexture object. An actor does not need to have an associated 00264 // texture map and multiple actors can share one texture. 00265 // This was added for orienated text which is rendered with a 00266 // vtkPolyDataMaper2D and a texture. 00267 virtual void SetTexture(vtkTexture*); 00268 vtkGetObjectMacro(Texture,vtkTexture); 00269 00270 private: 00271 vtkTextActor(const vtkTextActor&); // Not implemented. 00272 void operator=(const vtkTextActor&); // Not implemented. 00273 }; 00274 00275 00276 #endif 00277