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 "vtkRenderingCoreModule.h" // For export macro
36 #include "vtkObject.h"
37 
39 {
40 public:
41  vtkTypeMacro(vtkTextProperty,vtkObject);
42  void PrintSelf(ostream& os, vtkIndent indent);
43 
46  static vtkTextProperty *New();
47 
49 
50  vtkSetVector3Macro(Color,double);
51  vtkGetVector3Macro(Color,double);
53 
55 
57  vtkSetClampMacro(Opacity, double, 0., 1.);
58  vtkGetMacro(Opacity,double);
60 
62 
63  vtkSetVector3Macro(BackgroundColor, double);
64  vtkGetVector3Macro(BackgroundColor, double);
66 
68 
70  vtkSetClampMacro(BackgroundOpacity, double, 0., 1.);
71  vtkGetMacro(BackgroundOpacity, double);
73 
75 
79  vtkGetStringMacro(FontFamilyAsString);
80  vtkSetStringMacro(FontFamilyAsString);
81  void SetFontFamily(int t);
82  int GetFontFamily();
83  int GetFontFamilyMinValue() { return VTK_ARIAL; };
84  void SetFontFamilyToArial();
85  void SetFontFamilyToCourier();
86  void SetFontFamilyToTimes();
87  static int GetFontFamilyFromString( const char *f );
88  static const char *GetFontFamilyAsString( int f );
90 
92 
95  vtkGetStringMacro(FontFile)
96  vtkSetStringMacro(FontFile)
98 
100 
101  vtkSetClampMacro(FontSize,int,0,VTK_INT_MAX);
102  vtkGetMacro(FontSize, int);
104 
106 
107  vtkSetMacro(Bold, int);
108  vtkGetMacro(Bold, int);
109  vtkBooleanMacro(Bold, int);
111 
113 
114  vtkSetMacro(Italic, int);
115  vtkGetMacro(Italic, int);
116  vtkBooleanMacro(Italic, int);
118 
120 
121  vtkSetMacro(Shadow, int);
122  vtkGetMacro(Shadow, int);
123  vtkBooleanMacro(Shadow, int);
125 
127 
129  vtkSetVector2Macro(ShadowOffset,int);
130  vtkGetVectorMacro(ShadowOffset,int,2);
132 
134  void GetShadowColor(double color[3]);
135 
137 
139  vtkSetClampMacro(Justification,int,VTK_TEXT_LEFT,VTK_TEXT_RIGHT);
140  vtkGetMacro(Justification,int);
141  void SetJustificationToLeft()
142  { this->SetJustification(VTK_TEXT_LEFT);};
144  { this->SetJustification(VTK_TEXT_CENTERED);};
146  { this->SetJustification(VTK_TEXT_RIGHT);};
147  const char *GetJustificationAsString();
149 
151 
153  vtkSetClampMacro(VerticalJustification,int,VTK_TEXT_BOTTOM,VTK_TEXT_TOP);
154  vtkGetMacro(VerticalJustification,int);
156  {this->SetVerticalJustification(VTK_TEXT_BOTTOM);};
158  {this->SetVerticalJustification(VTK_TEXT_CENTERED);};
160  {this->SetVerticalJustification(VTK_TEXT_TOP);};
161  const char *GetVerticalJustificationAsString();
163 
165 
166  vtkSetMacro(Orientation,double);
167  vtkGetMacro(Orientation,double);
169 
171 
173  vtkSetMacro(LineSpacing, double);
174  vtkGetMacro(LineSpacing, double);
176 
178 
179  vtkSetMacro(LineOffset, double);
180  vtkGetMacro(LineOffset, double);
182 
184  void ShallowCopy(vtkTextProperty *tprop);
185 
186 protected:
187  vtkTextProperty();
188  ~vtkTextProperty();
189 
190  double Color[3];
191  double Opacity;
192  double BackgroundColor[3];
195  char* FontFile;
196  int FontSize;
197  int Bold;
198  int Italic;
199  int Shadow;
200  int ShadowOffset[2];
203  double Orientation;
204  double LineOffset;
205  double LineSpacing;
206 
207 private:
208  vtkTextProperty(const vtkTextProperty&); // Not implemented.
209  void operator=(const vtkTextProperty&); // Not implemented.
210 };
211 
212 inline const char *vtkTextProperty::GetFontFamilyAsString( int f )
213 {
214  if ( f == VTK_ARIAL )
215  {
216  return "Arial";
217  }
218  else if ( f == VTK_COURIER )
219  {
220  return "Courier";
221  }
222  else if ( f == VTK_TIMES )
223  {
224  return "Times";
225  }
226  else if ( f == VTK_FONT_FILE )
227  {
228  return "File";
229  }
230  return "Unknown";
231 }
232 
233 inline void vtkTextProperty::SetFontFamily( int t )
234 {
235  this->SetFontFamilyAsString( this->GetFontFamilyAsString( t ) );
236 }
237 
239 {
240  this->SetFontFamily(VTK_ARIAL);
241 }
242 
244 {
245  this->SetFontFamily(VTK_COURIER);
246 }
247 
249 {
250  this->SetFontFamily(VTK_TIMES);
251 }
252 
253 inline int vtkTextProperty::GetFontFamilyFromString( const char *f )
254 {
255  if ( strcmp( f, GetFontFamilyAsString( VTK_ARIAL ) ) == 0 )
256  {
257  return VTK_ARIAL;
258  }
259  else if ( strcmp( f, GetFontFamilyAsString( VTK_COURIER ) ) == 0 )
260  {
261  return VTK_COURIER;
262  }
263  else if ( strcmp( f, GetFontFamilyAsString( VTK_TIMES ) ) == 0 )
264  {
265  return VTK_TIMES;
266  }
267  else if ( strcmp( f, GetFontFamilyAsString( VTK_FONT_FILE) ) == 0 )
268  {
269  return VTK_FONT_FILE;
270  }
271  return VTK_UNKNOWN_FONT;
272 }
273 
275 {
277 }
278 
280 {
281  if (this->Justification == VTK_TEXT_LEFT)
282  {
283  return "Left";
284  }
285  else if (this->Justification == VTK_TEXT_CENTERED)
286  {
287  return "Centered";
288  }
289  else if (this->Justification == VTK_TEXT_RIGHT)
290  {
291  return "Right";
292  }
293  return "Unknown";
294 }
295 
297 {
299  {
300  return "Bottom";
301  }
302  else if (this->VerticalJustification == VTK_TEXT_CENTERED)
303  {
304  return "Centered";
305  }
306  else if (this->VerticalJustification == VTK_TEXT_TOP)
307  {
308  return "Top";
309  }
310  return "Unknown";
311 }
312 
313 #endif
void SetFontFamilyToArial()
#define VTK_UNKNOWN_FONT
void SetJustificationToRight()
abstract base class for most VTK objects
Definition: vtkObject.h:61
void SetVerticalJustificationToTop()
#define VTK_INT_MAX
Definition: vtkType.h:132
#define VTK_ARIAL
#define VTK_TEXT_TOP
void SetVerticalJustificationToBottom()
void SetVerticalJustificationToCentered()
#define VTK_TEXT_CENTERED
virtual void SetFontFamilyAsString(const char *)
#define VTK_TEXT_RIGHT
#define VTK_TEXT_LEFT
#define VTK_COURIER
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
#define VTK_TEXT_BOTTOM
#define VTK_TIMES
int GetFontFamilyMinValue()
represent text properties.
void SetFontFamilyToCourier()
static int GetFontFamilyFromString(const char *f)
#define VTKRENDERINGCORE_EXPORT
virtual char * GetFontFamilyAsString()
#define VTK_FONT_FILE
static vtkObject * New()
const char * GetVerticalJustificationAsString()
void SetFontFamilyToTimes()
void SetJustificationToCentered()
void SetFontFamily(int t)
const char * GetJustificationAsString()