VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkTextProperty.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 =========================================================================*/ 00032 #ifndef __vtkTextProperty_h 00033 #define __vtkTextProperty_h 00034 00035 #include "vtkRenderingCoreModule.h" // For export macro 00036 #include "vtkObject.h" 00037 00038 class VTKRENDERINGCORE_EXPORT vtkTextProperty : public vtkObject 00039 { 00040 public: 00041 vtkTypeMacro(vtkTextProperty,vtkObject); 00042 void PrintSelf(ostream& os, vtkIndent indent); 00043 00046 static vtkTextProperty *New(); 00047 00049 00050 vtkSetVector3Macro(Color,double); 00051 vtkGetVector3Macro(Color,double); 00053 00055 00057 vtkSetMacro(Opacity,double); 00058 vtkGetMacro(Opacity,double); 00060 00062 00063 vtkGetStringMacro(FontFamilyAsString); 00064 vtkSetStringMacro(FontFamilyAsString); 00065 void SetFontFamily(int t); 00066 int GetFontFamily(); 00067 int GetFontFamilyMinValue() { return VTK_ARIAL; }; 00068 void SetFontFamilyToArial(); 00069 void SetFontFamilyToCourier(); 00070 void SetFontFamilyToTimes(); 00071 static int GetFontFamilyFromString( const char *f ); 00072 static const char *GetFontFamilyAsString( int f ); 00074 00076 00077 vtkSetClampMacro(FontSize,int,0,VTK_INT_MAX); 00078 vtkGetMacro(FontSize, int); 00080 00082 00083 vtkSetMacro(Bold, int); 00084 vtkGetMacro(Bold, int); 00085 vtkBooleanMacro(Bold, int); 00087 00089 00090 vtkSetMacro(Italic, int); 00091 vtkGetMacro(Italic, int); 00092 vtkBooleanMacro(Italic, int); 00094 00096 00097 vtkSetMacro(Shadow, int); 00098 vtkGetMacro(Shadow, int); 00099 vtkBooleanMacro(Shadow, int); 00101 00103 00105 vtkSetVector2Macro(ShadowOffset,int); 00106 vtkGetVectorMacro(ShadowOffset,int,2); 00108 00110 void GetShadowColor(double color[3]); 00111 00113 00115 vtkSetClampMacro(Justification,int,VTK_TEXT_LEFT,VTK_TEXT_RIGHT); 00116 vtkGetMacro(Justification,int); 00117 void SetJustificationToLeft() 00118 { this->SetJustification(VTK_TEXT_LEFT);}; 00119 void SetJustificationToCentered() 00120 { this->SetJustification(VTK_TEXT_CENTERED);}; 00121 void SetJustificationToRight() 00122 { this->SetJustification(VTK_TEXT_RIGHT);}; 00123 const char *GetJustificationAsString(); 00125 00127 00129 vtkSetClampMacro(VerticalJustification,int,VTK_TEXT_BOTTOM,VTK_TEXT_TOP); 00130 vtkGetMacro(VerticalJustification,int); 00131 void SetVerticalJustificationToBottom() 00132 {this->SetVerticalJustification(VTK_TEXT_BOTTOM);}; 00133 void SetVerticalJustificationToCentered() 00134 {this->SetVerticalJustification(VTK_TEXT_CENTERED);}; 00135 void SetVerticalJustificationToTop() 00136 {this->SetVerticalJustification(VTK_TEXT_TOP);}; 00137 const char *GetVerticalJustificationAsString(); 00139 00141 00142 vtkSetMacro(Orientation,double); 00143 vtkGetMacro(Orientation,double); 00145 00147 00149 vtkSetMacro(LineSpacing, double); 00150 vtkGetMacro(LineSpacing, double); 00152 00154 00155 vtkSetMacro(LineOffset, double); 00156 vtkGetMacro(LineOffset, double); 00158 00160 void ShallowCopy(vtkTextProperty *tprop); 00161 00162 protected: 00163 vtkTextProperty(); 00164 ~vtkTextProperty(); 00165 00166 double Color[3]; 00167 double Opacity; 00168 char* FontFamilyAsString; 00169 int FontSize; 00170 int Bold; 00171 int Italic; 00172 int Shadow; 00173 int ShadowOffset[2]; 00174 int Justification; 00175 int VerticalJustification; 00176 double Orientation; 00177 double LineOffset; 00178 double LineSpacing; 00179 00180 private: 00181 vtkTextProperty(const vtkTextProperty&); // Not implemented. 00182 void operator=(const vtkTextProperty&); // Not implemented. 00183 }; 00184 00185 inline const char *vtkTextProperty::GetFontFamilyAsString( int f ) 00186 { 00187 if ( f == VTK_ARIAL ) 00188 { 00189 return "Arial"; 00190 } 00191 else if ( f == VTK_COURIER ) 00192 { 00193 return "Courier"; 00194 } 00195 else if ( f == VTK_TIMES ) 00196 { 00197 return "Times"; 00198 } 00199 return "Unknown"; 00200 } 00201 00202 inline void vtkTextProperty::SetFontFamily( int t ) 00203 { 00204 this->SetFontFamilyAsString( this->GetFontFamilyAsString( t ) ); 00205 } 00206 00207 inline void vtkTextProperty::SetFontFamilyToArial() 00208 { 00209 this->SetFontFamily(VTK_ARIAL); 00210 } 00211 00212 inline void vtkTextProperty::SetFontFamilyToCourier() 00213 { 00214 this->SetFontFamily(VTK_COURIER); 00215 } 00216 00217 inline void vtkTextProperty::SetFontFamilyToTimes() 00218 { 00219 this->SetFontFamily(VTK_TIMES); 00220 } 00221 00222 inline int vtkTextProperty::GetFontFamilyFromString( const char *f ) 00223 { 00224 if ( strcmp( f, GetFontFamilyAsString( VTK_ARIAL ) ) == 0 ) 00225 { 00226 return VTK_ARIAL; 00227 } 00228 else if ( strcmp( f, GetFontFamilyAsString( VTK_COURIER ) ) == 0 ) 00229 { 00230 return VTK_COURIER; 00231 } 00232 else if ( strcmp( f, GetFontFamilyAsString( VTK_TIMES ) ) == 0 ) 00233 { 00234 return VTK_TIMES; 00235 } 00236 return VTK_UNKNOWN_FONT; 00237 } 00238 00239 inline int vtkTextProperty::GetFontFamily() 00240 { 00241 return GetFontFamilyFromString( this->FontFamilyAsString ); 00242 } 00243 00244 inline const char *vtkTextProperty::GetJustificationAsString(void) 00245 { 00246 if (this->Justification == VTK_TEXT_LEFT) 00247 { 00248 return "Left"; 00249 } 00250 else if (this->Justification == VTK_TEXT_CENTERED) 00251 { 00252 return "Centered"; 00253 } 00254 else if (this->Justification == VTK_TEXT_RIGHT) 00255 { 00256 return "Right"; 00257 } 00258 return "Unknown"; 00259 } 00260 00261 inline const char *vtkTextProperty::GetVerticalJustificationAsString(void) 00262 { 00263 if (this->VerticalJustification == VTK_TEXT_BOTTOM) 00264 { 00265 return "Bottom"; 00266 } 00267 else if (this->VerticalJustification == VTK_TEXT_CENTERED) 00268 { 00269 return "Centered"; 00270 } 00271 else if (this->VerticalJustification == VTK_TEXT_TOP) 00272 { 00273 return "Top"; 00274 } 00275 return "Unknown"; 00276 } 00277 00278 #endif