VTK
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 "vtkRenderingCoreModule.h" // For export macro
31 #include "vtkObject.h"
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();
116  int GetFontFamilyMinValue() { return VTK_ARIAL; };
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);
191  { this->SetJustification(VTK_TEXT_LEFT);};
193  { this->SetJustification(VTK_TEXT_CENTERED);};
195  { this->SetJustification(VTK_TEXT_RIGHT);};
196  const char *GetJustificationAsString();
198 
200 
204  vtkSetClampMacro(VerticalJustification,int,VTK_TEXT_BOTTOM,VTK_TEXT_TOP);
205  vtkGetMacro(VerticalJustification,int);
207  {this->SetVerticalJustification(VTK_TEXT_BOTTOM);};
209  {this->SetVerticalJustification(VTK_TEXT_CENTERED);};
211  {this->SetVerticalJustification(VTK_TEXT_TOP);};
212  const char *GetVerticalJustificationAsString();
214 
216 
222  vtkSetMacro(UseTightBoundingBox, vtkTypeBool);
223  vtkGetMacro(UseTightBoundingBox, vtkTypeBool);
224  vtkBooleanMacro(UseTightBoundingBox, vtkTypeBool);
226 
228 
231  vtkSetMacro(Orientation,double);
232  vtkGetMacro(Orientation,double);
234 
236 
240  vtkSetMacro(LineSpacing, double);
241  vtkGetMacro(LineSpacing, double);
243 
245 
248  vtkSetMacro(LineOffset, double);
249  vtkGetMacro(LineOffset, double);
251 
255  void ShallowCopy(vtkTextProperty *tprop);
256 
257 protected:
258  vtkTextProperty();
259  ~vtkTextProperty() override;
260 
261  double Color[3];
262  double Opacity;
263  double BackgroundColor[3];
266  double FrameColor[3];
269  char* FontFile;
270  int FontSize;
274  int ShadowOffset[2];
278  double Orientation;
279  double LineOffset;
280  double LineSpacing;
281 
282 private:
283  vtkTextProperty(const vtkTextProperty&) = delete;
284  void operator=(const vtkTextProperty&) = delete;
285 };
286 
287 inline const char *vtkTextProperty::GetFontFamilyAsString( int f )
288 {
289  if ( f == VTK_ARIAL )
290  {
291  return "Arial";
292  }
293  else if ( f == VTK_COURIER )
294  {
295  return "Courier";
296  }
297  else if ( f == VTK_TIMES )
298  {
299  return "Times";
300  }
301  else if ( f == VTK_FONT_FILE )
302  {
303  return "File";
304  }
305  return "Unknown";
306 }
307 
308 inline void vtkTextProperty::SetFontFamily( int t )
309 {
310  this->SetFontFamilyAsString( this->GetFontFamilyAsString( t ) );
311 }
312 
314 {
315  this->SetFontFamily(VTK_ARIAL);
316 }
317 
319 {
320  this->SetFontFamily(VTK_COURIER);
321 }
322 
324 {
325  this->SetFontFamily(VTK_TIMES);
326 }
327 
328 inline int vtkTextProperty::GetFontFamilyFromString( const char *f )
329 {
330  if ( strcmp( f, GetFontFamilyAsString( VTK_ARIAL ) ) == 0 )
331  {
332  return VTK_ARIAL;
333  }
334  else if ( strcmp( f, GetFontFamilyAsString( VTK_COURIER ) ) == 0 )
335  {
336  return VTK_COURIER;
337  }
338  else if ( strcmp( f, GetFontFamilyAsString( VTK_TIMES ) ) == 0 )
339  {
340  return VTK_TIMES;
341  }
342  else if ( strcmp( f, GetFontFamilyAsString( VTK_FONT_FILE) ) == 0 )
343  {
344  return VTK_FONT_FILE;
345  }
346  return VTK_UNKNOWN_FONT;
347 }
348 
350 {
352 }
353 
355 {
356  if (this->Justification == VTK_TEXT_LEFT)
357  {
358  return "Left";
359  }
360  else if (this->Justification == VTK_TEXT_CENTERED)
361  {
362  return "Centered";
363  }
364  else if (this->Justification == VTK_TEXT_RIGHT)
365  {
366  return "Right";
367  }
368  return "Unknown";
369 }
370 
372 {
374  {
375  return "Bottom";
376  }
377  else if (this->VerticalJustification == VTK_TEXT_CENTERED)
378  {
379  return "Centered";
380  }
381  else if (this->VerticalJustification == VTK_TEXT_TOP)
382  {
383  return "Top";
384  }
385  return "Unknown";
386 }
387 
388 #endif
void SetFontFamilyToArial()
Set/Get the font family.
#define VTK_UNKNOWN_FONT
void SetJustificationToRight()
Set/Get the horizontal justification to left (default), centered, or right.
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkTypeBool Frame
vtkTypeBool Italic
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetVerticalJustificationToTop()
Set/Get the vertical justification to bottom (default), middle, or top.
#define VTK_INT_MAX
Definition: vtkType.h:157
#define VTK_ARIAL
#define VTK_TEXT_TOP
void SetVerticalJustificationToBottom()
Set/Get the vertical justification to bottom (default), middle, or top.
vtkTypeBool Shadow
void SetVerticalJustificationToCentered()
Set/Get the vertical justification to bottom (default), middle, or top.
#define VTK_TEXT_CENTERED
virtual void SetFontFamilyAsString(const char *)
Set/Get the font family.
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_TEXT_RIGHT
#define VTK_TEXT_LEFT
#define VTK_COURIER
a simple class to control print indentation
Definition: vtkIndent.h:33
#define VTK_TEXT_BOTTOM
#define VTK_TIMES
int GetFontFamily()
Set/Get the font family.
int GetFontFamilyMinValue()
Set/Get the font family.
void SetJustificationToLeft()
Set/Get the horizontal justification to left (default), centered, or right.
represent text properties.
void SetFontFamilyToCourier()
Set/Get the font family.
vtkTypeBool Bold
vtkTypeBool UseTightBoundingBox
static int GetFontFamilyFromString(const char *f)
Set/Get the font family.
virtual char * GetFontFamilyAsString()
Set/Get the font family.
#define VTK_FONT_FILE
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
const char * GetVerticalJustificationAsString()
Set/Get the vertical justification to bottom (default), middle, or top.
void SetFontFamilyToTimes()
Set/Get the font family.
void SetJustificationToCentered()
Set/Get the horizontal justification to left (default), centered, or right.
void SetFontFamily(int t)
Set/Get the font family.
const char * GetJustificationAsString()
Set/Get the horizontal justification to left (default), centered, or right.