gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx demo/xupdf.py libutil/effects.py


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz/gfx demo/xupdf.py libutil/effects.py
Date: Sat, 28 Sep 2002 15:01:21 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/09/28 15:01:20

Modified files:
        gfx/demo       : xupdf.py 
        gfx/libutil    : effects.py 

Log message:
        Buoys in xupdf almost work again

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/xupdf.py.diff?tr1=1.29&tr2=1.30&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/effects.py.diff?tr1=1.9&tr2=1.10&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/xupdf.py
diff -c gzz/gfx/demo/xupdf.py:1.29 gzz/gfx/demo/xupdf.py:1.30
*** gzz/gfx/demo/xupdf.py:1.29  Sat Sep 28 04:03:51 2002
--- gzz/gfx/demo/xupdf.py       Sat Sep 28 15:01:20 2002
***************
*** 102,108 ****
  
      # Check type
      if 1: # PDF
!       globalview = CellPDFView(cell)
  
      linktaken = globalcurlinks.get(cell.getId(), None)
      if linktaken:
--- 102,108 ----
  
      # Check type
      if 1: # PDF
!       globalview = getCellPDFView(cell)
  
      linktaken = globalcurlinks.get(cell.getId(), None)
      if linktaken:
***************
*** 121,126 ****
--- 121,129 ----
      java.lang.System.gc()
      AbstractUpdateManager.chg()
  
+ def getCellPDFView(cell):
+     return CellPDFView(cell)
+ 
  class CellPDFView:
      def __init__(self, cell):
          self.white = getDListNocoords("Color 1 1 1")
***************
*** 130,135 ****
--- 133,139 ----
        self.pap = getPDFPapers(self.content)
        self.irregu = IrreguFrame(0, 0, self.pap[0][1] / self.pap[0][2] * 
len(self.pap), 1,
                        0.06, 0.5)
+       self.papersize = (self.pap[0][1] * len(self.pap), self.pap[0][2])
        # self.irregu = IrreguFrame(-1, -1, 1, 1, 0.06, 0.5)
      # Height = always 1.
      # Start = always (0,0)
***************
*** 170,176 ****
                    self.curx += papers[i][1] * scale
  
        pp = PutPapers()
!       if cliprect:
            irr = vs.coords.affineCoordsys(0, 0, 
                    (cliprect[0]+cliprect[2])/2,
                    (cliprect[1]+cliprect[3])/2,
--- 174,180 ----
                    self.curx += papers[i][1] * scale
  
        pp = PutPapers()
!       if cliprect and 0:
            irr = vs.coords.affineCoordsys(0, 0, 
                    (cliprect[0]+cliprect[2])/2,
                    (cliprect[1]+cliprect[3])/2,
***************
*** 204,209 ****
--- 208,218 ----
                
        else:
            pp.run()
+     def paperpoint(self, page, pointx, pointy):
+       return (
+           page * self.papersize[0] + pointx/72.0/6, pointy/72.0/6
+       )
+ 
  
  
  globalscrollblockPapers = {}
***************
*** 313,327 ****
      """), pap = background.clone())
      return (papw, pw, ph, papo)
  
- 
- def paperpoint(papers, h, page, pointx, pointy):
-     ph = papers[0][1][2]
-     scale = h / ph
-     pscale = 1/72.0/6
-     return (
-       page * 1.02 * papers[0][1][1] * scale + pointx * pscale * scale,
-       pointy * pscale * scale,
-     )
  def bg(vs):
      putnoc(vs, background((0.3,0.5,0.4)))
      putnoc(vs, getDListNocoords("""
--- 322,327 ----
***************
*** 337,367 ****
        Enable TEXTURE_2D
      """ % { "w": screensize[0], "h": screensize[1] } ) )
  
- class PDFFloat(Runnable):
-     def __init__(self, vs, cell, linkspan):
-       self.vs = vs
-       self.cell = cell
-       self.linkspan = linkspan
-     def run(self):
-       vs = self.vs
-       pap = getPDFPapers(space.cellTexter.getEnfilade(self.cell, None))
-       bs = 0.01
-       p = self.linkspan.getLocation()
-       d = self.linkspan.getSize()
-       height = 400
-       pt = paperpoint(pap, height, self.linkspan.offset(), p.x+0.5*d.width, 
p.y+0.5*d.height)
-       # print "PT: ",pt
-       
-       cs2 = vs.coords.affineCoordsys(0, self.cell.getId()+"__bulg", 
-           0.05, 0, 0, bs, 0, 0, bs)
-       cliprect = (p.x, p.y, p.x+d.width, p.y+d.height)
-       placepapers(vs, cs2, pap, self.cell.getId(),
-           -pt[0], -pt[1], 
-           0, 0, 
-           height, onlypages=[self.linkspan.offset()], depth=5,
-           cliprect = cliprect)
-       
- 
  def addbuoy(vs, anchorX, anchorY, importance, floater, link):
      print "Addbuoy ",link
      linkspan = link.getList()[0]
--- 337,342 ----
***************
*** 372,393 ****
      if len(l) == 0: return
      m = l[0]
      print m
      global globalcurlinks
      globalcurlinks[m.getId()] = link
!     floater.addBuoy(anchorX, anchorY, importance, m.getId(), 
!           PDFFloat(vs, m, linkspan), 0, 0)
  
  class XuPDFScene_PDFContext:
      def __init__(self):
!       self.yheight = 50
        self.ctrx = screensize[0]/2
        self.ctry = screensize[1]/2
        self.rad = screensize[1]/2
        self.nadir = NadirAngler(self.ctrx, screensize[1]*2)
      def key(self, key):
        global currentScene
        if key == 'z':
            currentScene = XuPDFScene_PDFZoom()
      def mouse(self, ev):
        global globalx, globaly
        if ev.getID() == ev.MOUSE_CLICKED:
--- 347,394 ----
      if len(l) == 0: return
      m = l[0]
      print m
+     cell = m
      global globalcurlinks
      globalcurlinks[m.getId()] = link
!     view = getCellPDFView(m)
! 
!     p = linkspan.getLocation()
!     d = linkspan.getSize()
! 
!     p0 = view.paperpoint(linkspan.offset(), p.x, p.y)
!     p1 = view.paperpoint(linkspan.offset(), p.x+d.width, p.y+d.height)
! 
!     cs1 = floater.addBuoy(anchorX, anchorY, importance, m.getId(), 0, 0)
!     eye = 0.2
!     cs1_zoom= vs.coords.distort(cs1, 0, 0, eye, eye, 100, 100)
!     vs.matcher.add(cs1_zoom, cell.getId()+"__bulg") 
! 
!     # cs1_trans = vs.coords.translateXY(cs1_zoom, - (p0[0]+p1[0])/2, - 
(p0[1]+p1[1])/2)
!     cs1_trans = vs.coords.translateXY(cs1_zoom, 0, 0)
!     vs.matcher.add(cs1_trans, cell.getId()+"__trans") 
! 
!     view.placepapers(vs, cs1_trans, cliprect = (p0[0], p0[1], p1[0], p1[1]))
! 
  
  class XuPDFScene_PDFContext:
      def __init__(self):
!       self.mag = [(screensize[1],20)]
        self.ctrx = screensize[0]/2
        self.ctry = screensize[1]/2
        self.rad = screensize[1]/2
        self.nadir = NadirAngler(self.ctrx, screensize[1]*2)
+       self.showcontext = 0
+       self.clip = 0
      def key(self, key):
        global currentScene
        if key == 'z':
            currentScene = XuPDFScene_PDFZoom()
+       if key == 'm':
+           rotatelist(self.mag)
+       if key == 'c':
+           self.clip = not self.clip
+       if key == 's':
+           self.showcontext = not self.showcontext
      def mouse(self, ev):
        global globalx, globaly
        if ev.getID() == ev.MOUSE_CLICKED:
***************
*** 403,427 ****
        bfforw = NadirCircleFloater_NoAnchor(vs, (self.ctrx, self.ctry), 
self.rad,
                        self.nadir, -1)
        print "Context"
-       # The non-moving bulge coordinate
-       cs2 = vs.coords.affineCoordsys(0, globalcursor.getId()+"__bulg", 
-                   0.06,
-                   0,  0,
-                   20, 0,0, 20)
  
!       class CentralB(Runnable):
!           def run(rself):
!               # A single paper, keyed by the cell ID
!               placepapers(vs, cs2, globalpap, globalcursor.getId(), 
!                       0, 0,
!                       globalx, globaly,
!                       self.yheight)
!       bf.addCentralBuoy(globalcursor.getId(), CentralB())
            
!       for forwlink in globalforw:
!           addbuoy(vs, 0, 0, 1, bfforw, forwlink.to)
!       for backlink in globalback:
!           addbuoy(vs, 0, 0, 1, bf, getattr(backlink,"from"))
  
  class XuPDFScene_PDFZoom:
      def __init__(self):
--- 404,434 ----
        bfforw = NadirCircleFloater_NoAnchor(vs, (self.ctrx, self.ctry), 
self.rad,
                        self.nadir, -1)
        print "Context"
  
!       cs1 = bf.addCentralBuoy(globalcursor.getId())
! 
!       eye = 0.2
!       cs1_zoom= vs.coords.distort(cs1, 0, 0, eye, eye, *(self.mag[0]))
!       vs.matcher.add(cs1_zoom, globalcursor.getId()+"__bulg") 
! 
!       cs1_trans = vs.coords.translateXY(cs1_zoom, -globalx, -globaly)
!       vs.matcher.add(cs1_trans, globalcursor.getId()+"__trans") 
! 
!       if self.clip:
!           clip = (-0.2+globalx, -0.2+globaly, 0.2+globalx, 0.2+globaly)
!       else:
!           w = globalview.papersize[0]
!           extrax = 0.1
!           extray = 0.1
!           clip = (0-extrax, -extray, w+extrax, 1+extray)
! 
!       globalview.placepapers(vs, cs1_trans, cliprect = clip)
            
!       if self.showcontext:
!           for forwlink in globalforw:
!               addbuoy(vs, 0, 0, 1, bfforw, forwlink.to)
!           for backlink in globalback:
!               addbuoy(vs, 0, 0, 1, bf, getattr(backlink,"from"))
  
  class XuPDFScene_PDFZoom:
      def __init__(self):
***************
*** 462,470 ****
        if self.clip:
            clip = (-0.2+globalx, -0.2+globaly, 0.2+globalx, 0.2+globaly)
        else:
!           clip = (0, 0, 10, 2)
!       globalview.placepapers(vs, cs1_trans,
!           cliprect = clip)
        # placepapers(vs, cs1_trans, globalpap, globalcursor.getId())
                    
  
--- 469,479 ----
        if self.clip:
            clip = (-0.2+globalx, -0.2+globaly, 0.2+globalx, 0.2+globaly)
        else:
!           w = globalview.papersize[0]
!           extrax = 1
!           extray = 0.3
!           clip = (0-extrax, -extray, w+extrax, 1+extray)
!       globalview.placepapers(vs, cs1_trans, cliprect = clip)
        # placepapers(vs, cs1_trans, globalpap, globalcursor.getId())
                    
  
Index: gzz/gfx/libutil/effects.py
diff -c gzz/gfx/libutil/effects.py:1.9 gzz/gfx/libutil/effects.py:1.10
*** gzz/gfx/libutil/effects.py:1.9      Fri Sep 27 15:34:48 2002
--- gzz/gfx/libutil/effects.py  Sat Sep 28 15:01:20 2002
***************
*** 80,91 ****
        # Create the coordinate system
  
        vs = self.vs
!       transaffine(vs, str(key)+"_1", b[0], b[1], size, 0, 0, size)
!       rotate(vs, str(key)+"_2", 360 * self.nadir.getAngleRad(b[0], b[1]) / 
!                                       (2 * math.pi), 0, 0, 1)
!       buoy.run()
!       poptrans(vs, str(key)+"_2")
!       poptrans(vs, str(key)+"_1")
  
        # ac = vs.coords.coordsys(0, str(key)+"_5", 10, anchorX, anchorY, 0, 0)
        # bc = vs.coords.coordsys(0, str(key)+"_6", 10, b[0], b[1], 0, 0)
--- 80,90 ----
        # Create the coordinate system
  
        vs = self.vs
!       cs1 = vs.coords.affineCoordsys(0, 50, b[0], b[1], size, 0, 0, size)
!       vs.matcher.add(cs1, str(key)+"_buo_1")
!       cs2 = vs.coords.rotateXY(cs1, 360 * self.nadir.getAngleRad(b[0], b[1]) 
/ (2 * math.pi))
!       vs.matcher.add(cs2,str(key)+"_buo_2")
!       return cs2
  
        # ac = vs.coords.coordsys(0, str(key)+"_5", 10, anchorX, anchorY, 0, 0)
        # bc = vs.coords.coordsys(0, str(key)+"_6", 10, b[0], b[1], 0, 0)
***************
*** 98,104 ****
        vs.matcher.add(cs, str(key)+"_buo_1") 
  
        cs2 = vs.coords.rotateXY(cs, 0)
!       vs.matcher.add(cs2, str(key)+"_buoj2") 
        return cs2
  
        
--- 97,103 ----
        vs.matcher.add(cs, str(key)+"_buo_1") 
  
        cs2 = vs.coords.rotateXY(cs, 0)
!       vs.matcher.add(cs2, str(key)+"_buo_2") 
        return cs2
  
        




reply via email to

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