22 |
import gzz |
import gzz |
23 |
import traceback |
import traceback |
24 |
|
|
25 |
|
# Slow animation for the demo. |
26 |
|
AbstractUpdateManager.defaultAnimationTime = 3000 |
27 |
|
AbstractUpdateManager.fractCalc = AbstractUpdateManager.LinearCalculator() |
28 |
|
|
29 |
screensize = (1024, 768) # assuming XGA projector. |
screensize = (1024, 768) # assuming XGA projector. |
30 |
|
|
31 |
# center = little above physical center |
# center = little above physical center |
243 |
self.__dict__ = args |
self.__dict__ = args |
244 |
|
|
245 |
def rotatelist(list): |
def rotatelist(list): |
246 |
x = list[-1] |
list.append(list.pop(0)) |
|
del list[-1] |
|
|
list.insert(0, x) |
|
247 |
|
|
248 |
def ispdf(cell): |
def ispdf(cell): |
249 |
# xxx |
# xxx |
279 |
self.ctrx = screensize[0]/2 |
self.ctrx = screensize[0]/2 |
280 |
self.ctry = screensize[1]/2 |
self.ctry = screensize[1]/2 |
281 |
|
|
282 |
self.rad = screensize[0] / 2 |
self.rad = screensize[0] * 5/11 |
283 |
|
|
284 |
self.nadir = NadirAngler(self.ctrx, screensize[1]*2) |
self.nadir = NadirAngler(self.ctrx, screensize[1]*2) |
285 |
self.clip = 0 |
self.clip = 0 |
289 |
|
|
290 |
def key(self, key): |
def key(self, key): |
291 |
global currentScene |
global currentScene |
292 |
fallback = self.win.getFallback() |
if self.win: |
293 |
if fallback.mode != fallback.NORMAL: return 1 |
fallback = self.win.getFallback() |
294 |
|
if fallback.mode != fallback.NORMAL: return 1 |
295 |
|
|
296 |
if key == 'M': |
if key == 'M': |
297 |
rotatelist(self.modes) |
rotatelist(self.modes) |
298 |
|
AbstractUpdateManager.chg() |
299 |
elif key == 'm': |
elif key == 'm': |
300 |
if not self.corner1: return |
if not self.corner1: return |
301 |
print "Mark: %s; %s" % (self.corner1, self.corner2) |
print "Mark: %s; %s" % (self.corner1, self.corner2) |
322 |
AbstractUpdateManager.chg() |
AbstractUpdateManager.chg() |
323 |
elif key == 'c': |
elif key == 'c': |
324 |
self.clip = not self.clip |
self.clip = not self.clip |
325 |
|
AbstractUpdateManager.chg() |
326 |
elif key == 'l': |
elif key == 'l': |
327 |
pagespanview.globalLOD = 1 - pagespanview.globalLOD |
pagespanview.globalLOD = 1 - pagespanview.globalLOD |
328 |
print "Lod: ",pagespanview.globalLOD |
print "Lod: ",pagespanview.globalLOD |
329 |
|
AbstractUpdateManager.setNoAnimation() |
330 |
AbstractUpdateManager.chg() |
AbstractUpdateManager.chg() |
331 |
elif key == 'p': |
elif key == 'p': |
332 |
self.usefancypaper = not self.usefancypaper |
self.usefancypaper = not self.usefancypaper |
333 |
|
AbstractUpdateManager.setNoAnimation() |
334 |
|
AbstractUpdateManager.chg() |
335 |
elif key == ',': |
elif key == ',': |
336 |
pagespanview.globalseedoffs -= 1 |
pagespanview.globalseedoffs -= 1 |
337 |
|
AbstractUpdateManager.setNoAnimation() |
338 |
|
AbstractUpdateManager.chg() |
339 |
self.moveToCell(self.cursor) |
self.moveToCell(self.cursor) |
340 |
elif key == '.': |
elif key == '.': |
341 |
pagespanview.globalseedoffs += 1 |
pagespanview.globalseedoffs += 1 |
342 |
|
AbstractUpdateManager.setNoAnimation() |
343 |
|
AbstractUpdateManager.chg() |
344 |
self.moveToCell(self.cursor) |
self.moveToCell(self.cursor) |
345 |
elif key == 't': |
elif key == 't': |
346 |
self.showtessel = not self.showtessel |
self.showtessel = not self.showtessel |
347 |
|
AbstractUpdateManager.setNoAnimation() |
348 |
|
AbstractUpdateManager.chg() |
349 |
elif key == 's': |
elif key == 's': |
350 |
# select some rect at random |
# select some rect at random |
351 |
# for testing w/o mouse :-) |
# for testing w/o mouse :-) |
401 |
h = b.hit(self.currentvs.coords, point) |
h = b.hit(self.currentvs.coords, point) |
402 |
if h: |
if h: |
403 |
print "BUOY HIT!\n" |
print "BUOY HIT!\n" |
404 |
|
global globalx, globaly |
405 |
|
globalx, globaly = h[0], h[1] |
406 |
|
if self.win: |
407 |
|
self.win.cursor = b.cell |
408 |
self.moveToCell(b.cell, h[0], h[1], redraw=1) |
self.moveToCell(b.cell, h[0], h[1], redraw=1) |
409 |
AbstractUpdateManager.chg() |
AbstractUpdateManager.chg() |
410 |
return |
return |
411 |
h = self.view.hitClip(self.currentvs.coords, point, None) |
h = self.view.hitClip(self.currentvs.coords, point, None) |
412 |
if h: |
if h: |
413 |
|
print "Move to ",globalx, globaly |
414 |
globalx,globaly = h |
globalx,globaly = h |
415 |
else: |
else: |
416 |
print "Didn't hit anything" |
print "Didn't hit anything" |
456 |
replaceNewScene(self.currentvs) |
replaceNewScene(self.currentvs) |
457 |
|
|
458 |
|
|
459 |
def moveToCell(self, cell, nx=1, ny=1, redraw=1): |
def moveToCell(self, cell, nx=None, ny=None, redraw=1): |
460 |
global globalx, globaly |
global globalx, globaly |
461 |
global globalforw, globalback |
global globalforw, globalback |
462 |
|
|
467 |
self.view = None |
self.view = None |
468 |
|
|
469 |
self.cursor = cell |
self.cursor = cell |
470 |
globalx, globaly = nx, ny |
if nx != None: |
471 |
|
globalx, globaly = nx, ny |
472 |
|
|
473 |
content = cell.space.cellTexter.getEnfilade(cell, None) |
content = cell.space.cellTexter.getEnfilade(cell, None) |
474 |
self.span = enf2span(content) |
self.span = enf2span(content) |
588 |
|
|
589 |
def windowClosed(self, win): pass |
def windowClosed(self, win): pass |
590 |
def mouse(self, ev, win): |
def mouse(self, ev, win): |
591 |
|
win.prioritize() |
592 |
self._getview(win).mouse(ev) |
self._getview(win).mouse(ev) |
593 |
def keystroke(self, key, win): |
def keystroke(self, key, win): |
594 |
|
win.prioritize() |
595 |
if self._getview(win).key(key): |
if self._getview(win).key(key): |
596 |
# event not handled |
# event not handled |
597 |
win.getFallback().binder.keystroke(key, win) |
win.getFallback().binder.keystroke(key, win) |