77 |
space.cellTexter.setEnfilade(cell, p) |
space.cellTexter.setEnfilade(cell, p) |
78 |
cells.append(cell) |
cells.append(cell) |
79 |
|
|
80 |
globalcursor = None |
execfile("gzz/view/xubuoy.py") |
|
globalspan = None |
|
|
|
|
|
# Paper coordinates of current focus |
|
|
globalx = 0 |
|
|
globaly = 0 |
|
|
|
|
|
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() |
|
|
|
|
|
def getCellPDFView(cell): |
|
|
return pagespanview.CellPDFView(cell) |
|
|
|
|
|
|
|
|
|
|
|
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] |
|
|
|
|
|
fps_text = GLRen.createHorizText2(getFont(), "FOO", 1, 1, 1, 1) |
|
|
GL.setDebugVar("JNI.fps", 1) |
|
|
# Show the intended screen size |
|
|
def bg(vs): |
|
|
putnoc(vs, background((0.3,0.5,0.4))) |
|
|
putnoc(vs, getDListNocoords(""" |
|
|
Disable TEXTURE_2D |
|
|
LineWidth 2 |
|
|
Color 0 0 0 |
|
|
Begin LINE_LOOP |
|
|
Vertex 0 0 |
|
|
Vertex 0 %(h)s |
|
|
Vertex %(w)s %(h)s |
|
|
Vertex %(w)s 0 |
|
|
End |
|
|
Enable TEXTURE_2D |
|
|
""" % { "w": screensize[0], "h": screensize[1] } ) ) |
|
|
fps = vs.coords.coordsys(0, 10, 10, 20, 1.5, 1.5) |
|
|
vs.matcher.add(fps, "FPS") |
|
|
vs.map.put(fps_text, fps, 0) |
|
|
|
|
|
|
|
|
lineconn = GLRen.createLineConnector(0,0) |
|
|
|
|
|
class XuPDFBuoy: |
|
|
def __init__(self, linkindex, link): |
|
|
self.link = link |
|
|
self.linkindex = linkindex |
|
|
self.linkspan = link[linkindex].getList()[0] |
|
|
self.mat = enfoverlap.getMatches(link[linkindex]) |
|
|
l = [m for m in self.mat] |
|
|
if len(l) == 0: |
|
|
self.cell = None |
|
|
return |
|
|
m = l[0] |
|
|
print m |
|
|
self.cell = m |
|
|
self.view = getCellPDFView(self.cell) |
|
|
|
|
|
p = self.linkspan.getLocation() |
|
|
d = self.linkspan.getSize() |
|
|
o = self.linkspan.offset() |
|
|
# print "page, loc, size: ", linkspan.offset(), p, d |
|
|
# print "P0, P1: ",p0, p1 |
|
|
|
|
|
self.p0 = self.view.paperpoint(o, p.x, p.y) |
|
|
self.p1 = self.view.paperpoint(o, p.x+d.width, p.y+d.height) |
|
|
self.pctr = [0.5 * (self.p0[i] + self.p1[i]) for i in range(0,2)] |
|
|
|
|
|
self.eye = 0.2 |
|
|
self.buoyscale = 400 |
|
|
|
|
|
def add(self, vs, anchorX, anchorY, importance, floater, |
|
|
maincs = None): |
|
|
if not self.cell: |
|
|
return |
|
|
cell = self.cell |
|
|
|
|
|
cs1 = floater.addBuoy(anchorX, anchorY, importance, self.cell.getId(), 0, 0) |
|
|
cs1_zoom= vs.coords.distort(cs1, 0, 0, self.eye, self.eye, self.buoyscale, self.buoyscale) |
|
|
vs.matcher.add(cs1_zoom, cell.getId()+"__bulg") |
|
|
|
|
|
cs1_trans = vs.coords.translateXY(cs1_zoom, -self.pctr[0], -self.pctr[1]) |
|
|
# cs1_trans = vs.coords.translateXY(cs1_zoom, 0, 0) |
|
|
vs.matcher.add(cs1_trans, cell.getId()+"__trans") |
|
|
|
|
|
self.cliprect = (self.p0[0], self.p0[1], self.p1[0], self.p1[1]) |
|
|
|
|
|
self.view.placepapers(vs, cs1_trans, cliprect = self.cliprect, |
|
|
fancy = globalusefancypaper, showTessel = globalshowtessel) |
|
|
|
|
|
# Then, the xu link connector |
|
|
if maincs != None: |
|
|
mainlinkspan = self.link[1-self.linkindex].getList()[0] |
|
|
# XXX if cell not everything... |
|
|
mainpage = mainlinkspan.offset() - globalspan.offset() |
|
|
mainp = mainlinkspan.getLocation() |
|
|
mainoffsp = globalspan.getLocation() |
|
|
maind = mainlinkspan.getSize() |
|
|
mainpoint = globalview.paperpoint(mainpage, mainp.x-mainoffsp.x+0.5*maind.width, |
|
|
mainp.y-mainoffsp.y+0.5*maind.height) |
|
|
|
|
|
main_end_cs = vs.coords.coordsys(maincs, -20, mainpoint[0], mainpoint[1], 0, 0) |
|
|
|
|
|
link_end_cs = vs.coords.coordsys(cs1_trans, -20, self.pctr[0], self.pctr[1], 0, 0) |
|
|
|
|
|
vs.matcher.add(main_end_cs, "link"+str(self.link)+str(self.linkindex)) |
|
|
vs.matcher.add(link_end_cs, "link"+str(self.link)+str(1-self.linkindex)) |
|
|
|
|
|
print "lineconn!" |
|
|
putnoc(vs, getDListNocoords(""" |
|
|
PushAttrib ENABLE_BIT |
|
|
Disable TEXTURE_2D |
|
|
LineWidth 5 |
|
|
Enable BLEND |
|
|
Color 0 0 0 0.6 |
|
|
""")) |
|
|
vs.map.put(lineconn, main_end_cs, link_end_cs) |
|
|
putnoc(vs, getDListNocoords(""" |
|
|
PopAttrib |
|
|
""")) |
|
|
|
|
|
def hit(self, coords, point3): |
|
|
return self.view.hitClip(coords, point3, self.cliprect) |
|
|
|
|
|
if 1: |
|
|
selectPaper = Paper() |
|
|
selectPaper.setNPasses(1) |
|
|
pas = selectPaper.getPass(0) |
|
|
pas.setSetupcode(""" |
|
|
PushAttrib ENABLE_BIT COLOR_BUFFER_BIT |
|
|
Disable TEXTURE_2D |
|
|
Disable DEPTH_TEST |
|
|
Disable STENCIL_TEST |
|
|
Color 1 1 1 |
|
|
Enable BLEND |
|
|
BlendFunc ONE_MINUS_DST_COLOR ZERO |
|
|
""") |
|
|
pas.setTeardowncode(""" |
|
|
PopAttrib |
|
|
""") |
|
|
selectPaperQuad = GLRen.createPaperQuad(selectPaper, -1,-1,1,1, 1) |
|
|
|
|
|
class Mode: |
|
|
def __init__(self, **args): |
|
|
self.__dict__ = args |
|
|
|
|
|
class XuPDFScene_PDFContext: |
|
|
def __init__(self): |
|
|
self.modes = [ |
|
|
Mode( |
|
|
mag=(screensize[1]*1.6,screensize[1]/10), |
|
|
context=1, |
|
|
movefocus=0, |
|
|
eye = 0.2, |
|
|
), |
|
|
Mode( |
|
|
mag=(screensize[1],screensize[1]), # full-screen |
|
|
context=0, |
|
|
movefocus=1, |
|
|
eye = 0.2, |
|
|
), |
|
|
Mode( |
|
|
mag=(screensize[1]*2,screensize[1]/2), # full-screen |
|
|
context=0, |
|
|
movefocus=1, |
|
|
eye = 0.2, |
|
|
), |
|
|
] |
|
|
|
|
|
self.ctrx = screensize[0]/2 |
|
|
self.ctry = screensize[1]/2 |
|
|
self.rad = screensize[1]/2 |
|
|
self.nadir = NadirAngler(self.ctrx, screensize[1]*2) |
|
|
self.clip = 0 |
|
|
self.selectCS = None |
|
|
self.currentvs = None |
|
|
def key(self, key): |
|
|
global currentScene |
|
|
if key == 'm': |
|
|
rotatelist(self.modes) |
|
|
if key == 'c': |
|
|
self.clip = not self.clip |
|
|
def mouse(self, ev): |
|
|
global globalx, globaly |
|
|
if ev.getID() == ev.MOUSE_CLICKED: |
|
|
# scale = 0.01 |
|
|
# globalx += (ev.getX() - screensize[0]/2) * scale |
|
|
# globaly += (ev.getY() - screensize[1]/2) * scale |
|
|
point = array([ev.getX(), ev.getY(), 0], 'f') |
|
|
for b in self.buoys: |
|
|
h = b.hit(self.currentvs.coords, point) |
|
|
if h: |
|
|
print "BUOY HIT!\n" |
|
|
moveToCell(b.cell, *h) |
|
|
AbstractUpdateManager.chg() |
|
|
return |
|
|
h = globalview.hitClip(self.currentvs.coords, point, None) |
|
|
if h: |
|
|
globalx,globaly = h |
|
|
else: |
|
|
print "Didn't hit anything" |
|
|
checkGlobalCoords() |
|
|
print "Mouse ",globalx, globaly |
|
|
AbstractUpdateManager.chg() |
|
|
elif ev.getID() == ev.MOUSE_PRESSED: |
|
|
self.pressx = ev.getX() |
|
|
self.pressy = ev.getY() |
|
|
self.origpt = None |
|
|
return |
|
|
elif ev.getID() == ev.MOUSE_DRAGGED: |
|
|
if not self.selectCS: |
|
|
self.selectCS = self.currentvs.coords.affineCoordsys(self.papercs, 0, 0, 0, 1, 0, 0, 1) |
|
|
self.currentvs.map.put(selectPaperQuad, self.selectCS, 0) |
|
|
if not self.origpt: |
|
|
point = array([self.pressx, self.pressy, 0], 'f') |
|
|
dst = zeros(3, 'f') |
|
|
self.currentvs.coords.inverseTransformPoints3(self.papercs, point, dst) |
|
|
self.corner1 = (dst[0], dst[1]) |
|
|
point = array([ev.getX(), ev.getY(), 0], 'f') |
|
|
dst = zeros(3, 'f') |
|
|
self.currentvs.coords.inverseTransformPoints3(self.papercs, point, dst) |
|
|
self.corner2 = (dst[0], dst[1]) |
|
|
ctr = (0.5*(self.corner1[0]+self.corner2[0]), |
|
|
0.5 *(self.corner1[1]+self.corner2[1])) |
|
|
s = (0.5*(self.corner1[0]-self.corner2[0]), |
|
|
0.5 *(self.corner1[1]-self.corner2[1])) |
|
|
self.currentvs.coords.setAffineParams(self.selectCS, 0, |
|
|
ctr[0], ctr[1], s[0], 0, 0, s[1]) |
|
|
# print "paint: ",ctr, s |
|
|
AbstractUpdateManager.chg() |
|
|
replaceNewScene(self.currentvs) |
|
|
|
|
|
|
|
|
else: |
|
|
print "Unused mouse: ",ev |
|
|
def scene(self, vs): |
|
|
bg(vs) |
|
|
bf = effects.NadirCircleFloater_NoAnchor(vs, (self.ctrx, self.ctry), self.rad, |
|
|
self.nadir, 1) |
|
|
bfforw = effects.NadirCircleFloater_NoAnchor(vs, (self.ctrx, self.ctry), self.rad, |
|
|
self.nadir, -1) |
|
|
print "Context" |
|
|
|
|
|
cs1 = bf.addCentralBuoy(globalcursor.getId()) |
|
|
|
|
|
|
|
|
if self.modes[0].movefocus: |
|
|
focusy_at = globaly * screensize[1] |
|
|
else: |
|
|
focusy_at = self.ctry |
|
|
|
|
|
# The buoy cs is centered |
|
|
focusy_at -= self.ctry |
|
|
|
|
|
eye = self.modes[0].eye |
|
|
cs1_zoom= vs.coords.distort(cs1, 0, focusy_at, |
|
|
eye, eye, *(self.modes[0].mag)) |
|
|
vs.matcher.add(cs1_zoom, globalcursor.getId()+"__bulg") |
|
|
|
|
|
cs1_trans = vs.coords.translateXY(cs1_zoom, |
|
|
-globalx, -globaly + focusy_at) |
|
|
vs.matcher.add(cs1_trans, globalcursor.getId()+"__trans") |
|
|
|
|
|
if self.clip: |
|
|
clip = (-0.2+globalx, -0.2+globaly, 0.2+globalx, 0.2+globaly) |
|
|
self.cliprect = clip |
|
|
else: |
|
|
w = globalview.papersize[0] |
|
|
extrax = 0.1 |
|
|
extray = 0.1 |
|
|
clip = (0-extrax, -extray, w+extrax, 1+extray) |
|
|
self.cliprect = None |
|
|
|
|
|
globalview.placepapers(vs, cs1_trans, cliprect = clip, |
|
|
fancy = globalusefancypaper, showTessel = globalshowtessel) |
|
|
|
|
|
self.buoys = [] |
|
|
|
|
|
if self.modes[0].context: |
|
|
for forwlink in globalforw: |
|
|
b = XuPDFBuoy(1, (getattr(forwlink, "from"), forwlink.to)) |
|
|
b.add(vs, 0, 0, 1, bfforw, maincs = cs1_trans) |
|
|
self.buoys.append(b) |
|
|
for backlink in globalback: |
|
|
b = XuPDFBuoy(0,(getattr(backlink,"from"), backlink.to)) |
|
|
b.add(vs, 0, 0, 1, bf, maincs = cs1_trans) |
|
|
self.buoys.append(b) |
|
|
self.currentvs = vs |
|
|
self.selectCS = None |
|
|
self.papercs = cs1_trans |
|
81 |
|
|
82 |
currentScene = XuPDFScene_PDFContext() |
currentScene = XuPDFScene_PDFContext() |
83 |
moveToCell(cells[1]) |
moveToCell(cells[1]) |