VTK  9.6.20260112
vtkZSpaceSDKManager.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
31
32#ifndef vtkZSpaceSDKManager_h
33#define vtkZSpaceSDKManager_h
34
35#include "vtkNew.h" // for vtkNew
36#include "vtkObject.h"
37#include "vtkRenderingZSpaceModule.h" // for export macro
38
39#include <vector> // for std::vector
40
41VTK_ABI_NAMESPACE_BEGIN
42
43class vtkRenderWindow;
44class vtkCamera;
45class vtkMatrix4x4;
46class vtkTransform;
47class vtkPVZSpaceView;
48
49class VTKRENDERINGZSPACE_EXPORT vtkZSpaceSDKManager : public vtkObject
50{
51public:
53 void PrintSelf(ostream& os, vtkIndent indent) override;
54
61
66 virtual void InitializeZSpace() = 0;
67
72 virtual void UpdateViewport() = 0;
73
77 virtual void UpdateTrackers() = 0;
78
83
87 virtual void UpdateButtonState() = 0;
88
93 virtual void CalculateFrustumFit(
94 const double bounds[6], double position[3], double viewUp[3]) = 0;
95
97
101 virtual void BeginFrame() = 0;
102 virtual void EndFrame() = 0;
104
109 virtual void ShutDown(){};
110
112
116 virtual void EnableGraphicsBinding(){};
117 virtual void SubmitFrame(unsigned int vtkNotUsed(leftText), unsigned int vtkNotUsed(rightText)){};
118 virtual void GetPerEyeImageResolution(int* vtkNotUsed(width), int* vtkNotUsed(height)){};
119 virtual void SetStereoDisplayEnabled(bool vtkNotUsed(enabled)){};
120 virtual bool GetStereoDisplayEnabled() { return false; };
122
128
130
132
136 virtual void SetRenderWindow(vtkRenderWindow* renderWindow);
138
143 void Update();
144
149 vtkGetMacro(WindowX, int);
150
155 vtkGetMacro(WindowY, int);
156
160 vtkGetMacro(WindowWidth, int);
161
165 vtkGetMacro(WindowHeight, int);
166
170 vtkGetMacro(StylusTargets, int);
171
175 vtkGetMacro(HeadTargets, int);
176
180 vtkGetMacro(SecondaryTargets, int);
181
183
186 vtkGetMacro(InterPupillaryDistance, float);
187 vtkSetClampMacro(InterPupillaryDistance, float, 0.f, 1.f);
189
193 void SetClippingRange(const float nearPlane, const float farPlane);
194
198 vtkGetMacro(ViewerScale, float);
199
203 vtkGetMacro(NearPlane, float);
204
208 vtkGetMacro(FarPlane, float);
209
215
221
227
233
240
247
253
261
265 static std::string ButtonToString(ButtonIds buttonId);
266
268 {
269 Down = 0,
271 Up = 2,
272 None = 3,
274 };
275
281 {
283 : Button(button)
284 , State(state)
285 {
286 }
287
290 };
291
293
298 void SetButtonState(ButtonIds buttonId, ButtonState buttonState);
300
302
305 vtkGetMacro(LeftButtonState, int);
308
310
313 vtkGetMacro(MiddleButtonState, int);
316
318
321 vtkGetMacro(RightButtonState, int);
324
326
330 bool GetUseDefaultBehavior(ButtonIds buttonId) const;
331 void SetUseDefaultBehavior(ButtonIds buttonId, bool enabled);
333
334protected:
337
339
346
347 // In column major format, used by openGL
349
350 // In row major format, used by VTK
353
354 int WindowX = 0;
355 int WindowY = 0;
356 int WindowWidth = 0;
358
359 // Store the type for each detected display devices
360 std::vector<std::string> Displays;
361 // The number of stylus
363 // The number of glasses
364 int HeadTargets = 0;
365 // Additional targets
367
368 // Inter pupillary distance in meters
370 float ViewerScale = 1.f;
371 // Camera near plane
372 float NearPlane = 0.0001f;
373 // Camera far plane
374 float FarPlane = 1000.f;
375
376 // For interactions, store the state of each buttons
380 // Store buttons state to iterate over them
383
384 // Store whether or not to use the default behavior per button.
386
387private:
389 void operator=(const vtkZSpaceSDKManager&) = delete;
390};
391
392VTK_ABI_NAMESPACE_END
393
394#endif
a virtual camera for 3D rendering
Definition vtkCamera.h:151
a simple class to control print indentation
Definition vtkIndent.h:108
represent and manipulate 4x4 transformation matrices
Allocate and hold a VTK object.
Definition vtkNew.h:167
create a window for renderers to draw into
describes linear transformations via a 4x4 matrix
Abstract zSpace SDK manager class.
ButtonState * ButtonsState[NumberOfButtons]
bool GetUseDefaultBehavior(ButtonIds buttonId) const
Set whether or not to use the default behavior for the given buttonId.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SubmitFrame(unsigned int leftText, unsigned int rightText)
These functions are overridden by vtkZSpaceCoreCompatibility (specific to zSpace Inspire).
vtkNew< vtkMatrix4x4 > LeftEyeProjectionMatrix
bool DefaultStylusButtonEventsEnabled[NumberOfButtons]
static std::string ButtonToString(ButtonIds buttonId)
Helper function to convert a button enum value to a string.
virtual void EndFrame()=0
Notify the zSpace SDK for the beginning/end of a frame (vtkZSpaceCoreCompatibility only)
virtual void SetRenderWindow(vtkRenderWindow *renderWindow)
Set the render windwow the manager makes viewport computations from.
vtkNew< vtkMatrix4x4 > RightEyeProjectionMatrix
virtual void InitializeZSpace()=0
Initialize the zSpace SDK and check for zSpace devices : the display, the stylus and the head tracker...
vtkSetEnumMacro(RightButtonState, ButtonState)
Get/Set the state of the right button of the stylus.
vtkMatrix4x4 * GetStereoViewMatrix(bool leftEye)
Get the zSpace view matrix for the right or left eye in row major format (VTK format)
void Update()
Update the viewport, the trackers and the camera matrix by calling the zSpace SDK.
~vtkZSpaceSDKManager() override
vtkNew< vtkMatrix4x4 > CenterEyeProjectionMatrix
virtual void ShutDown()
Shutdown the zSpace SDK (clean its internal state).
vtkNew< vtkMatrix4x4 > StylusMatrixRowMajor
vtkNew< vtkMatrix4x4 > StylusMatrixColMajor
virtual StereoDisplayMode GetStereoDisplayMode()
vtkNew< vtkMatrix4x4 > LeftEyeViewMatrix
ButtonState GetButtonState(ButtonIds buttonId) const
Set/Get the button state associated to the given buttonId.
virtual void UpdateButtonState()=0
Update the stylus buttons state.
void SetButtonState(ButtonIds buttonId, ButtonState buttonState)
Set/Get the button state associated to the given buttonId.
virtual void UpdateTrackers()=0
Update the position of the stylus and head trackers.
vtkSetEnumMacro(LeftButtonState, ButtonState)
Get/Set the state of the left button of the stylus.
virtual void SetStereoDisplayEnabled(bool enabled)
These functions are overridden by vtkZSpaceCoreCompatibility (specific to zSpace Inspire).
vtkRenderWindow * RenderWindow
void SetUseDefaultBehavior(ButtonIds buttonId, bool enabled)
Set whether or not to use the default behavior for the given buttonId.
virtual void EnableGraphicsBinding()
These functions are overridden by vtkZSpaceCoreCompatibility (specific to zSpace Inspire).
virtual void UpdateViewport()=0
Update the zSpace viewport position and size based on the position and size of the application window...
virtual bool GetStereoDisplayEnabled()
These functions are overridden by vtkZSpaceCoreCompatibility (specific to zSpace Inspire).
void SetClippingRange(const float nearPlane, const float farPlane)
Set the near and far plane.
vtkMatrix4x4 * GetStereoProjectionMatrix(bool leftEye)
Get the zSpace projection matrix for the right or left eye in row major format (VTK format)
virtual void BeginFrame()=0
Notify the zSpace SDK for the beginning/end of a frame (vtkZSpaceCoreCompatibility only)
virtual void CalculateFrustumFit(const double bounds[6], double position[3], double viewUp[3])=0
Let zSpace compute the viewer scale, camera position and camera view up from the input bounds.
virtual void GetPerEyeImageResolution(int *width, int *height)
These functions are overridden by vtkZSpaceCoreCompatibility (specific to zSpace Inspire).
vtkNew< vtkMatrix4x4 > RightEyeViewMatrix
vtkSetEnumMacro(MiddleButtonState, ButtonState)
Get/Set the state of the middle button of the stylus.
vtkNew< vtkTransform > StylusTransformRowMajor
std::vector< std::string > Displays
static vtkZSpaceSDKManager * GetInstance()
Return the singleton instance (with no reference counting) of a vtkZSpaceCoreSDKManager or vtkZSpaceC...
virtual void UpdateViewAndProjectionMatrix()=0
Update the zSpace view and projection matrix for each eye.
vtkNew< vtkMatrix4x4 > CenterEyeViewMatrix
StylusEventData(ButtonIds button, ButtonState state)