Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Rendering/vtkTextMapper.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkTextMapper.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00038 #ifndef __vtkTextMapper_h
00039 #define __vtkTextMapper_h
00040 
00041 #include "vtkMapper2D.h"
00042 
00043 class vtkActor2D;
00044 class vtkTextProperty;
00045 class vtkViewport;
00046 
00047 class VTK_RENDERING_EXPORT vtkTextMapper : public vtkMapper2D
00048 {
00049 public:
00050   vtkTypeRevisionMacro(vtkTextMapper,vtkMapper2D);
00051   void PrintSelf(ostream& os, vtkIndent indent);
00052 
00054   static vtkTextMapper *New();
00055 
00057 
00059   virtual void GetSize(vtkViewport*, int size[2]) {size[0]=size[0];};
00060   virtual int GetWidth(vtkViewport*v);
00061   virtual int GetHeight(vtkViewport*v);
00063   
00065 
00067   virtual void SetInput(const char *inputString);
00068   vtkGetStringMacro(Input);
00070 
00072 
00073   virtual void SetTextProperty(vtkTextProperty *p);
00074   vtkGetObjectMacro(TextProperty,vtkTextProperty);
00076   
00077 #ifndef VTK_REMOVE_LEGACY_CODE
00078 
00079 
00083   virtual void SetFontFamily(int val);
00084   virtual int GetFontFamily();
00085   void SetFontFamilyToArial()   { this->SetFontFamily(VTK_ARIAL);  };
00086   void SetFontFamilyToCourier() { this->SetFontFamily(VTK_COURIER);};
00087   void SetFontFamilyToTimes()   { this->SetFontFamily(VTK_TIMES);  };
00089 #endif
00090 
00091 #ifndef VTK_REMOVE_LEGACY_CODE
00092 
00093 
00096   virtual void SetFontSize(int size);
00097   virtual int GetFontSize();
00099 #endif
00100 
00101 #ifndef VTK_REMOVE_LEGACY_CODE
00102 
00103 
00106   virtual void SetBold(int val);
00107   virtual int GetBold();
00108   vtkBooleanMacro(Bold, int);
00110 #endif
00111 
00112 #ifndef VTK_REMOVE_LEGACY_CODE
00113 
00114 
00117   virtual void SetItalic(int val);
00118   virtual int GetItalic();
00119   vtkBooleanMacro(Italic, int);
00121 #endif
00122 
00123 #ifndef VTK_REMOVE_LEGACY_CODE
00124 
00125 
00128   virtual void SetShadow(int val);
00129   virtual int GetShadow();
00130   vtkBooleanMacro(Shadow, int);
00132 #endif
00133   
00134 #ifndef VTK_REMOVE_LEGACY_CODE
00135 
00136 
00140   virtual void SetJustification(int val);
00141   virtual int GetJustification();
00142   void SetJustificationToLeft()     
00143     { this->SetJustification(VTK_TEXT_LEFT);};
00144   void SetJustificationToCentered() 
00145     { this->SetJustification(VTK_TEXT_CENTERED);};
00146   void SetJustificationToRight()    
00147     { this->SetJustification(VTK_TEXT_RIGHT);};
00149 #endif
00150     
00151 #ifndef VTK_REMOVE_LEGACY_CODE
00152 
00153 
00157   virtual void SetVerticalJustification(int val);
00158   virtual int GetVerticalJustification();
00159   void SetVerticalJustificationToBottom() 
00160     {this->SetVerticalJustification(VTK_TEXT_BOTTOM);};
00161   void SetVerticalJustificationToCentered() 
00162     {this->SetVerticalJustification(VTK_TEXT_CENTERED);};
00163   void SetVerticalJustificationToTop() 
00164     {this->SetVerticalJustification(VTK_TEXT_TOP);};
00166 #endif
00167     
00168 #ifndef VTK_REMOVE_LEGACY_CODE
00169 
00170 
00176   virtual void SetLineOffset(float val);
00177   virtual float GetLineOffset();
00178   virtual void SetLineSpacing(float val);
00179   virtual float GetLineSpacing();
00181 #endif
00182 
00183   vtkGetMacro(NumberOfLines,int);
00184   
00186   void ShallowCopy(vtkTextMapper *tm);
00187   
00190   int  GetNumberOfLines(const char *input);
00191 
00193 
00195   virtual int SetConstrainedFontSize(vtkViewport*, 
00196                                      int targetWidth, int targetHeight);
00198 
00200 
00205   static int SetMultipleConstrainedFontSize(vtkViewport*, 
00206                                             int targetWidth, int targetHeight,
00207                                             vtkTextMapper** mappers, 
00208                                             int nbOfMappers, 
00209                                             int* maxResultingSize);
00211 
00213 
00214   virtual int GetSystemFontSize(int size) 
00215     { return size; };
00217 
00218 protected:
00219   vtkTextMapper();
00220   ~vtkTextMapper();
00221 
00222   char* Input;
00223   vtkTextProperty *TextProperty;
00224 
00225   int  LineSize;
00226   int  NumberOfLines;
00227   int  NumberOfLinesAllocated;
00228 
00229   vtkTextMapper **TextLines;
00230 
00231   // These functions are used to parse, process, and render multiple lines 
00232 
00233   char *NextLine(const char *input, int lineNum);
00234   void GetMultiLineSize(vtkViewport* viewport, int size[2]);
00235   void RenderOverlayMultipleLines(vtkViewport *viewport, vtkActor2D *actor);
00236   
00237 private:
00238   vtkTextMapper(const vtkTextMapper&);  // Not implemented.
00239   void operator=(const vtkTextMapper&);  // Not implemented.
00240 };
00241 
00242 #endif
00243