vtkVRQueue.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef vtkVRQueue_h
5 #define vtkVRQueue_h
6 
7 #include "vtkNew.h"
8 #include "vtkObject.h"
9 #include "vtkPVIncubatorCAVEInteractionStylesModule.h" // for export macro
10 #include "vtkType.h"
11 
12 #include <condition_variable>
13 #include <mutex>
14 #include <queue>
15 
16 #define BUTTON_EVENT 1
17 #define VALUATOR_EVENT 2
18 #define TRACKER_EVENT 3
19 #define VTK_VALUATOR_CHANNEL_MAX 128
20 
21 struct vtkTracker
22 {
23  long sensor; // Which sensor is reporting
24  double matrix[16]; // The matrix with transformations applied
25 };
26 
28 {
29  int num_channels; // how many channels
30  double channel[VTK_VALUATOR_CHANNEL_MAX]; // channel diliever valuator values
31 };
32 
33 struct vtkButton
34 {
35  int button; // Which button (zero-based)
36  int state; // New state (0 = off, 1 = on)
37 };
38 
40 {
44 };
45 
46 struct vtkVREvent
47 {
48  std::string connId;
49  std::string name; // Specified from configuration
50  unsigned int eventType;
52  vtkTypeInt64 timeStamp;
53 };
54 
55 class VTKPVINCUBATORCAVEINTERACTIONSTYLES_EXPORT vtkVRQueue : public vtkObject
56 {
57 public:
58  static vtkVRQueue* New();
59  vtkTypeMacro(vtkVRQueue, vtkObject);
60  void PrintSelf(ostream& os, vtkIndent indent) override;
61 
62  void Enqueue(const vtkVREvent& event);
63  bool IsEmpty() const;
64  bool TryDequeue(vtkVREvent& event);
65  bool TryDequeue(std::queue<vtkVREvent>& event);
66  void Dequeue(vtkVREvent& event);
67 
68 protected:
69  vtkVRQueue();
70  ~vtkVRQueue();
71 
72 private:
73  vtkVRQueue(const vtkVRQueue&) = delete;
74  void operator=(const vtkVRQueue&) = delete;
75 
76  std::queue<vtkVREvent> Queue;
77  mutable std::mutex Mutex;
78  std::condition_variable_any CondVar;
79 };
80 #endif // vtkVRQueue_h
int button
Definition: vtkVRQueue.h:35
vtkTypeInt64 timeStamp
Definition: vtkVRQueue.h:52
std::string name
Definition: vtkVRQueue.h:49
double matrix[16]
Definition: vtkVRQueue.h:24
long sensor
Definition: vtkVRQueue.h:23
vtkValuator valuator
Definition: vtkVRQueue.h:42
std::string connId
Definition: vtkVRQueue.h:48
vtkVREventCommonData data
Definition: vtkVRQueue.h:51
int num_channels
Definition: vtkVRQueue.h:29
vtkTracker tracker
Definition: vtkVRQueue.h:41
int state
Definition: vtkVRQueue.h:36
unsigned int eventType
Definition: vtkVRQueue.h:50
#define VTK_VALUATOR_CHANNEL_MAX
Definition: vtkVRQueue.h:19