gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz ./TODO gfx/jni/GzzGL-jni.cxx gfx/libcoords/...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz ./TODO gfx/jni/GzzGL-jni.cxx gfx/libcoords/...
Date: Fri, 01 Nov 2002 03:05:14 -0500

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

Modified files:
        .              : TODO 
        gfx/jni        : GzzGL-jni.cxx 
        gfx/libcoords  : Coords.cxx Coords.hxx 
        gzz/gfx/gl     : GLVobCoorder.java 
        test/gzz/gfx/gl: glvobcoorder.test 

Log message:
        Box coordinates for GLVobCoorder

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/TODO.diff?tr1=1.340&tr2=1.341&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/jni/GzzGL-jni.cxx.diff?tr1=1.56&tr2=1.57&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.cxx.diff?tr1=1.46&tr2=1.47&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.hxx.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GLVobCoorder.java.diff?tr1=1.49&tr2=1.50&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/gfx/gl/glvobcoorder.test.diff?tr1=1.16&tr2=1.17&r1=text&r2=text

Patches:
Index: gzz/TODO
diff -u gzz/TODO:1.340 gzz/TODO:1.341
--- gzz/TODO:1.340      Wed Oct 30 14:10:17 2002
+++ gzz/TODO    Fri Nov  1 03:05:13 2002
@@ -131,6 +131,7 @@
           bounding boxes. Fast, but not very efficient.
     tjl:        
        - PP [deadline 5.11]
+           - help mudyc with String[] to renderable passing
            - refactor
                - tests for box activation
                - implement using the new gzz.view classes
Index: gzz/gfx/jni/GzzGL-jni.cxx
diff -u gzz/gfx/jni/GzzGL-jni.cxx:1.56 gzz/gfx/jni/GzzGL-jni.cxx:1.57
--- gzz/gfx/jni/GzzGL-jni.cxx:1.56      Tue Oct 29 14:55:36 2002
+++ gzz/gfx/jni/GzzGL-jni.cxx   Fri Nov  1 03:05:13 2002
@@ -1236,9 +1236,10 @@
 
        // Transform screen point to inside coordsys
        ZPt pt = cs->getInverse()->transform(screenpt);
+       Pt sq = cs->getSqSize();
        // See whether inside unit square
-       if(pt.x < 0 || pt.x > 1 ||
-          pt.y < 0 || pt.y > 1) continue;
+       if(pt.x < 0 || pt.x > sq.x ||
+          pt.y < 0 || pt.y > sq.y) continue;
        // Project to zero plane
        pt.z = 0;
        // Transform back to screen coordinates
Index: gzz/gfx/libcoords/Coords.cxx
diff -u gzz/gfx/libcoords/Coords.cxx:1.46 gzz/gfx/libcoords/Coords.cxx:1.47
--- gzz/gfx/libcoords/Coords.cxx:1.46   Tue Oct 29 14:55:36 2002
+++ gzz/gfx/libcoords/Coords.cxx        Fri Nov  1 03:05:13 2002
@@ -78,15 +78,29 @@
 
     };
 
+    /** A TransformCoordSys that also uses the W, H definition of its 
parameter.
+     */
+    template<class Transform> class TransformWHCoordSys : public 
TransformCoordSys<Transform> {
+    public:
+       virtual Pt getSqSize() {
+           return t.getSqSize(); 
+       }
+
+    };
+
     template<class Deriver> 
            class DerivedTransformCoordSys : 
                public TransformCoordSys<typename Deriver::BaseTransform> {
-       CoordSys *dep;
+       CoordSys *dep[Deriver::NDetermining >? 1];
        float nparams[Deriver::BaseTransform::NParams];
+
+
        virtual void setSuper(CoordSys **super) {
            CoordSys::setSuper(super);
-           this->dep = super[1];
+           for(int i=0; i<Deriver::NDetermining; i++)
+               this->dep[i] = super[1 + i];
        }
+
        virtual void setParams(float *params) {
            Deriver d;
            d.derivedParams(super, dep, params, nparams);
@@ -148,6 +162,42 @@
        }
     };
 
+    struct UnitCoords {
+       enum { NParams = 0 };
+       void tr(const ZPt &from, ZPt &to) const {
+           to = from;
+       }
+       float tr_radius(const ZPt &from, float radius) const {
+           return radius;
+       }
+       bool canPerformGL() { return true; }
+        bool performGL() { return true; }
+       float nonlinearity(const ZPt &p, float radius) { 
+           return 0;
+       }
+       template<class Ptr> void setParams(Ptr p, CoordSys *super) {
+       }
+    };
+
+    struct BoxCoords : public UnitCoords {
+       enum { NParams = 2 };
+       float w, h;
+
+       template<class Ptr> void setParams(Ptr p, CoordSys *super) {
+           w = p[0];
+           h = p[1];
+       }
+
+       Pt getSqSize() {
+           return Pt(w, h);
+       }
+
+       typedef UnitCoords InverseType;
+       UnitCoords inverseTransform() {
+           return UnitCoords();
+       }
+    };
+
     /** Affine coordinate system (in xy), offset in z.
      * Parameter layout: x, y, depth, xx, xy, yx, yy
      */
@@ -207,9 +257,100 @@
            inv.params[2] = -params[2];
            return inv;
        }
+    };
+
+    /** Orthogonal coordinate system (in xy), offset in z.
+     * Parameter layout: x, y, depth, xx, yy
+     */
+    class OrthoCoords {
+       float x, y, z;
+       float sx, sy;
+    public:
+       enum { NParams = 5, 
+               TransId = 13
+           };
+       template<class Ptr> void setParams(Ptr p, CoordSys *super) {
+           x = p[0];
+           y = p[1];
+           z = p[2];
+           sx = p[3];
+           sy = p[4];
+       }
+       /** Perform the internal transformation of this 
+        * coordsys.
+        */
+       void tr(const ZPt &from, ZPt &to) const {
+           to.x = x + from.x * sx;
+           to.y = y + from.y * sy;
+           to.z = z + from.z;
+       }
+       float tr_radius(const ZPt &from, float radius) const {
+           // XXX Oblique?!?!
+           float a = fabs(sx);
+           float b = fabs(sy);
+           return radius * (a > b ? a : b);
+       }
+       bool canPerformGL() { return true; }
+        bool performGL() {
+           glTranslatef(x, y, z);
+           glScalef(sx, sy, 1);
+           return true;
+        }
+       float nonlinearity(const ZPt &p, float radius) { 
+           return 0;
+       }
+
+       typedef OrthoCoords InverseType;
+       OrthoCoords inverseTransform() {
+           OrthoCoords inv;
+           inv.sx = 1.0/sx;
+           inv.sy = 1.0/sy;
+
+           inv.x = -x*inv.sx;
+           inv.y = -y*inv.sy;
+           inv.z = -z;
+           return inv;
+       }
+    };
+
+
+    /** A coordinate system which gives the "unit square"
+     * of its parent.
+     */
+    class UnitSqCoords {
+    public:
+       typedef OrthoCoords BaseTransform;
+       enum { NParams = 0,
+              NDetermining = 0 };
+       void derivedParams(CoordSys *super, CoordSys **XXX,
+                           float *params, float *newparams) {
+           newparams[0] = 0;
+           newparams[1] = 0;
+           newparams[2] = 0;
+           Pt sq = super->getSqSize();
+           DBG(dbg) << "UnitSq: getSqSize returned " << sq << "\n";
+           newparams[3] = sq.x;
+           newparams[4] = sq.y;
+       }
+    };
 
+    /** An ortho coordsys with the unit square box.
+     */
+    class OrthoBoxCoords : public OrthoCoords {
+       float w, h;
+    public:
+       enum { NParams = 7, TransId = 14 };
+       template<class Ptr> void setParams(Ptr p, CoordSys *super) {
+           OrthoCoords::setParams(p, super);
+           w = p[5];
+           h = p[6];
+       }
+       Pt getSqSize() {
+           return Pt(w, h);
+       }
     };
 
+
     /** Rotation clockwise. 
      * Parameter layout: angle (degrees)
      */
@@ -266,9 +407,11 @@
     class NadirOriginCoords {
     public:
        typedef RotateXYCoords BaseTransform;
-       enum { NParams = 0 };
-       void derivedParams(CoordSys *super, CoordSys *nadirCS,
+       enum { NParams = 0,
+               NDetermining = 1 };
+       void derivedParams(CoordSys *super, CoordSys **nadirCSp,
                            float *params, float *newparams) {
+           CoordSys *nadirCS = *nadirCSp;
            ZPt origin = super->transform(ZPt(0,0,0));
            ZPt nadir = nadirCS->transform(ZPt(0,0,0));
 
@@ -342,10 +485,12 @@
        bool valid;
     public:
        typedef AffineXYCoords BaseTransform;
-       enum { NParams = 6 };
-       void derivedParams(CoordSys *super, CoordSys *anchor,
+       enum { NParams = 6, NDetermining = 1 };
+       void derivedParams(CoordSys *super, CoordSys **anchorp,
                            float *params, float *newparams) {
 
+           CoordSys *anchor = *anchorp;
+
            float pointdir = params[5];
            ZVec ctr(params[0], params[1], 0);
            ZVec proj(params[3], params[4], 0);
@@ -850,10 +995,18 @@
        virtual int nparents() { return 1; }
        virtual CoordSys *create() { return new TransformCoordSys<C>(); }
     };
+
+    template<class C> class WHTransFactory : public SomeFactory {
+    public:
+       virtual int nparams() { return C::NParams; }
+       virtual int nprevious() { return 1; }
+       virtual int nparents() { return 1; }
+       virtual CoordSys *create() { return new TransformWHCoordSys<C>(); }
+    };
     template<class C> class DerTransFactory : public SomeFactory {
     public:
        virtual int nparams() { return C::NParams; }
-       virtual int nprevious() { return 2; }
+       virtual int nprevious() { return C::NDetermining + 1; }
        virtual int nparents() { return 1; }
        virtual CoordSys *create() { 
            return new DerivedTransformCoordSys<C>(); 
@@ -888,19 +1041,26 @@
        new NoTransFactory<ConcatCoordSys>(), // 8
        new DerTransFactory<NadirOriginCoords>(), // 9
        new NoTransFactory<CullingCoordSys>(), // 10
+       new WHTransFactory<BoxCoords>(), // 11
+       new DerTransFactory<UnitSqCoords>(), // 12
+       new TransFactory<OrthoCoords>(), // 13
+       new WHTransFactory<OrthoBoxCoords>(), // 14
        0
     };
 
-    bool canconvert[9][9] = { // [source][target]
-       { 1, 0, 0, 0, 0, 0, 0, 0, 0 },
-       { 0, 1, 0, 0, 0, 0, 0, 0, 0 },
-       { 0, 0, 1, 0, 0, 0, 0, 0, 0 },
-       { 0, 0, 0, 1, 0, 0, 0, 0, 0 },
-       { 0, 0, 0, 0, 1, 0, 0, 0, 0 },
-       { 0, 0, 0, 0, 0, 1, 0, 0, 0 },
-       { 0, 0, 0, 0, 0, 0, 1, 0, 0 },
-       { 0, 1, 0, 0, 0, 0, 0, 1, 0 }, // buoyoncircle -> affine
-       { 0, 0, 0, 0, 0, 0, 0, 0, 1 }
+    bool canconvert[12][12] = { // [source][target]
+       { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+       { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+       { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+       { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 },
+       { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 },
+       { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 },
+       { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
+       { 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, // buoyoncircle -> affine
+       { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 },
+       { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 },
+       { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 },
+       { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }
     };
 
     int CoordSet::nprevious(int typecode) { 
Index: gzz/gfx/libcoords/Coords.hxx
diff -u gzz/gfx/libcoords/Coords.hxx:1.21 gzz/gfx/libcoords/Coords.hxx:1.22
--- gzz/gfx/libcoords/Coords.hxx:1.21   Tue Oct 29 14:55:36 2002
+++ gzz/gfx/libcoords/Coords.hxx        Fri Nov  1 03:05:13 2002
@@ -151,7 +151,18 @@
        virtual bool getOthertypeParams(int type, float *into) {
            return false;
        }
+
+       /** Get the size of the "unit square" of this coordinate system.
+        * For most coordinate systems, this will be Pt(1,1) but there are
+        * some which alter this, for the purpose of catching mouse clicks
+        * at a larger area. A mouse click is "in" this coordinate system,
+        * if it is in the area Pt(0,0) .. getSqSize()
+        */
+       virtual Pt getSqSize() {
+           return Pt(1, 1);
+       }
     };
+
     /** A class that manages a set of coordinate systems.
      */
     class CoordSet {
Index: gzz/gzz/gfx/gl/GLVobCoorder.java
diff -u gzz/gzz/gfx/gl/GLVobCoorder.java:1.49 
gzz/gzz/gfx/gl/GLVobCoorder.java:1.50
--- gzz/gzz/gfx/gl/GLVobCoorder.java:1.49       Tue Oct 29 14:55:36 2002
+++ gzz/gzz/gfx/gl/GLVobCoorder.java    Fri Nov  1 03:05:13 2002
@@ -29,7 +29,7 @@
 import gzz.client.gl.*;
 
 public class GLVobCoorder extends AffineVobCoorder {
-public static final String rcsid = "$Id: GLVobCoorder.java,v 1.49 2002/10/29 
19:55:36 tjl Exp $";
+public static final String rcsid = "$Id: GLVobCoorder.java,v 1.50 2002/11/01 
08:05:13 tjl Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.err.println(s); }
 
@@ -211,6 +211,63 @@
        floats[ind + 0] = sx;
        floats[ind + 1] = sy;
        floats[ind + 2] = sz;
+    }
+
+    public int box(int into, float w, float h) {
+       int paramInd = nfloats;
+       nfloats += 2;
+
+       inds[ninds + 0] = 11; // box
+       inds[ninds + 1] = into;
+       inds[ninds + 2] = paramInd;
+       int was = ninds;
+       ninds += 3;
+
+       setBoxParams(was, w, h);
+
+       return was;
+    }
+
+    public void setBoxParams(int cs, float w, float h) {
+       int ind = inds[cs + 2];
+       floats[ind + 0] = w;
+       floats[ind + 1] = h;
+    }
+
+    public int unitSq(int into) {
+       inds[ninds + 0] = 12; // unitsq 
+       inds[ninds + 1] = into;
+       inds[ninds + 2] = -42; // not used
+       int was = ninds;
+       ninds += 3;
+       return was;
+    }
+
+
+    public int orthoBox(int into, float z, float x, float y, float sx, float 
sy, float w, float h) {
+       int paramInd = nfloats;
+       nfloats += 7;
+
+       inds[ninds + 0] = 14; // orthobox
+       inds[ninds + 1] = into;
+       inds[ninds + 2] = paramInd;
+       int was = ninds;
+       ninds += 3;
+
+       setOrthoBoxParams(was, z, x, y, sx, sy, w, h);
+
+       return was;
+    }
+
+    public void setOrthoBoxParams(int cs, float z, float x, float y, float sx, 
float sy, float w, float h) {
+       int ind = inds[cs + 2];
+       floats[ind + 0] = x;
+       floats[ind + 1] = y;
+       floats[ind + 2] = z;
+       floats[ind + 3] = sx;
+       floats[ind + 4] = sy;
+       floats[ind + 5] = w;
+       floats[ind + 6] = h;
     }
 
 
Index: gzz/test/gzz/gfx/gl/glvobcoorder.test
diff -u gzz/test/gzz/gfx/gl/glvobcoorder.test:1.16 
gzz/test/gzz/gfx/gl/glvobcoorder.test:1.17
--- gzz/test/gzz/gfx/gl/glvobcoorder.test:1.16  Tue Oct 29 09:09:32 2002
+++ gzz/test/gzz/gfx/gl/glvobcoorder.test       Fri Nov  1 03:05:13 2002
@@ -17,6 +17,15 @@
 vs2 = getvs()
 c2 = vs2.coords
 
+def testBoxes():
+    cs1 = c.box(0, 200, 100)
+    cs2 = c.unitSq(cs1)
+    checkTrans(vs, cs2, [0, 0, 0, 1, 1, 1, 2, 2, 2], 
+                       [0, 0, 0, 200, 100, 1, 400, 200, 2])
+
+    cs1 = c.orthoBox(0, 5, 200, 100, 2, 2, 10, 10)
+    cs2 = c.unitSq(cs1)
+    checkTrans(vs, cs2, [0, 0, 0, 1, 1, 1], [200, 100, 5, 220, 120, 6])
     
 
 def testTransform():
@@ -272,8 +281,3 @@
     checkAvgColor(10, 10, 80, 80, (255, 0, 0), delta=50)
 
 # : vim: set syntax=python :
-
-
-
-
-




reply via email to

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