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 
11 #include <condition_variable>
12 #include <mutex>
13 #include <queue>
14 
15 #define BUTTON_EVENT 1
16 #define VALUATOR_EVENT 2
17 #define TRACKER_EVENT 3
18 #define VTK_VALUATOR_CHANNEL_MAX 128
19 
20 struct vtkTracker
21 {
22  long sensor; // Which sensor is reporting
23  double matrix[16]; // The matrix with transformations applied
24 };
25 
27 {
28  int num_channels; // how many channels
29  double channel[VTK_VALUATOR_CHANNEL_MAX]; // channel diliever valuator values
30 };
31 
32 struct vtkButton
33 {
34  int button; // Which button (zero-based)
35  int state; // New state (0 = off, 1 = on)
36 };
37 
42 };
43 
44 struct vtkVREvent
45 {
46  std::string connId;
47  std::string name; // Specified from configuration
48  unsigned int eventType;
50  unsigned int timeStamp;
51 };
52 
53 class VTKPVINCUBATORCAVEINTERACTIONSTYLES_EXPORT vtkVRQueue : public vtkObject
54 {
55 public:
56  static vtkVRQueue* New();
57  vtkTypeMacro(vtkVRQueue, vtkObject);
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
60  void Enqueue(const vtkVREvent& event);
61  bool IsEmpty() const;
62  bool TryDequeue(vtkVREvent& event);
63  bool TryDequeue(std::queue<vtkVREvent>& event);
64  void Dequeue(vtkVREvent& event);
65 
66 protected:
67  vtkVRQueue();
68  ~vtkVRQueue();
69 
70 private:
71  vtkVRQueue(const vtkVRQueue&) = delete;
72  void operator=(const vtkVRQueue&) = delete;
73 
74  std::queue<vtkVREvent> Queue;
75  mutable std::mutex Mutex;
76  std::condition_variable_any CondVar;
77 };
78 #endif // vtkVRQueue_h
int button
Definition: vtkVRQueue.h:34
unsigned int timeStamp
Definition: vtkVRQueue.h:50
std::string name
Definition: vtkVRQueue.h:47
double matrix[16]
Definition: vtkVRQueue.h:23
long sensor
Definition: vtkVRQueue.h:22
vtkValuator valuator
Definition: vtkVRQueue.h:40
std::string connId
Definition: vtkVRQueue.h:46
vtkVREventCommonData data
Definition: vtkVRQueue.h:49
int num_channels
Definition: vtkVRQueue.h:28
vtkTracker tracker
Definition: vtkVRQueue.h:39
int state
Definition: vtkVRQueue.h:35
unsigned int eventType
Definition: vtkVRQueue.h:48
#define VTK_VALUATOR_CHANNEL_MAX
Definition: vtkVRQueue.h:18