-
Notifications
You must be signed in to change notification settings - Fork 4
/
vtkRenciMultiTouch.h
138 lines (109 loc) · 3.34 KB
/
vtkRenciMultiTouch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*=========================================================================
Name: vtkRenciMultiTouch.h
Author: David Borland, The Renaissance Computing Institute (RENCI)
Copyright: The Renaissance Computing Institute (RENCI)
License: Licensed under the RENCI Open Source Software License v. 1.0.
See included License.txt or
http://www.renci.org/resources/open-source-software-license
for details.
=========================================================================*/
// .NAME vtkRenciMultiTouch
// .SECTION Description
// vtkRenciMultiTouch interfaces with multi-touch devices developed at
// the Renaissance Computing Institute
// (http://vis.renci.org/multitouch/).
// .SECTION see also
// vtkInteractionDeviceManager vtkDeviceInteractorStyle
#ifndef __vtkRenciMultiTouch_h
#define __vtkRenciMultiTouch_h
#include "vtkInteractionDeviceConfigure.h"
#include "vtkInteractionDevice.h"
#ifdef WIN32
# include "vtkWindows.h"
# include "winsock.h"
#endif
#include "vtkCommand.h"
// Structure defining a touch point. Gestures can have multiple touch points.
struct TouchPoint
{
int Id;
double Location[2];
double Direction[2];
int MoveLocation;
};
// Holds vtkstd member variables, which must be hidden
class vtkRenciMultiTouchInternals;
class VTK_INTERACTIONDEVICE_EXPORT vtkRenciMultiTouch : public vtkInteractionDevice
{
public:
static vtkRenciMultiTouch* New();
vtkTypeRevisionMacro(vtkRenciMultiTouch,vtkInteractionDevice);
void PrintSelf(ostream&, vtkIndent);
// Description:
// Initialize the device
virtual int Initialize();
// Description:
// Receive updates from the device
virtual void Update();
// Description:
// Invoke events for observers to listen for
virtual void InvokeInteractionEvent();
// Description:
// Set socket information. Must be set before Initialize().
vtkSetStringMacro(HostName);
vtkSetMacro(Port,int);
// Description:
// Get methods for gesture data
int GetNumberOfTouchPoints();
const TouchPoint& GetTouchPoint(int which);
// Enumeration for multi-touch events
//BTX
enum RenciMultiTouchEventIds {
OneTouchEvent = vtkCommand::UserEvent,
OneDragEvent,
TwoTouchEvent,
TwoDragEvent,
ThreeTouchEvent,
ThreeDragEvent,
FourTouchEvent,
FourDragEvent,
FiveTouchEvent,
FiveDragEvent,
SixTouchEvent,
SixDragEvent,
ZoomEvent,
TranslateXEvent,
TranslateYEvent,
TranslateZEvent,
RotateXEvent,
RotateYEvent,
RotateZEvent,
ReleaseEvent
};
//ETX
protected:
vtkRenciMultiTouch();
~vtkRenciMultiTouch();
// The socket being read
char* HostName;
int Port;
int SocketDescriptor;
vtkRenciMultiTouchInternals* Internals;
// Description:
// Parse the buffer
void ParseBuffer(char* buffer, int numBytes);
// Description:
// Clear the current gesture
void ClearGesture();
// Description:
// Socket code. vtkSocket currently uses TCP, so leave this code in here for now.
int CreateSocket();
int Receive(void* data, int length);
int ReadInt(char** buffer);
double ReadDouble(char** buffer);
double Ntohd(double d);
private:
vtkRenciMultiTouch(const vtkRenciMultiTouch&); // Not implemented.
void operator=(const vtkRenciMultiTouch&); // Not implemented.
};
#endif