gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz gfx/demo/buoyoing.py gzz/view/PageSpanCellV...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz gfx/demo/buoyoing.py gzz/view/PageSpanCellV...
Date: Wed, 05 Feb 2003 04:44:33 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        03/02/05 04:44:32

Modified files:
        gfx/demo       : buoyoing.py 
        gzz/view       : PageSpanCellView.java 
        gzz/view/buoy  : buoymanager.py pagespanNodes.py 
        test/gzz/view  : pagespancellview.test 

Log message:
        Refactor pagespancellview for easier irregu borders and anchor coordsys

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/buoyoing.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/PageSpanCellView.java.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/buoy/buoymanager.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/buoy/pagespanNodes.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/test/gzz/view/pagespancellview.test.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/buoyoing.py
diff -u gzz/gfx/demo/buoyoing.py:1.3 gzz/gfx/demo/buoyoing.py:1.4
--- gzz/gfx/demo/buoyoing.py:1.3        Wed Feb  5 03:14:45 2003
+++ gzz/gfx/demo/buoyoing.py    Wed Feb  5 04:44:32 2003
@@ -1,4 +1,4 @@
-# Buoy - Open Implementation - Next Generation demo
+# Buoy-oriented interface - Next Generation demo
 
 import jarray
 
Index: gzz/gzz/view/PageSpanCellView.java
diff -u gzz/gzz/view/PageSpanCellView.java:1.9 
gzz/gzz/view/PageSpanCellView.java:1.10
--- gzz/gzz/view/PageSpanCellView.java:1.9      Tue Feb  4 07:21:25 2003
+++ gzz/gzz/view/PageSpanCellView.java  Wed Feb  5 04:44:32 2003
@@ -24,68 +24,115 @@
 
     public boolean useBg = true;
 
-    PageSpan[] pages;
-    PageSpanPaper[] psps;
-    float[] xywh;
-    float w;
-    float h;
-
-    // XXX KLUDGE!
-    public float xoffs, yoffs;
-
-    public void getSize(Enfilade1D enf, float[] out, 
-                           PageSpan center) {
-       int npages = enf.length();
-
-       pages = new PageSpan[npages];
-       psps = new PageSpanPaper[npages];
-       xywh = new float[npages * 4]; // x, y, w, h in PAPER coordinates
-       w = 0;
-       h = 0;
-
-       boolean foundCenter = false;
-       xoffs = 0;
-       yoffs = 0;
-
-       for(int p = 0; p < npages; p++) {
-           pages[p] = (PageSpan)enf.sub(p, p+1).getList().get(0); // XXX 
INEFFICIENT!
-           GLSpanner.SpanRect rect = GLSpanner.getSpanRect(pages[p]);
-           psps[p] = new PageSpanPaper(null, rect.page);
-
-           Point l_p = pages[p].getLocation();
-           Dimension d_p = pages[p].getSize();
-
-           xywh[4*p + 0] = psps[p].getX(l_p.x);
-           xywh[4*p + 1] = psps[p].getY(l_p.y);
-           xywh[4*p + 2] = psps[p].getX(d_p.width);
-           xywh[4*p + 3] = psps[p].getY(d_p.height);
-
-           if(dbg) pa("Page "+p+" "+
-                       xywh[4*p+0]+" "+
-                       xywh[4*p+1]+" "+
-                       xywh[4*p+2]+" "+
-                       xywh[4*p+3]+" "+
-                       pages[p]);
-
-           if(!foundCenter && center != null && center.intersects(pages[p])) {
-               foundCenter = true;
-               Point l_c = center.getLocation(); // XXX Center?
-               Dimension d_c = center.getSize(); // XXX Center?
-
-               xoffs = w + scale * (psps[p].getX(l_c.x + .5f * d_c.width) - 
xywh[4*p + 0]);
-               yoffs = scale * (psps[p].getY(l_c.y + .5f * d_c.height) - 
xywh[4*p + 1]);
-               if(dbg) pa("Center found: "+p+" "+pages[p]+" "+
-                           xoffs + " " + yoffs);
-               
+    public Layout getLayout(Enfilade1D enf) {
+       return new Layout(enf);
+    }
+
+    public void getSize(Enfilade1D enf, float[] out) {
+       Layout l = getLayout(enf);
+       out[0] = l.w;
+       out[1] = l.h;
+    }
+
+    /** A single enfilade laid out on the plane.
+     */
+    public class Layout {
+
+       int npages;
+       PageSpan[] pages;
+       PageSpanPaper[] psps;
+       float[] xywh;
+       float w;
+       float h;
+
+       // XXX KLUDGE!
+       public float xoffs, yoffs;
+
+       public Layout(Enfilade1D enf) {
+           npages = enf.length();
+
+           pages = new PageSpan[npages];
+           psps = new PageSpanPaper[npages];
+           xywh = new float[npages * 4]; // x, y, w, h in PAPER coordinates
+           w = 0;
+           h = 0;
+
+           boolean foundCenter = false;
+           xoffs = 0;
+           yoffs = 0;
+
+           for(int p = 0; p < npages; p++) {
+               pages[p] = (PageSpan)enf.sub(p, p+1).getList().get(0); // XXX 
INEFFICIENT!
+               GLSpanner.SpanRect rect = GLSpanner.getSpanRect(pages[p]);
+               psps[p] = new PageSpanPaper(null, rect.page);
+
+               Point l_p = pages[p].getLocation();
+               Dimension d_p = pages[p].getSize();
+
+               xywh[4*p + 0] = psps[p].getX(l_p.x);
+               xywh[4*p + 1] = psps[p].getY(l_p.y);
+               xywh[4*p + 2] = psps[p].getX(d_p.width);
+               xywh[4*p + 3] = psps[p].getY(d_p.height);
+
+               if(dbg) pa("Page "+p+" "+
+                           xywh[4*p+0]+" "+
+                           xywh[4*p+1]+" "+
+                           xywh[4*p+2]+" "+
+                           xywh[4*p+3]+" "+
+                           pages[p]);
+
+               w += scale * xywh[4*p + 2];
+               if(h < scale * xywh[4*p + 3])
+                   h = scale * xywh[4*p + 3];
            }
-           w += scale * xywh[4*p + 2];
-           if(h < scale * xywh[4*p + 3])
-               h = scale * xywh[4*p + 3];
+
+
+
        }
 
-       if(out != null) {
-           out[0] = w;
-           out[1] = h;
+       /** Get the extents (in the output coordinates)
+        * of a given page span.
+        * Currently, only the first intersecting page
+        * is used, but this may change.
+        */
+       public void getExtents(PageSpan s, float[] xywh_out) {
+
+           for(int p = 0; p < npages; p++) {
+               if(s.intersects(pages[p])) {
+                   Point l_c = s.getLocation(); 
+                   Dimension d_c = s.getSize(); 
+
+                   xoffs = w + scale * (psps[p].getX(l_c.x + .5f * d_c.width) 
- xywh[4*p + 0]);
+                   yoffs = scale * (psps[p].getY(l_c.y + .5f * d_c.height) - 
xywh[4*p + 1]);
+                   if(dbg) pa("Center found: "+p+" "+pages[p]+" "+
+                               xoffs + " " + yoffs);
+                   
+               }
+           }
+       }
+
+       /** Place this layout into the given coordinate system.
+        * Note that the layout is not affected by the 
+        * box size of the coordinate system.
+        */
+       public void place(VobScene vs, int into, float importance, float 
pixelscale) {
+           float curx = 0;
+           // Now we can draw the pages.
+           for(int p = 0; p < npages; p++) {
+               // We want a coordinate system
+               // whose box is exactly the span
+               int around = vs.orthoBoxCS(into, pages[p], 0, 
+                               curx, -yoffs, scale, scale,
+                               xywh[4*p+2], xywh[4*p+3]);
+               // and then translate to the whole page.
+               int tr = vs.translateCS(around, "T", -xywh[4*p+0], 
-xywh[4*p+1]);
+               curx += scale * xywh[4*p + 2];
+
+               psps[p].request(importance, scale * pixelscale);
+               vs.map.put(GLRen.createPaperQuad(psps[p].getPaper(useBg), 
+                           xywh[4*p + 0], xywh[4*p + 1], 
+                           xywh[4*p + 2], xywh[4*p + 3], 0), tr, 0);
+           }
        }
 
 
@@ -109,27 +156,9 @@
      * @param importance The importance to be given to the image requests
      * @param pixelscale The pixel scale at which the image requests are made
      */
-    public void placeCentered(Enfilade1D enf, VobScene vs, int into, 
-                                PageSpan center,
+    public void place(Enfilade1D enf, VobScene vs, int into, 
                                float importance, float pixelscale) {
-       int npages = enf.length();
-       xoffs = 0; yoffs = 0;
-       getSize(enf, null, center);
-
-       // Now we can draw the pages.
-       float curx = -xoffs;
-       for(int p = 0; p < npages; p++) {
-           int around = vs.orthoBoxCS(into, pages[p], 0, 
-                           curx, -yoffs, scale, scale,
-                           xywh[4*p+2], xywh[4*p+3]);
-           int tr = vs.translateCS(around, "T", -xywh[4*p+0], -xywh[4*p+1]);
-           curx += scale * xywh[4*p + 2];
-
-           psps[p].request(importance, scale * pixelscale);
-           vs.map.put(GLRen.createPaperQuad(psps[p].getPaper(useBg), 
-                       xywh[4*p + 0], xywh[4*p + 1], 
-                       xywh[4*p + 2], xywh[4*p + 3], 0), tr, 0);
-       }
+       getLayout(enf).place(vs, into, importance, pixelscale);
 
     }
 
@@ -137,15 +166,14 @@
     //
     public void place(Cell c, VobScene vs, int box,
                           ViewContext context) {
-       placeCentered(
-           ((VStreamCellTexter)c.space.getCellTexter()).getEnfilade(c, null),
-           vs, box, null,
-           .5f, 100);
+       Layout l = getLayout(
+         ((VStreamCellTexter)c.space.getCellTexter()).getEnfilade(c, null)
+               );
+       l.place( vs, box, .5f, 100);
     }
     public void getSize(Cell c, ViewContext context, float[] out) {
        getSize(
-           ((VStreamCellTexter)c.space.getCellTexter()).getEnfilade(c, null),
-           out,
-           null);
+         ((VStreamCellTexter)c.space.getCellTexter()).getEnfilade(c, null),
+         out);
     }
 }
Index: gzz/gzz/view/buoy/buoymanager.py
diff -u gzz/gzz/view/buoy/buoymanager.py:1.3 
gzz/gzz/view/buoy/buoymanager.py:1.4
--- gzz/gzz/view/buoy/buoymanager.py:1.3        Wed Feb  5 03:14:45 2003
+++ gzz/gzz/view/buoy/buoymanager.py    Wed Feb  5 04:44:32 2003
@@ -27,7 +27,7 @@
        self.mainNode = initBuoyviewnodetype.createMainNode(
                            initLinkId, initAnchor, self)
     def nadir(self, cs):
-       n =  self.vs.coords.nadirUnitSq(cs, self.nadirCS)
+       n =  self.vs.coords.nadir(cs, self.nadirCS)
        self.vs.matcher.add(cs, n, "NADIR")
        return n
     def scene(self, vs):
@@ -38,7 +38,10 @@
 
        vs.put(background((.5,.8,.5)))
 
-       main = vs.orthoBoxCS(0, "MAINVP", 0, 300, 200, .3, .3, 200, 200)
+       center = vs.translateCS(0, "Center", 0, 400, 300)
+
+       main = vs.orthoBoxCS(center, "MAINVP", 0, 
+                               -100, -100, .2, .2, 1000, 1000)
 
        self.mainNode.renderMain(vs, self.nadir(main))
 
Index: gzz/gzz/view/buoy/pagespanNodes.py
diff -u gzz/gzz/view/buoy/pagespanNodes.py:1.8 
gzz/gzz/view/buoy/pagespanNodes.py:1.9
--- gzz/gzz/view/buoy/pagespanNodes.py:1.8      Tue Feb  4 16:24:10 2003
+++ gzz/gzz/view/buoy/pagespanNodes.py  Wed Feb  5 04:44:32 2003
@@ -1,5 +1,8 @@
 import jarray
 
+# Page span scrollblock as a whole;
+# in buoys, a part is shown.
+
 import gzz
 from gzz.view.buoy import BuoyViewNodeType, BuoyViewMainNode
 
Index: gzz/test/gzz/view/pagespancellview.test
diff -u gzz/test/gzz/view/pagespancellview.test:1.5 
gzz/test/gzz/view/pagespancellview.test:1.6
--- gzz/test/gzz/view/pagespancellview.test:1.5 Tue Feb  4 04:37:52 2003
+++ gzz/test/gzz/view/pagespancellview.test     Wed Feb  5 04:44:32 2003
@@ -65,7 +65,7 @@
 
     s = sc.getCurrent().getSize()
     z = jarray.zeros(2, "f")
-    PageSpanCellView().getSize(enfMaker.makeEnfilade(sc.getCurrent()), z, None)
+    PageSpanCellView().getSize(enfMaker.makeEnfilade(sc.getCurrent()), z)
 
     failUnlessApprox(.1, z[0], 2 * 612)
     failUnlessApprox(.1, z[1], 792)
@@ -91,8 +91,8 @@
 
 
        scaled = vs.orthoCS(0, "X", 0, 150, 150, .2, .2)
-       v.placeCentered(enfMaker.makeEnfilade(sc.getCurrent()), vs, scaled, 
-                       None, 1, 100000)
+       v.place(enfMaker.makeEnfilade(sc.getCurrent()), vs, scaled, 
+                       1, 100000)
 
        render(vs)
 
@@ -105,16 +105,16 @@
 
     failUnlessEqual(passed, 1, "didn't get the image " + exc)
 
-    # Now that the images are loaded, check span offsets
-    vs = getvs()
-    vs.map.put(SolidBgVob(Color.yellow))
-    scaled = vs.orthoCS(0, "X", 0, 200, 150, .2, .2)
-    v.placeCentered(enfMaker.makeEnfilade(sc.getCurrent()), vs, scaled, 
-           sc.getCurrent().subSpan(1), 1, 100000)
-    render(vs)
-    if not checkColors(int(200 - 1.5 * 612 / 5.0), 
-                           int(150 - .5 * 792 / 5.0)):
-       fail(exc)
+    # # Now that the images are loaded, check span offsets
+    # vs = getvs()
+    # vs.map.put(SolidBgVob(Color.yellow))
+    # scaled = vs.orthoCS(0, "X", 0, 200, 150, .2, .2)
+    # v.placeCentered(enfMaker.makeEnfilade(sc.getCurrent()), vs, scaled, 
+           # sc.getCurrent().subSpan(1), 1, 100000)
+    # render(vs)
+    # if not checkColors(int(200 - 1.5 * 612 / 5.0), 
+                           # int(150 - .5 * 792 / 5.0)):
+       # fail(exc)
 
     
 




reply via email to

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