VTK  9.1.0
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 =========================================================================*/
136 #ifndef vtkTextProperty_h
137 #define vtkTextProperty_h
138 
139 #include "vtkObject.h"
140 #include "vtkRenderingCoreModule.h" // For export macro
141 
142 class VTKRENDERINGCORE_EXPORT vtkTextProperty : public vtkObject
143 {
144 public:
145  vtkTypeMacro(vtkTextProperty, vtkObject);
146  void PrintSelf(ostream& os, vtkIndent indent) override;
147 
152  static vtkTextProperty* New();
153 
155 
158  vtkSetVector3Macro(Color, double);
159  vtkGetVector3Macro(Color, double);
161 
163 
167  vtkSetClampMacro(Opacity, double, 0., 1.);
168  vtkGetMacro(Opacity, double);
170 
172 
175  vtkSetVector3Macro(BackgroundColor, double);
176  vtkGetVector3Macro(BackgroundColor, double);
178 
180 
184  vtkSetClampMacro(BackgroundOpacity, double, 0., 1.);
185  vtkGetMacro(BackgroundOpacity, double);
187 
189 
192  void SetBackgroundRGBA(double rgba[4]);
193  void SetBackgroundRGBA(double r, double g, double b, double a);
194 
198  void GetBackgroundRGBA(double rgba[4]);
199  void GetBackgroundRGBA(double& r, double& g, double& b, double& a);
201 
203 
206  vtkSetVector3Macro(FrameColor, double);
207  vtkGetVector3Macro(FrameColor, double);
209 
211 
214  vtkSetMacro(Frame, vtkTypeBool);
215  vtkGetMacro(Frame, vtkTypeBool);
216  vtkBooleanMacro(Frame, vtkTypeBool);
218 
220 
224  vtkSetClampMacro(FrameWidth, int, 0, VTK_INT_MAX);
225  vtkGetMacro(FrameWidth, int);
227 
229 
235  vtkGetStringMacro(FontFamilyAsString);
236  vtkSetStringMacro(FontFamilyAsString);
237  void SetFontFamily(int t);
238  int GetFontFamily();
240  void SetFontFamilyToArial();
241  void SetFontFamilyToCourier();
242  void SetFontFamilyToTimes();
243  static int GetFontFamilyFromString(const char* f);
244  static const char* GetFontFamilyAsString(int f);
246 
248 
256 
258 
261  vtkSetClampMacro(FontSize, int, 0, VTK_INT_MAX);
262  vtkGetMacro(FontSize, int);
264 
266 
269  vtkSetMacro(Bold, vtkTypeBool);
270  vtkGetMacro(Bold, vtkTypeBool);
271  vtkBooleanMacro(Bold, vtkTypeBool);
273 
275 
278  vtkSetMacro(Italic, vtkTypeBool);
279  vtkGetMacro(Italic, vtkTypeBool);
280  vtkBooleanMacro(Italic, vtkTypeBool);
282 
284 
287  vtkSetMacro(Shadow, vtkTypeBool);
288  vtkGetMacro(Shadow, vtkTypeBool);
289  vtkBooleanMacro(Shadow, vtkTypeBool);
291 
293 
297  vtkSetVector2Macro(ShadowOffset, int);
298  vtkGetVectorMacro(ShadowOffset, int, 2);
300 
304  void GetShadowColor(double color[3]);
305 
307 
311  vtkSetClampMacro(Justification, int, VTK_TEXT_LEFT, VTK_TEXT_RIGHT);
312  vtkGetMacro(Justification, int);
313  void SetJustificationToLeft() { this->SetJustification(VTK_TEXT_LEFT); }
314  void SetJustificationToCentered() { this->SetJustification(VTK_TEXT_CENTERED); }
315  void SetJustificationToRight() { this->SetJustification(VTK_TEXT_RIGHT); }
316  const char* GetJustificationAsString();
318 
320 
324  vtkSetClampMacro(VerticalJustification, int, VTK_TEXT_BOTTOM, VTK_TEXT_TOP);
325  vtkGetMacro(VerticalJustification, int);
326  void SetVerticalJustificationToBottom() { this->SetVerticalJustification(VTK_TEXT_BOTTOM); }
327  void SetVerticalJustificationToCentered() { this->SetVerticalJustification(VTK_TEXT_CENTERED); }
328  void SetVerticalJustificationToTop() { this->SetVerticalJustification(VTK_TEXT_TOP); }
329  const char* GetVerticalJustificationAsString();
331 
333 
339  vtkSetMacro(UseTightBoundingBox, vtkTypeBool);
340  vtkGetMacro(UseTightBoundingBox, vtkTypeBool);
341  vtkBooleanMacro(UseTightBoundingBox, vtkTypeBool);
343 
345 
348  vtkSetMacro(Orientation, double);
349  vtkGetMacro(Orientation, double);
351 
353 
357  vtkSetMacro(LineSpacing, double);
358  vtkGetMacro(LineSpacing, double);
360 
362 
365  vtkSetMacro(LineOffset, double);
366  vtkGetMacro(LineOffset, double);
368 
370 
374  vtkSetMacro(CellOffset, double);
375  vtkGetMacro(CellOffset, double);
377 
382 
383 protected:
385  ~vtkTextProperty() override;
386 
387  double Color[3];
388  double Opacity;
389  double BackgroundColor[3];
392  double FrameColor[3];
395  char* FontFile;
396  int FontSize;
400  int ShadowOffset[2];
404  double Orientation;
405  double LineOffset;
406  double LineSpacing;
407  double CellOffset;
408 
409 private:
410  vtkTextProperty(const vtkTextProperty&) = delete;
411  void operator=(const vtkTextProperty&) = delete;
412 };
413 
414 inline const char* vtkTextProperty::GetFontFamilyAsString(int f)
415 {
416  if (f == VTK_ARIAL)
417  {
418  return "Arial";
419  }
420  else if (f == VTK_COURIER)
421  {
422  return "Courier";
423  }
424  else if (f == VTK_TIMES)
425  {
426  return "Times";
427  }
428  else if (f == VTK_FONT_FILE)
429  {
430  return "File";
431  }
432  return "Unknown";
433 }
434 
436 {
438 }
439 
441 {
442  this->SetFontFamily(VTK_ARIAL);
443 }
444 
446 {
447  this->SetFontFamily(VTK_COURIER);
448 }
449 
451 {
452  this->SetFontFamily(VTK_TIMES);
453 }
454 
456 {
457  if (strcmp(f, GetFontFamilyAsString(VTK_ARIAL)) == 0)
458  {
459  return VTK_ARIAL;
460  }
461  else if (strcmp(f, GetFontFamilyAsString(VTK_COURIER)) == 0)
462  {
463  return VTK_COURIER;
464  }
465  else if (strcmp(f, GetFontFamilyAsString(VTK_TIMES)) == 0)
466  {
467  return VTK_TIMES;
468  }
469  else if (strcmp(f, GetFontFamilyAsString(VTK_FONT_FILE)) == 0)
470  {
471  return VTK_FONT_FILE;
472  }
473  return VTK_UNKNOWN_FONT;
474 }
475 
477 {
479 }
480 
482 {
483  if (this->Justification == VTK_TEXT_LEFT)
484  {
485  return "Left";
486  }
487  else if (this->Justification == VTK_TEXT_CENTERED)
488  {
489  return "Centered";
490  }
491  else if (this->Justification == VTK_TEXT_RIGHT)
492  {
493  return "Right";
494  }
495  return "Unknown";
496 }
497 
499 {
501  {
502  return "Bottom";
503  }
504  else if (this->VerticalJustification == VTK_TEXT_CENTERED)
505  {
506  return "Centered";
507  }
508  else if (this->VerticalJustification == VTK_TEXT_TOP)
509  {
510  return "Top";
511  }
512  return "Unknown";
513 }
514 
515 #endif
a simple class to control print indentation
Definition: vtkIndent.h:113
abstract base class for most VTK objects
Definition: vtkObject.h:73
represent text properties.
void SetFontFamilyToArial()
Set/Get the font family.
vtkTypeBool Shadow
void ShallowCopy(vtkTextProperty *tprop)
Shallow copy of a text property.
static int GetFontFamilyFromString(const char *f)
Set/Get the font family.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetJustificationToCentered()
Set/Get the horizontal justification to left (default), centered, or right.
void SetFontFamilyToCourier()
Set/Get the font family.
vtkTypeBool Italic
vtkTypeBool Bold
void SetVerticalJustificationToCentered()
Set/Get the vertical justification to bottom (default), middle, or top.
void GetBackgroundRGBA(double rgba[4])
Convenience method to get the background color and the opacity at once.
static vtkTextProperty * New()
Creates a new text property with font size 12, bold off, italic off, and Arial font.
int GetFontFamily()
Set/Get the font family.
void SetJustificationToLeft()
Set/Get the horizontal justification to left (default), centered, or right.
int GetFontFamilyMinValue()
Set/Get the font family.
const char * GetVerticalJustificationAsString()
Set/Get the vertical justification to bottom (default), middle, or top.
vtkGetFilePathMacro(FontFile)
The absolute filepath to a local file containing a freetype-readable font if GetFontFamily() return V...
vtkSetFilePathMacro(FontFile)
The absolute filepath to a local file containing a freetype-readable font if GetFontFamily() return V...
vtkTypeBool UseTightBoundingBox
void GetBackgroundRGBA(double &r, double &g, double &b, double &a)
Convenience method to set the background color and the opacity at once.
void SetJustificationToRight()
Set/Get the horizontal justification to left (default), centered, or right.
void SetVerticalJustificationToTop()
Set/Get the vertical justification to bottom (default), middle, or top.
~vtkTextProperty() override
void SetBackgroundRGBA(double rgba[4])
Convenience method to set the background color and the opacity at once.
void SetFontFamily(int t)
Set/Get the font family.
vtkTypeBool Frame
void GetShadowColor(double color[3])
Get the shadow color.
virtual char * GetFontFamilyAsString()
Set/Get the font family.
void SetVerticalJustificationToBottom()
Set/Get the vertical justification to bottom (default), middle, or top.
const char * GetJustificationAsString()
Set/Get the horizontal justification to left (default), centered, or right.
virtual void SetFontFamilyAsString(const char *)
Set/Get the font family.
void SetBackgroundRGBA(double r, double g, double b, double a)
Convenience method to set the background color and the opacity at once.
void SetFontFamilyToTimes()
Set/Get the font family.
@ Color
Definition: vtkX3D.h:52
@ color
Definition: vtkX3D.h:227
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_TEXT_TOP
#define VTK_TEXT_RIGHT
#define VTK_TEXT_LEFT
#define VTK_COURIER
#define VTK_TEXT_BOTTOM
#define VTK_FONT_FILE
#define VTK_ARIAL
#define VTK_TIMES
#define VTK_UNKNOWN_FONT
#define VTK_TEXT_CENTERED
#define VTK_INT_MAX
Definition: vtkType.h:155