-
Notifications
You must be signed in to change notification settings - Fork 4
/
vtkDeviceInteractor.cxx
146 lines (115 loc) · 4.67 KB
/
vtkDeviceInteractor.cxx
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
139
140
141
142
143
144
145
146
/*=========================================================================
Name: vtkDeviceInteractor.cxx
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.
=========================================================================*/
#include "vtkDeviceInteractor.h"
#include "vtkCommand.h"
#include "vtkDeviceInteractorStyle.h"
#include "vtkInteractionDevice.h"
#include "vtkObjectFactory.h"
#include "vtkstd/vector"
class vtkDeviceInteractorInternals
{
public:
vtkstd::vector<vtkInteractionDevice*> InteractionDevices;
vtkstd::vector<vtkDeviceInteractorStyle*> DeviceInteractorStyles;
};
vtkCxxRevisionMacro(vtkDeviceInteractor, "$Revision: 1.0 $");
vtkStandardNewMacro(vtkDeviceInteractor);
//----------------------------------------------------------------------------
vtkDeviceInteractor::vtkDeviceInteractor()
{
this->Internals = new vtkDeviceInteractorInternals;
}
//----------------------------------------------------------------------------
vtkDeviceInteractor::~vtkDeviceInteractor()
{
for (unsigned int i = 0; i < this->Internals->InteractionDevices.size(); i++)
{
this->Internals->InteractionDevices[i]->UnRegister(this);
}
for (unsigned int i = 0; i < this->Internals->DeviceInteractorStyles.size(); i++)
{
this->Internals->DeviceInteractorStyles[i]->UnRegister(this);
}
delete this->Internals;
}
//----------------------------------------------------------------------------
void vtkDeviceInteractor::Update()
{
for (unsigned int i = 0; i < this->Internals->InteractionDevices.size(); i++)
{
this->Internals->InteractionDevices[i]->Update();
this->Internals->InteractionDevices[i]->InvokeInteractionEvent();
}
}
//----------------------------------------------------------------------------
void vtkDeviceInteractor::AddInteractionDevice(vtkInteractionDevice* device)
{
if (device == NULL) return;
for (unsigned int i = 0; i < this->Internals->InteractionDevices.size(); i++)
{
if (this->Internals->InteractionDevices[i] == device) return;
}
this->Internals->InteractionDevices.push_back(device);
this->Internals->InteractionDevices.back()->Register(this);
}
//----------------------------------------------------------------------------
void vtkDeviceInteractor::RemoveInteractionDevice(vtkInteractionDevice* device)
{
if (device == NULL) return;
for (unsigned int i = 0; i < this->Internals->InteractionDevices.size(); i++)
{
if (this->Internals->InteractionDevices[i] == device)
{
this->Internals->InteractionDevices[i]->UnRegister(this);
this->Internals->InteractionDevices.erase(this->Internals->InteractionDevices.begin() + i);
return;
}
}
}
//----------------------------------------------------------------------------
void vtkDeviceInteractor::AddDeviceInteractorStyle(vtkDeviceInteractorStyle* device)
{
if (device == NULL) return;
for (unsigned int i = 0; i < this->Internals->DeviceInteractorStyles.size(); i++)
{
if (this->Internals->DeviceInteractorStyles[i] == device) return;
}
this->Internals->DeviceInteractorStyles.push_back(device);
this->Internals->DeviceInteractorStyles.back()->Register(this);
}
//----------------------------------------------------------------------------
void vtkDeviceInteractor::RemoveDeviceInteractorStyle(vtkDeviceInteractorStyle* device)
{
if (device == NULL) return;
for (unsigned int i = 0; i < this->Internals->DeviceInteractorStyles.size(); i++)
{
if (this->Internals->DeviceInteractorStyles[i] == device)
{
this->Internals->DeviceInteractorStyles[i]->UnRegister(this);
this->Internals->DeviceInteractorStyles.erase(this->Internals->DeviceInteractorStyles.begin() + i);
return;
}
}
}
//----------------------------------------------------------------------------
void vtkDeviceInteractor::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "InteractionDevices:" << endl;
for (unsigned int i = 0; i < this->Internals->InteractionDevices.size(); i++)
{
os << indent; this->Internals->InteractionDevices[i]->PrintSelf(os,indent.GetNextIndent());
}
os << indent << "DeviceInteractorStyles:" << endl;
for (unsigned int i = 0; i < this->Internals->DeviceInteractorStyles.size(); i++)
{
os << indent; this->Internals->DeviceInteractorStyles[i]->PrintSelf(os,indent.GetNextIndent());
}
}