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 "vtkRenderingCoreModule.h" // For export macro 00044 #include "vtkTexturedActor2D.h" 00045 00046 class vtkTextProperty; 00047 class vtkPolyDataMapper2D; 00048 class vtkImageData; 00049 class vtkTextRenderer; 00050 class vtkTransform; 00051 class vtkPolyData; 00052 class vtkPoints; 00053 00054 class VTKRENDERINGCORE_EXPORT vtkTextActor : public vtkTexturedActor2D 00055 { 00056 public: 00057 vtkTypeMacro(vtkTextActor,vtkTexturedActor2D); 00058 void PrintSelf(ostream& os, vtkIndent indent); 00059 00062 static vtkTextActor *New(); 00063 00066 void ShallowCopy(vtkProp *prop); 00067 00069 00072 void SetInput(const char *inputString); 00073 char *GetInput(); 00075 00077 00079 vtkSetVector2Macro(MinimumSize,int); 00080 vtkGetVector2Macro(MinimumSize,int); 00082 00084 00087 vtkSetMacro(MaximumLineHeight,float); 00088 vtkGetMacro(MaximumLineHeight,float); 00090 00092 00099 vtkSetClampMacro(TextScaleMode, int, 00100 TEXT_SCALE_MODE_NONE, TEXT_SCALE_MODE_VIEWPORT); 00101 vtkGetMacro(TextScaleMode, int); 00102 void SetTextScaleModeToNone() 00103 { this->SetTextScaleMode(TEXT_SCALE_MODE_NONE); } 00104 void SetTextScaleModeToProp() 00105 { this->SetTextScaleMode(TEXT_SCALE_MODE_PROP); } 00106 void SetTextScaleModeToViewport() 00107 { this->SetTextScaleMode(TEXT_SCALE_MODE_VIEWPORT); } 00109 00110 //BTX 00111 enum { 00112 TEXT_SCALE_MODE_NONE = 0, 00113 TEXT_SCALE_MODE_PROP, 00114 TEXT_SCALE_MODE_VIEWPORT 00115 }; 00116 //ETX 00117 00119 00122 vtkSetMacro(UseBorderAlign,int); 00123 vtkGetMacro(UseBorderAlign,int); 00124 vtkBooleanMacro(UseBorderAlign,int); 00126 00128 00136 void SetAlignmentPoint(int point); 00137 int GetAlignmentPoint(); 00139 00141 00145 void SetOrientation(float orientation); 00146 vtkGetMacro(Orientation,float); 00148 00150 00151 virtual void SetTextProperty(vtkTextProperty *p); 00152 vtkGetObjectMacro(TextProperty,vtkTextProperty); 00154 00158 virtual void GetBoundingBox(vtkViewport* vport, double bbox[4]); 00159 00162 virtual void GetSize(vtkViewport* vport, double size[2]); 00163 00165 00169 virtual int SetConstrainedFontSize( 00170 vtkViewport*, int targetWidth, int targetHeight); 00171 static int SetConstrainedFontSize( 00172 vtkTextActor*, vtkViewport*, int targetWidth, int targetHeight); 00174 00176 00180 static int SetMultipleConstrainedFontSize( 00181 vtkViewport*, int targetWidth, int targetHeight, 00182 vtkTextActor** actors, int nbOfActors, int* maxResultingSize); 00184 00192 virtual void SetNonLinearFontScale(double exponent, int target); 00193 00196 void SpecifiedToDisplay(double *pos, vtkViewport *vport, int specified); 00197 00200 void DisplayToSpecified(double *pos, vtkViewport *vport, int specified); 00201 00204 virtual void ComputeScaledFont(vtkViewport *viewport); 00205 00207 00209 vtkGetObjectMacro(ScaledTextProperty, vtkTextProperty); 00211 00218 static float GetFontScale(vtkViewport *viewport); 00219 00220 //BTX 00225 virtual void ReleaseGraphicsResources(vtkWindow *); 00226 00228 00231 virtual int RenderOpaqueGeometry(vtkViewport* viewport); 00232 virtual int RenderTranslucentPolygonalGeometry(vtkViewport* ) {return 0;}; 00233 virtual int RenderOverlay(vtkViewport* viewport); 00235 00237 00238 virtual int HasTranslucentPolygonalGeometry(); 00239 //ETX 00241 00242 protected: 00244 virtual bool RenderImage(vtkTextProperty *tprop, vtkViewport *viewport); 00245 00247 00248 virtual bool GetImageBoundingBox( 00249 vtkTextProperty *tprop, vtkViewport *viewport, int bbox[4]); 00251 00252 vtkTextActor(); 00253 ~vtkTextActor(); 00254 00255 int MinimumSize[2]; 00256 float MaximumLineHeight; 00257 double FontScaleExponent; 00258 int TextScaleMode; 00259 float Orientation; 00260 int UseBorderAlign; 00261 00262 vtkTextProperty *TextProperty; 00263 vtkImageData *ImageData; 00264 vtkTextRenderer *TextRenderer; 00265 vtkTimeStamp BuildTime; 00266 vtkTransform *Transform; 00267 int LastSize[2]; 00268 int LastOrigin[2]; 00269 char *Input; 00270 bool InputRendered; 00271 double FormerOrientation; 00272 00273 vtkTextProperty *ScaledTextProperty; 00274 00275 // Stuff needed to display the image text as a texture map. 00276 vtkPolyData* Rectangle; 00277 vtkPoints* RectanglePoints; 00278 00279 virtual void ComputeRectangle(vtkViewport *viewport); 00280 00288 virtual int UpdateRectangle(vtkViewport* viewport); 00289 00290 private: 00291 vtkTextActor(const vtkTextActor&); // Not implemented. 00292 void operator=(const vtkTextActor&); // Not implemented. 00293 }; 00294 00295 00296 #endif