VTK: Rendering/VR/vtkVRControlsHelper.h Source File

| VTK 9.3.1

vtkVRControlsHelper.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
12 #ifndef vtkVRControlsHelper_h
13 #define vtkVRControlsHelper_h
14
15 #include "vtkEventData.h" // for vtkEventDataDevice
16 #include "vtkNew.h" // for iVar
17 #include "vtkProp.h"
18 #include "vtkRenderingVRModule.h" // For export macro
19 #include "vtkWeakPointer.h" // needed for vtkWeakPointer iVar.
20 #include <string> // for std::string
21
22 VTK_ABI_NAMESPACE_BEGIN
23 class vtkActor;
24 class vtkCallbackCommand;
25 class vtkLineSource;
26 class vtkPolyDataMapper;
27 class vtkRenderer;
28 class vtkTextActor3D;
29 class vtkTransform;
30
31 class VTKRENDERINGVR_EXPORT vtkVRControlsHelper : public vtkProp
32 {
33 public:
35
38 vtkTypeMacro(vtkVRControlsHelper, vtkProp);
39 void PrintSelf(ostream& os, vtkIndent indent) override;
41
42 enum ButtonSides
43 {
44 Back = -1,
45 Front = 1
46 };
47
48 enum DrawSides
49 {
50 Left = -1,
51 Right = 1
52 };
53
55
58 void BuildRepresentation();
59 void UpdateRepresentation();
61
63
66 void ReleaseGraphicsResources(vtkWindow*) override;
67 int RenderOpaqueGeometry(vtkViewport*) override;
68 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
69 vtkTypeBool HasTranslucentPolygonalGeometry() override;
71
73
76 void SetText(const std::string& str);
78
79 void SetTooltipInfo(const char* s, int buttonSide, int drawSide, const char* txt)
80 {
81 if (!s || !txt)
82 {
83 return;
84 }
85 this->ComponentName = std::string(s);
86 this->DrawSide = drawSide;
87 this->ButtonSide = buttonSide;
88 this->SetText(std::string(txt));
89 }
90
91 void SetEnabled(bool enabled);
92 vtkGetMacro(Enabled, bool);
93 vtkBooleanMacro(Enabled, bool);
94
95 void SetDevice(vtkEventDataDevice val);
96
97 virtual void SetRenderer(vtkRenderer* ren);
98 virtual vtkRenderer* GetRenderer();
99
100 protected:
101 vtkVRControlsHelper();
102 ~vtkVRControlsHelper() override;
103
104 double FrameSize[2];
105
106 // The text
107 vtkTextActor3D* TextActor;
108 std::string Text;
109
110 // The line
111 vtkLineSource* LineSource;
112 vtkPolyDataMapper* LineMapper;
113 vtkActor* LineActor;
114
115 vtkEventDataDevice Device;
116
117 // Tooltip parameters
118 std::string ComponentName;
119 int DrawSide; // Left/Right
120 int ButtonSide; // Front/Back
121
122 bool Enabled;
123
124 double ControlPositionLC[3];
125
126 // The renderer in which this widget is placed
127 vtkWeakPointer<vtkRenderer> Renderer;
128
129 vtkCallbackCommand* MoveCallbackCommand;
130 unsigned long ObserverTag;
131 static void MoveEvent(vtkObject* object, unsigned long event, void* clientdata, void* calldata);
132
137 virtual void InitControlPosition() = 0;
138
139 vtkNew<vtkTransform> TempTransform;
140 double LastPhysicalTranslation[3];
141 double LastEventPosition[3];
142 double LastEventOrientation[4];
143 bool NeedUpdate;
144 bool LabelVisible;
145
146 private:
147 vtkVRControlsHelper(const vtkVRControlsHelper&) = delete;
148 void operator=(const vtkVRControlsHelper&) = delete;
149 };
150
151 VTK_ABI_NAMESPACE_END
152 #endif
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:49
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:62
vtkNew< vtkTransform >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:42
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:55
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:71
vtkTextActor3D
An actor that displays text.
Definition: vtkTextActor3D.h:37
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
vtkVRControlsHelper
Tooltip helper explaining controls Helper class to draw one tooltip per button around the controller.
Definition: vtkVRControlsHelper.h:32
vtkVRControlsHelper::SetEnabled
void SetEnabled(bool enabled)
vtkVRControlsHelper::TextActor
vtkTextActor3D * TextActor
Definition: vtkVRControlsHelper.h:107
vtkVRControlsHelper::DrawSide
int DrawSide
Definition: vtkVRControlsHelper.h:119
vtkVRControlsHelper::ComponentName
std::string ComponentName
Definition: vtkVRControlsHelper.h:118
vtkVRControlsHelper::RenderTranslucentPolygonalGeometry
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting the rendering process.
vtkVRControlsHelper::DrawSides
DrawSides
Definition: vtkVRControlsHelper.h:49
vtkVRControlsHelper::ReleaseGraphicsResources
void ReleaseGraphicsResources(vtkWindow *) override
Methods supporting the rendering process.
vtkVRControlsHelper::InitControlPosition
virtual void InitControlPosition()=0
Must be overridden in subclasses to init the member variable ControlPositionLC to position the toolti...
vtkVRControlsHelper::MoveEvent
static void MoveEvent(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkVRControlsHelper::MoveCallbackCommand
vtkCallbackCommand * MoveCallbackCommand
Definition: vtkVRControlsHelper.h:129
vtkVRControlsHelper::TempTransform
vtkNew< vtkTransform > TempTransform
Definition: vtkVRControlsHelper.h:139
vtkVRControlsHelper::Enabled
bool Enabled
Definition: vtkVRControlsHelper.h:122
vtkVRControlsHelper::SetTooltipInfo
void SetTooltipInfo(const char *s, int buttonSide, int drawSide, const char *txt)
Definition: vtkVRControlsHelper.h:79
vtkVRControlsHelper::LabelVisible
bool LabelVisible
Definition: vtkVRControlsHelper.h:144
vtkVRControlsHelper::ButtonSides
ButtonSides
Definition: vtkVRControlsHelper.h:43
vtkVRControlsHelper::ObserverTag
unsigned long ObserverTag
Definition: vtkVRControlsHelper.h:130
vtkVRControlsHelper::RenderOpaqueGeometry
int RenderOpaqueGeometry(vtkViewport *) override
Methods supporting the rendering process.
vtkVRControlsHelper::ButtonSide
int ButtonSide
Definition: vtkVRControlsHelper.h:120
vtkVRControlsHelper::Renderer
vtkWeakPointer< vtkRenderer > Renderer
Definition: vtkVRControlsHelper.h:127
vtkVRControlsHelper::SetDevice
void SetDevice(vtkEventDataDevice val)
vtkVRControlsHelper::vtkVRControlsHelper
vtkVRControlsHelper()
vtkVRControlsHelper::Device
vtkEventDataDevice Device
Definition: vtkVRControlsHelper.h:115
vtkVRControlsHelper::SetRenderer
virtual void SetRenderer(vtkRenderer *ren)
vtkVRControlsHelper::Text
std::string Text
Definition: vtkVRControlsHelper.h:108
vtkVRControlsHelper::NeedUpdate
bool NeedUpdate
Definition: vtkVRControlsHelper.h:143
vtkVRControlsHelper::LineMapper
vtkPolyDataMapper * LineMapper
Definition: vtkVRControlsHelper.h:112
vtkVRControlsHelper::SetText
void SetText(const std::string &str)
Set Tooltip text (used by TextActor)
vtkVRControlsHelper::LineActor
vtkActor * LineActor
Definition: vtkVRControlsHelper.h:113
vtkVRControlsHelper::~vtkVRControlsHelper
~vtkVRControlsHelper() override
vtkVRControlsHelper::BuildRepresentation
void BuildRepresentation()
Methods to interface with the vtkVRPanelWidget.
vtkVRControlsHelper::GetRenderer
virtual vtkRenderer * GetRenderer()
vtkVRControlsHelper::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
vtkVRControlsHelper::HasTranslucentPolygonalGeometry
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting the rendering process.
vtkVRControlsHelper::UpdateRepresentation
void UpdateRepresentation()
Methods to interface with the vtkVRPanelWidget.
vtkVRControlsHelper::LineSource
vtkLineSource * LineSource
Definition: vtkVRControlsHelper.h:111
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:54
vtkWeakPointer< vtkRenderer >
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkX3D::enabled
@ enabled
Definition: vtkX3D.h:259
vtkX3D::string
@ string
Definition: vtkX3D.h:490
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
vtkEventData.h
vtkEventDataDevice
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:15
vtkNew.h
vtkProp.h
vtkWeakPointer.h