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) 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, vtkTypeBool);
98  vtkGetMacro(Frame, vtkTypeBool);
99  vtkBooleanMacro(Frame, vtkTypeBool);
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, vtkTypeBool);
153  vtkGetMacro(Bold, vtkTypeBool);
154  vtkBooleanMacro(Bold, vtkTypeBool);
156 
158 
161  vtkSetMacro(Italic, vtkTypeBool);
162  vtkGetMacro(Italic, vtkTypeBool);
163  vtkBooleanMacro(Italic, vtkTypeBool);
165 
167 
170  vtkSetMacro(Shadow, vtkTypeBool);
171  vtkGetMacro(Shadow, vtkTypeBool);
172  vtkBooleanMacro(Shadow, vtkTypeBool);
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);
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, vtkTypeBool);
229  vtkGetMacro(UseTightBoundingBox, vtkTypeBool);
230  vtkBooleanMacro(UseTightBoundingBox, vtkTypeBool);
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() override;
266 
267  double Color[3];
268  double Opacity;
269  double BackgroundColor[3];
272  double FrameColor[3];
275  char* FontFile;
276  int FontSize;
280  int ShadowOffset[2];
284  double Orientation;
285  double LineOffset;
286  double LineSpacing;
287 
288 private:
289  vtkTextProperty(const vtkTextProperty&) = delete;
290  void operator=(const vtkTextProperty&) = delete;
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 {
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 {
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
vtkTextProperty::FontSize
int FontSize
Definition: vtkTextProperty.h:276
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:159
vtkTextProperty::GetFontFamilyAsString
virtual char * GetFontFamilyAsString()
Set/Get the font family.
vtkTextProperty::SetJustificationToCentered
void SetJustificationToCentered()
Definition: vtkTextProperty.h:198
vtkTextProperty::SetFontFamilyAsString
virtual void SetFontFamilyAsString(const char *)
vtkTextProperty::LineSpacing
double LineSpacing
Definition: vtkTextProperty.h:286
vtkTextProperty::Bold
vtkTypeBool Bold
Definition: vtkTextProperty.h:277
vtkTextProperty::Orientation
double Orientation
Definition: vtkTextProperty.h:284
VTK_TIMES
#define VTK_TIMES
Definition: vtkSystemIncludes.h:82
vtkTextProperty::GetVerticalJustificationAsString
const char * GetVerticalJustificationAsString()
Definition: vtkTextProperty.h:377
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkX3D::Color
Definition: vtkX3D.h:46
vtkTextProperty::UseTightBoundingBox
vtkTypeBool UseTightBoundingBox
Definition: vtkTextProperty.h:283
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:59
vtkTextProperty::GetJustificationAsString
const char * GetJustificationAsString()
Definition: vtkTextProperty.h:360
VTK_UNKNOWN_FONT
#define VTK_UNKNOWN_FONT
Definition: vtkSystemIncludes.h:83
vtkTextProperty::SetJustificationToLeft
void SetJustificationToLeft()
Definition: vtkTextProperty.h:196
vtkTextProperty::GetFontFamily
int GetFontFamily()
Definition: vtkTextProperty.h:355
vtkTextProperty::SetFontFamilyToCourier
void SetFontFamilyToCourier()
Definition: vtkTextProperty.h:324
VTK_TEXT_LEFT
#define VTK_TEXT_LEFT
Definition: vtkSystemIncludes.h:86
vtkTextProperty::SetVerticalJustificationToTop
void SetVerticalJustificationToTop()
Definition: vtkTextProperty.h:216
vtkX3D::color
Definition: vtkX3D.h:221
VTK_FONT_FILE
#define VTK_FONT_FILE
Definition: vtkSystemIncludes.h:84
vtkTextProperty::SetVerticalJustificationToCentered
void SetVerticalJustificationToCentered()
Definition: vtkTextProperty.h:214
vtkTextProperty::Justification
int Justification
Definition: vtkTextProperty.h:281
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkTextProperty::VerticalJustification
int VerticalJustification
Definition: vtkTextProperty.h:282
vtkTextProperty::Frame
vtkTypeBool Frame
Definition: vtkTextProperty.h:271
VTK_TEXT_BOTTOM
#define VTK_TEXT_BOTTOM
Definition: vtkSystemIncludes.h:90
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
VTK_TEXT_RIGHT
#define VTK_TEXT_RIGHT
Definition: vtkSystemIncludes.h:88
vtkTextProperty::SetJustificationToRight
void SetJustificationToRight()
Definition: vtkTextProperty.h:200
vtkTextProperty::SetFontFamilyToTimes
void SetFontFamilyToTimes()
Definition: vtkTextProperty.h:329
vtkTextProperty::FontFile
char * FontFile
Definition: vtkTextProperty.h:275
VTK_ARIAL
#define VTK_ARIAL
Definition: vtkSystemIncludes.h:80
VTK_TEXT_TOP
#define VTK_TEXT_TOP
Definition: vtkSystemIncludes.h:91
vtkObject.h
vtkTextProperty::FrameWidth
int FrameWidth
Definition: vtkTextProperty.h:273
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:39
vtkTextProperty::SetFontFamilyToArial
void SetFontFamilyToArial()
Definition: vtkTextProperty.h:319
vtkTextProperty::Opacity
double Opacity
Definition: vtkTextProperty.h:268
vtkTextProperty::FontFamilyAsString
char * FontFamilyAsString
Definition: vtkTextProperty.h:274
vtkTextProperty::Italic
vtkTypeBool Italic
Definition: vtkTextProperty.h:278
VTK_TEXT_CENTERED
#define VTK_TEXT_CENTERED
Definition: vtkSystemIncludes.h:87
vtkTextProperty::BackgroundOpacity
double BackgroundOpacity
Definition: vtkTextProperty.h:270
vtkTextProperty::SetFontFamily
void SetFontFamily(int t)
Definition: vtkTextProperty.h:314
vtkTextProperty::GetFontFamilyMinValue
int GetFontFamilyMinValue()
Definition: vtkTextProperty.h:122
VTK_COURIER
#define VTK_COURIER
Definition: vtkSystemIncludes.h:81
vtkTextProperty::SetVerticalJustificationToBottom
void SetVerticalJustificationToBottom()
Definition: vtkTextProperty.h:212
vtkTextProperty::GetFontFamilyFromString
static int GetFontFamilyFromString(const char *f)
Definition: vtkTextProperty.h:334
vtkTextProperty::Shadow
vtkTypeBool Shadow
Definition: vtkTextProperty.h:279
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkTextProperty::LineOffset
double LineOffset
Definition: vtkTextProperty.h:285