VTK  9.7.1
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
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 
41 VTK_ABI_NAMESPACE_BEGIN
42 
43 class vtkRenderWindow;
44 class vtkCamera;
45 class vtkMatrix4x4;
46 class vtkTransform;
47 class vtkPVZSpaceView;
48 
49 class VTKRENDERINGZSPACE_EXPORT vtkZSpaceSDKManager : public vtkObject
50 {
51 public:
53  void PrintSelf(ostream& os, vtkIndent indent) override;
54 
60  static vtkZSpaceSDKManager* GetInstance();
61 
66  virtual void InitializeZSpace() = 0;
67 
72  virtual void UpdateViewport() = 0;
73 
77  virtual void UpdateTrackers() = 0;
78 
82  virtual void UpdateViewAndProjectionMatrix() = 0;
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(
118  unsigned int vtkNotUsed(leftText), unsigned int vtkNotUsed(rightText)) {};
119  virtual void GetPerEyeImageResolution(int* vtkNotUsed(width), int* vtkNotUsed(height)) {};
120  virtual void SetStereoDisplayEnabled(bool vtkNotUsed(enabled)) {};
121  virtual bool GetStereoDisplayEnabled() { return false; };
123 
125  {
126  QUAD_BUFFER_STEREO = 0,
127  STEREO_DISPLAY_API = 1
128  };
129 
130  virtual StereoDisplayMode GetStereoDisplayMode() { return QUAD_BUFFER_STEREO; };
131 
133 
137  virtual void SetRenderWindow(vtkRenderWindow* renderWindow);
139 
144  void Update();
145 
150  vtkGetMacro(WindowX, int);
151 
156  vtkGetMacro(WindowY, int);
157 
161  vtkGetMacro(WindowWidth, int);
162 
166  vtkGetMacro(WindowHeight, int);
167 
171  vtkGetMacro(StylusTargets, int);
172 
176  vtkGetMacro(HeadTargets, int);
177 
181  vtkGetMacro(SecondaryTargets, int);
182 
184 
187  vtkGetMacro(InterPupillaryDistance, float);
188  vtkSetClampMacro(InterPupillaryDistance, float, 0.f, 1.f);
190 
194  void SetClippingRange(const float nearPlane, const float farPlane);
195 
199  vtkGetMacro(ViewerScale, float);
200 
204  vtkGetMacro(NearPlane, float);
205 
209  vtkGetMacro(FarPlane, float);
210 
215  vtkGetObjectMacro(CenterEyeViewMatrix, vtkMatrix4x4);
216 
221  vtkMatrix4x4* GetStereoViewMatrix(bool leftEye);
222 
227  vtkGetObjectMacro(CenterEyeProjectionMatrix, vtkMatrix4x4);
228 
233  vtkMatrix4x4* GetStereoProjectionMatrix(bool leftEye);
234 
240  vtkGetObjectMacro(StylusMatrixColMajor, vtkMatrix4x4);
241 
247  vtkGetObjectMacro(StylusMatrixRowMajor, vtkMatrix4x4);
248 
253  vtkGetObjectMacro(StylusTransformRowMajor, vtkTransform);
254 
256  {
257  MiddleButton = 0,
258  RightButton = 1,
259  LeftButton = 2,
260  NumberOfButtons = 3
261  };
262 
266  static std::string ButtonToString(ButtonIds buttonId);
267 
269  {
270  Down = 0,
271  Pressed = 1,
272  Up = 2,
273  None = 3,
274  NumberOfStates = 4
275  };
276 
282  {
284  : Button(button)
285  , State(state)
286  {
287  }
288 
291  };
292 
294 
298  ButtonState GetButtonState(ButtonIds buttonId) const;
299  void SetButtonState(ButtonIds buttonId, ButtonState buttonState);
301 
303 
306  vtkGetMacro(LeftButtonState, int);
307  vtkSetEnumMacro(LeftButtonState, ButtonState);
309 
311 
314  vtkGetMacro(MiddleButtonState, int);
315  vtkSetEnumMacro(MiddleButtonState, ButtonState);
317 
319 
322  vtkGetMacro(RightButtonState, int);
323  vtkSetEnumMacro(RightButtonState, ButtonState);
325 
327 
331  bool GetUseDefaultBehavior(ButtonIds buttonId) const;
332  void SetUseDefaultBehavior(ButtonIds buttonId, bool enabled);
334 
335 protected:
337  ~vtkZSpaceSDKManager() override;
338 
339  vtkRenderWindow* RenderWindow = nullptr;
340 
347 
348  // In column major format, used by openGL
350 
351  // In row major format, used by VTK
354 
355  int WindowX = 0;
356  int WindowY = 0;
357  int WindowWidth = 0;
358  int WindowHeight = 0;
359 
360  // Store the type for each detected display devices
361  std::vector<std::string> Displays;
362  // The number of stylus
363  int StylusTargets = 0;
364  // The number of glasses
365  int HeadTargets = 0;
366  // Additional targets
367  int SecondaryTargets = 0;
368 
369  // Inter pupillary distance in meters
370  float InterPupillaryDistance = 0.056f;
371  float ViewerScale = 1.f;
372  // Camera near plane
373  float NearPlane = 0.0001f;
374  // Camera far plane
375  float FarPlane = 1000.f;
376 
377  // For interactions, store the state of each buttons
378  ButtonState LeftButtonState = None;
379  ButtonState MiddleButtonState = None;
380  ButtonState RightButtonState = None;
381  // Store buttons state to iterate over them
382  ButtonState* ButtonsState[NumberOfButtons] = { &MiddleButtonState, &RightButtonState,
383  &LeftButtonState };
384 
385  // Store whether or not to use the default behavior per button.
386  bool DefaultStylusButtonEventsEnabled[NumberOfButtons] = { true, true, true };
387 
388 private:
389  vtkZSpaceSDKManager(const vtkZSpaceSDKManager&) = delete;
390  void operator=(const vtkZSpaceSDKManager&) = delete;
391 };
392 
393 VTK_ABI_NAMESPACE_END
394 
395 #endif
vtkNew< vtkTransform > StylusTransformRowMajor
std::vector< std::string > Displays
abstract base class for most VTK objects
Definition: vtkObject.h:52
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
vtkNew< vtkMatrix4x4 > CenterEyeViewMatrix
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void EnableGraphicsBinding()
These functions are overridden by vtkZSpaceCoreCompatibility (specific to zSpace Inspire).
vtkNew< vtkMatrix4x4 > LeftEyeViewMatrix
virtual void SubmitFrame(unsigned int leftText, unsigned int rightText)
These functions are overridden by vtkZSpaceCoreCompatibility (specific to zSpace Inspire).
vtkNew< vtkMatrix4x4 > StylusMatrixRowMajor
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
virtual bool GetStereoDisplayEnabled()
These functions are overridden by vtkZSpaceCoreCompatibility (specific to zSpace Inspire).
virtual void ShutDown()
Shutdown the zSpace SDK (clean its internal state).
vtkNew< vtkMatrix4x4 > RightEyeViewMatrix
vtkNew< vtkMatrix4x4 > LeftEyeProjectionMatrix
virtual void SetStereoDisplayEnabled(bool enabled)
These functions are overridden by vtkZSpaceCoreCompatibility (specific to zSpace Inspire).
Event data structure used for sending vtkCommand::UserEvent considered here also as custom stylus eve...
vtkNew< vtkMatrix4x4 > CenterEyeProjectionMatrix
vtkNew< vtkMatrix4x4 > StylusMatrixColMajor
a simple class to control print indentation
Definition: vtkIndent.h:28
a virtual camera for 3D rendering
Definition: vtkCamera.h:41
!< For HCURL
Abstract zSpace SDK manager class.
vtkNew< vtkMatrix4x4 > RightEyeProjectionMatrix
create a window for renderers to draw into
virtual StereoDisplayMode GetStereoDisplayMode()
StylusEventData(ButtonIds button, ButtonState state)
virtual void GetPerEyeImageResolution(int *width, int *height)
These functions are overridden by vtkZSpaceCoreCompatibility (specific to zSpace Inspire).