VTK  9.2.6
vtkTextRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTextRepresentation.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 =========================================================================*/
30 #ifndef vtkTextRepresentation_h
31 #define vtkTextRepresentation_h
32 
34 #include "vtkInteractionWidgetsModule.h" // For export macro
35 
36 class vtkRenderer;
37 class vtkTextActor;
38 class vtkTextProperty;
39 class vtkTextRepresentationObserver;
40 
41 class VTKINTERACTIONWIDGETS_EXPORT vtkTextRepresentation : public vtkBorderRepresentation
42 {
43 public:
47  static vtkTextRepresentation* New();
48 
50 
54  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
58 
62  void SetTextActor(vtkTextActor* textActor);
63  vtkGetObjectMacro(TextActor, vtkTextActor);
65 
67 
70  void SetText(const char* text);
71  const char* GetText();
73 
77  void BuildRepresentation() override;
78  void GetSize(double size[2]) override
79  {
80  size[0] = 2.0;
81  size[1] = 2.0;
82  }
83 
85 
89  void GetActors2D(vtkPropCollection*) override;
90  void ReleaseGraphicsResources(vtkWindow*) override;
91  int RenderOverlay(vtkViewport*) override;
92  int RenderOpaqueGeometry(vtkViewport*) override;
96 
108  void SetWindowLocation(int enumLocation) override;
109 
111 
115  void SetPosition(double x, double y) override;
116  void SetPosition(double pos[2]) override { this->SetPosition(pos[0], pos[1]); }
118 
120 
123  void ExecuteTextPropertyModifiedEvent(vtkObject* obj, unsigned long enumEvent, void* p);
124  void ExecuteTextActorModifiedEvent(vtkObject* obj, unsigned long enumEvent, void* p);
126 
128 
133  vtkSetClampMacro(PaddingLeft, int, 0, 4000);
134  vtkGetMacro(PaddingLeft, int);
136 
138 
143  vtkSetClampMacro(PaddingRight, int, 0, 4000);
144  vtkGetMacro(PaddingRight, int);
146 
148 
153  vtkSetClampMacro(PaddingTop, int, 0, 4000);
154  vtkGetMacro(PaddingTop, int);
156 
158 
163  vtkSetClampMacro(PaddingBottom, int, 0, 4000);
164  vtkGetMacro(PaddingBottom, int);
166 
168 
173  void SetPadding(int padding);
175 
176 protected:
178  ~vtkTextRepresentation() override;
179 
180  // Initialize text actor
181  virtual void InitializeTextActor();
182 
183  // Check and adjust boundaries according to the size of the text
184  virtual void CheckTextBoundary();
185 
186  // the text to manage
189 
190  // observer to observe internal TextActor and TextProperty
191  vtkTextRepresentationObserver* Observer;
192 
193  int PaddingLeft = 0;
194  int PaddingRight = 0;
195  int PaddingTop = 0;
196  int PaddingBottom = 0;
197 
198 private:
200  void operator=(const vtkTextRepresentation&) = delete;
201 };
202 
203 #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:62
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:55
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:72
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:69
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
An actor that displays text.
Definition: vtkTextActor.h:56
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:39
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...