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
vtkObjectBase::operator=
void operator=(const vtkObjectBase &)
vtkVREvent::timeStamp
unsigned int timeStamp
Definition: vtkVRQueue.h:50
vtkVREventCommonData
Definition: vtkVRQueue.h:38
vtkButton::button
int button
Definition: vtkVRQueue.h:34
vtkObject::New
static vtkObject * New()
vtkVREventCommonData::button
vtkButton button
Definition: vtkVRQueue.h:41
vtkTracker::matrix
double matrix[16]
Definition: vtkVRQueue.h:23
vtkTracker
Definition: vtkVRQueue.h:20
vtkValuator::channel
double channel[VTK_VALUATOR_CHANNEL_MAX]
Definition: vtkVRQueue.h:29
vtkVREventCommonData::tracker
vtkTracker tracker
Definition: vtkVRQueue.h:39
vtkObject
vtkVREvent::name
std::string name
Definition: vtkVRQueue.h:47
VTK_VALUATOR_CHANNEL_MAX
#define VTK_VALUATOR_CHANNEL_MAX
Definition: vtkVRQueue.h:18
vtkTracker::sensor
long sensor
Definition: vtkVRQueue.h:22
vtkVREvent::data
vtkVREventCommonData data
Definition: vtkVRQueue.h:49
vtkVREvent::connId
std::string connId
Definition: vtkVRQueue.h:46
vtkButton
Definition: vtkVRQueue.h:32
vtkIndent
vtkObject.h
vtkButton::state
int state
Definition: vtkVRQueue.h:35
vtkVREventCommonData::valuator
vtkValuator valuator
Definition: vtkVRQueue.h:40
vtkVREvent
Definition: vtkVRQueue.h:44
vtkNew.h
vtkVREvent::eventType
unsigned int eventType
Definition: vtkVRQueue.h:48
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
vtkValuator::num_channels
int num_channels
Definition: vtkVRQueue.h:28
vtkValuator
Definition: vtkVRQueue.h:26
vtkVRQueue
Definition: vtkVRQueue.h:53