VTK  9.3.20240329
vtkTextProperty.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
127 #ifndef vtkTextProperty_h
128 #define vtkTextProperty_h
129 
130 #include "vtkObject.h"
131 #include "vtkRenderingCoreModule.h" // For export macro
132 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
133 
134 VTK_ABI_NAMESPACE_BEGIN
135 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkTextProperty : public vtkObject
136 {
137 public:
138  vtkTypeMacro(vtkTextProperty, vtkObject);
139  void PrintSelf(ostream& os, vtkIndent indent) override;
140 
145  static vtkTextProperty* New();
146 
148 
151  vtkSetVector3Macro(Color, double);
152  vtkGetVector3Macro(Color, double);
154 
156 
160  vtkSetClampMacro(Opacity, double, 0., 1.);
161  vtkGetMacro(Opacity, double);
163 
165 
168  vtkSetVector3Macro(BackgroundColor, double);
169  vtkGetVector3Macro(BackgroundColor, double);
171 
173 
177  vtkSetClampMacro(BackgroundOpacity, double, 0., 1.);
178  vtkGetMacro(BackgroundOpacity, double);
180 
182 
185  void SetBackgroundRGBA(double rgba[4]);
186  void SetBackgroundRGBA(double r, double g, double b, double a);
187 
191  void GetBackgroundRGBA(double rgba[4]);
192  void GetBackgroundRGBA(double& r, double& g, double& b, double& a);
194 
196 
199  vtkSetVector3Macro(FrameColor, double);
200  vtkGetVector3Macro(FrameColor, double);
202 
204 
207  vtkSetMacro(Frame, vtkTypeBool);
208  vtkGetMacro(Frame, vtkTypeBool);
209  vtkBooleanMacro(Frame, vtkTypeBool);
211 
213 
217  vtkSetClampMacro(FrameWidth, int, 0, VTK_INT_MAX);
218  vtkGetMacro(FrameWidth, int);
220 
222 
228  vtkGetStringMacro(FontFamilyAsString);
229  vtkSetStringMacro(FontFamilyAsString);
230  void SetFontFamily(int t);
231  int GetFontFamily();
233  void SetFontFamilyToArial();
234  void SetFontFamilyToCourier();
235  void SetFontFamilyToTimes();
236  static int GetFontFamilyFromString(const char* f);
237  static const char* GetFontFamilyAsString(int f);
239 
241 
249 
251 
254  vtkSetClampMacro(FontSize, int, 0, VTK_INT_MAX);
255  vtkGetMacro(FontSize, int);
257 
259 
262  vtkSetMacro(Bold, vtkTypeBool);
263  vtkGetMacro(Bold, vtkTypeBool);
264  vtkBooleanMacro(Bold, vtkTypeBool);
266 
268 
271  vtkSetMacro(Italic, vtkTypeBool);
272  vtkGetMacro(Italic, vtkTypeBool);
273  vtkBooleanMacro(Italic, vtkTypeBool);
275 
277 
280  vtkSetMacro(Shadow, vtkTypeBool);
281  vtkGetMacro(Shadow, vtkTypeBool);
282  vtkBooleanMacro(Shadow, vtkTypeBool);
284 
286 
290  vtkSetVector2Macro(ShadowOffset, int);
291  vtkGetVectorMacro(ShadowOffset, int, 2);
293 
297  void GetShadowColor(double color[3]);
298 
300 
304  vtkSetClampMacro(Justification, int, VTK_TEXT_LEFT, VTK_TEXT_RIGHT);
305  vtkGetMacro(Justification, int);
306  void SetJustificationToLeft() { this->SetJustification(VTK_TEXT_LEFT); }
307  void SetJustificationToCentered() { this->SetJustification(VTK_TEXT_CENTERED); }
308  void SetJustificationToRight() { this->SetJustification(VTK_TEXT_RIGHT); }
309  const char* GetJustificationAsString();
311 
313 
317  vtkSetClampMacro(VerticalJustification, int, VTK_TEXT_BOTTOM, VTK_TEXT_TOP);
318  vtkGetMacro(VerticalJustification, int);
319  void SetVerticalJustificationToBottom() { this->SetVerticalJustification(VTK_TEXT_BOTTOM); }
320  void SetVerticalJustificationToCentered() { this->SetVerticalJustification(VTK_TEXT_CENTERED); }
321  void SetVerticalJustificationToTop() { this->SetVerticalJustification(VTK_TEXT_TOP); }
322  const char* GetVerticalJustificationAsString();
324 
326 
332  vtkSetMacro(UseTightBoundingBox, vtkTypeBool);
333  vtkGetMacro(UseTightBoundingBox, vtkTypeBool);
334  vtkBooleanMacro(UseTightBoundingBox, vtkTypeBool);
336 
338 
341  vtkSetMacro(Orientation, double);
342  vtkGetMacro(Orientation, double);
344 
346 
350  vtkSetMacro(LineSpacing, double);
351  vtkGetMacro(LineSpacing, double);
353 
355 
358  vtkSetMacro(LineOffset, double);
359  vtkGetMacro(LineOffset, double);
361 
363 
367  vtkSetMacro(CellOffset, double);
368  vtkGetMacro(CellOffset, double);
370 
372 
376  vtkSetMacro(InteriorLinesVisibility, bool);
377  vtkGetMacro(InteriorLinesVisibility, bool);
379 
381 
385  vtkSetMacro(InteriorLinesWidth, int);
386  vtkGetMacro(InteriorLinesWidth, int);
388 
390 
394  vtkSetVector3Macro(InteriorLinesColor, double);
395  vtkGetVector3Macro(InteriorLinesColor, double);
397 
402 
403 protected:
405  ~vtkTextProperty() override;
406 
407  double Color[3];
408  double Opacity;
409  double BackgroundColor[3];
412  double FrameColor[3];
415  char* FontFile;
416  int FontSize;
420  int ShadowOffset[2];
424  double Orientation;
425  double LineOffset;
426  double LineSpacing;
427  double CellOffset;
428  bool InteriorLinesVisibility = false;
429  int InteriorLinesWidth = 1;
430  double InteriorLinesColor[3] = { 0.0, 0.0, 0.0 };
431 
432 private:
433  vtkTextProperty(const vtkTextProperty&) = delete;
434  void operator=(const vtkTextProperty&) = delete;
435 };
436 
437 inline const char* vtkTextProperty::GetFontFamilyAsString(int f)
438 {
439  if (f == VTK_ARIAL)
440  {
441  return "Arial";
442  }
443  else if (f == VTK_COURIER)
444  {
445  return "Courier";
446  }
447  else if (f == VTK_TIMES)
448  {
449  return "Times";
450  }
451  else if (f == VTK_FONT_FILE)
452  {
453  return "File";
454  }
455  return "Unknown";
456 }
457 
459 {
461 }
462 
464 {
465  this->SetFontFamily(VTK_ARIAL);
466 }
467 
469 {
470  this->SetFontFamily(VTK_COURIER);
471 }
472 
474 {
475  this->SetFontFamily(VTK_TIMES);
476 }
477 
479 {
480  if (strcmp(f, GetFontFamilyAsString(VTK_ARIAL)) == 0)
481  {
482  return VTK_ARIAL;
483  }
484  else if (strcmp(f, GetFontFamilyAsString(VTK_COURIER)) == 0)
485  {
486  return VTK_COURIER;
487  }
488  else if (strcmp(f, GetFontFamilyAsString(VTK_TIMES)) == 0)
489  {
490  return VTK_TIMES;
491  }
492  else if (strcmp(f, GetFontFamilyAsString(VTK_FONT_FILE)) == 0)
493  {
494  return VTK_FONT_FILE;
495  }
496  return VTK_UNKNOWN_FONT;
497 }
498 
500 {
502 }
503 
505 {
506  if (this->Justification == VTK_TEXT_LEFT)
507  {
508  return "Left";
509  }
510  else if (this->Justification == VTK_TEXT_CENTERED)
511  {
512  return "Centered";
513  }
514  else if (this->Justification == VTK_TEXT_RIGHT)
515  {
516  return "Right";
517  }
518  return "Unknown";
519 }
520 
522 {
524  {
525  return "Bottom";
526  }
527  else if (this->VerticalJustification == VTK_TEXT_CENTERED)
528  {
529  return "Centered";
530  }
531  else if (this->VerticalJustification == VTK_TEXT_TOP)
532  {
533  return "Top";
534  }
535  return "Unknown";
536 }
537 
538 VTK_ABI_NAMESPACE_END
539 #endif
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:162
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:46
@ color
Definition: vtkX3D.h:221
int vtkTypeBool
Definition: vtkABI.h:64
#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:144
#define VTK_MARSHALAUTO