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 
39 {
43 };
44 
45 struct vtkVREvent
46 {
47  std::string connId;
48  std::string name; // Specified from configuration
49  unsigned int eventType;
51  unsigned int timeStamp;
52 };
53 
54 class VTKPVINCUBATORCAVEINTERACTIONSTYLES_EXPORT vtkVRQueue : public vtkObject
55 {
56 public:
57  static vtkVRQueue* New();
58  vtkTypeMacro(vtkVRQueue, vtkObject);
59  void PrintSelf(ostream& os, vtkIndent indent) override;
60 
61  void Enqueue(const vtkVREvent& event);
62  bool IsEmpty() const;
63  bool TryDequeue(vtkVREvent& event);
64  bool TryDequeue(std::queue<vtkVREvent>& event);
65  void Dequeue(vtkVREvent& event);
66 
67 protected:
68  vtkVRQueue();
69  ~vtkVRQueue();
70 
71 private:
72  vtkVRQueue(const vtkVRQueue&) = delete;
73  void operator=(const vtkVRQueue&) = delete;
74 
75  std::queue<vtkVREvent> Queue;
76  mutable std::mutex Mutex;
77  std::condition_variable_any CondVar;
78 };
79 #endif // vtkVRQueue_h
int button
Definition: vtkVRQueue.h:34
unsigned int timeStamp
Definition: vtkVRQueue.h:51
std::string name
Definition: vtkVRQueue.h:48
double matrix[16]
Definition: vtkVRQueue.h:23
long sensor
Definition: vtkVRQueue.h:22
vtkValuator valuator
Definition: vtkVRQueue.h:41
std::string connId
Definition: vtkVRQueue.h:47
vtkVREventCommonData data
Definition: vtkVRQueue.h:50
int num_channels
Definition: vtkVRQueue.h:28
vtkTracker tracker
Definition: vtkVRQueue.h:40
int state
Definition: vtkVRQueue.h:35
unsigned int eventType
Definition: vtkVRQueue.h:49
#define VTK_VALUATOR_CHANNEL_MAX
Definition: vtkVRQueue.h:18