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 "vtkObject.h" 00036 00037 class VTK_RENDERING_EXPORT vtkTextProperty : public vtkObject 00038 { 00039 public: 00040 vtkTypeMacro(vtkTextProperty,vtkObject); 00041 void PrintSelf(ostream& os, vtkIndent indent); 00042 00045 static vtkTextProperty *New(); 00046 00048 00049 vtkSetVector3Macro(Color,double); 00050 vtkGetVector3Macro(Color,double); 00052 00054 00056 vtkSetMacro(Opacity,double); 00057 vtkGetMacro(Opacity,double); 00059 00061 00062 vtkGetStringMacro(FontFamilyAsString); 00063 vtkSetStringMacro(FontFamilyAsString); 00064 void SetFontFamily(int t); 00065 int GetFontFamily(); 00066 int GetFontFamilyMinValue() { return VTK_ARIAL; }; 00067 void SetFontFamilyToArial(); 00068 void SetFontFamilyToCourier(); 00069 void SetFontFamilyToTimes(); 00070 static int GetFontFamilyFromString( const char *f ); 00071 static const char *GetFontFamilyAsString( int f ); 00073 00075 00076 vtkSetClampMacro(FontSize,int,0,VTK_LARGE_INTEGER); 00077 vtkGetMacro(FontSize, int); 00079 00081 00082 vtkSetMacro(Bold, int); 00083 vtkGetMacro(Bold, int); 00084 vtkBooleanMacro(Bold, int); 00086 00088 00089 vtkSetMacro(Italic, int); 00090 vtkGetMacro(Italic, int); 00091 vtkBooleanMacro(Italic, int); 00093 00095 00096 vtkSetMacro(Shadow, int); 00097 vtkGetMacro(Shadow, int); 00098 vtkBooleanMacro(Shadow, int); 00100 00102 00104 vtkSetVector2Macro(ShadowOffset,int); 00105 vtkGetVectorMacro(ShadowOffset,int,2); 00107 00109 void GetShadowColor(double color[3]); 00110 00112 00114 vtkSetClampMacro(Justification,int,VTK_TEXT_LEFT,VTK_TEXT_RIGHT); 00115 vtkGetMacro(Justification,int); 00116 void SetJustificationToLeft() 00117 { this->SetJustification(VTK_TEXT_LEFT);}; 00118 void SetJustificationToCentered() 00119 { this->SetJustification(VTK_TEXT_CENTERED);}; 00120 void SetJustificationToRight() 00121 { this->SetJustification(VTK_TEXT_RIGHT);}; 00122 const char *GetJustificationAsString(); 00124 00126 00128 vtkSetClampMacro(VerticalJustification,int,VTK_TEXT_BOTTOM,VTK_TEXT_TOP); 00129 vtkGetMacro(VerticalJustification,int); 00130 void SetVerticalJustificationToBottom() 00131 {this->SetVerticalJustification(VTK_TEXT_BOTTOM);}; 00132 void SetVerticalJustificationToCentered() 00133 {this->SetVerticalJustification(VTK_TEXT_CENTERED);}; 00134 void SetVerticalJustificationToTop() 00135 {this->SetVerticalJustification(VTK_TEXT_TOP);}; 00136 const char *GetVerticalJustificationAsString(); 00138 00140 00141 vtkSetMacro(Orientation,double); 00142 vtkGetMacro(Orientation,double); 00144 00146 00148 vtkSetMacro(LineSpacing, double); 00149 vtkGetMacro(LineSpacing, double); 00151 00153 00154 vtkSetMacro(LineOffset, double); 00155 vtkGetMacro(LineOffset, double); 00157 00159 void ShallowCopy(vtkTextProperty *tprop); 00160 00161 protected: 00162 vtkTextProperty(); 00163 ~vtkTextProperty(); 00164 00165 double Color[3]; 00166 double Opacity; 00167 char* FontFamilyAsString; 00168 int FontSize; 00169 int Bold; 00170 int Italic; 00171 int Shadow; 00172 int ShadowOffset[2]; 00173 int Justification; 00174 int VerticalJustification; 00175 double Orientation; 00176 double LineOffset; 00177 double LineSpacing; 00178 00179 private: 00180 vtkTextProperty(const vtkTextProperty&); // Not implemented. 00181 void operator=(const vtkTextProperty&); // Not implemented. 00182 }; 00183 00184 inline const char *vtkTextProperty::GetFontFamilyAsString( int f ) 00185 { 00186 if ( f == VTK_ARIAL ) 00187 { 00188 return "Arial"; 00189 } 00190 else if ( f == VTK_COURIER ) 00191 { 00192 return "Courier"; 00193 } 00194 else if ( f == VTK_TIMES ) 00195 { 00196 return "Times"; 00197 } 00198 return "Unknown"; 00199 } 00200 00201 inline void vtkTextProperty::SetFontFamily( int t ) 00202 { 00203 this->SetFontFamilyAsString( this->GetFontFamilyAsString( t ) ); 00204 } 00205 00206 inline void vtkTextProperty::SetFontFamilyToArial() 00207 { 00208 this->SetFontFamily(VTK_ARIAL); 00209 } 00210 00211 inline void vtkTextProperty::SetFontFamilyToCourier() 00212 { 00213 this->SetFontFamily(VTK_COURIER); 00214 } 00215 00216 inline void vtkTextProperty::SetFontFamilyToTimes() 00217 { 00218 this->SetFontFamily(VTK_TIMES); 00219 } 00220 00221 inline int vtkTextProperty::GetFontFamilyFromString( const char *f ) 00222 { 00223 if ( strcmp( f, GetFontFamilyAsString( VTK_ARIAL ) ) == 0 ) 00224 { 00225 return VTK_ARIAL; 00226 } 00227 else if ( strcmp( f, GetFontFamilyAsString( VTK_COURIER ) ) == 0 ) 00228 { 00229 return VTK_COURIER; 00230 } 00231 else if ( strcmp( f, GetFontFamilyAsString( VTK_TIMES ) ) == 0 ) 00232 { 00233 return VTK_TIMES; 00234 } 00235 return VTK_UNKNOWN_FONT; 00236 } 00237 00238 inline int vtkTextProperty::GetFontFamily() 00239 { 00240 return GetFontFamilyFromString( this->FontFamilyAsString ); 00241 } 00242 00243 inline const char *vtkTextProperty::GetJustificationAsString(void) 00244 { 00245 if (this->Justification == VTK_TEXT_LEFT) 00246 { 00247 return "Left"; 00248 } 00249 else if (this->Justification == VTK_TEXT_CENTERED) 00250 { 00251 return "Centered"; 00252 } 00253 else if (this->Justification == VTK_TEXT_RIGHT) 00254 { 00255 return "Right"; 00256 } 00257 return "Unknown"; 00258 } 00259 00260 inline const char *vtkTextProperty::GetVerticalJustificationAsString(void) 00261 { 00262 if (this->VerticalJustification == VTK_TEXT_BOTTOM) 00263 { 00264 return "Bottom"; 00265 } 00266 else if (this->VerticalJustification == VTK_TEXT_CENTERED) 00267 { 00268 return "Centered"; 00269 } 00270 else if (this->VerticalJustification == VTK_TEXT_TOP) 00271 { 00272 return "Top"; 00273 } 00274 return "Unknown"; 00275 } 00276 00277 #endif