57 |
0, 0, 0, 1]) |
0, 0, 0, 1]) |
58 |
return (pap, pw, ph) |
return (pap, pw, ph) |
59 |
|
|
60 |
pap = [ |
globalpap = [ |
61 |
pdfpaper(p) for p in prect |
pdfpaper(p) for p in prect |
62 |
] |
] |
63 |
|
|
64 |
def placepapers(vs, cs2, papers, key, x, y, h): |
def placepapers(vs, cs2, papers, key, x, y, paperx, papery, h): |
65 |
# The height in coords |
# The height in coords |
66 |
ph = papers[0][2] |
ph = papers[0][2] |
67 |
curx = x |
curx = x - h/ph * paperx |
68 |
|
ycoord = y - h/ph * papery |
69 |
|
print "x,y for place: ",curx, ycoord |
70 |
for i in range(0, len(papers)): |
for i in range(0, len(papers)): |
71 |
cs1 = vs.coords.affineCoordsys(0, key+"_"+str(i), 10, |
cs1 = vs.coords.affineCoordsys(0, key+"_"+str(i), 10, |
72 |
curx, y, h/ph, 0, 0, h/ph) |
curx, ycoord, h/ph, 0, 0, h/ph) |
73 |
curx += 1.02 * h/ph * papers[i][1] |
curx += 1.02 * h/ph * papers[i][1] |
74 |
pq = GZZGL.createFisheyePaperQuad( |
pq = GZZGL.createFisheyePaperQuad( |
75 |
papers[i][0], 0, 0, papers[i][1], papers[i][2], 21, 21) |
papers[i][0], 0, 0, papers[i][1], papers[i][2], 21, 21) |
76 |
vs.map.put(pq, cs1, cs2) |
vs.map.put(pq, cs1, cs2) |
77 |
|
|
78 |
|
# Paper coordinates of current focus |
79 |
|
globalx = 0 |
80 |
|
globaly = 0 |
81 |
|
|
82 |
|
def bg(vs): |
83 |
|
putnoc(vs, background((0.3,0.5,0.4))) |
84 |
|
putnoc(vs, getDListNocoords(""" |
85 |
|
Disable TEXTURE_2D |
86 |
|
LineWidth 2 |
87 |
|
Color 0 0 0 |
88 |
|
Begin LINE_LOOP |
89 |
|
Vertex 0 0 |
90 |
|
Vertex 0 %(h)s |
91 |
|
Vertex %(w)s %(h)s |
92 |
|
Vertex %(w)s 0 |
93 |
|
End |
94 |
|
Enable TEXTURE_2D |
95 |
|
""" % { "w": screensize[0], "h": screensize[1] } ) ) |
96 |
|
|
97 |
class XuPDFScene: |
class XuPDFScene_PDFContext: |
98 |
def __init__(self): |
def __init__(self): |
99 |
self.x = self.y = 0 |
self.yheight = 100 |
100 |
def key(self, key): |
def key(self, key): |
101 |
|
global currentScene |
102 |
|
if key == 'z': |
103 |
|
currentScene = XuPDFScene_PDFZoom() |
104 |
|
def mouse(self, ev): |
105 |
|
global globalx, globaly |
106 |
|
if ev.getID() == ev.MOUSE_CLICKED: |
107 |
|
scale = 0.01 |
108 |
|
globalx += (ev.getX() - screensize[0]/2) * scale |
109 |
|
globaly += (ev.getY() - screensize[1]/2) * scale |
110 |
|
print "Mouse ",globalx, globaly |
111 |
|
AbstractUpdateManager.chg() |
112 |
|
def scene(self, vs): |
113 |
|
bg(vs) |
114 |
|
print "Context" |
115 |
|
cs2 = vs.coords.affineCoordsys(0, "2", 2, |
116 |
|
screensize[0]/2, 0.9 * screensize[1]/2, 50, 0,0,50) |
117 |
|
|
118 |
|
placepapers(vs, cs2, globalpap, "foo", |
119 |
|
screensize[0]/2, 0.9 * screensize[1]/2, |
120 |
|
globalx, globaly, |
121 |
|
self.yheight) |
122 |
|
|
123 |
|
|
124 |
|
class XuPDFScene_PDFZoom: |
125 |
|
def key(self, key): |
126 |
|
print "Key: ",key |
127 |
|
global currentScene |
128 |
|
if key == 'z': |
129 |
|
currentScene = XuPDFScene_PDFContext() |
130 |
pass |
pass |
131 |
def mouse(self, ev): |
def mouse(self, ev): |
132 |
print "Mousehere ",ev |
global globalx, globaly |
133 |
if ev.getID() == ev.MOUSE_CLICKED: |
if ev.getID() == ev.MOUSE_CLICKED: |
134 |
self.x -= ev.getX() - screensize[0]/2 |
scale = globalpap[0][2] / screensize[1] |
135 |
|
globalx += (ev.getX() - screensize[0]/2) * scale |
136 |
# self.y -= ev.getY() - screensize[1]/2 |
# self.y -= ev.getY() - screensize[1]/2 |
137 |
self.y = ev.getY() |
globaly = ev.getY() * scale |
138 |
print "Mouse ",self.x,self.y |
print "Mouse ",globalx, globaly |
139 |
AbstractUpdateManager.chg() |
AbstractUpdateManager.chg() |
140 |
def scene(self, vs): |
def scene(self, vs): |
141 |
putnoc(vs, background((0.3,0.5,0.4))) |
bg(vs) |
|
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] } ) ) |
|
|
|
|
|
# cs2 = vs.coords.affineCoordsys(0, "2", 8.5, |
|
|
# screensize[0]/2, 0.9 * screensize[1]/2, 100, 0,0,70) |
|
142 |
cs2 = vs.coords.affineCoordsys(0, "2", 9.0, |
cs2 = vs.coords.affineCoordsys(0, "2", 9.0, |
143 |
screensize[0]/2, self.y, 150, 0,0, 100) |
screensize[0]/2, globaly / globalpap[0][2] * screensize[1], |
144 |
placepapers(vs, cs2, pap, "foo", self.x, 0, 768) |
150, 0,0, 100) |
145 |
# for i in range(0,len(pap)): |
placepapers(vs, cs2, globalpap, "foo", screensize[0]/2, |
146 |
# pq = GZZGL.createFisheyePaperQuad( |
globaly / globalpap[0][2] * screensize[1], |
147 |
# pap[i][0], 0, 0, pap[i][1], pap[i][2], 21, 21) |
globalx, globaly, |
148 |
# cs1 = vs.coords.affineCoordsys(0, "1_"+str(i), 10, |
768) |
|
# self.x + 290 * i, self.y, |
|
|
# 200, 0, 0, 200 ) |
|
|
# vs.map.put(pq, cs1, cs2) |
|
|
|
|
149 |
|
|
150 |
currentScene = XuPDFScene() |
currentScene = XuPDFScene_PDFZoom() |
151 |
|
|