-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathControllerGroup.py
More file actions
227 lines (191 loc) · 7.74 KB
/
ControllerGroup.py
File metadata and controls
227 lines (191 loc) · 7.74 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
'''
// Copyright 2008 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Original Author: John Taylor
//
// Notification of Change: The original java source code has been
// modified in that it has been rewritten in the python programming
// language and additionally, may contain components and ideas that are
// not found in the original source code.
Copyright 2013 Neil Borle and Paul Lu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Created on 2013-06-09
@author: Neil Borle
'''
from Controller import Controller
from LocationController import LocationController
from ManualOrientationController import ManualOrientationController
from ZoomController import ZoomController
def create_controller_group(prefs):
'''
Creates an instance of a controller group and provides it
with the necessary controllers to allow for manipulation
of the appearance of the sky. This class is both a factory
and a facade for the underlying controllers
'''
group = ControllerGroup()
group.add_controller(LocationController(prefs))
# group.sensorOrientationController = new SensorOrientationController(context);
# group.addController(group.sensorOrientationController);
group.manual_direction_controller = ManualOrientationController()
group.add_controller(group.manual_direction_controller)
group.zoom_controller = ZoomController()
group.add_controller(group.zoom_controller)
# group.teleportingController = new TeleportingController();
# group.addController(group.teleportingController);
group.set_auto_mode(True)
return group
class ControllerGroup(Controller):
'''
Class which holds all the controllers and provides
methods for using the controllers. This way there
is one collection of controllers that can be used
centrally.
'''
def set_enabled(self, enabled_bool):
'''
enables or disables all controllers
'''
for controller in self.controllers:
controller.enabled = enabled_bool
def set_model(self, m_model):
'''
Provides all controllers with access to the model.
'''
for controller in self.controllers:
controller.model = m_model
self.model = m_model
self.model.auto_update_pointing = self.using_auto_mode
#self.model.set_clock(transitioning_clock)
def go_time_travel(self, date):
'''
Switches to time-travel model and start with the supplied time.
'''
raise NotImplementedError("not finished time stuff")
#transitioningClock.goTimeTravel(d);
def get_current_speed_tag(self):
'''
Gets the id of the string used to display the current speed of time travel.
'''
#return timeTravelClock.getCurrentSpeedTag();
raise NotImplementedError("not finished time stuff")
def use_real_time(self):
'''
Sets the model back to using real time.
'''
#transitioningClock.returnToRealTime();
raise NotImplementedError("not finished time stuff")
def accelerate_time_travel(self):
'''
Increases the rate of time travel into the future (or decreases the rate of
time travel into the past) if in time travel mode.
'''
#timeTravelClock.accelerateTimeTravel();
raise NotImplementedError("not finished time stuff")
def decelerate_time_travel(self):
'''
Decreases the rate of time travel into the future (or increases the rate of
time travel into the past) if in time travel mode.
'''
#timeTravelClock.decelerateTimeTravel();
raise NotImplementedError("not finished time stuff")
def pause_time(self):
'''
Pauses time, if in time travel mode.
'''
#timeTravelClock.pauseTime();
raise NotImplementedError("not finished time stuff")
def set_auto_mode(self, enabled_bool):
'''
Sets auto mode (true) or manual mode (false).
'''
self.manual_direction_controller.enabled = (not enabled_bool)
#sensorOrientationController.setEnabled(enabled_bool)
if self.model != None:
self.model.auto_update_pointing = enabled_bool
self.using_auto_mode = enabled_bool
def start(self):
for controller in self.controllers:
controller.start()
def stop(self):
for controller in self.controllers:
controller.stop()
def change_right_left(self, radians):
'''
Moves the pointing right and left.
radians is the angular change in the pointing in radians (only
accurate in the limit as radians tends to 0.)
'''
self.manual_direction_controller.change_right_left(radians)
def change_up_down(self, radians):
'''
Moves the pointing up and down.
radians is the angular change in the pointing in radians (only
accurate in the limit as radians tends to 0.)
'''
self.manual_direction_controller.change_up_down(radians)
def rotate(self, degrees):
'''
Rotates the view about the current center point.
'''
self.manual_direction_controller.rotate(degrees)
def zoom_in(self):
'''
Zooms the user in.
'''
self.zoom_controller.zoom_in()
def zoom_out(self):
'''
Zooms the user out.
'''
self.zoom_controller.zoom_out()
def teleport(self, target):
'''
Sends the astronomer's pointing to the new target.
takes the target the destination
'''
#teleportingController.teleport(target)
raise NotImplementedError("Not done yet")
def add_controller(self, controller):
'''
Adds a new controller to this group.
'''
self.controllers.append(controller)
def zoom_by(self, ratio):
'''
Zoomz by a given ratio
'''
self.zoom_controller.zoom_by(ratio)
def __init__(self):
'''
Constructor
'''
Controller.__init__(self)
self.controllers = []
self.zoom_controller = None
self.manual_direction_controller = None
self.sensor_orientation_controller = None
#self.time_travel_clock = TimeTravelClock();
#self.transitioning_clock = TransitioningCompositeClock(timeTravelClock, RealClock())
self.teleporting_controller = None
self.using_auto_mode = True