VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkTextMapper.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 =========================================================================*/ 00031 #ifndef __vtkTextMapper_h 00032 #define __vtkTextMapper_h 00033 00034 #include "vtkMapper2D.h" 00035 00036 class vtkActor2D; 00037 class vtkTextProperty; 00038 class vtkViewport; 00039 00040 class VTK_RENDERING_EXPORT vtkTextMapper : public vtkMapper2D 00041 { 00042 public: 00043 vtkTypeRevisionMacro(vtkTextMapper,vtkMapper2D); 00044 void PrintSelf(ostream& os, vtkIndent indent); 00045 00047 static vtkTextMapper *New(); 00048 00050 00052 virtual void GetSize(vtkViewport*, int size[2]) {size[0]=size[0];} 00053 virtual int GetWidth(vtkViewport*v); 00054 virtual int GetHeight(vtkViewport*v); 00056 00058 00060 virtual void SetInput(const char *inputString); 00061 vtkGetStringMacro(Input); 00063 00065 00066 virtual void SetTextProperty(vtkTextProperty *p); 00067 vtkGetObjectMacro(TextProperty,vtkTextProperty); 00069 00071 void ShallowCopy(vtkTextMapper *tm); 00072 00075 int GetNumberOfLines(const char *input); 00076 00078 00081 vtkGetMacro(NumberOfLines,int); 00083 00085 00089 virtual int SetConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight); 00090 static int SetConstrainedFontSize(vtkTextMapper*, vtkViewport*, int targetWidth, int targetHeight); 00092 00094 00098 static int SetMultipleConstrainedFontSize(vtkViewport*, 00099 int targetWidth, int targetHeight, 00100 vtkTextMapper** mappers, 00101 int nbOfMappers, 00102 int* maxResultingSize); 00104 00106 00109 static int SetRelativeFontSize(vtkTextMapper*, vtkViewport*, int *winSize, 00110 int *stringSize, float sizeFactor=0.0); 00111 static int SetMultipleRelativeFontSize(vtkViewport *viewport, 00112 vtkTextMapper **textMappers, 00113 int nbOfMappers, int *winSize, 00114 int *stringSize, float sizeFactor); 00116 00118 00119 virtual int GetSystemFontSize(int size) 00120 { return size; } 00122 00123 protected: 00124 vtkTextMapper(); 00125 ~vtkTextMapper(); 00126 00127 char* Input; 00128 vtkTextProperty *TextProperty; 00129 00130 int LineSize; 00131 int NumberOfLines; 00132 int NumberOfLinesAllocated; 00133 00134 vtkTextMapper **TextLines; 00135 00136 // These functions are used to parse, process, and render multiple lines 00137 char *NextLine(const char *input, int lineNum); 00138 void GetMultiLineSize(vtkViewport* viewport, int size[2]); 00139 void RenderOverlayMultipleLines(vtkViewport *viewport, vtkActor2D *actor); 00140 00141 private: 00142 vtkTextMapper(const vtkTextMapper&); // Not implemented. 00143 void operator=(const vtkTextMapper&); // Not implemented. 00144 }; 00145 00146 #endif 00147