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 =========================================================================*/
33 #ifndef vtkTextProperty_h
34 #define vtkTextProperty_h
35 
36 #include "vtkRenderingCoreModule.h" // For export macro
37 #include "vtkObject.h"
38 
39 class VTKRENDERINGCORE_EXPORT vtkTextProperty : public vtkObject
40 {
41 public:
42  vtkTypeMacro(vtkTextProperty,vtkObject);
43  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
44 
49  static vtkTextProperty *New();
50 
52 
55  vtkSetVector3Macro(Color,double);
56  vtkGetVector3Macro(Color,double);
58 
60 
64  vtkSetClampMacro(Opacity, double, 0., 1.);
65  vtkGetMacro(Opacity,double);
67 
69 
72  vtkSetVector3Macro(BackgroundColor, double);
73  vtkGetVector3Macro(BackgroundColor, double);
75 
77 
81  vtkSetClampMacro(BackgroundOpacity, double, 0., 1.);
82  vtkGetMacro(BackgroundOpacity, double);
84 
86 
89  vtkSetVector3Macro(FrameColor, double);
90  vtkGetVector3Macro(FrameColor, double);
92 
94 
97  vtkSetMacro(Frame, int);
98  vtkGetMacro(Frame, int);
99  vtkBooleanMacro(Frame, int);
101 
103 
107  vtkSetClampMacro(FrameWidth, int, 0, VTK_INT_MAX);
108  vtkGetMacro(FrameWidth, int);
110 
112 
118  vtkGetStringMacro(FontFamilyAsString);
119  vtkSetStringMacro(FontFamilyAsString);
120  void SetFontFamily(int t);
121  int GetFontFamily();
122  int GetFontFamilyMinValue() { return VTK_ARIAL; };
123  void SetFontFamilyToArial();
124  void SetFontFamilyToCourier();
125  void SetFontFamilyToTimes();
126  static int GetFontFamilyFromString( const char *f );
127  static const char *GetFontFamilyAsString( int f );
129 
131 
136  vtkGetStringMacro(FontFile)
137  vtkSetStringMacro(FontFile)
139 
141 
144  vtkSetClampMacro(FontSize,int,0,VTK_INT_MAX);
145  vtkGetMacro(FontSize, int);
147 
149 
152  vtkSetMacro(Bold, int);
153  vtkGetMacro(Bold, int);
154  vtkBooleanMacro(Bold, int);
156 
158 
161  vtkSetMacro(Italic, int);
162  vtkGetMacro(Italic, int);
163  vtkBooleanMacro(Italic, int);
165 
167 
170  vtkSetMacro(Shadow, int);
171  vtkGetMacro(Shadow, int);
172  vtkBooleanMacro(Shadow, int);
174 
176 
180  vtkSetVector2Macro(ShadowOffset,int);
181  vtkGetVectorMacro(ShadowOffset,int,2);
183 
187  void GetShadowColor(double color[3]);
188 
190 
194  vtkSetClampMacro(Justification,int,VTK_TEXT_LEFT,VTK_TEXT_RIGHT);
195  vtkGetMacro(Justification,int);
196  void SetJustificationToLeft()
197  { this->SetJustification(VTK_TEXT_LEFT);};
199  { this->SetJustification(VTK_TEXT_CENTERED);};
201  { this->SetJustification(VTK_TEXT_RIGHT);};
202  const char *GetJustificationAsString();
204 
206 
210  vtkSetClampMacro(VerticalJustification,int,VTK_TEXT_BOTTOM,VTK_TEXT_TOP);
211  vtkGetMacro(VerticalJustification,int);
213  {this->SetVerticalJustification(VTK_TEXT_BOTTOM);};
215  {this->SetVerticalJustification(VTK_TEXT_CENTERED);};
217  {this->SetVerticalJustification(VTK_TEXT_TOP);};
218  const char *GetVerticalJustificationAsString();
220 
222 
228  vtkSetMacro(UseTightBoundingBox, int);
229  vtkGetMacro(UseTightBoundingBox, int);
230  vtkBooleanMacro(UseTightBoundingBox, int);
232 
234 
237  vtkSetMacro(Orientation,double);
238  vtkGetMacro(Orientation,double);
240 
242 
246  vtkSetMacro(LineSpacing, double);
247  vtkGetMacro(LineSpacing, double);
249 
251 
254  vtkSetMacro(LineOffset, double);
255  vtkGetMacro(LineOffset, double);
257 
261  void ShallowCopy(vtkTextProperty *tprop);
262 
263 protected:
264  vtkTextProperty();
265  ~vtkTextProperty();
266 
267  double Color[3];
268  double Opacity;
269  double BackgroundColor[3];
271  int Frame;
272  double FrameColor[3];
275  char* FontFile;
276  int FontSize;
277  int Bold;
278  int Italic;
279  int Shadow;
280  int ShadowOffset[2];
284  double Orientation;
285  double LineOffset;
286  double LineSpacing;
287 
288 private:
289  vtkTextProperty(const vtkTextProperty&) VTK_DELETE_FUNCTION;
290  void operator=(const vtkTextProperty&) VTK_DELETE_FUNCTION;
291 };
292 
293 inline const char *vtkTextProperty::GetFontFamilyAsString( int f )
294 {
295  if ( f == VTK_ARIAL )
296  {
297  return "Arial";
298  }
299  else if ( f == VTK_COURIER )
300  {
301  return "Courier";
302  }
303  else if ( f == VTK_TIMES )
304  {
305  return "Times";
306  }
307  else if ( f == VTK_FONT_FILE )
308  {
309  return "File";
310  }
311  return "Unknown";
312 }
313 
314 inline void vtkTextProperty::SetFontFamily( int t )
315 {
316  this->SetFontFamilyAsString( this->GetFontFamilyAsString( t ) );
317 }
318 
320 {
321  this->SetFontFamily(VTK_ARIAL);
322 }
323 
325 {
326  this->SetFontFamily(VTK_COURIER);
327 }
328 
330 {
331  this->SetFontFamily(VTK_TIMES);
332 }
333 
334 inline int vtkTextProperty::GetFontFamilyFromString( const char *f )
335 {
336  if ( strcmp( f, GetFontFamilyAsString( VTK_ARIAL ) ) == 0 )
337  {
338  return VTK_ARIAL;
339  }
340  else if ( strcmp( f, GetFontFamilyAsString( VTK_COURIER ) ) == 0 )
341  {
342  return VTK_COURIER;
343  }
344  else if ( strcmp( f, GetFontFamilyAsString( VTK_TIMES ) ) == 0 )
345  {
346  return VTK_TIMES;
347  }
348  else if ( strcmp( f, GetFontFamilyAsString( VTK_FONT_FILE) ) == 0 )
349  {
350  return VTK_FONT_FILE;
351  }
352  return VTK_UNKNOWN_FONT;
353 }
354 
356 {
357  return GetFontFamilyFromString( this->FontFamilyAsString );
358 }
359 
361 {
362  if (this->Justification == VTK_TEXT_LEFT)
363  {
364  return "Left";
365  }
366  else if (this->Justification == VTK_TEXT_CENTERED)
367  {
368  return "Centered";
369  }
370  else if (this->Justification == VTK_TEXT_RIGHT)
371  {
372  return "Right";
373  }
374  return "Unknown";
375 }
376 
378 {
379  if (this->VerticalJustification == VTK_TEXT_BOTTOM)
380  {
381  return "Bottom";
382  }
383  else if (this->VerticalJustification == VTK_TEXT_CENTERED)
384  {
385  return "Centered";
386  }
387  else if (this->VerticalJustification == VTK_TEXT_TOP)
388  {
389  return "Top";
390  }
391  return "Unknown";
392 }
393 
394 #endif
void SetFontFamilyToArial()
Set/Get the font family.
#define VTK_UNKNOWN_FONT
void SetJustificationToRight()
Set/Get the horizontal justification to left (default), centered, or right.
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetVerticalJustificationToTop()
Set/Get the vertical justification to bottom (default), middle, or top.
#define VTK_INT_MAX
Definition: vtkType.h:153
#define VTK_ARIAL
#define VTK_TEXT_TOP
void SetVerticalJustificationToBottom()
Set/Get the vertical justification to bottom (default), middle, or top.
void SetVerticalJustificationToCentered()
Set/Get the vertical justification to bottom (default), middle, or top.
#define VTK_TEXT_CENTERED
#define VTK_TEXT_RIGHT
#define VTK_TEXT_LEFT
#define VTK_COURIER
a simple class to control print indentation
Definition: vtkIndent.h:39
#define VTK_TEXT_BOTTOM
#define VTK_TIMES
int GetFontFamily()
Set/Get the font family.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
int GetFontFamilyMinValue()
Set/Get the font family.
represent text properties.
void SetFontFamilyToCourier()
Set/Get the font family.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static int GetFontFamilyFromString(const char *f)
Set/Get the font family.
#define VTK_FONT_FILE
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
const char * GetVerticalJustificationAsString()
Set/Get the vertical justification to bottom (default), middle, or top.
void SetFontFamilyToTimes()
Set/Get the font family.
void SetJustificationToCentered()
Set/Get the horizontal justification to left (default), centered, or right.
void SetFontFamily(int t)
Set/Get the font family.
const char * GetJustificationAsString()
Set/Get the horizontal justification to left (default), centered, or right.