gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz ./TODO Documentation/VISION gfx/jni/GzzGL-j...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz ./TODO Documentation/VISION gfx/jni/GzzGL-j...
Date: Tue, 29 Oct 2002 14:55:36 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/10/29 14:55:36

Modified files:
        .              : TODO 
        Documentation  : VISION 
        gfx/jni        : GzzGL-jni.cxx 
        gfx/libcoords  : Coords.cxx Coords.hxx 
        gzz/gfx/gl     : GL.java GLVobCoorder.java 
        test           : testutil.py 

Log message:
        Peg work

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/TODO.diff?tr1=1.337&tr2=1.338&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Documentation/VISION.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/jni/GzzGL-jni.cxx.diff?tr1=1.55&tr2=1.56&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.cxx.diff?tr1=1.45&tr2=1.46&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcoords/Coords.hxx.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GL.java.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GLVobCoorder.java.diff?tr1=1.48&tr2=1.49&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/testutil.py.diff?tr1=1.32&tr2=1.33&r1=text&r2=text

Patches:
Index: gzz/Documentation/VISION
diff -u gzz/Documentation/VISION:1.7 gzz/Documentation/VISION:1.8
--- gzz/Documentation/VISION:1.7        Thu Oct 24 22:57:17 2002
+++ gzz/Documentation/VISION    Tue Oct 29 14:55:36 2002
@@ -14,6 +14,10 @@
     - mostly LGPL, most valuable innovations GPL.
     - if we ever acquire patents, we shall make a worldwide
       irrevocable license grant for use in GPL software
+       - we are funded by companies who will either own 
+         or license these patents; we have an understanding
+         that they will grant the GPL rights: this does not
+         undermine their business interests.
 
 
 Computers should be easy to use but powerful.
@@ -22,7 +26,8 @@
 
 User interfaces
 
-    Technology fragments
+    Technology fragments (moved from research)
+     
        - focus + context views
        - irregularframe: showing a piece of a larger plane
          in a natural way
@@ -42,9 +47,11 @@
 
 Structure
 
-    zzStructure
+    Implementing Ted Nelson's ideas
 
-    Xanadu hypertext model
+       zzStructure
+
+       Xanadu hypertext model
 
 Storage
 
Index: gzz/TODO
diff -u gzz/TODO:1.337 gzz/TODO:1.338
--- gzz/TODO:1.337      Tue Oct 29 10:48:27 2002
+++ gzz/TODO    Tue Oct 29 14:55:35 2002
@@ -129,7 +129,6 @@
        + better algorithm for CullingCoordSys. Uses now parallel
           bounding boxes. Fast, but not very efficient.
     tjl:        
-       - tests for PEG 1021
        - PP [deadline 5.11]
            - refactor
                - separate objects on paper from coordinates and scale.
@@ -185,6 +184,8 @@
        + clean GzzGL-jni
        + complete "Gzz technologies" white paper
     anybody:
+       - tests for PEG 1021
+       - implement PEG 1021 for AWT
        - autogenerate the pegboard page from
          a .rst file and the .rst files of the pegs - currently
          we need to change several locations.
Index: gzz/gfx/jni/GzzGL-jni.cxx
diff -u gzz/gfx/jni/GzzGL-jni.cxx:1.55 gzz/gfx/jni/GzzGL-jni.cxx:1.56
--- gzz/gfx/jni/GzzGL-jni.cxx:1.55      Wed Oct 23 10:55:39 2002
+++ gzz/gfx/jni/GzzGL-jni.cxx   Tue Oct 29 14:55:36 2002
@@ -1203,6 +1203,70 @@
       return (cs != 0);
  }
 
+struct Match {
+    int ind;
+    float depth;
+    bool operator<(const Match &m) const {
+       return depth < m.depth;
+    }
+};
+
+JNIEXPORT jintArray JNICALL Java_gzz_gfx_gl_GL_getAllCSAt
+ (JNIEnv *env, jclass, jint ninds, jintArray j_inds, jfloatArray j_pts,
+    jint parent, jfloat x, jfloat y) {
+      jint *inds = env->GetIntArrayElements(j_inds, 0);
+      jfloat *pts = env->GetFloatArrayElements(j_pts, 0);
+
+      vector<Match> matches;
+
+      Coords::CoordSet coordset;
+      coordset.clean();
+      coordset.setPoints((int)ninds, (int*)inds, 
+                        (float*)pts, (int*)0,
+                        (int*)0, (float*)0, 
+                        (float)0, (bool)true);
+
+     ZPt screenpt(x, y, 0);
+     for(Coords::CoordSet::iterator iter = coordset.begin(); 
+            iter != coordset.end(); iter++) {
+       // XXX Break encapsulation badly
+       if(!(inds[*iter] & Coords::CSFLAG_ACTIVE))
+           continue;
+       Coords::CoordSys *cs = coordset.get(*iter);
+
+       // Transform screen point to inside coordsys
+       ZPt pt = cs->getInverse()->transform(screenpt);
+       // See whether inside unit square
+       if(pt.x < 0 || pt.x > 1 ||
+          pt.y < 0 || pt.y > 1) continue;
+       // Project to zero plane
+       pt.z = 0;
+       // Transform back to screen coordinates
+       pt = cs->transform(pt);
+       // Add match object
+       Match m = { *iter, pt.z };
+       matches.push_back(m);
+     }
+
+     // Sort the matches according to depth
+     std::sort(matches.begin(), matches.end());
+
+     // Put the matching indices into the output array.
+     jintArray arr = env->NewIntArray(matches.size());
+     jint *els = env->GetIntArrayElements(arr, 0);
+
+     for(unsigned i = 0; i<matches.size(); i++)
+       els[i] = matches[i].ind;
+
+     env->ReleaseIntArrayElements(arr, els, 0); // Commit
+
+
+      env->ReleaseIntArrayElements(j_inds, inds, JNI_ABORT);
+      env->ReleaseFloatArrayElements(j_pts, pts, JNI_ABORT);
+
+      return arr;
+ }
+
 
 
 using namespace Renderables;
Index: gzz/gfx/libcoords/Coords.cxx
diff -u gzz/gfx/libcoords/Coords.cxx:1.45 gzz/gfx/libcoords/Coords.cxx:1.46
--- gzz/gfx/libcoords/Coords.cxx:1.45   Tue Oct 29 10:07:40 2002
+++ gzz/gfx/libcoords/Coords.cxx        Tue Oct 29 14:55:36 2002
@@ -939,6 +939,8 @@
        CoordSet *cs1_tmp = 0;
        CoordSet *cs2_tmp = 0;
 
+       this->maxcs = ninds;
+
        for(int i=1; i<ninds; i+=lastIndSize) {
            DBG(dbg)  << "loop "<<i<<"\n";
            int parind = params.size();
@@ -1086,6 +1088,12 @@
        return new RootCoords(); 
     }
 
+    CoordSet::iterator CoordSet::begin() {
+       return iterator(1, this);
+    }
+    CoordSet::iterator CoordSet::end() {
+       return iterator(maxcs, this);
+    }
 
 }
 
Index: gzz/gfx/libcoords/Coords.hxx
diff -u gzz/gfx/libcoords/Coords.hxx:1.20 gzz/gfx/libcoords/Coords.hxx:1.21
--- gzz/gfx/libcoords/Coords.hxx:1.20   Tue Oct 29 09:09:32 2002
+++ gzz/gfx/libcoords/Coords.hxx        Tue Oct 29 14:55:36 2002
@@ -158,6 +158,8 @@
        vector<CoordSys *> cs;
        vector<float> params;
 
+       int maxcs;
+
        int nparams(int typecode) ;
        int nprevious(int typecode) ;
        CoordSys *create(int typecode) ;
@@ -172,6 +174,40 @@
                }
            }
        }
+       class iterator {
+           int ind;
+           CoordSet *parent;
+
+           void incr() {
+               ind++;
+               while(parent->get(ind) == 0 && ind < parent->maxcs)
+                   ind++;
+           }
+       public:
+           iterator(int ind, CoordSet *parent) : ind(ind), parent(parent) { }
+           int operator*() { 
+               return ind;
+           }
+           iterator& operator++() { 
+               incr();
+               return *this;
+           }
+           iterator operator++(int) { 
+               iterator tmp = *this;
+               incr();
+               return tmp;
+           }
+           bool operator==(const iterator &it) const { return ind == it.ind; }
+           bool operator!=(const iterator &it) const { return ind != it.ind; }
+
+       };
+       /** Return an iterator pointing to the first coordinate system 
+        * (not root, i.e. not 0).
+        */
+       iterator begin();
+       /** Return an iterator pointing one past the last coordinate system.
+        */
+       iterator end();
        /** Set the coordinate systems.
         * @param points1 floats: the parameters of the coordinate
         *              systems.
Index: gzz/gzz/gfx/gl/GL.java
diff -u gzz/gzz/gfx/gl/GL.java:1.18 gzz/gzz/gfx/gl/GL.java:1.19
--- gzz/gzz/gfx/gl/GL.java:1.18 Tue Oct 29 09:09:32 2002
+++ gzz/gzz/gfx/gl/GL.java      Tue Oct 29 14:55:36 2002
@@ -768,6 +768,13 @@
                        boolean show1,
                    int coordsys, boolean inverse, float[] points, float[]into);
 
+    /** Get all the activated coordinate systems in whose unit squares the
+     * given point falls..
+     * @param parent (currently ignored, may be used to restrict in future)
+     */
+    public static native int[] getAllCSAt(int ninds, int[] inds, float[] pts,
+                           int parent, float x, float y);
+
     /** Process native events.
      * @param wait If false, this function will return once there are no more
      *                 native events to process. If true, this function will 
wait
Index: gzz/gzz/gfx/gl/GLVobCoorder.java
diff -u gzz/gzz/gfx/gl/GLVobCoorder.java:1.48 
gzz/gzz/gfx/gl/GLVobCoorder.java:1.49
--- gzz/gzz/gfx/gl/GLVobCoorder.java:1.48       Tue Oct 29 10:07:40 2002
+++ gzz/gzz/gfx/gl/GLVobCoorder.java    Tue Oct 29 14:55:36 2002
@@ -29,7 +29,7 @@
 import gzz.client.gl.*;
 
 public class GLVobCoorder extends AffineVobCoorder {
-public static final String rcsid = "$Id: GLVobCoorder.java,v 1.48 2002/10/29 
15:07:40 humppake Exp $";
+public static final String rcsid = "$Id: GLVobCoorder.java,v 1.49 2002/10/29 
19:55:36 tjl Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.err.println(s); }
 
@@ -44,7 +44,21 @@
     }
 
     public int getCSAt(int parent, float x, float y, float[] targetcoords) {
+       int[] inds = GL.getAllCSAt(ninds, this.inds, floats, parent, x, y);
+       for(int i=0; i<inds.length; i++)
+           if(isAncestor(inds[i], parent))
+               return inds[i];
        return -1;
+    }
+
+    private boolean isAncestor(int cs, int parent) {
+       while(cs != parent && cs != -1) 
+           cs = getParent(cs);
+       return cs == parent;
+    }
+
+    public int getParent(int cs) {
+       return inds[cs+1];
     }
 
     public int affineCoordsys(
Index: gzz/test/testutil.py
diff -u gzz/test/testutil.py:1.32 gzz/test/testutil.py:1.33
--- gzz/test/testutil.py:1.32   Sat Oct 19 11:00:06 2002
+++ gzz/test/testutil.py        Tue Oct 29 14:55:36 2002
@@ -221,6 +221,7 @@
                print str(val)
                l = traceback.format_list(traceback.extract_tb(tra))
                print "\n".join(l)
+           print "Calling system.exit"
            java.lang.System.exit(0)
     GraphicsAPI.getInstance().startUpdateManager(Starter())
 




reply via email to

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