Code Search for Developers
 
 
  

xupdf.py from gzz at Krugle


Show xupdf.py syntax highlighted

# 
# Copyright (c) 2003, Tuomas J. Lukka
# 
# This file is part of Gzz.
# 
# Gzz is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# Gzz is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
# Public License for more details.
# 
# You should have received a copy of the GNU Lesser General
# Public License along with Gzz; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA
# 
# 

from __future__ import nested_scopes

import gzz.view.xubuoy
reload(gzz.view.xubuoy)

from gzz.index import XuLink
from gzz.gfx.gl import Stencil
from gfx.libutil import saveanim

from jarray import array, zeros

from gzz.view import pagespanview
pagespanview.window = w

from gfx.libutil import saveanim

gzz.gfx.gl.PageSpanPaper.paperMill = gzz.gfx.gl.PaperMill.getInstance()
gzz.gfx.gl.PageSpanPaper.paperMillWindow = w

# Now, this is the start of the REAL demo, the one
# with Xanadu links between PDF and text.


# Slow animation for the demo.
AbstractUpdateManager.defaultAnimationTime = 2000
AbstractUpdateManager.fractCalc = AbstractUpdateManager.LinearCalculator()

from test.tools import tools

space = gzz.impl.ModularSpace(*tools.spaceArgList())
xuspace = gzz.impl.ModularSpace(*tools.spaceArgList())
# xuindexer = gzz.index.impl.TransientXuIndexer()
xuindexer = gzz.index.IndexManager.getXuIndexer(xuspace)
enfoverlap = gzz.index.IndexManager.getEnfiladeOverlap(space)

enfMaker = gzz.media.impl.Enfilade1DImpl.Enfilade1DImplMaker()

# PDF files
pagescrolls = (
gzz.media.impl.PageImageScroll(None, gzz.mediaserver.Mediaserver.Id(
#"0000000008000000E9573F43E00004CB42D4BEFEBAA27C20403F7D57693141B9E4D9A46329AC9C")),
"01E1682758ABF63E7833692653A5DE46EA53A6F8AA")),
gzz.media.impl.PageImageScroll(None, gzz.mediaserver.Mediaserver.Id(
#"0000000008000000E9573F40460004592C0AC2038D1250E0ED08F865D8C9148654B87A7AA82CC6")),
"010DA2A88F8C71B76061AA8F1418C0CC77C3C3200D")),
gzz.media.impl.PageImageScroll(None, gzz.mediaserver.Mediaserver.Id(
#"0000000008000000E9573F38AE000410A88E08C0C3AB6E45E102B9921BBE71DC74E1A7492D70AE")),
"010D41691A3EC1332F7D7BC81686F80A6D1362EBE9")),
)


d1 = space.getDim(gzz.zzutil.Ids.d_1)

# Two cells, with one PDF span in each
home = space.getHomeCell()

pagespans = [s.getCurrent() for s in pagescrolls]
# XXX
# pagespans = [s.getCurrent().subSpan(0,5) for s in pagescrolls]

pages = [enfMaker.makeEnfilade(sp) for sp in pagespans]


xuindexer.add(XuLink(
    enfMaker.makeEnfilade(pagespans[0].subSpan(1,2).subArea(0,50,400,200)),
    enfMaker.makeEnfilade(pagespans[1].subSpan(2,3).subArea(20,500,350,200))
    ))

xuindexer.add(XuLink(
    enfMaker.makeEnfilade(pagespans[2].subSpan(1,2).subArea(0,300,350,300)),
    enfMaker.makeEnfilade(pagespans[0].subSpan(2,3).subArea(300,400,300,100)),
    ))

cells = []
for p in pages:
    cell = home.N(d1)
    space.cellTexter.setEnfilade(cell, p)
    cells.append(cell)

#execfile("gzz/view/xubuoy.py")

def globalkey(key):
    if '1' <= key <= '9':
        currentScene.moveToCell(cells[ord(key) - ord('1')])
    if key == 'P':
	makeShots()

def makeShots():
    scene = gzz.view.xubuoy.XuPDFScene_PDFContext(xuspace)
    # scene.bgcolor = (.9, .9, .8)

    def frame(fileprefix):
	vs = w.createVobScene()
	scene.scene(vs)
	w.renderStill(vs, 0)
	saveanim.saveframe("shots/%s.png" % fileprefix, w)

    scene.moveToCell(cells[0], 1.05, .22)
    frame("xupdf1")
    scene.moveToCell(cells[1], 1.7, .7)
    frame("xupdf2")
    print "FRAME DONE"


    if key == "Print": makeScreenshots()

def r(sc, filename):
    vs = w.createVobScene()
    sc.scene(vs)
    w.renderStill(vs, 0)
    saveanim.saveframe(filename, w)

def makeScreenshots():
    ps = gzz.view.xubuoy.XuPDFScene_PDFContext(xuspace)

    for i in range(0,24):
        ps.moveToCell(cells[1], .1 * i, 0)
        r(ps, "tmpfilm/xupdf%03i.jpg" % i)

    saveanim.encodefilm("tmpfilm/xupdf\\*.jpg", "xupdffilm.avi")

currentScene = gzz.view.xubuoy.XuPDFScene_PDFContext(xuspace)
gzz.view.xubuoy.replaceNewScene = replaceNewScene
currentScene.moveToCell(cells[1], 0, 0, redraw=1)





See more files for this project here

gzz

An implementation of Ted Nelson's ZZstructure. ZZstructure is a new type of programming platform for structured data.

Project homepage: http://savannah.nongnu.org/projects/gzz
Programming language(s): C++,Java,Python
License: lgpl21

  color/
    colors.py
  fillet/
    __init__.py
    ambiguity.py
    oldcode.py
    util.py
    zbuffer.py
  nic/
    README
    stencil.py
    stencildepth.py
  opengl/
    __init__.py
    bumpy.py
    culltest.py
    fragprog.py
    glinfo.py
    imaging.py
    mipmap.py
    pacman.py
    readpixels.py
    stencil.py
    texform.py
    texperf.py
  paper/
    __init__.py
    basis.py
    combinerflow.py
    combiners.py
    combinerutil.py
    multipaper.py
    singlepaper.py
    util.py
  Makefile
  __init__.py
  brokentext.py
  buoydev.py
  buoyoing.py
  calendarvobtest.py
  clamptexture.cxx
  clonetest.py
  coords_benchmark.py
  debugtest.cxx
  fillets.py
  fisheye.py
  fontfilter.py
  fontfilter2.py
  fpfont.py
  frametest.cxx
  irregu3.py
  irregu4.py
  irreguellipse.py
  irregular2.py
  irregularframe.py
  keymap-test.py
  memoryleak.py
  mipzip.py
  motion.py
  ovalvobtest.py
  pagespan.py
  projectivecoords.py
  psyko.py
  psyko2.py
  softshadow.py
  sqfillet.py
  testtimeout.py
  texlab.py
  text.py
  text_benchmark.py
  texturelab.py
  tubeframe.cxx
  tubeframe.hxx
  viewtest.py
  vpbuoy.py
  xuconn.py
  xupdf.py
  zipf.py