gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gfx demo/paper/singlepaper.py demo/paper/ut...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz/gfx demo/paper/singlepaper.py demo/paper/ut...
Date: Thu, 19 Dec 2002 10:31:00 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/12/19 10:31:00

Modified files:
        gfx/demo/paper : singlepaper.py util.py 
        gfx/util       : demokeys.py 

Log message:
        More declarative keys

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/paper/singlepaper.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/paper/util.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/util/demokeys.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/paper/singlepaper.py
diff -u gzz/gfx/demo/paper/singlepaper.py:1.2 
gzz/gfx/demo/paper/singlepaper.py:1.3
--- gzz/gfx/demo/paper/singlepaper.py:1.2       Thu Dec 19 10:02:33 2002
+++ gzz/gfx/demo/paper/singlepaper.py   Thu Dec 19 10:31:00 2002
@@ -15,7 +15,15 @@
        self.optimized = ["not", "opt", "both"]
 
        print "Paper2scene, keys = ",keys
-       self.key = KeyPresses(self, *keys)
+       self.key = KeyPresses(self, 
+           Action("Choose random seed", "v", self.randomize,
+               noAnimation=1),
+           *keys
+           )
+
+    def randomize(self):
+       self.seed = rng.nextInt(2000000000)
+       self.initpaper()
 
     def initpaper(self):
         self.pq = getpaper(self.seed)
@@ -25,8 +33,6 @@
         oldseed = self.seed
         if k >= "0" and k <= "9": self.seed = self.seed * 10 + int(k)
         if k == "BackSpace" or k == "Backspace": self.seed = self.seed / 10
-       if k == "v":
-            self.seed = rng.nextInt(2000000000)
        if k == 'o':
            rotatelist(self.optimized)
 
Index: gzz/gfx/demo/paper/util.py
diff -u gzz/gfx/demo/paper/util.py:1.2 gzz/gfx/demo/paper/util.py:1.3
--- gzz/gfx/demo/paper/util.py:1.2      Thu Dec 19 10:02:33 2002
+++ gzz/gfx/demo/paper/util.py  Thu Dec 19 10:31:00 2002
@@ -97,9 +97,16 @@
 
 rng = java.util.Random()
 
+def toggleOpengl11():
+    gzz.gfx.gl.PaperOptions.use_opengl_1_1 = \
+           not gzz.gfx.gl.PaperOptions.use_opengl_1_1
+    print 'Use of OpenGL 1.1:', gzz.gfx.gl.PaperOptions.use_opengl_1_1 
+
 from gfx.util.demokeys import *
 keys = [
     SlideLog("zoom", 900.0, "zoom factor", "<", ">"),
+    Action("Reload textures", "t", retexture),
+    Action("Toggle using OpenGL 1.1 -compatibility mode", "O", toggleOpengl11),
 ]
 
 benchmark = 0
@@ -107,12 +114,6 @@
     global benchmark
     global currentScene
     global zoom
-    if k == "t":
-        retexture();
-    if k == "b":
-        benchmark=1
-       AbstractUpdateManager.setNoAnimation()
-       AbstractUpdateManager.chg()
     if k >= "F5" and k <= "F8":
         i = int(k[1]) - 5
         global passmask
@@ -121,25 +122,22 @@
         currentScene.initpaper()
     if k == "d":
         gfx.libpaper.papermill.dbg = not gfx.libpaper.papermill.dbg
-    if k == "c":
-        global cmap
-        x,y = 0,0
-        xs,ys = 200,200
-        pixels = GL.createByteVector(xs*ys*3)
-        pixels.readFromBuffer_ubytes(demowindow.w.window, "FRONT", x, y, xs, 
ys, "RGB");
-
-        print "Read pixels"
-        cmap = GLRen.createLABColorMap(pixels, xs * ys);
-        currentScene = ColorMapScene()
-       AbstractUpdateManager.setNoAnimation()
-    if k == "C":
-        currentScene = ColorMapScene()
-       AbstractUpdateManager.setNoAnimation()
-    if k == "O":
-        gzz.gfx.gl.PaperOptions.use_opengl_1_1 = not 
gzz.gfx.gl.PaperOptions.use_opengl_1_1
-        print 'Use of OpenGL 1.1:', gzz.gfx.gl.PaperOptions.use_opengl_1_1 
-    if k == "p":
-       makeScreenshots()
+#    if k == "c":
+#        global cmap
+#        x,y = 0,0
+#        xs,ys = 200,200
+#        pixels = GL.createByteVector(xs*ys*3)
+#        pixels.readFromBuffer_ubytes(demowindow.w.window, "FRONT", x, y, xs, 
ys, "RGB");
+#
+#        print "Read pixels"
+#        cmap = GLRen.createLABColorMap(pixels, xs * ys);
+#        currentScene = ColorMapScene()
+#      AbstractUpdateManager.setNoAnimation()
+#    if k == "C":
+#        currentScene = ColorMapScene()
+#      AbstractUpdateManager.setNoAnimation()
+#    if k == "p":
+#      makeScreenshots()
 
 
 
Index: gzz/gfx/util/demokeys.py
diff -u gzz/gfx/util/demokeys.py:1.1 gzz/gfx/util/demokeys.py:1.2
--- gzz/gfx/util/demokeys.py:1.1        Thu Dec 19 10:02:33 2002
+++ gzz/gfx/util/demokeys.py    Thu Dec 19 10:31:00 2002
@@ -1,6 +1,7 @@
 # Demo keystroke handling
 
 from __future__ import nested_scopes
+from gzz.client import AbstractUpdateManager
 
 
 class KeyPresses:
@@ -22,11 +23,20 @@
            return self.keymap[key](self.scene,key)
        print "No such key known: ",key,"Here:",self.keymap
     
+class _NoAnimation:
+    def __init__(self, func): self.func = func
+    def __call__(self, *args):
+       print "NOANIMATION CALL"
+       AbstractUpdateManager.setNoAnimation()
+       self.func(*args)
 
 class _Presses:
     def __init__(self, opts, *keys):
        print "PRESSES: ",keys
        self.keys = keys
+       if opts.get("noAnimation", 0):
+           self.keys = [
+               (k[0], _NoAnimation(k[1])) for k in self.keys]
     def getKeys(self):
        return self.keys
            
@@ -36,6 +46,23 @@
        """
        pass 
 
+class Action(_Presses):
+    """A key used to fire an action.
+    """
+    def __init__(self, description, key, func, **opts):
+       _Presses.__init__(self, opts, 
+          (key, self.act),
+           )
+       self.func = func
+       self.descline = key + ": " + description
+
+    def prepare(self, scene):
+       pass
+
+    def act(self, scene, key):
+       self.func()
+
+
 class Toggle(_Presses):
     """A key used to toggle a feature on or off.
     """
@@ -52,7 +79,7 @@
        setattr(scene, self.attr, 1 - getattr(scene, self.attr))
 
 class SlideLog(_Presses):
-    """A key used to toggle a feature on or off.
+    """A pair of keys used to move a log slider up&down.
     """
     def __init__(self, attr, default, description, keydown, keyup, **opts):
        _Presses.__init__(self, opts, 
@@ -69,7 +96,7 @@
     def move(self, dir, scene, key):
        v = getattr(scene, self.attr)
        if dir > 0:
-           v *= 1.05
+           v *= 1.1
        else:
-           v /= 1.05
+           v /= 1.1
        setattr(scene, self.attr, v)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]