VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkTextMapper.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 =========================================================================*/ 00034 #ifndef __vtkTextMapper_h 00035 #define __vtkTextMapper_h 00036 00037 #include "vtkRenderingCoreModule.h" // For export macro 00038 #include "vtkMapper2D.h" 00039 00040 class vtkActor2D; 00041 class vtkTextProperty; 00042 class vtkViewport; 00043 00044 class VTKRENDERINGCORE_EXPORT vtkTextMapper : public vtkMapper2D 00045 { 00046 public: 00047 vtkTypeMacro(vtkTextMapper,vtkMapper2D); 00048 void PrintSelf(ostream& os, vtkIndent indent); 00049 00051 static vtkTextMapper *New(); 00052 00054 00056 virtual void GetSize(vtkViewport*, int size[2]) {size[0]=size[0];} 00057 virtual int GetWidth(vtkViewport*v); 00058 virtual int GetHeight(vtkViewport*v); 00060 00062 00064 virtual void SetInput(const char *inputString); 00065 vtkGetStringMacro(Input); 00067 00069 00070 virtual void SetTextProperty(vtkTextProperty *p); 00071 vtkGetObjectMacro(TextProperty,vtkTextProperty); 00073 00075 void ShallowCopy(vtkTextMapper *tm); 00076 00079 int GetNumberOfLines(const char *input); 00080 00082 00085 vtkGetMacro(NumberOfLines,int); 00087 00089 00093 virtual int SetConstrainedFontSize(vtkViewport*, int targetWidth, int targetHeight); 00094 static int SetConstrainedFontSize(vtkTextMapper*, vtkViewport*, int targetWidth, int targetHeight); 00096 00098 00102 static int SetMultipleConstrainedFontSize(vtkViewport*, 00103 int targetWidth, int targetHeight, 00104 vtkTextMapper** mappers, 00105 int nbOfMappers, 00106 int* maxResultingSize); 00108 00110 00113 static int SetRelativeFontSize(vtkTextMapper*, vtkViewport*, int *winSize, 00114 int *stringSize, float sizeFactor=0.0); 00115 static int SetMultipleRelativeFontSize(vtkViewport *viewport, 00116 vtkTextMapper **textMappers, 00117 int nbOfMappers, int *winSize, 00118 int *stringSize, float sizeFactor); 00120 00122 00123 virtual int GetSystemFontSize(int size) 00124 { return size; } 00126 00127 protected: 00128 vtkTextMapper(); 00129 ~vtkTextMapper(); 00130 00131 char* Input; 00132 vtkTextProperty *TextProperty; 00133 00134 int LineSize; 00135 int NumberOfLines; 00136 int NumberOfLinesAllocated; 00137 00138 vtkTextMapper **TextLines; 00139 00140 // These functions are used to parse, process, and render multiple lines 00141 char *NextLine(const char *input, int lineNum); 00142 void GetMultiLineSize(vtkViewport* viewport, int size[2]); 00143 void RenderOverlayMultipleLines(vtkViewport *viewport, vtkActor2D *actor); 00144 00145 private: 00146 vtkTextMapper(const vtkTextMapper&); // Not implemented. 00147 void operator=(const vtkTextMapper&); // Not implemented. 00148 }; 00149 00150 #endif 00151