VTK
vtkTextProperty.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTextProperty.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
32 #ifndef __vtkTextProperty_h
33 #define __vtkTextProperty_h
34 
35 #include "vtkObject.h"
36 
38 {
39 public:
40  vtkTypeMacro(vtkTextProperty,vtkObject);
41  void PrintSelf(ostream& os, vtkIndent indent);
42 
45  static vtkTextProperty *New();
46 
48 
49  vtkSetVector3Macro(Color,double);
50  vtkGetVector3Macro(Color,double);
52 
54 
56  vtkSetMacro(Opacity,double);
57  vtkGetMacro(Opacity,double);
59 
61 
62  vtkGetStringMacro(FontFamilyAsString);
63  vtkSetStringMacro(FontFamilyAsString);
64  void SetFontFamily(int t);
65  int GetFontFamily();
66  int GetFontFamilyMinValue() { return VTK_ARIAL; };
67  void SetFontFamilyToArial();
68  void SetFontFamilyToCourier();
69  void SetFontFamilyToTimes();
70  static int GetFontFamilyFromString( const char *f );
71  static const char *GetFontFamilyAsString( int f );
73 
75 
76  vtkSetClampMacro(FontSize,int,0,VTK_LARGE_INTEGER);
77  vtkGetMacro(FontSize, int);
79 
81 
82  vtkSetMacro(Bold, int);
83  vtkGetMacro(Bold, int);
84  vtkBooleanMacro(Bold, int);
86 
88 
89  vtkSetMacro(Italic, int);
90  vtkGetMacro(Italic, int);
91  vtkBooleanMacro(Italic, int);
93 
95 
96  vtkSetMacro(Shadow, int);
97  vtkGetMacro(Shadow, int);
98  vtkBooleanMacro(Shadow, int);
100 
102 
104  vtkSetVector2Macro(ShadowOffset,int);
105  vtkGetVectorMacro(ShadowOffset,int,2);
107 
109  void GetShadowColor(double color[3]);
110 
112 
114  vtkSetClampMacro(Justification,int,VTK_TEXT_LEFT,VTK_TEXT_RIGHT);
115  vtkGetMacro(Justification,int);
117  { this->SetJustification(VTK_TEXT_LEFT);};
119  { this->SetJustification(VTK_TEXT_CENTERED);};
121  { this->SetJustification(VTK_TEXT_RIGHT);};
122  const char *GetJustificationAsString();
124 
126 
128  vtkSetClampMacro(VerticalJustification,int,VTK_TEXT_BOTTOM,VTK_TEXT_TOP);
129  vtkGetMacro(VerticalJustification,int);
131  {this->SetVerticalJustification(VTK_TEXT_BOTTOM);};
133  {this->SetVerticalJustification(VTK_TEXT_CENTERED);};
135  {this->SetVerticalJustification(VTK_TEXT_TOP);};
136  const char *GetVerticalJustificationAsString();
138 
140 
141  vtkSetMacro(Orientation,double);
142  vtkGetMacro(Orientation,double);
144 
146 
148  vtkSetMacro(LineSpacing, double);
149  vtkGetMacro(LineSpacing, double);
151 
153 
154  vtkSetMacro(LineOffset, double);
155  vtkGetMacro(LineOffset, double);
157 
159  void ShallowCopy(vtkTextProperty *tprop);
160 
161 protected:
162  vtkTextProperty();
163  ~vtkTextProperty();
164 
165  double Color[3];
166  double Opacity;
168  int FontSize;
169  int Bold;
170  int Italic;
171  int Shadow;
172  int ShadowOffset[2];
175  double Orientation;
176  double LineOffset;
177  double LineSpacing;
178 
179 private:
180  vtkTextProperty(const vtkTextProperty&); // Not implemented.
181  void operator=(const vtkTextProperty&); // Not implemented.
182 };
183 
184 inline const char *vtkTextProperty::GetFontFamilyAsString( int f )
185 {
186  if ( f == VTK_ARIAL )
187  {
188  return "Arial";
189  }
190  else if ( f == VTK_COURIER )
191  {
192  return "Courier";
193  }
194  else if ( f == VTK_TIMES )
195  {
196  return "Times";
197  }
198  return "Unknown";
199 }
200 
201 inline void vtkTextProperty::SetFontFamily( int t )
202 {
203  this->SetFontFamilyAsString( this->GetFontFamilyAsString( t ) );
204 }
205 
207 {
208  this->SetFontFamily(VTK_ARIAL);
209 }
210 
212 {
213  this->SetFontFamily(VTK_COURIER);
214 }
215 
217 {
218  this->SetFontFamily(VTK_TIMES);
219 }
220 
221 inline int vtkTextProperty::GetFontFamilyFromString( const char *f )
222 {
223  if ( strcmp( f, GetFontFamilyAsString( VTK_ARIAL ) ) == 0 )
224  {
225  return VTK_ARIAL;
226  }
227  else if ( strcmp( f, GetFontFamilyAsString( VTK_COURIER ) ) == 0 )
228  {
229  return VTK_COURIER;
230  }
231  else if ( strcmp( f, GetFontFamilyAsString( VTK_TIMES ) ) == 0 )
232  {
233  return VTK_TIMES;
234  }
235  return VTK_UNKNOWN_FONT;
236 }
237 
239 {
241 }
242 
244 {
245  if (this->Justification == VTK_TEXT_LEFT)
246  {
247  return "Left";
248  }
249  else if (this->Justification == VTK_TEXT_CENTERED)
250  {
251  return "Centered";
252  }
253  else if (this->Justification == VTK_TEXT_RIGHT)
254  {
255  return "Right";
256  }
257  return "Unknown";
258 }
259 
261 {
263  {
264  return "Bottom";
265  }
266  else if (this->VerticalJustification == VTK_TEXT_CENTERED)
267  {
268  return "Centered";
269  }
270  else if (this->VerticalJustification == VTK_TEXT_TOP)
271  {
272  return "Top";
273  }
274  return "Unknown";
275 }
276 
277 #endif