gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz gzz/gfx/gl/GLVobCoorder.java gzz/vob/Defaul...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz gzz/gfx/gl/GLVobCoorder.java gzz/vob/Defaul...
Date: Fri, 01 Nov 2002 08:10:55 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/11/01 08:10:55

Modified files:
        gzz/gfx/gl     : GLVobCoorder.java 
        gzz/vob        : DefaultVobMap.java OrthoCoorder.java 
                         OrthoCoordsys.java VobCoorder.java 
        test/gzz/vob   : vobcoorder.test 

Log message:
        Work towards boxes in awt

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GLVobCoorder.java.diff?tr1=1.50&tr2=1.51&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/DefaultVobMap.java.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/OrthoCoorder.java.diff?tr1=1.37&tr2=1.38&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/OrthoCoordsys.java.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/VobCoorder.java.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/vob/vobcoorder.test.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: gzz/gzz/gfx/gl/GLVobCoorder.java
diff -u gzz/gzz/gfx/gl/GLVobCoorder.java:1.50 
gzz/gzz/gfx/gl/GLVobCoorder.java:1.51
--- gzz/gzz/gfx/gl/GLVobCoorder.java:1.50       Fri Nov  1 03:05:13 2002
+++ gzz/gzz/gfx/gl/GLVobCoorder.java    Fri Nov  1 08:10:55 2002
@@ -29,7 +29,7 @@
 import gzz.client.gl.*;
 
 public class GLVobCoorder extends AffineVobCoorder {
-public static final String rcsid = "$Id: GLVobCoorder.java,v 1.50 2002/11/01 
08:05:13 tjl Exp $";
+public static final String rcsid = "$Id: GLVobCoorder.java,v 1.51 2002/11/01 
13:10:55 tjl Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.err.println(s); }
 
@@ -270,7 +270,27 @@
        floats[ind + 6] = h;
     }
 
-
+    public void getSqSize(int cs, float[] into) {
+       // XXX Dangerous: this needs to be updated whenever new non-unit box 
+       // coordsys are added.
+       int type = inds[cs];
+       int ind=-42;
+       switch(type) {
+           case 11: // box
+               ind = inds[cs+2];
+               into[0] = floats[ind + 0];
+               into[1] = floats[ind + 1];
+               break;
+           case 14: // orthobox
+               ind = inds[cs+2];
+               into[0] = floats[ind + 5];
+               into[1] = floats[ind + 6];
+               break;
+           default:
+               into[0] = into[1] = 1;
+               break;
+       }
+    }
 
 
     /** A fisheye coordinate system: non-linear magnification.
Index: gzz/gzz/vob/DefaultVobMap.java
diff -u gzz/gzz/vob/DefaultVobMap.java:1.11 gzz/gzz/vob/DefaultVobMap.java:1.12
--- gzz/gzz/vob/DefaultVobMap.java:1.11 Thu Sep 26 07:05:48 2002
+++ gzz/gzz/vob/DefaultVobMap.java      Fri Nov  1 08:10:55 2002
@@ -26,7 +26,7 @@
 /** An implementation of VobMap.
  */
 public class DefaultVobMap implements VobMap {
-public static final String rcsid = "$Id: DefaultVobMap.java,v 1.11 2002/09/26 
11:05:48 tjl Exp $";
+public static final String rcsid = "$Id: DefaultVobMap.java,v 1.12 2002/11/01 
13:10:55 tjl Exp $";
     public static boolean dbg = false;
     private static void p(String s) { if(dbg) pa(s); }
     private static void pa(String s) { System.err.println(s); }
@@ -43,10 +43,6 @@
        return arr;
     }
 
-    OrthoCoorder coorder;
-
-    public OrthoCoorder getCoorder() { return coorder; }
-
     /** For each coordinate system, the index of the first vob
      * stored there.
      */
@@ -122,7 +118,6 @@
     public void clear() {
        nvobs = 1;
         for(int i=0; i<vstart.length; i++) vstart[i] = -1;
-       coorder.clear();
     }
 
     /** An interface for setting the vob render info for the second coordinate 
system
Index: gzz/gzz/vob/OrthoCoorder.java
diff -u gzz/gzz/vob/OrthoCoorder.java:1.37 gzz/gzz/vob/OrthoCoorder.java:1.38
--- gzz/gzz/vob/OrthoCoorder.java:1.37  Tue Oct 29 09:09:32 2002
+++ gzz/gzz/vob/OrthoCoorder.java       Fri Nov  1 08:10:55 2002
@@ -28,7 +28,7 @@
  */
 
 public class OrthoCoorder extends VobCoorder {
-public static final String rcsid = "$Id: OrthoCoorder.java,v 1.37 2002/10/29 
14:09:32 tjl Exp $";
+public static final String rcsid = "$Id: OrthoCoorder.java,v 1.38 2002/11/01 
13:10:55 tjl Exp $";
     public static boolean dbg = false;
     private static void p(String s) { if(dbg) pa(s); }
     private static void pa(String s) { System.err.println(s); }
@@ -108,18 +108,27 @@
     OrthoCoordsys sys;
     float maxdepth = 0;
 
-    public int ortho(int into, float depth, float x, float y,
-                                                          float w, float h) {
+    public int orthoBox(int into, float depth, float x, float y, float sx, 
float sy, float w, float h) {
        if(maxdepth < depth) maxdepth = depth;
-       return sys.add(into, depth, x, y, w, h);
+       return sys.add(into, depth, x, y, sx, sy, w, h);
     }
+    public int ortho(int into, float depth, float x, float y, float w, float 
h) {
+       return orthoBox(into, depth, x, y, w, h, 1, 1);
+    }
+
 
+    public void setOrthoBoxParams(int cs, float depth, float x, float y, float 
sx, float sy, float w, float h) {
+       if(maxdepth < depth) maxdepth = depth;
+       sys.setParams(cs, depth, x, y, sx, sy, w, h);
+    }
     public void setOrthoParams(int cs, float depth,
                float x, float y, float w, float h) {
-       if(maxdepth < depth) maxdepth = depth;
-       sys.setParams(cs, depth, x, y, w, h);
+       setOrthoBoxParams(cs, depth, x, y, w, h, 1, 1);
     }
 
+    public void getSqSize(int cs, float[] into) {
+       sys.getSqSize(cs, into);
+    }
 
     /** Remove all rectangles (except root rect);
      *  start creating new coordsys from start.
@@ -237,6 +246,23 @@
        setInfo(cs, 0, 0, 1, 1, info);
        return info;
     }
+
+    public void transformPoints3(int withCS, float[] pt, float[]into) {
+       float[] rect = new float[] { 0, 0, 1, 1 };
+       sys.transformRect(withCS, rect);
+
+       float ox = rect[0];
+       float oy = rect[1];
+       float sx = rect[2];
+       float sy = rect[3];
+       for(int i=0; i<pt.length; i+=3) {
+           into[i + 0] = ox + sx * pt[i + 0];
+           into[i + 1] = oy + sy * pt[i + 1];
+           into[i + 2] = sys.depth[withCS] + pt[i + 2];
+       }
+    }
+
+
 
     public void dump() {
        pa("OrthoCoorder: "+sys.nsys);
Index: gzz/gzz/vob/OrthoCoordsys.java
diff -u gzz/gzz/vob/OrthoCoordsys.java:1.7 gzz/gzz/vob/OrthoCoordsys.java:1.8
--- gzz/gzz/vob/OrthoCoordsys.java:1.7  Wed Oct 16 03:46:39 2002
+++ gzz/gzz/vob/OrthoCoordsys.java      Fri Nov  1 08:10:55 2002
@@ -18,13 +18,13 @@
  *
  */
 /*
- * Written by Benja Fallenstein
+ * Written by Benja Fallenstein and Tuomas Lukka
  */
 package gzz.vob;
 class OrthoCoordsys {
     OrthoDepthSorter sorter;
 
-    float[] depth, x, y, w, h;
+    float[] depth, x, y, sx, sy, w, h;
     int[] parent;
     int[] nancestors;
 
@@ -42,6 +42,8 @@
        depth = new float[initialSize];
        x = new float[initialSize];
        y = new float[initialSize];
+       sx = new float[initialSize];
+       sy = new float[initialSize];
        w = new float[initialSize];
        h = new float[initialSize];
         parent = new int[initialSize];
@@ -53,7 +55,8 @@
 
     void clear(float mw, float mh) {
         depth[0] = 0;
-       x[0] = 0; y[0] = 0; w[0] = mw; h[0] = mh;
+       x[0] = 0; y[0] = 0; sx[0] = mw; sy[0] = mh;
+       w[0] = 1; h[0] = 1;
         parent[0] = -1; nancestors[0] = 0;
 
        nsys = 1;
@@ -61,12 +64,12 @@
        sorter.clear();
     }
 
-    int add(int mparent, float mdepth, float mx, float my,
-                                                   float mw, float mh) {
+    int add(int mparent, float mdepth, float mx, float my, float msx, float 
msy,
+                                           float mw, float mh) {
        int cs = next();
 
         parent[cs] = mparent;
-       setParams(cs, mdepth, mx, my, mw, mh);
+       setParams(cs, mdepth, mx, my, msx, msy, mw, mh);
 
         nancestors[cs] = nancestors[mparent] + 1;
 
@@ -75,10 +78,12 @@
        return cs;
     }
 
-    void setParams(int cs, float mdepth, float mx, float my, 
+    void setParams(int cs, float mdepth, float mx, float my, float msx, float 
msy,
                        float mw, float mh) {
        int mparent = parent[cs];
 
+       sx[cs] = msx;
+       sy[cs] = msy;
        w[cs] = mw;
        h[cs] = mh;
 
@@ -87,16 +92,19 @@
        // XXX Depth doesn't change right with setXParams later
        x[cs] = mx;
        y[cs] = my;
+    }
 
-
+    public void getSqSize(int cs, float[] into) {
+       into[0] = w[cs];
+       into[1] = h[cs];
     }
 
     void transformRect(int cs, float[] rect) {
        if(cs == 0) return;
-       rect[0] *= w[cs];
-       rect[1] *= h[cs];
-       rect[2] *= w[cs];
-       rect[3] *= h[cs];
+       rect[0] *= sx[cs];
+       rect[1] *= sy[cs];
+       rect[2] *= sx[cs];
+       rect[3] *= sy[cs];
 
        rect[0] += x[cs];
        rect[1] += y[cs];
@@ -112,6 +120,8 @@
            float[] ndepth = new float[l];
            float[] nx = new float[l];
            float[] ny = new float[l];
+           float[] nsx = new float[l];
+           float[] nsy = new float[l];
            float[] nw = new float[l];
            float[] nh = new float[l];
             int[] nparent = new int[l];
@@ -121,6 +131,8 @@
            System.arraycopy(depth, 0, ndepth, 0, o);
            System.arraycopy(x, 0, nx, 0, o);
            System.arraycopy(y, 0, ny, 0, o);
+           System.arraycopy(sx, 0, nsx, 0, o);
+           System.arraycopy(sy, 0, nsy, 0, o);
            System.arraycopy(w, 0, nw, 0, o);
            System.arraycopy(h, 0, nh, 0, o);
             System.arraycopy(parent, 0, nparent, 0, o);
@@ -128,7 +140,9 @@
            System.arraycopy(nextHashtableEntry, 0, nnext, 0, o);
 
            depth = ndepth;
-           x = nx; y = ny; w = nw; h = nh;
+           x = nx; y = ny; 
+           sx = nsx; sy = nsy; 
+           w = nw; h = nh;
             parent = nparent;
            nancestors = nnancestors;
            nextHashtableEntry = nnext;
@@ -159,15 +173,15 @@
     }
 
     float cx2(int cs) {
-        if(cs == 0) return x[0] + w[0];
-        float x1 = x[cs] + w[cs];
+        if(cs == 0) return x[0] + sx[0];
+        float x1 = x[cs] + sx[cs];
         float x2 = cx2(parent[cs]);
         return x1<x2 ? x1 : x2;
     }
 
     float cy2(int cs) {
-        if(cs == 0) return y[0] + h[0];
-        float y1 = y[cs] + h[cs];
+        if(cs == 0) return y[0] + sy[0];
+        float y1 = y[cs] + sy[cs];
         float y2 = cy2(parent[cs]);
         return y1<y2 ? y1 : y2;
     }
Index: gzz/gzz/vob/VobCoorder.java
diff -u gzz/gzz/vob/VobCoorder.java:1.19 gzz/gzz/vob/VobCoorder.java:1.20
--- gzz/gzz/vob/VobCoorder.java:1.19    Tue Oct 29 09:09:32 2002
+++ gzz/gzz/vob/VobCoorder.java Fri Nov  1 08:10:55 2002
@@ -65,7 +65,28 @@
        setOrthoParams(into, 0, 0, 0, sx, sy);
     }
 
+    public int box(int into, float w, float h) {
+       return orthoBox(into, 0, 0, 0, 1, 1, w, h);
+    }
+    public void setBoxParams(int cs, float w, float h) {
+       setOrthoBoxParams(cs, 0, 0, 0, 1, 1, w, h);
+    }
 
+    public int unitSq(int into) {
+       // XXX Really bad default impl...
+       float []tmp = new float[2];
+       getSqSize(into, tmp);
+       return ortho(into, 0, 0, 0, tmp[0], tmp[1]);
+    }
+
+    abstract public int orthoBox(int into, float z, float x, float y, float 
sx, float sy, float w, float h) ;
+    abstract public void setOrthoBoxParams(int cs, float z, float x, float y, 
float sx, float sy, float w, float h) ;
+
+    /** Get the size of the "unit square" of the given coordinate
+     * system. This is the size that the unit square of unitSqCS() 
+     * would be in the given coordinate system.
+     */
+    abstract public void getSqSize(int cs, float[] into);
 
     abstract public boolean needInterp(VobCoorder interpTo, int[] interpList);
 
Index: gzz/test/gzz/vob/vobcoorder.test
diff -u gzz/test/gzz/vob/vobcoorder.test:1.4 
gzz/test/gzz/vob/vobcoorder.test:1.5
--- gzz/test/gzz/vob/vobcoorder.test:1.4        Fri Nov  1 03:50:36 2002
+++ gzz/test/gzz/vob/vobcoorder.test    Fri Nov  1 08:10:55 2002
@@ -11,8 +11,8 @@
     cs1 = c.ortho(0, 5, 10, 15, 0.5, 1)
     checkTrans(vs, cs1, [0, 0, 0, 1, 1, 1], [10, 15, 5, 10.5, 16, 6])
 
-    cs2 = c.scale(0, 2, 3, 4)
-    checkTrans(vs, cs2, [0, 0, 0, 1, 1, 1], [0, 0, 0, 2, 3, 4])
+    cs2 = c.scale(0, 2, 3)
+    checkTrans(vs, cs2, [0, 0, 0, 1, 1, 1], [0, 0, 0, 2, 3, 1])
 
 def testActivateSimply():
     """First, trivial test: two "buttons", activate




reply via email to

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