VTK  9.2.6
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 =========================================================================*/
39 #ifndef vtkTextProperty_h
40 #define vtkTextProperty_h
41 
42 #include "vtkObject.h"
43 #include "vtkRenderingCoreModule.h" // For export macro
44 
45 class VTKRENDERINGCORE_EXPORT vtkTextProperty : public vtkObject
46 {
47 public:
48  vtkTypeMacro(vtkTextProperty, vtkObject);
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
55  static vtkTextProperty* New();
56 
58 
61  vtkSetVector3Macro(Color, double);
62  vtkGetVector3Macro(Color, double);
64 
66 
70  vtkSetClampMacro(Opacity, double, 0., 1.);
71  vtkGetMacro(Opacity, double);
73 
75 
78  vtkSetVector3Macro(BackgroundColor, double);
79  vtkGetVector3Macro(BackgroundColor, double);
81 
83 
87  vtkSetClampMacro(BackgroundOpacity, double, 0., 1.);
88  vtkGetMacro(BackgroundOpacity, double);
90 
92 
95  void SetBackgroundRGBA(double rgba[4]);
96  void SetBackgroundRGBA(double r, double g, double b, double a);
97 
101  void GetBackgroundRGBA(double rgba[4]);
102  void GetBackgroundRGBA(double& r, double& g, double& b, double& a);
104 
106 
109  vtkSetVector3Macro(FrameColor, double);
110  vtkGetVector3Macro(FrameColor, double);
112 
114 
117  vtkSetMacro(Frame, vtkTypeBool);
118  vtkGetMacro(Frame, vtkTypeBool);
119  vtkBooleanMacro(Frame, vtkTypeBool);
121 
123 
127  vtkSetClampMacro(FrameWidth, int, 0, VTK_INT_MAX);
128  vtkGetMacro(FrameWidth, int);
130 
132 
138  vtkGetStringMacro(FontFamilyAsString);
139  vtkSetStringMacro(FontFamilyAsString);
140  void SetFontFamily(int t);
141  int GetFontFamily();
143  void SetFontFamilyToArial();
144  void SetFontFamilyToCourier();
145  void SetFontFamilyToTimes();
146  static int GetFontFamilyFromString(const char* f);
147  static const char* GetFontFamilyAsString(int f);
149 
151 
159 
161 
164  vtkSetClampMacro(FontSize, int, 0, VTK_INT_MAX);
165  vtkGetMacro(FontSize, int);
167 
169 
172  vtkSetMacro(Bold, vtkTypeBool);
173  vtkGetMacro(Bold, vtkTypeBool);
174  vtkBooleanMacro(Bold, vtkTypeBool);
176 
178 
181  vtkSetMacro(Italic, vtkTypeBool);
182  vtkGetMacro(Italic, vtkTypeBool);
183  vtkBooleanMacro(Italic, vtkTypeBool);
185 
187 
190  vtkSetMacro(Shadow, vtkTypeBool);
191  vtkGetMacro(Shadow, vtkTypeBool);
192  vtkBooleanMacro(Shadow, vtkTypeBool);
194 
196 
200  vtkSetVector2Macro(ShadowOffset, int);
201  vtkGetVectorMacro(ShadowOffset, int, 2);
203 
207  void GetShadowColor(double color[3]);
208 
210 
214  vtkSetClampMacro(Justification, int, VTK_TEXT_LEFT, VTK_TEXT_RIGHT);
215  vtkGetMacro(Justification, int);
216  void SetJustificationToLeft() { this->SetJustification(VTK_TEXT_LEFT); }
217  void SetJustificationToCentered() { this->SetJustification(VTK_TEXT_CENTERED); }
218  void SetJustificationToRight() { this->SetJustification(VTK_TEXT_RIGHT); }
219  const char* GetJustificationAsString();
221 
223 
227  vtkSetClampMacro(VerticalJustification, int, VTK_TEXT_BOTTOM, VTK_TEXT_TOP);
228  vtkGetMacro(VerticalJustification, int);
229  void SetVerticalJustificationToBottom() { this->SetVerticalJustification(VTK_TEXT_BOTTOM); }
230  void SetVerticalJustificationToCentered() { this->SetVerticalJustification(VTK_TEXT_CENTERED); }
231  void SetVerticalJustificationToTop() { this->SetVerticalJustification(VTK_TEXT_TOP); }
232  const char* GetVerticalJustificationAsString();
234 
236 
242  vtkSetMacro(UseTightBoundingBox, vtkTypeBool);
243  vtkGetMacro(UseTightBoundingBox, vtkTypeBool);
244  vtkBooleanMacro(UseTightBoundingBox, vtkTypeBool);
246 
248 
251  vtkSetMacro(Orientation, double);
252  vtkGetMacro(Orientation, double);
254 
256 
260  vtkSetMacro(LineSpacing, double);
261  vtkGetMacro(LineSpacing, double);
263 
265 
268  vtkSetMacro(LineOffset, double);
269  vtkGetMacro(LineOffset, double);
271 
273 
277  vtkSetMacro(CellOffset, double);
278  vtkGetMacro(CellOffset, double);
280 
282 
286  vtkSetMacro(InteriorLinesVisibility, bool);
287  vtkGetMacro(InteriorLinesVisibility, bool);
289 
291 
295  vtkSetMacro(InteriorLinesWidth, int);
296  vtkGetMacro(InteriorLinesWidth, int);
298 
300 
304  vtkSetVector3Macro(InteriorLinesColor, double);
305  vtkGetVector3Macro(InteriorLinesColor, double);
307 
312 
313 protected:
315  ~vtkTextProperty() override;
316 
317  double Color[3];
318  double Opacity;
319  double BackgroundColor[3];
322  double FrameColor[3];
325  char* FontFile;
326  int FontSize;
330  int ShadowOffset[2];
334  double Orientation;
335  double LineOffset;
336  double LineSpacing;
337  double CellOffset;
338  bool InteriorLinesVisibility = false;
339  int InteriorLinesWidth = 1;
340  double InteriorLinesColor[3] = { 0.0, 0.0, 0.0 };
341 
342 private:
343  vtkTextProperty(const vtkTextProperty&) = delete;
344  void operator=(const vtkTextProperty&) = delete;
345 };
346 
347 inline const char* vtkTextProperty::GetFontFamilyAsString(int f)
348 {
349  if (f == VTK_ARIAL)
350  {
351  return "Arial";
352  }
353  else if (f == VTK_COURIER)
354  {
355  return "Courier";
356  }
357  else if (f == VTK_TIMES)
358  {
359  return "Times";
360  }
361  else if (f == VTK_FONT_FILE)
362  {
363  return "File";
364  }
365  return "Unknown";
366 }
367 
369 {
371 }
372 
374 {
375  this->SetFontFamily(VTK_ARIAL);
376 }
377 
379 {
380  this->SetFontFamily(VTK_COURIER);
381 }
382 
384 {
385  this->SetFontFamily(VTK_TIMES);
386 }
387 
389 {
390  if (strcmp(f, GetFontFamilyAsString(VTK_ARIAL)) == 0)
391  {
392  return VTK_ARIAL;
393  }
394  else if (strcmp(f, GetFontFamilyAsString(VTK_COURIER)) == 0)
395  {
396  return VTK_COURIER;
397  }
398  else if (strcmp(f, GetFontFamilyAsString(VTK_TIMES)) == 0)
399  {
400  return VTK_TIMES;
401  }
402  else if (strcmp(f, GetFontFamilyAsString(VTK_FONT_FILE)) == 0)
403  {
404  return VTK_FONT_FILE;
405  }
406  return VTK_UNKNOWN_FONT;
407 }
408 
410 {
412 }
413 
415 {
416  if (this->Justification == VTK_TEXT_LEFT)
417  {
418  return "Left";
419  }
420  else if (this->Justification == VTK_TEXT_CENTERED)
421  {
422  return "Centered";
423  }
424  else if (this->Justification == VTK_TEXT_RIGHT)
425  {
426  return "Right";
427  }
428  return "Unknown";
429 }
430 
432 {
434  {
435  return "Bottom";
436  }
437  else if (this->VerticalJustification == VTK_TEXT_CENTERED)
438  {
439  return "Centered";
440  }
441  else if (this->VerticalJustification == VTK_TEXT_TOP)
442  {
443  return "Top";
444  }
445  return "Unknown";
446 }
447 
448 #endif
a simple class to control print indentation
Definition: vtkIndent.h:49
abstract base class for most VTK objects
Definition: vtkObject.h:72
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