VTK  9.3.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 
106 
110  virtual void SetRenderWindow(vtkRenderWindow* renderWindow);
112 
117  void Update();
118 
123  vtkGetMacro(WindowX, int);
124 
129  vtkGetMacro(WindowY, int);
130 
134  vtkGetMacro(WindowWidth, int);
135 
139  vtkGetMacro(WindowHeight, int);
140 
144  vtkGetMacro(StylusTargets, int);
145 
149  vtkGetMacro(HeadTargets, int);
150 
154  vtkGetMacro(SecondaryTargets, int);
155 
157 
160  vtkGetMacro(InterPupillaryDistance, float);
161  vtkSetClampMacro(InterPupillaryDistance, float, 0.f, 1.f);
163 
167  void SetClippingRange(const float nearPlane, const float farPlane);
168 
172  vtkGetMacro(ViewerScale, float);
173 
177  vtkGetMacro(NearPlane, float);
178 
182  vtkGetMacro(FarPlane, float);
183 
188  vtkGetObjectMacro(CenterEyeViewMatrix, vtkMatrix4x4);
189 
194  vtkMatrix4x4* GetStereoViewMatrix(bool leftEye);
195 
200  vtkGetObjectMacro(CenterEyeProjectionMatrix, vtkMatrix4x4);
201 
206  vtkMatrix4x4* GetStereoProjectionMatrix(bool leftEye);
207 
213  vtkGetObjectMacro(StylusMatrixColMajor, vtkMatrix4x4);
214 
220  vtkGetObjectMacro(StylusMatrixRowMajor, vtkMatrix4x4);
221 
226  vtkGetObjectMacro(StylusTransformRowMajor, vtkTransform);
227 
229  {
230  MiddleButton = 0,
231  RightButton = 1,
232  LeftButton = 2,
233  NumberOfButtons = 3
234  };
235 
237  {
238  Down = 0,
239  Pressed = 1,
240  Up = 2,
241  None = 3,
242  NumberOfStates = 4
243  };
244 
246 
249  vtkGetMacro(LeftButtonState, int);
250  vtkSetEnumMacro(LeftButtonState, ButtonState);
252 
254 
257  vtkGetMacro(MiddleButtonState, int);
258  vtkSetEnumMacro(MiddleButtonState, ButtonState);
260 
262 
265  vtkGetMacro(RightButtonState, int);
266  vtkSetEnumMacro(RightButtonState, ButtonState);
268 
269 protected:
271  ~vtkZSpaceSDKManager() override;
272 
273  vtkRenderWindow* RenderWindow = nullptr;
274 
281 
282  // In column major format, used by openGL
284 
285  // In row major format, used by VTK
288 
289  int WindowX = 0;
290  int WindowY = 0;
291  int WindowWidth = 0;
292  int WindowHeight = 0;
293 
294  // Store the type for each detected display devices
295  std::vector<std::string> Displays;
296  // The number of stylus
297  int StylusTargets = 0;
298  // The number of glasses
299  int HeadTargets = 0;
300  // Additional targets
301  int SecondaryTargets = 0;
302 
303  // Inter pupillary distance in meters
304  float InterPupillaryDistance = 0.056f;
305  float ViewerScale = 1.f;
306  // Camera near plane
307  float NearPlane = 0.0001f;
308  // Camera far plane
309  float FarPlane = 1000.f;
310 
311  // For interactions, store the state of each buttons
312  ButtonState LeftButtonState = None;
313  ButtonState MiddleButtonState = None;
314  ButtonState RightButtonState = None;
315  // Store buttons state to iterate over them
316  ButtonState* ButtonsState[NumberOfButtons] = { &MiddleButtonState, &RightButtonState,
317  &LeftButtonState };
318 
319 private:
320  vtkZSpaceSDKManager(const vtkZSpaceSDKManager&) = delete;
321  void operator=(const vtkZSpaceSDKManager&) = delete;
322 };
323 
324 VTK_ABI_NAMESPACE_END
325 
326 #endif
vtkNew< vtkTransform > StylusTransformRowMajor
std::vector< std::string > Displays
abstract base class for most VTK objects
Definition: vtkObject.h:51
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:30
vtkNew< vtkMatrix4x4 > CenterEyeViewMatrix
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkNew< vtkMatrix4x4 > LeftEyeViewMatrix
vtkNew< vtkMatrix4x4 > StylusMatrixRowMajor
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
vtkNew< vtkMatrix4x4 > RightEyeViewMatrix
vtkNew< vtkMatrix4x4 > LeftEyeProjectionMatrix
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:40
Abstract zSpace SDK manager class.
vtkNew< vtkMatrix4x4 > RightEyeProjectionMatrix
create a window for renderers to draw into