VTK  9.1.0
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 =========================================================================*/
46 #ifndef vtkTextRepresentation_h
47 #define vtkTextRepresentation_h
48 
50 #include "vtkInteractionWidgetsModule.h" // For export macro
51 
52 class vtkRenderer;
53 class vtkTextActor;
54 class vtkTextProperty;
55 class vtkTextRepresentationObserver;
56 
57 class VTKINTERACTIONWIDGETS_EXPORT vtkTextRepresentation : public vtkBorderRepresentation
58 {
59 public:
64 
66 
70  void PrintSelf(ostream& os, vtkIndent indent) override;
72 
74 
78  void SetTextActor(vtkTextActor* textActor);
79  vtkGetObjectMacro(TextActor, vtkTextActor);
81 
83 
86  void SetText(const char* text);
87  const char* GetText();
89 
93  void BuildRepresentation() override;
94  void GetSize(double size[2]) override
95  {
96  size[0] = 2.0;
97  size[1] = 2.0;
98  }
99 
101 
107  int RenderOverlay(vtkViewport*) override;
112 
113  enum
114  {
115  AnyLocation = 0,
121  UpperCenter
122  };
123 
125 
136  virtual void SetWindowLocation(int enumLocation);
137  vtkGetMacro(WindowLocation, int);
139 
141 
145  void SetPosition(double x, double y) override;
146  void SetPosition(double pos[2]) override { this->SetPosition(pos[0], pos[1]); }
148 
150 
153  void ExecuteTextPropertyModifiedEvent(vtkObject* obj, unsigned long enumEvent, void* p);
154  void ExecuteTextActorModifiedEvent(vtkObject* obj, unsigned long enumEvent, void* p);
156 
158 
163  vtkSetClampMacro(PaddingLeft, int, 0, 4000);
164  vtkGetMacro(PaddingLeft, int);
166 
168 
173  vtkSetClampMacro(PaddingRight, int, 0, 4000);
174  vtkGetMacro(PaddingRight, int);
176 
178 
183  vtkSetClampMacro(PaddingTop, int, 0, 4000);
184  vtkGetMacro(PaddingTop, int);
186 
188 
193  vtkSetClampMacro(PaddingBottom, int, 0, 4000);
194  vtkGetMacro(PaddingBottom, int);
196 
198 
203  void SetPadding(int padding);
205 
206 protected:
209 
210  // Initialize text actor
211  virtual void InitializeTextActor();
212 
213  // Check and adjust boundaries according to the size of the text
214  virtual void CheckTextBoundary();
215 
216  // the text to manage
219 
220  // Window location by enumeration
222  virtual void UpdateWindowLocation();
223 
224  // observer to observe internal TextActor and TextProperty
225  vtkTextRepresentationObserver* Observer;
226 
227  int PaddingLeft = 0;
228  int PaddingRight = 0;
229  int PaddingTop = 0;
230  int PaddingBottom = 0;
231 
232 private:
234  void operator=(const vtkTextRepresentation&) = delete;
235 };
236 
237 #endif
vtkTextRepresentation::SetPosition
void SetPosition(double pos[2]) override
Set the text position, by overriding the same function of vtkBorderRepresentation so that the Modifie...
Definition: vtkTextRepresentation.h:146
vtkTextRepresentation::LowerCenter
@ LowerCenter
Definition: vtkTextRepresentation.h:118
vtkTextRepresentation::UpperLeftCorner
@ UpperLeftCorner
Definition: vtkTextRepresentation.h:119
vtkBorderRepresentation
represent a vtkBorderWidget
Definition: vtkBorderRepresentation.h:107
vtkTextRepresentation::GetActors2D
void GetActors2D(vtkPropCollection *) override
These methods are necessary to make this representation behave as a vtkProp.
vtkTextRepresentation::UpperRightCorner
@ UpperRightCorner
Definition: vtkTextRepresentation.h:120
vtkTextRepresentation::~vtkTextRepresentation
~vtkTextRepresentation() override
vtkTextRepresentation::vtkTextRepresentation
vtkTextRepresentation()
vtkTextRepresentation::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
These methods are necessary to make this representation behave as a vtkProp.
vtkTextRepresentation::SetWindowLocation
virtual void SetWindowLocation(int enumLocation)
Set the text position, by enumeration ( AnyLocation = 0, LowerLeftCorner, LowerRightCorner,...
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:82
vtkTextRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Standard VTK methods.
vtkTextRepresentation::LowerLeftCorner
@ LowerLeftCorner
Definition: vtkTextRepresentation.h:116
vtkTextRepresentation::Observer
vtkTextRepresentationObserver * Observer
Definition: vtkTextRepresentation.h:225
vtkTextRepresentation::BuildRepresentation
void BuildRepresentation() override
Satisfy the superclasses API.
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
vtkTextRepresentation::SetTextActor
void SetTextActor(vtkTextActor *textActor)
Specify the vtkTextActor to manage.
vtkTextRepresentation::HasTranslucentPolygonalGeometry
vtkTypeBool HasTranslucentPolygonalGeometry() override
These methods are necessary to make this representation behave as a vtkProp.
vtkTextRepresentation::TextProperty
vtkTextProperty * TextProperty
Definition: vtkTextRepresentation.h:218
vtkBorderRepresentation.h
vtkTextRepresentation::ExecuteTextPropertyModifiedEvent
void ExecuteTextPropertyModifiedEvent(vtkObject *obj, unsigned long enumEvent, void *p)
Internal.
vtkTextRepresentation::SetPosition
void SetPosition(double x, double y) override
Set the text position, by overriding the same function of vtkBorderRepresentation so that the Modifie...
vtkTextRepresentation
represent text for vtkTextWidget
Definition: vtkTextRepresentation.h:58
vtkTextRepresentation::GetText
const char * GetText()
Get/Set the text string display by this representation.
vtkTextRepresentation::ExecuteTextActorModifiedEvent
void ExecuteTextActorModifiedEvent(vtkObject *obj, unsigned long enumEvent, void *p)
Internal.
vtkTextRepresentation::RenderOpaqueGeometry
int RenderOpaqueGeometry(vtkViewport *) override
These methods are necessary to make this representation behave as a vtkProp.
vtkTextRepresentation::LowerRightCorner
@ LowerRightCorner
Definition: vtkTextRepresentation.h:117
vtkTextActor
An actor that displays text.
Definition: vtkTextActor.h:160
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkX3D::size
@ size
Definition: vtkX3D.h:259
vtkTextRepresentation::UpdateWindowLocation
virtual void UpdateWindowLocation()
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:47
vtkTextRepresentation::InitializeTextActor
virtual void InitializeTextActor()
vtkTextRepresentation::WindowLocation
int WindowLocation
Definition: vtkTextRepresentation.h:221
vtkTextProperty
represent text properties.
Definition: vtkTextProperty.h:143
vtkTextRepresentation::RenderTranslucentPolygonalGeometry
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
These methods are necessary to make this representation behave as a vtkProp.
vtkTextRepresentation::SetText
void SetText(const char *text)
Get/Set the text string display by this representation.
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:182
vtkTextRepresentation::CheckTextBoundary
virtual void CheckTextBoundary()
vtkTextRepresentation::SetPadding
void SetPadding(int padding)
Set the padding between the text and the left/right/top/bottom border, in pixels unit.
vtkTextRepresentation::New
static vtkTextRepresentation * New()
Instantiate class.
vtkTextRepresentation::TextActor
vtkTextActor * TextActor
Definition: vtkTextRepresentation.h:217
vtkTextRepresentation::GetSize
void GetSize(double size[2]) override
Subclasses should implement these methods.
Definition: vtkTextRepresentation.h:94
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:85
vtkTextRepresentation::RenderOverlay
int RenderOverlay(vtkViewport *) override
These methods are necessary to make this representation behave as a vtkProp.
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69