VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkTextActor.h,v $ 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 =========================================================================*/ 00037 #ifndef __vtkTextActor_h 00038 #define __vtkTextActor_h 00039 00040 #include "vtkActor2D.h" 00041 00042 class vtkTextProperty; 00043 class vtkPolyDataMapper2D; 00044 class vtkImageData; 00045 class vtkFreeTypeUtilities; 00046 class vtkTransform; 00047 class vtkPolyData; 00048 class vtkPoints; 00049 class vtkTexture; 00050 00051 class VTK_RENDERING_EXPORT vtkTextActor : public vtkActor2D 00052 { 00053 public: 00054 vtkTypeRevisionMacro(vtkTextActor,vtkActor2D); 00055 void PrintSelf(ostream& os, vtkIndent indent); 00056 00059 static vtkTextActor *New(); 00060 00063 void ShallowCopy(vtkProp *prop); 00064 00067 void SetMapper(vtkPolyDataMapper2D *mapper); 00068 00070 00074 void SetInput(const char *inputString); 00075 char *GetInput(); 00077 00079 00081 vtkSetVector2Macro(MinimumSize,int); 00082 vtkGetVector2Macro(MinimumSize,int); 00084 00086 00089 vtkSetMacro(MaximumLineHeight,float); 00090 vtkGetMacro(MaximumLineHeight,float); 00092 00094 00101 vtkSetClampMacro(TextScaleMode, int, 00102 TEXT_SCALE_MODE_NONE, TEXT_SCALE_MODE_VIEWPORT); 00103 vtkGetMacro(TextScaleMode, int); 00104 void SetTextScaleModeToNone() 00105 { this->SetTextScaleMode(TEXT_SCALE_MODE_NONE); } 00106 void SetTextScaleModeToProp() 00107 { this->SetTextScaleMode(TEXT_SCALE_MODE_PROP); } 00108 void SetTextScaleModeToViewport() 00109 { this->SetTextScaleMode(TEXT_SCALE_MODE_VIEWPORT); } 00111 00112 //BTX 00113 enum { 00114 TEXT_SCALE_MODE_NONE = 0, 00115 TEXT_SCALE_MODE_PROP, 00116 TEXT_SCALE_MODE_VIEWPORT 00117 }; 00118 //ETX 00119 00121 00123 VTK_LEGACY(void SetScaledText(int)); 00124 VTK_LEGACY(int GetScaledText()); 00125 VTK_LEGACY(void ScaledTextOn()); 00126 VTK_LEGACY(void ScaledTextOff()); 00128 00130 00133 vtkSetMacro(UseBorderAlign,int); 00134 vtkGetMacro(UseBorderAlign,int); 00135 vtkBooleanMacro(UseBorderAlign,int); 00137 00139 00147 void SetAlignmentPoint(int point); 00148 int GetAlignmentPoint(); 00150 00152 00156 void SetOrientation(float orientation); 00157 vtkGetMacro(Orientation,float); 00159 00161 00162 virtual void SetTextProperty(vtkTextProperty *p); 00163 vtkGetObjectMacro(TextProperty,vtkTextProperty); 00165 00173 virtual void SetNonLinearFontScale(double exponent, int target); 00174 00177 void SpecifiedToDisplay(double *pos, vtkViewport *vport, int specified); 00178 00181 void DisplayToSpecified(double *pos, vtkViewport *vport, int specified); 00182 00185 virtual void ComputeScaledFont(vtkViewport *viewport); 00186 00188 00190 vtkGetObjectMacro(ScaledTextProperty, vtkTextProperty); 00192 00199 static float GetFontScale(vtkViewport *viewport); 00200 00201 //BTX 00206 virtual void ReleaseGraphicsResources(vtkWindow *); 00207 00209 00212 virtual int RenderOpaqueGeometry(vtkViewport* viewport); 00213 virtual int RenderTranslucentPolygonalGeometry(vtkViewport* ) {return 0;}; 00214 virtual int RenderOverlay(vtkViewport* viewport); 00216 00218 virtual int HasTranslucentPolygonalGeometry(); 00219 //ETX 00220 00221 protected: 00224 void SetMapper(vtkMapper2D *mapper); 00225 00226 vtkTextActor(); 00227 ~vtkTextActor(); 00228 00229 int MinimumSize[2]; 00230 float MaximumLineHeight; 00231 double FontScaleExponent; 00232 int TextScaleMode; 00233 float Orientation; 00234 int UseBorderAlign; 00235 00236 vtkTextProperty *TextProperty; 00237 vtkImageData *ImageData; 00238 // This used to be "Mapper" but I changed it to PDMapper because 00239 // Mapper is an ivar in Actor2D (bad form). 00240 vtkPolyDataMapper2D *PDMapper; 00241 vtkFreeTypeUtilities *FreeTypeUtilities; 00242 vtkTimeStamp BuildTime; 00243 vtkTransform *Transform; 00244 int LastSize[2]; 00245 int LastOrigin[2]; 00246 char *Input; 00247 bool InputRendered; 00248 double FormerOrientation; 00249 00250 vtkTextProperty *ScaledTextProperty; 00251 00252 // Stuff needed to display the image text as a texture map. 00253 vtkPolyData* Rectangle; 00254 vtkPoints* RectanglePoints; 00255 vtkTexture *Texture; 00256 00257 virtual void ComputeRectangle(vtkViewport *viewport); 00258 00259 // Set/Get the texture object to control rendering texture maps. This will 00260 // be a vtkTexture object. An actor does not need to have an associated 00261 // texture map and multiple actors can share one texture. 00262 // This was added for orienated text which is rendered with a 00263 // vtkPolyDataMaper2D and a texture. 00264 virtual void SetTexture(vtkTexture*); 00265 vtkGetObjectMacro(Texture,vtkTexture); 00266 00267 private: 00268 vtkTextActor(const vtkTextActor&); // Not implemented. 00269 void operator=(const vtkTextActor&); // Not implemented. 00270 }; 00271 00272 00273 #endif 00274