00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00034 #ifndef __vtkTextMapper_h
00035 #define __vtkTextMapper_h
00036 
00037 #include "vtkMapper2D.h"
00038 
00039 class vtkActor2D;
00040 class vtkTextProperty;
00041 class vtkViewport;
00042 
00043 class VTK_RENDERING_EXPORT vtkTextMapper : public vtkMapper2D
00044 {
00045 public:
00046   vtkTypeMacro(vtkTextMapper,vtkMapper2D);
00047   void PrintSelf(ostream& os, vtkIndent indent);
00048 
00050   static vtkTextMapper *New();
00051 
00053 
00055   virtual void GetSize(vtkViewport*, int size[2]) {size[0]=size[0];}
00056   virtual int GetWidth(vtkViewport*v);
00057   virtual int GetHeight(vtkViewport*v);
00059   
00061 
00063   virtual void SetInput(const char *inputString);
00064   vtkGetStringMacro(Input);
00066 
00068 
00069   virtual void SetTextProperty(vtkTextProperty *p);
00070   vtkGetObjectMacro(TextProperty,vtkTextProperty);
00072   
00074   void ShallowCopy(vtkTextMapper *tm);
00075   
00078   int  GetNumberOfLines(const char *input);
00079 
00081 
00084   vtkGetMacro(NumberOfLines,int);
00086   
00088 
00092   virtual int SetConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight);
00093   static int SetConstrainedFontSize(vtkTextMapper*, vtkViewport*, int targetWidth, int targetHeight);
00095 
00097 
00101   static int SetMultipleConstrainedFontSize(vtkViewport*, 
00102                                             int targetWidth, int targetHeight,
00103                                             vtkTextMapper** mappers, 
00104                                             int nbOfMappers, 
00105                                             int* maxResultingSize);
00107 
00109 
00112   static int SetRelativeFontSize(vtkTextMapper*, vtkViewport*, int *winSize, 
00113                                  int *stringSize, float sizeFactor=0.0);
00114   static int SetMultipleRelativeFontSize(vtkViewport *viewport, 
00115                                          vtkTextMapper **textMappers, 
00116                                          int nbOfMappers, int *winSize, 
00117                                          int *stringSize, float sizeFactor);
00119 
00121 
00122   virtual int GetSystemFontSize(int size) 
00123     { return size; }
00125 
00126 protected:
00127   vtkTextMapper();
00128   ~vtkTextMapper();
00129 
00130   char* Input;
00131   vtkTextProperty *TextProperty;
00132 
00133   int  LineSize;
00134   int  NumberOfLines;
00135   int  NumberOfLinesAllocated;
00136 
00137   vtkTextMapper **TextLines;
00138 
00139   
00140   char *NextLine(const char *input, int lineNum);
00141   void GetMultiLineSize(vtkViewport* viewport, int size[2]);
00142   void RenderOverlayMultipleLines(vtkViewport *viewport, vtkActor2D *actor);
00143   
00144 private:
00145   vtkTextMapper(const vtkTextMapper&);  
00146   void operator=(const vtkTextMapper&);  
00147 };
00148 
00149 #endif
00150