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 |
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] |
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 |
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( |
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: |
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: |
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, |
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: |
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 |