VTK  9.3.1
vtkTextRepresentation.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
18 #ifndef vtkTextRepresentation_h
19 #define vtkTextRepresentation_h
20 
22 #include "vtkInteractionWidgetsModule.h" // For export macro
23 
24 VTK_ABI_NAMESPACE_BEGIN
25 class vtkRenderer;
26 class vtkTextActor;
27 class vtkTextProperty;
28 class vtkTextRepresentationObserver;
29 
30 class VTKINTERACTIONWIDGETS_EXPORT vtkTextRepresentation : public vtkBorderRepresentation
31 {
32 public:
36  static vtkTextRepresentation* New();
37 
39 
43  void PrintSelf(ostream& os, vtkIndent indent) override;
45 
47 
51  void SetTextActor(vtkTextActor* textActor);
52  vtkGetObjectMacro(TextActor, vtkTextActor);
54 
56 
59  void SetText(const char* text);
60  const char* GetText();
62 
66  void BuildRepresentation() override;
67  void GetSize(double size[2]) override
68  {
69  size[0] = 2.0;
70  size[1] = 2.0;
71  }
72 
74 
78  void GetActors2D(vtkPropCollection*) override;
79  void ReleaseGraphicsResources(vtkWindow*) override;
80  int RenderOverlay(vtkViewport*) override;
81  int RenderOpaqueGeometry(vtkViewport*) override;
85 
97  void SetWindowLocation(int enumLocation) override;
98 
100 
104  void SetPosition(double x, double y) override;
105  void SetPosition(double pos[2]) override { this->SetPosition(pos[0], pos[1]); }
107 
109 
112  void ExecuteTextPropertyModifiedEvent(vtkObject* obj, unsigned long enumEvent, void* p);
113  void ExecuteTextActorModifiedEvent(vtkObject* obj, unsigned long enumEvent, void* p);
115 
117 
122  vtkSetClampMacro(PaddingLeft, int, 0, 4000);
123  vtkGetMacro(PaddingLeft, int);
125 
127 
132  vtkSetClampMacro(PaddingRight, int, 0, 4000);
133  vtkGetMacro(PaddingRight, int);
135 
137 
142  vtkSetClampMacro(PaddingTop, int, 0, 4000);
143  vtkGetMacro(PaddingTop, int);
145 
147 
152  vtkSetClampMacro(PaddingBottom, int, 0, 4000);
153  vtkGetMacro(PaddingBottom, int);
155 
157 
162  void SetPadding(int padding);
164 
165 protected:
167  ~vtkTextRepresentation() override;
168 
169  // Initialize text actor
170  virtual void InitializeTextActor();
171 
172  // Check and adjust boundaries according to the size of the text
173  virtual void CheckTextBoundary();
174 
175  // the text to manage
178 
179  // observer to observe internal TextActor and TextProperty
180  vtkTextRepresentationObserver* Observer;
181 
182  int PaddingLeft = 0;
183  int PaddingRight = 0;
184  int PaddingTop = 0;
185  int PaddingBottom = 0;
186 
187 private:
189  void operator=(const vtkTextRepresentation&) = delete;
190 };
191 
192 VTK_ABI_NAMESPACE_END
193 #endif
int RenderOverlay(vtkViewport *) override
These methods are necessary to make this representation behave as a vtkProp.
abstract base class for most VTK objects
Definition: vtkObject.h:51
virtual void SetPosition(float x[2])
Specify opposite corners of the box defining the boundary of the widget.
vtkTypeBool HasTranslucentPolygonalGeometry() override
These methods are necessary to make this representation behave as a vtkProp.
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkTextProperty * TextProperty
vtkTextRepresentationObserver * Observer
void GetSize(double size[2]) override
Subclasses should implement these methods.
int RenderOpaqueGeometry(vtkViewport *) override
These methods are necessary to make this representation behave as a vtkProp.
void GetActors2D(vtkPropCollection *) override
These methods are necessary to make this representation behave as a vtkProp.
abstract specification for renderers
Definition: vtkRenderer.h:61
represent text for vtkTextWidget
static vtkBorderRepresentation * New()
Instantiate this class.
an ordered list of Props
void PrintSelf(ostream &os, vtkIndent indent) override
Define standard methods.
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
An actor that displays text.
Definition: vtkTextActor.h:45
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
These methods are necessary to make this representation behave as a vtkProp.
void BuildRepresentation() override
Subclasses should implement these methods.
a simple class to control print indentation
Definition: vtkIndent.h:28
void ReleaseGraphicsResources(vtkWindow *) override
These methods are necessary to make this representation behave as a vtkProp.
represent a vtkBorderWidget
represent text properties.
virtual void SetWindowLocation(int enumLocation)
Set the representation position, by enumeration ( AnyLocation = 0, LowerLeftCorner, LowerRightCorner, LowerCenter, UpperLeftCorner, UpperRightCorner, UpperCenter) related to the render window.
void SetPosition(double pos[2]) override
Set the text position, by overriding the same function of vtkBorderRepresentation so that the Modifie...