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 00066 vtkGetStringMacro(FontFamilyAsString); 00067 vtkSetStringMacro(FontFamilyAsString); 00068 void SetFontFamily(int t); 00069 int GetFontFamily(); 00070 int GetFontFamilyMinValue() { return VTK_ARIAL; }; 00071 void SetFontFamilyToArial(); 00072 void SetFontFamilyToCourier(); 00073 void SetFontFamilyToTimes(); 00074 static int GetFontFamilyFromString( const char *f ); 00075 static const char *GetFontFamilyAsString( int f ); 00077 00079 00082 vtkGetStringMacro(FontFile) 00083 vtkSetStringMacro(FontFile) 00085 00087 00088 vtkSetClampMacro(FontSize,int,0,VTK_INT_MAX); 00089 vtkGetMacro(FontSize, int); 00091 00093 00094 vtkSetMacro(Bold, int); 00095 vtkGetMacro(Bold, int); 00096 vtkBooleanMacro(Bold, int); 00098 00100 00101 vtkSetMacro(Italic, int); 00102 vtkGetMacro(Italic, int); 00103 vtkBooleanMacro(Italic, int); 00105 00107 00108 vtkSetMacro(Shadow, int); 00109 vtkGetMacro(Shadow, int); 00110 vtkBooleanMacro(Shadow, int); 00112 00114 00116 vtkSetVector2Macro(ShadowOffset,int); 00117 vtkGetVectorMacro(ShadowOffset,int,2); 00119 00121 void GetShadowColor(double color[3]); 00122 00124 00126 vtkSetClampMacro(Justification,int,VTK_TEXT_LEFT,VTK_TEXT_RIGHT); 00127 vtkGetMacro(Justification,int); 00128 void SetJustificationToLeft() 00129 { this->SetJustification(VTK_TEXT_LEFT);}; 00130 void SetJustificationToCentered() 00131 { this->SetJustification(VTK_TEXT_CENTERED);}; 00132 void SetJustificationToRight() 00133 { this->SetJustification(VTK_TEXT_RIGHT);}; 00134 const char *GetJustificationAsString(); 00136 00138 00140 vtkSetClampMacro(VerticalJustification,int,VTK_TEXT_BOTTOM,VTK_TEXT_TOP); 00141 vtkGetMacro(VerticalJustification,int); 00142 void SetVerticalJustificationToBottom() 00143 {this->SetVerticalJustification(VTK_TEXT_BOTTOM);}; 00144 void SetVerticalJustificationToCentered() 00145 {this->SetVerticalJustification(VTK_TEXT_CENTERED);}; 00146 void SetVerticalJustificationToTop() 00147 {this->SetVerticalJustification(VTK_TEXT_TOP);}; 00148 const char *GetVerticalJustificationAsString(); 00150 00152 00153 vtkSetMacro(Orientation,double); 00154 vtkGetMacro(Orientation,double); 00156 00158 00160 vtkSetMacro(LineSpacing, double); 00161 vtkGetMacro(LineSpacing, double); 00163 00165 00166 vtkSetMacro(LineOffset, double); 00167 vtkGetMacro(LineOffset, double); 00169 00171 void ShallowCopy(vtkTextProperty *tprop); 00172 00173 protected: 00174 vtkTextProperty(); 00175 ~vtkTextProperty(); 00176 00177 double Color[3]; 00178 double Opacity; 00179 char* FontFamilyAsString; 00180 char* FontFile; 00181 int FontSize; 00182 int Bold; 00183 int Italic; 00184 int Shadow; 00185 int ShadowOffset[2]; 00186 int Justification; 00187 int VerticalJustification; 00188 double Orientation; 00189 double LineOffset; 00190 double LineSpacing; 00191 00192 private: 00193 vtkTextProperty(const vtkTextProperty&); // Not implemented. 00194 void operator=(const vtkTextProperty&); // Not implemented. 00195 }; 00196 00197 inline const char *vtkTextProperty::GetFontFamilyAsString( int f ) 00198 { 00199 if ( f == VTK_ARIAL ) 00200 { 00201 return "Arial"; 00202 } 00203 else if ( f == VTK_COURIER ) 00204 { 00205 return "Courier"; 00206 } 00207 else if ( f == VTK_TIMES ) 00208 { 00209 return "Times"; 00210 } 00211 else if ( f == VTK_FONT_FILE ) 00212 { 00213 return "File"; 00214 } 00215 return "Unknown"; 00216 } 00217 00218 inline void vtkTextProperty::SetFontFamily( int t ) 00219 { 00220 this->SetFontFamilyAsString( this->GetFontFamilyAsString( t ) ); 00221 } 00222 00223 inline void vtkTextProperty::SetFontFamilyToArial() 00224 { 00225 this->SetFontFamily(VTK_ARIAL); 00226 } 00227 00228 inline void vtkTextProperty::SetFontFamilyToCourier() 00229 { 00230 this->SetFontFamily(VTK_COURIER); 00231 } 00232 00233 inline void vtkTextProperty::SetFontFamilyToTimes() 00234 { 00235 this->SetFontFamily(VTK_TIMES); 00236 } 00237 00238 inline int vtkTextProperty::GetFontFamilyFromString( const char *f ) 00239 { 00240 if ( strcmp( f, GetFontFamilyAsString( VTK_ARIAL ) ) == 0 ) 00241 { 00242 return VTK_ARIAL; 00243 } 00244 else if ( strcmp( f, GetFontFamilyAsString( VTK_COURIER ) ) == 0 ) 00245 { 00246 return VTK_COURIER; 00247 } 00248 else if ( strcmp( f, GetFontFamilyAsString( VTK_TIMES ) ) == 0 ) 00249 { 00250 return VTK_TIMES; 00251 } 00252 else if ( strcmp( f, GetFontFamilyAsString( VTK_FONT_FILE) ) == 0 ) 00253 { 00254 return VTK_FONT_FILE; 00255 } 00256 return VTK_UNKNOWN_FONT; 00257 } 00258 00259 inline int vtkTextProperty::GetFontFamily() 00260 { 00261 return GetFontFamilyFromString( this->FontFamilyAsString ); 00262 } 00263 00264 inline const char *vtkTextProperty::GetJustificationAsString(void) 00265 { 00266 if (this->Justification == VTK_TEXT_LEFT) 00267 { 00268 return "Left"; 00269 } 00270 else if (this->Justification == VTK_TEXT_CENTERED) 00271 { 00272 return "Centered"; 00273 } 00274 else if (this->Justification == VTK_TEXT_RIGHT) 00275 { 00276 return "Right"; 00277 } 00278 return "Unknown"; 00279 } 00280 00281 inline const char *vtkTextProperty::GetVerticalJustificationAsString(void) 00282 { 00283 if (this->VerticalJustification == VTK_TEXT_BOTTOM) 00284 { 00285 return "Bottom"; 00286 } 00287 else if (this->VerticalJustification == VTK_TEXT_CENTERED) 00288 { 00289 return "Centered"; 00290 } 00291 else if (this->VerticalJustification == VTK_TEXT_TOP) 00292 { 00293 return "Top"; 00294 } 00295 return "Unknown"; 00296 } 00297 00298 #endif