VTK  9.0.1
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 =========================================================================*/
27 #ifndef vtkTextProperty_h
28 #define vtkTextProperty_h
29 
30 #include "vtkObject.h"
31 #include "vtkRenderingCoreModule.h" // For export macro
32 
33 class VTKRENDERINGCORE_EXPORT vtkTextProperty : public vtkObject
34 {
35 public:
36  vtkTypeMacro(vtkTextProperty, vtkObject);
37  void PrintSelf(ostream& os, vtkIndent indent) override;
38 
43  static vtkTextProperty* New();
44 
46 
49  vtkSetVector3Macro(Color, double);
50  vtkGetVector3Macro(Color, double);
52 
54 
58  vtkSetClampMacro(Opacity, double, 0., 1.);
59  vtkGetMacro(Opacity, double);
61 
63 
66  vtkSetVector3Macro(BackgroundColor, double);
67  vtkGetVector3Macro(BackgroundColor, double);
69 
71 
75  vtkSetClampMacro(BackgroundOpacity, double, 0., 1.);
76  vtkGetMacro(BackgroundOpacity, double);
78 
80 
83  vtkSetVector3Macro(FrameColor, double);
84  vtkGetVector3Macro(FrameColor, double);
86 
88 
91  vtkSetMacro(Frame, vtkTypeBool);
92  vtkGetMacro(Frame, vtkTypeBool);
93  vtkBooleanMacro(Frame, vtkTypeBool);
95 
97 
101  vtkSetClampMacro(FrameWidth, int, 0, VTK_INT_MAX);
102  vtkGetMacro(FrameWidth, int);
104 
106 
112  vtkGetStringMacro(FontFamilyAsString);
113  vtkSetStringMacro(FontFamilyAsString);
114  void SetFontFamily(int t);
115  int GetFontFamily();
117  void SetFontFamilyToArial();
118  void SetFontFamilyToCourier();
119  void SetFontFamilyToTimes();
120  static int GetFontFamilyFromString(const char* f);
121  static const char* GetFontFamilyAsString(int f);
123 
125 
130  vtkGetStringMacro(FontFile);
131  vtkSetStringMacro(FontFile);
133 
135 
138  vtkSetClampMacro(FontSize, int, 0, VTK_INT_MAX);
139  vtkGetMacro(FontSize, int);
141 
143 
146  vtkSetMacro(Bold, vtkTypeBool);
147  vtkGetMacro(Bold, vtkTypeBool);
148  vtkBooleanMacro(Bold, vtkTypeBool);
150 
152 
155  vtkSetMacro(Italic, vtkTypeBool);
156  vtkGetMacro(Italic, vtkTypeBool);
157  vtkBooleanMacro(Italic, vtkTypeBool);
159 
161 
164  vtkSetMacro(Shadow, vtkTypeBool);
165  vtkGetMacro(Shadow, vtkTypeBool);
166  vtkBooleanMacro(Shadow, vtkTypeBool);
168 
170 
174  vtkSetVector2Macro(ShadowOffset, int);
175  vtkGetVectorMacro(ShadowOffset, int, 2);
177 
181  void GetShadowColor(double color[3]);
182 
184 
188  vtkSetClampMacro(Justification, int, VTK_TEXT_LEFT, VTK_TEXT_RIGHT);
189  vtkGetMacro(Justification, int);
190  void SetJustificationToLeft() { this->SetJustification(VTK_TEXT_LEFT); }
191  void SetJustificationToCentered() { this->SetJustification(VTK_TEXT_CENTERED); }
192  void SetJustificationToRight() { this->SetJustification(VTK_TEXT_RIGHT); }
193  const char* GetJustificationAsString();
195 
197 
201  vtkSetClampMacro(VerticalJustification, int, VTK_TEXT_BOTTOM, VTK_TEXT_TOP);
202  vtkGetMacro(VerticalJustification, int);
203  void SetVerticalJustificationToBottom() { this->SetVerticalJustification(VTK_TEXT_BOTTOM); }
204  void SetVerticalJustificationToCentered() { this->SetVerticalJustification(VTK_TEXT_CENTERED); }
205  void SetVerticalJustificationToTop() { this->SetVerticalJustification(VTK_TEXT_TOP); }
206  const char* GetVerticalJustificationAsString();
208 
210 
216  vtkSetMacro(UseTightBoundingBox, vtkTypeBool);
217  vtkGetMacro(UseTightBoundingBox, vtkTypeBool);
218  vtkBooleanMacro(UseTightBoundingBox, vtkTypeBool);
220 
222 
225  vtkSetMacro(Orientation, double);
226  vtkGetMacro(Orientation, double);
228 
230 
234  vtkSetMacro(LineSpacing, double);
235  vtkGetMacro(LineSpacing, double);
237 
239 
242  vtkSetMacro(LineOffset, double);
243  vtkGetMacro(LineOffset, double);
245 
249  void ShallowCopy(vtkTextProperty* tprop);
250 
251 protected:
252  vtkTextProperty();
253  ~vtkTextProperty() override;
254 
255  double Color[3];
256  double Opacity;
257  double BackgroundColor[3];
260  double FrameColor[3];
263  char* FontFile;
264  int FontSize;
268  int ShadowOffset[2];
272  double Orientation;
273  double LineOffset;
274  double LineSpacing;
275 
276 private:
277  vtkTextProperty(const vtkTextProperty&) = delete;
278  void operator=(const vtkTextProperty&) = delete;
279 };
280 
281 inline const char* vtkTextProperty::GetFontFamilyAsString(int f)
282 {
283  if (f == VTK_ARIAL)
284  {
285  return "Arial";
286  }
287  else if (f == VTK_COURIER)
288  {
289  return "Courier";
290  }
291  else if (f == VTK_TIMES)
292  {
293  return "Times";
294  }
295  else if (f == VTK_FONT_FILE)
296  {
297  return "File";
298  }
299  return "Unknown";
300 }
301 
303 {
305 }
306 
308 {
309  this->SetFontFamily(VTK_ARIAL);
310 }
311 
313 {
314  this->SetFontFamily(VTK_COURIER);
315 }
316 
318 {
319  this->SetFontFamily(VTK_TIMES);
320 }
321 
323 {
324  if (strcmp(f, GetFontFamilyAsString(VTK_ARIAL)) == 0)
325  {
326  return VTK_ARIAL;
327  }
328  else if (strcmp(f, GetFontFamilyAsString(VTK_COURIER)) == 0)
329  {
330  return VTK_COURIER;
331  }
332  else if (strcmp(f, GetFontFamilyAsString(VTK_TIMES)) == 0)
333  {
334  return VTK_TIMES;
335  }
336  else if (strcmp(f, GetFontFamilyAsString(VTK_FONT_FILE)) == 0)
337  {
338  return VTK_FONT_FILE;
339  }
340  return VTK_UNKNOWN_FONT;
341 }
342 
344 {
346 }
347 
349 {
350  if (this->Justification == VTK_TEXT_LEFT)
351  {
352  return "Left";
353  }
354  else if (this->Justification == VTK_TEXT_CENTERED)
355  {
356  return "Centered";
357  }
358  else if (this->Justification == VTK_TEXT_RIGHT)
359  {
360  return "Right";
361  }
362  return "Unknown";
363 }
364 
366 {
368  {
369  return "Bottom";
370  }
371  else if (this->VerticalJustification == VTK_TEXT_CENTERED)
372  {
373  return "Centered";
374  }
375  else if (this->VerticalJustification == VTK_TEXT_TOP)
376  {
377  return "Top";
378  }
379  return "Unknown";
380 }
381 
382 #endif
vtkTextProperty::FontSize
int FontSize
Definition: vtkTextProperty.h:264
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:155
vtkTextProperty::GetFontFamilyAsString
virtual char * GetFontFamilyAsString()
Set/Get the font family.
vtkTextProperty::SetJustificationToCentered
void SetJustificationToCentered()
Definition: vtkTextProperty.h:191
vtkTextProperty::SetFontFamilyAsString
virtual void SetFontFamilyAsString(const char *)
vtkTextProperty::LineSpacing
double LineSpacing
Definition: vtkTextProperty.h:274
vtkTextProperty::Bold
vtkTypeBool Bold
Definition: vtkTextProperty.h:265
vtkTextProperty::Orientation
double Orientation
Definition: vtkTextProperty.h:272
VTK_TIMES
#define VTK_TIMES
Definition: vtkSystemIncludes.h:69
vtkTextProperty::GetVerticalJustificationAsString
const char * GetVerticalJustificationAsString()
Definition: vtkTextProperty.h:365
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkX3D::Color
@ Color
Definition: vtkX3D.h:52
vtkTextProperty::UseTightBoundingBox
vtkTypeBool UseTightBoundingBox
Definition: vtkTextProperty.h:271
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkTextProperty::GetJustificationAsString
const char * GetJustificationAsString()
Definition: vtkTextProperty.h:348
VTK_UNKNOWN_FONT
#define VTK_UNKNOWN_FONT
Definition: vtkSystemIncludes.h:70
vtkTextProperty::SetJustificationToLeft
void SetJustificationToLeft()
Definition: vtkTextProperty.h:190
vtkTextProperty::GetFontFamily
int GetFontFamily()
Definition: vtkTextProperty.h:343
vtkTextProperty::SetFontFamilyToCourier
void SetFontFamilyToCourier()
Definition: vtkTextProperty.h:312
VTK_TEXT_LEFT
#define VTK_TEXT_LEFT
Definition: vtkSystemIncludes.h:73
vtkTextProperty::SetVerticalJustificationToTop
void SetVerticalJustificationToTop()
Definition: vtkTextProperty.h:205
vtkX3D::color
@ color
Definition: vtkX3D.h:227
VTK_FONT_FILE
#define VTK_FONT_FILE
Definition: vtkSystemIncludes.h:71
vtkTextProperty::SetVerticalJustificationToCentered
void SetVerticalJustificationToCentered()
Definition: vtkTextProperty.h:204
vtkTextProperty::Justification
int Justification
Definition: vtkTextProperty.h:269
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkTextProperty::VerticalJustification
int VerticalJustification
Definition: vtkTextProperty.h:270
vtkTextProperty::Frame
vtkTypeBool Frame
Definition: vtkTextProperty.h:259
VTK_TEXT_BOTTOM
#define VTK_TEXT_BOTTOM
Definition: vtkSystemIncludes.h:77
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:75
vtkTextProperty::SetJustificationToRight
void SetJustificationToRight()
Definition: vtkTextProperty.h:192
vtkTextProperty::SetFontFamilyToTimes
void SetFontFamilyToTimes()
Definition: vtkTextProperty.h:317
vtkTextProperty::FontFile
char * FontFile
Definition: vtkTextProperty.h:263
VTK_ARIAL
#define VTK_ARIAL
Definition: vtkSystemIncludes.h:67
VTK_TEXT_TOP
#define VTK_TEXT_TOP
Definition: vtkSystemIncludes.h:78
vtkObject.h
vtkTextProperty::FrameWidth
int FrameWidth
Definition: vtkTextProperty.h:261
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:33
vtkTextProperty::SetFontFamilyToArial
void SetFontFamilyToArial()
Definition: vtkTextProperty.h:307
vtkTextProperty::Opacity
double Opacity
Definition: vtkTextProperty.h:256
vtkTextProperty::FontFamilyAsString
char * FontFamilyAsString
Definition: vtkTextProperty.h:262
vtkTextProperty::Italic
vtkTypeBool Italic
Definition: vtkTextProperty.h:266
VTK_TEXT_CENTERED
#define VTK_TEXT_CENTERED
Definition: vtkSystemIncludes.h:74
vtkTextProperty::BackgroundOpacity
double BackgroundOpacity
Definition: vtkTextProperty.h:258
vtkTextProperty::SetFontFamily
void SetFontFamily(int t)
Definition: vtkTextProperty.h:302
vtkTextProperty::GetFontFamilyMinValue
int GetFontFamilyMinValue()
Definition: vtkTextProperty.h:116
VTK_COURIER
#define VTK_COURIER
Definition: vtkSystemIncludes.h:68
vtkTextProperty::SetVerticalJustificationToBottom
void SetVerticalJustificationToBottom()
Definition: vtkTextProperty.h:203
vtkTextProperty::GetFontFamilyFromString
static int GetFontFamilyFromString(const char *f)
Definition: vtkTextProperty.h:322
vtkTextProperty::Shadow
vtkTypeBool Shadow
Definition: vtkTextProperty.h:267
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkTextProperty::LineOffset
double LineOffset
Definition: vtkTextProperty.h:273