/[gzz]/gzz/gzz/view/xubuoy.py
ViewVC logotype

Diff of /gzz/gzz/view/xubuoy.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by benja, Thu Oct 3 08:43:36 2002 UTC revision 1.4 by tjl, Thu Oct 3 08:51:46 2002 UTC
# Line 30  def getFont(): Line 30  def getFont():
30          font = GL.createFont("gfx/fonts/a010013l.pfb", 32);          font = GL.createFont("gfx/fonts/a010013l.pfb", 32);
31      return font      return font
32    
 globalcursor = None  
33  globalspan = None  globalspan = None
34    
35  # Paper coordinates of current focus  # Paper coordinates of current focus
36  globalx = 0  globalx = 0
37  globaly = 0  globaly = 0
38    
 globalusefancypaper = 1  
   
 globalshowtessel = 0  
   
 def moveToCell(cell, nx=1, ny=1):  
     global globalcursor, globalx, globaly, globalview  
     global globalforw, globalback, globalspan  
   
     # Check type  
     if 1: # PDF  
         globalview = getCellPDFView(cell)  
   
     globalcursor = cell  
     globalx, globaly = nx, ny  
   
     content = space.cellTexter.getEnfilade(cell, None)  
     globalspan = enf2span(content)  
     globalforw = xuindexer.getForwardIndex().getMatches(content)  
     globalback = xuindexer.getBackwardIndex().getMatches(content)  
   
     print "Xu: ",globalforw,globalback  
   
     java.lang.System.gc()  
     AbstractUpdateManager.chg()  
   
39  def getCellPDFView(cell):  def getCellPDFView(cell):
40      return pagespanview.CellPDFView(cell)      return pagespanview.CellPDFView(cell)
41    
42    
   
 def globalkey(key):  
     global globalusefancypaper, globalshowtessel  
     if '1' <= key <= '9':  
         moveToCell(cells[int(key)-1])  
     elif key == 'l':  
         pagespanview.globalLOD = 1 - pagespanview.globalLOD  
         print "Lod: ",pagespanview.globalLOD  
         AbstractUpdateManager.chg()  
     elif key == 'p':  
         globalusefancypaper = not globalusefancypaper  
     elif key == ',':  
         pagespanview.globalseedoffs -= 1  
         moveToCell(globalcursor)  
     elif key == '.':  
         pagespanview.globalseedoffs += 1  
         moveToCell(globalcursor)  
     elif key == 't':  
         globalshowtessel = not globalshowtessel  
   
 def checkGlobalCoords():  
     global globalx, globaly  
     if globalx < 0: globalx = 0  
     if globaly < 0: globaly = 0  
     if globalx > globalview.scaledsize[0]: globalx = globalview.scaledsize[0]  
     if globaly > globalview.scaledsize[1]: globaly = globalview.scaledsize[1]  
   
43  fps_text = GLRen.createHorizText2(getFont(), "FOO", 1, 1, 1, 1)  fps_text = GLRen.createHorizText2(getFont(), "FOO", 1, 1, 1, 1)
44  GL.setDebugVar("JNI.fps", 1)  GL.setDebugVar("JNI.fps", 1)
45  # Show the intended screen size  # Show the intended screen size
# Line 119  lineconn = GLRen.createLineConnector(0,0 Line 66  lineconn = GLRen.createLineConnector(0,0
66    
67  class XuPDFBuoy:  class XuPDFBuoy:
68      def __init__(self, linkindex, link):      def __init__(self, linkindex, link):
69            self.cursor = None
70          self.link = link          self.link = link
71          self.linkindex = linkindex          self.linkindex = linkindex
72          self.linkspan = link[linkindex].getList()[0]          self.linkspan = link[linkindex].getList()[0]
# Line 146  class XuPDFBuoy: Line 94  class XuPDFBuoy:
94          self.buoyscale = 400          self.buoyscale = 400
95    
96      def add(self, vs, anchorX, anchorY, importance, floater,      def add(self, vs, anchorX, anchorY, importance, floater,
97                          maincs = None):                          maincs = None, globalview = None):
98          if not self.cell:          if not self.cell:
99              return              return
100          cell = self.cell          cell = self.cell
# Line 222  class Mode: Line 170  class Mode:
170    
171  class XuPDFScene_PDFContext:  class XuPDFScene_PDFContext:
172      def __init__(self, win=None):      def __init__(self, win=None):
173            self.usefancypaper = 1
174            self.showtessel = 0
175          self.win = win          self.win = win
176          self.modes = [          self.modes = [
177                  Mode(                  Mode(
# Line 255  class XuPDFScene_PDFContext: Line 205  class XuPDFScene_PDFContext:
205          global currentScene          global currentScene
206          if key == 'm':          if key == 'm':
207              rotatelist(self.modes)              rotatelist(self.modes)
208          if key == 'c':          elif key == 'c':
209              self.clip = not self.clip              self.clip = not self.clip
210            elif key == 'l':
211                pagespanview.globalLOD = 1 - pagespanview.globalLOD
212                print "Lod: ",pagespanview.globalLOD
213                AbstractUpdateManager.chg()
214            elif key == 'p':
215                self.usefancypaper = not self.usefancypaper
216            elif key == ',':
217                pagespanview.globalseedoffs -= 1
218                self.moveToCell(self.cursor)
219            elif key == '.':
220                pagespanview.globalseedoffs += 1
221                self.moveToCell(self.cursor)
222            elif key == 't':
223                self.showtessel = not self.showtessel
224    
225        def checkGlobalCoords(self):
226            global globalx, globaly
227            if globalx < 0: globalx = 0
228            if globaly < 0: globaly = 0
229            if globalx > self.view.scaledsize[0]: globalx = self.view.scaledsize[0]
230            if globaly > self.view.scaledsize[1]: globaly = self.view.scaledsize[1]
231    
232      def mouse(self, ev):      def mouse(self, ev):
233          global globalx, globaly          global globalx, globaly
234          if ev.getID() == ev.MOUSE_CLICKED:          if ev.getID() == ev.MOUSE_CLICKED:
# Line 265  class XuPDFScene_PDFContext: Line 237  class XuPDFScene_PDFContext:
237                  h = b.hit(self.currentvs.coords, point)                  h = b.hit(self.currentvs.coords, point)
238                  if h:                  if h:
239                      print "BUOY HIT!\n"                      print "BUOY HIT!\n"
240                      moveToCell(b.cell, *h)                      self.moveToCell(b.cell, *h)
241                      AbstractUpdateManager.chg()                      AbstractUpdateManager.chg()
242                      return                      return
243              h = globalview.hitClip(self.currentvs.coords, point, None)              h = self.view.hitClip(self.currentvs.coords, point, None)
244              if h:              if h:
245                  globalx,globaly = h                  globalx,globaly = h
246              else:              else:
247                  print "Didn't hit anything"                  print "Didn't hit anything"
248              checkGlobalCoords()              self.checkGlobalCoords()
249              print "Mouse ",globalx, globaly              print "Mouse ",globalx, globaly
250              AbstractUpdateManager.chg()              AbstractUpdateManager.chg()
251          elif ev.getID() == ev.MOUSE_PRESSED:          elif ev.getID() == ev.MOUSE_PRESSED:
# Line 311  class XuPDFScene_PDFContext: Line 283  class XuPDFScene_PDFContext:
283    
284          else:          else:
285              print "Unused mouse: ",ev              print "Unused mouse: ",ev
286    
287        def moveToCell(self, cell, nx=1, ny=1):
288            global globalx, globaly
289            global globalforw, globalback, globalspan
290    
291            # Check type
292            if 1: # PDF
293                self.view = getCellPDFView(cell)
294    
295            self.cursor = cell
296            globalx, globaly = nx, ny
297    
298            content = space.cellTexter.getEnfilade(cell, None)
299            globalspan = enf2span(content)
300            globalforw = xuindexer.getForwardIndex().getMatches(content)
301            globalback = xuindexer.getBackwardIndex().getMatches(content)
302    
303            print "Xu: ",globalforw,globalback
304    
305            java.lang.System.gc()
306            AbstractUpdateManager.chg()
307    
308      def scene(self, vs):      def scene(self, vs):
309          bg(vs)          bg(vs)
310          bf = effects.NadirCircleFloater_NoAnchor(vs, (self.ctrx, self.ctry), self.rad,          bf = effects.NadirCircleFloater_NoAnchor(vs, (self.ctrx, self.ctry), self.rad,
# Line 319  class XuPDFScene_PDFContext: Line 313  class XuPDFScene_PDFContext:
313                          self.nadir, -1)                          self.nadir, -1)
314          print "Context"          print "Context"
315    
316          cs1 = bf.addCentralBuoy(globalcursor.getId())          cs1 = bf.addCentralBuoy(self.cursor.getId())
317    
318    
319          if self.modes[0].movefocus:          if self.modes[0].movefocus:
# Line 333  class XuPDFScene_PDFContext: Line 327  class XuPDFScene_PDFContext:
327          eye = self.modes[0].eye          eye = self.modes[0].eye
328          cs1_zoom= vs.coords.distort(cs1, 0, focusy_at,          cs1_zoom= vs.coords.distort(cs1, 0, focusy_at,
329              eye, eye, *(self.modes[0].mag))              eye, eye, *(self.modes[0].mag))
330          vs.matcher.add(cs1_zoom, globalcursor.getId()+"__bulg")          vs.matcher.add(cs1_zoom, self.cursor.getId()+"__bulg")
331    
332          cs1_trans = vs.coords.translateXY(cs1_zoom,          cs1_trans = vs.coords.translateXY(cs1_zoom,
333                  -globalx, -globaly + focusy_at)                  -globalx, -globaly + focusy_at)
334          vs.matcher.add(cs1_trans, globalcursor.getId()+"__trans")          vs.matcher.add(cs1_trans, self.cursor.getId()+"__trans")
335    
336          if self.clip:          if self.clip:
337              clip = (-0.2+globalx, -0.2+globaly, 0.2+globalx, 0.2+globaly)              clip = (-0.2+globalx, -0.2+globaly, 0.2+globalx, 0.2+globaly)
338              self.cliprect = clip              self.cliprect = clip
339          else:          else:
340              w = globalview.papersize[0]              w = self.view.papersize[0]
341              extrax = 0.1              extrax = 0.1
342              extray = 0.1              extray = 0.1
343              clip = (0-extrax, -extray, w+extrax, 1+extray)              clip = (0-extrax, -extray, w+extrax, 1+extray)
344              self.cliprect = None              self.cliprect = None
345    
346          globalview.placepapers(vs, cs1_trans, cliprect = clip,          self.view.placepapers(vs, cs1_trans, cliprect = clip,
347                  fancy = globalusefancypaper, showTessel = globalshowtessel)                  fancy = self.usefancypaper, showTessel = self.showtessel)
348    
349          self.buoys = []          self.buoys = []
350                            
351          if self.modes[0].context:          if self.modes[0].context:
352              for forwlink in globalforw:              for forwlink in globalforw:
353                  b = XuPDFBuoy(1, (getattr(forwlink, "from"), forwlink.to))                  b = XuPDFBuoy(1, (getattr(forwlink, "from"), forwlink.to))
354                  b.add(vs, 0, 0, 1, bfforw, maincs = cs1_trans)                  b.add(vs, 0, 0, 1, bfforw, maincs = cs1_trans,
355                            globalview = self.view)
356                  self.buoys.append(b)                  self.buoys.append(b)
357              for backlink in globalback:              for backlink in globalback:
358                  b = XuPDFBuoy(0,(getattr(backlink,"from"), backlink.to))                  b = XuPDFBuoy(0,(getattr(backlink,"from"), backlink.to))
359                  b.add(vs, 0, 0, 1, bf, maincs = cs1_trans)                  b.add(vs, 0, 0, 1, bf, maincs = cs1_trans,
360                            globalview = self.view)
361                  self.buoys.append(b)                  self.buoys.append(b)
362          self.currentvs = vs          self.currentvs = vs
363          self.selectCS = None          self.selectCS = None

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26