gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz ./TODO gzz/modules/pp/PPView2.java gzz/modu...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz ./TODO gzz/modules/pp/PPView2.java gzz/modu...
Date: Sun, 03 Nov 2002 07:03:09 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/11/03 07:03:07

Modified files:
        .              : TODO 
        gzz/modules/pp : PPView2.java demotest.py 

Log message:
        zooming

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/TODO.diff?tr1=1.354&tr2=1.355&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/pp/PPView2.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/pp/demotest.py.diff?tr1=1.11&tr2=1.12&r1=text&r2=text

Patches:
Index: gzz/TODO
diff -u gzz/TODO:1.354 gzz/TODO:1.355
--- gzz/TODO:1.354      Sat Nov  2 19:16:42 2002
+++ gzz/TODO    Sun Nov  3 07:03:07 2002
@@ -102,6 +102,7 @@
            - make it work again
                - bindings
                - mouse click coordinates
+           - scale irregu border right (bound to bg)
            - images
            - CullingCellInBox
            - nadir
Index: gzz/gzz/modules/pp/PPView2.java
diff -u gzz/gzz/modules/pp/PPView2.java:1.2 gzz/gzz/modules/pp/PPView2.java:1.3
--- gzz/gzz/modules/pp/PPView2.java:1.2 Sat Nov  2 15:32:48 2002
+++ gzz/gzz/modules/pp/PPView2.java     Sun Nov  3 07:03:07 2002
@@ -10,11 +10,25 @@
 
 public class PPView2 implements View {
 
+    /** The current zoom.
+     * Pixels for 1 paper coordinate unit.
+     */
+    public float zoom = 1;
+
+    /** The scale of the background.
+     * bgscale in paper coordinates = 1 in background coords.
+     */
+    public float bgscale = 200;
+
     Space space;
     PPDims d;
 
     CoordinatePlaneView coordinatePlaneView;
 
+    /** A single PP plane, with given view context.
+     * This class takes care of drawing the stencil, 
+     * the background and the vobs inside the plane.
+     */
     class SinglePlane {
        ViewContext context;
        void render(final VobScene vs, final int frameCS, final int c2fCS) {
@@ -27,7 +41,7 @@
            final BgVob bg = BgVob.create(plane);
 
            final IrregularFrame f = IrregularFrame.create(-100,-100,1600,1600,
-                                       50.3f, 1000f);
+                                       50.3f, 500f);
 
            final int frameUnit = vs.unitSqCS(frameCS, "USQ");
 
@@ -41,7 +55,9 @@
            float[] sqs = new float[2];
            glc.getSqSize(frameCS, sqs);
 
-           final int c2fUnit = vs.scaleCS(c2fCS, "SCA", 1.0f/sqs[0], 
1.0f/sqs[1]);
+
+           final int c2fUnit = vs.scaleCS(c2fCS, "SCA", 
+                       bgscale/sqs[0], bgscale/sqs[1]);
 
            Stencil.drawStenciled(vs, 
                        new Putter(f.getContent()),
@@ -72,8 +88,19 @@
        pl.context = vc;
 
        int frameCS = vs.orthoBoxCS(0, "frame", 0, 100, 100, 1, 1, 400, 400);
-       int c2fCS = 0;
+
+       int c2fCS = vs.orthoCS(0, "C2F", 0, 0, 0, 10, 10);
+       setZoomPan(vs);
        pl.render(vs, frameCS, c2fCS);
 
+    }
+
+    /** Cause the changes to the zooming and panning variables
+     * to be shown in the given vobscene.
+     * This changes the parameters of the coordinate systems created by 
render().
+     */
+    public void setZoomPan(VobScene vs) {
+       int cs = vs.matcher.getCS("C2F");
+       vs.coords.setOrthoParams(cs, 0, 0, 0, zoom, zoom);
     }
 }
Index: gzz/gzz/modules/pp/demotest.py
diff -u gzz/gzz/modules/pp/demotest.py:1.11 gzz/gzz/modules/pp/demotest.py:1.12
--- gzz/gzz/modules/pp/demotest.py:1.11 Sat Nov  2 15:32:48 2002
+++ gzz/gzz/modules/pp/demotest.py      Sun Nov  3 07:03:07 2002
@@ -115,12 +115,43 @@
                self.scale, 0, 0, self.scale)
 
 class PPView2Scene:
+    def __init__(self):
+       self.ppv = PPView2(space)
+       self.ppv.bgscale = 500
+    def key(self, key):
+       pass
     def scene(self, vs):
        vs.map.put(background((0.4,0.5,0.8)))
        avc = gzz.view.AbstractViewContext()
        avc.setAccursed(space.getCell(n1))
-       ppv = PPView2(space)
-       ppv.render(vs, 0, avc)
+       self.ppv.render(vs, 0, avc)
+       self.vs = vs
+    def mouse(self, ev):
+       if ev.getID() == ev.MOUSE_CLICKED:
+           pass
+       elif ev.getID() == ev.MOUSE_PRESSED:
+           self.press = (ev.getX(), ev.getY())
+           self.pzoom = self.ppv.zoom
+           self.but = ev.getModifiers()
+       elif ev.getID() == ev.MOUSE_DRAGGED:
+           if self.but == ev.BUTTON3_MASK:
+               self.ppv.zoom = self.pzoom * math.exp(
+                       (self.press[1] - ev.getY())/150.0)
+               self.ppv.setZoomPan(self.vs)
+               replaceNewScene(self.vs)
+               AbstractUpdateManager.setNoAnimation()
+               AbstractUpdateManager.chg()
+           elif self.but == ev.BUTTON1_MASK:
+               self.offset = (
+                self.poffset[0] - (ev.getX() - self.press[0]),
+                self.poffset[1] - (ev.getY() - self.press[1]),
+                )
+    def sap(self):
+       self.currentvs.coords.setAffineParams(self.cs2,
+               0, -self.scale*self.offset[0]+.5, 
+                  -self.scale*self.offset[1]+.5, 
+               self.scale, 0, 0, self.scale)
+
 
 # currentScene = PlaneViewScene()
 currentScene = PPView2Scene()




reply via email to

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