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 
250 
251 protected:
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
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract base class for most VTK objects
Definition: vtkObject.h:63
represent text properties.
void SetFontFamilyToArial()
vtkTypeBool Shadow
void ShallowCopy(vtkTextProperty *tprop)
Shallow copy of a text property.
static int GetFontFamilyFromString(const char *f)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetJustificationToCentered()
void SetFontFamilyToCourier()
vtkTypeBool Italic
vtkTypeBool Bold
void SetVerticalJustificationToCentered()
static vtkTextProperty * New()
Creates a new text property with font size 12, bold off, italic off, and Arial font.
void SetJustificationToLeft()
const char * GetVerticalJustificationAsString()
vtkTypeBool UseTightBoundingBox
void SetJustificationToRight()
void SetVerticalJustificationToTop()
~vtkTextProperty() override
void SetFontFamily(int t)
vtkTypeBool Frame
void GetShadowColor(double color[3])
Get the shadow color.
virtual char * GetFontFamilyAsString()
Set/Get the font family.
void SetVerticalJustificationToBottom()
const char * GetJustificationAsString()
virtual void SetFontFamilyAsString(const char *)
void SetFontFamilyToTimes()
@ 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