38 |
|
|
39 |
# Define the actions. |
# Define the actions. |
40 |
|
|
41 |
def defineActions(fenPDF, context): |
def defineActions(fenPDF): |
42 |
def getMainNode(): |
def getMainNode(): |
43 |
return fenPDF.views.getBuoyManager().getLastMain() |
return fenPDF.views.getBuoyManager().getLastMain() |
44 |
def getOldVS(): |
def getOldVS(): |
45 |
return fenPDF.animation.lastVs |
return fenPDF.animation.lastVs |
46 |
|
def getNodeCS(x,y): |
47 |
|
""" Return node's coordinate system by given coordinates |
48 |
|
found from underlying main node. |
49 |
|
""" |
50 |
|
box2screen = getMainNode().getBox2Screen() |
51 |
|
plane = getMainNode().getPlane() |
52 |
|
if getMainNode().getView2D().getContentView2D() == None: |
53 |
|
return -1 |
54 |
|
return getMainNode().getView2D(). \ |
55 |
|
getContentView2D().getNodeCS(getOldVS(),\ |
56 |
|
x,y, plane, box2screen, box2screen, 0, None) |
57 |
|
def getNodeOnPlane(x,y): |
58 |
|
""" Return node from underlying main node |
59 |
|
found by given coordinates. Node may be null. |
60 |
|
""" |
61 |
|
cs = getNodeCS(x,y) |
62 |
|
if dbg: p('cs', cs) |
63 |
|
if cs < 1: return None |
64 |
|
return getOldVS().matcher.getKey(cs) |
65 |
|
def getNodeCSbyNode(node): |
66 |
|
""" Return given node's coordinate system from underlying main node. |
67 |
|
""" |
68 |
|
box2screen = getMainNode().getBox2Screen() |
69 |
|
plane = getMainNode().getPlane() |
70 |
|
if getMainNode().getView2D().getContentView2D() == None: |
71 |
|
return None |
72 |
|
return getMainNode().getView2D(). \ |
73 |
|
getContentView2D().getNodeCS(getOldVS(),\ |
74 |
|
node, plane, box2screen, box2screen, 0) |
75 |
|
|
76 |
def getOffset(node, x,y): |
def getOffset(node, x,y): |
77 |
""" Get the text offset in screen coordinates if placeable |
""" Get the text offset in screen coordinates if placeable |
80 |
viewFunction = fenPDF.views.getMultiplexerNodeContentFunction() |
viewFunction = fenPDF.views.getMultiplexerNodeContentFunction() |
81 |
placeable = viewFunction.f(fenPDF.fen.graph, node) |
placeable = viewFunction.f(fenPDF.fen.graph, node) |
82 |
if isinstance(placeable, vob.lava.placeable.TextPlaceable): |
if isinstance(placeable, vob.lava.placeable.TextPlaceable): |
83 |
cs = getMainNode().getNodeCS(getOldVS(), node) |
cs = getNodeCSbyNode(node) |
84 |
ptsIn = jarray.array([x,y,0], 'f') |
ptsIn = jarray.array([x,y,0], 'f') |
85 |
ptsOut = jarray.zeros(3, 'f') |
ptsOut = jarray.zeros(3, 'f') |
86 |
getOldVS().coords.inverseTransformPoints3(cs, ptsIn, ptsOut) |
getOldVS().coords.inverseTransformPoints3(cs, ptsIn, ptsOut) |
95 |
placeable = viewFunction.f(fenPDF.fen.graph, node) |
placeable = viewFunction.f(fenPDF.fen.graph, node) |
96 |
retArray = [] |
retArray = [] |
97 |
if isinstance(placeable, vob.lava.placeable.TextPlaceable): |
if isinstance(placeable, vob.lava.placeable.TextPlaceable): |
98 |
cs = getMainNode().getNodeCS(getOldVS(), node) |
cs = getNodeCSbyNode(node) |
99 |
xyy = jarray.zeros(3, 'f') |
xyy = jarray.zeros(3, 'f') |
100 |
placeable.getCursorXYY(offset, xyy) |
placeable.getCursorXYY(offset, xyy) |
101 |
ptsIn = jarray.array([xyy[0],xyy[1],0], 'f') |
ptsIn = jarray.array([xyy[0],xyy[1],0], 'f') |
120 |
placeable = viewFunction.f(fenPDF.fen.graph, node) |
placeable = viewFunction.f(fenPDF.fen.graph, node) |
121 |
retArray = [] |
retArray = [] |
122 |
if isinstance(placeable, vob.lava.placeable.TextPlaceable): |
if isinstance(placeable, vob.lava.placeable.TextPlaceable): |
123 |
cs = getMainNode().getNodeCS(getOldVS(), node) |
cs = getNodeCSbyNode(node) |
124 |
ptsOut = jarray.zeros(3, 'f') |
ptsOut = jarray.zeros(3, 'f') |
125 |
ptsIn = jarray.array([0,0,0], 'f') |
ptsIn = jarray.array([0,0,0], 'f') |
126 |
getOldVS().coords.transformPoints3(cs, ptsIn, ptsOut) |
getOldVS().coords.transformPoints3(cs, ptsIn, ptsOut) |
148 |
class ScrollWheelPan(vob.input.RelativeAxisListener): |
class ScrollWheelPan(vob.input.RelativeAxisListener): |
149 |
"""Scroll vertically using the scroll wheel. |
"""Scroll vertically using the scroll wheel. |
150 |
""" |
""" |
151 |
|
def __init__(self): self.mul = 13 |
152 |
def changedRelative(self, d): |
def changedRelative(self, d): |
153 |
f = getMainNode().getFocus() |
f = getMainNode().getFocus() |
154 |
fX, fY = f.getPanX(), f.getPanY() |
fX, fY = f.getPanX(), f.getPanY() |
155 |
f.setPan(fX, fY-d/f.zoom) |
f.setPan(fX, fY - d*self.mul/f.zoom) |
156 |
getMainNode().setZoomPan(getOldVS()) |
getMainNode().setZoomPan(getOldVS()) |
157 |
|
|
158 |
class Pan_Fastest(vob.mouse.RelativeAdapter): |
class Pan_Fastest(vob.mouse.RelativeAdapter): |
197 |
class BrowseClick(vob.mouse.MouseClickListener): |
class BrowseClick(vob.mouse.MouseClickListener): |
198 |
def clicked(self, x, y): |
def clicked(self, x, y): |
199 |
if dbg: p('move pan slow') |
if dbg: p('move pan slow') |
200 |
obj = getMainNode().getNodeOnPlane(getOldVS(), x,y) |
obj = getNodeOnPlane(x,y) |
201 |
context.states.cursor.setAccursed(obj) |
if dbg: p('node', obj) |
202 |
|
fenPDF.uistate.cursor.setAccursed(obj) |
203 |
getMainNode().moveToPoint(int(x),int(y), getOldVS()) |
getMainNode().moveToPoint(int(x),int(y), getOldVS()) |
204 |
|
|
205 |
|
# clear selection |
206 |
|
fenPDF.views.getAreaSelectView2D().clear() |
207 |
|
|
208 |
viewFunction = fenPDF.views.getMultiplexerNodeContentFunction() |
viewFunction = fenPDF.views.getMultiplexerNodeContentFunction() |
209 |
placeable = viewFunction.f(fenPDF.fen.graph, obj) |
placeable = viewFunction.f(fenPDF.fen.graph, obj) |
210 |
if dbg: p(placeable) |
if dbg: p(placeable) |
211 |
if obj != None and isinstance(placeable, vob.lava.placeable.TextPlaceable): |
if obj != None and isinstance(placeable, vob.lava.placeable.TextPlaceable): |
212 |
cs = getMainNode().getNodeCS(getOldVS(), x,y) |
cs = getNodeCS(x,y) |
213 |
ptsIn = jarray.array([x,y,0], 'f') |
ptsIn = jarray.array([x,y,0], 'f') |
214 |
ptsOut = jarray.zeros(3, 'f') |
ptsOut = jarray.zeros(3, 'f') |
215 |
getOldVS().coords.inverseTransformPoints3(cs, ptsIn, ptsOut) |
getOldVS().coords.inverseTransformPoints3(cs, ptsIn, ptsOut) |
230 |
|
|
231 |
class IfSelectNodeOnPlane(vob.mouse.MouseClickListener): |
class IfSelectNodeOnPlane(vob.mouse.MouseClickListener): |
232 |
def clicked(self, x, y): |
def clicked(self, x, y): |
233 |
obj = getMainNode().getNodeOnPlane(getOldVS(), x,y) |
obj = getNodeOnPlane(x,y) |
234 |
context.states.cursor.setAccursed(obj) |
fenPDF.uistate.cursor.setAccursed(obj) |
235 |
fenPDF.animation.regenerateVS() |
fenPDF.animation.regenerateVS() |
236 |
|
|
237 |
class MouseMenu(vob.mouse.MouseClickListener): |
class MouseMenu(vob.mouse.MouseClickListener): |
238 |
def clicked(self, x, y): |
def clicked(self, x, y): |
239 |
obj = getMainNode().getNodeOnPlane(getOldVS(), x,y) |
obj = getNodeOnPlane(x,y) |
240 |
#if obj != None: |
#if obj != None: |
241 |
# context.states.objectOnPlane = obj |
# context.states.objectOnPlane = obj |
242 |
#context.mousemenu.link = 1 |
#context.mousemenu.link = 1 |
247 |
if dbg: p(placeable) |
if dbg: p(placeable) |
248 |
offs = None |
offs = None |
249 |
if obj != None and isinstance(placeable, vob.lava.placeable.TextPlaceable): |
if obj != None and isinstance(placeable, vob.lava.placeable.TextPlaceable): |
250 |
cs = getMainNode().getNodeCS(getOldVS(), x,y) |
cs = getNodeCS(x,y) |
251 |
ptsIn = jarray.array([x,y,0], 'f') |
ptsIn = jarray.array([x,y,0], 'f') |
252 |
ptsOut = jarray.zeros(3, 'f') |
ptsOut = jarray.zeros(3, 'f') |
253 |
getOldVS().coords.inverseTransformPoints3(cs, ptsIn, ptsOut) |
getOldVS().coords.inverseTransformPoints3(cs, ptsIn, ptsOut) |
256 |
|
|
257 |
fenPDF.uistate.menu.originateFromMainNode(getMainNode(), obj, offs) |
fenPDF.uistate.menu.originateFromMainNode(getMainNode(), obj, offs) |
258 |
|
|
259 |
context.mousemenu.showList(x,y,'mainmenu') |
fenPDF.events.mousemenu.showList(x,y,'mainmenu') |
260 |
fenPDF.animation.regenerateVS() |
fenPDF.animation.regenerateVS() |
261 |
vob.AbstractUpdateManager.setNoAnimation() |
vob.AbstractUpdateManager.setNoAnimation() |
262 |
|
|
265 |
class NodeMover(vob.mouse.RelativeAdapter, |
class NodeMover(vob.mouse.RelativeAdapter, |
266 |
vob.mouse.MousePressListener): |
vob.mouse.MousePressListener): |
267 |
def pressed(self, x,y): |
def pressed(self, x,y): |
268 |
self.set(getMainNode().getNodeOnPlane(getOldVS(), x,y),x,y) |
self.set(getNodeOnPlane(x,y),x,y) |
269 |
return self |
return self |
270 |
def set(self, node, x,y): |
def set(self, node, x,y): |
271 |
self.evX, self.evY = x, y |
self.evX, self.evY = x, y |
287 |
viewFunction = fenPDF.views.getMultiplexerNodeContentFunction() |
viewFunction = fenPDF.views.getMultiplexerNodeContentFunction() |
288 |
placeable = viewFunction.f(fenPDF.fen.graph, self.node) |
placeable = viewFunction.f(fenPDF.fen.graph, self.node) |
289 |
if isinstance(placeable, vob.lava.placeable.TextPlaceable): |
if isinstance(placeable, vob.lava.placeable.TextPlaceable): |
290 |
cs = getMainNode().getNodeCS(getOldVS(), self.evX,self.evY) |
cs = getNodeCS(self.evX,self.evY) |
291 |
ptsIn = jarray.array([self.evX,self.evY,0], 'f') |
ptsIn = jarray.array([self.evX,self.evY,0], 'f') |
292 |
ptsOut = jarray.zeros(3, 'f') |
ptsOut = jarray.zeros(3, 'f') |
293 |
getOldVS().coords.inverseTransformPoints3(cs, ptsIn, ptsOut) |
getOldVS().coords.inverseTransformPoints3(cs, ptsIn, ptsOut) |
294 |
offs = placeable.getCursorPos(ptsOut[0], ptsOut[1]) |
offs = placeable.getCursorPos(ptsOut[0], ptsOut[1]) |
295 |
|
|
296 |
# optional textcloud |
if fenPDF.useExtension('TextCloud') and fenPDF.uistate.textScissors.isScissored(self.node, offs): |
|
textcloud = 0 |
|
|
if textcloud and fenPDF.uistate.textScissors.isScissored(self.node, offs): |
|
297 |
fenPDF.uistate.textScissors.fixOffset() |
fenPDF.uistate.textScissors.fixOffset() |
298 |
node = ff.swamp.Nodes.N() |
node = ff.swamp.Nodes.N() |
299 |
enf = fenPDF.structure.ff \ |
enf = fenPDF.structure.ff \ |
331 |
return self |
return self |
332 |
def startDrag(self, x,y): |
def startDrag(self, x,y): |
333 |
self.oldxy = getMainNode().getXYHit(getOldVS(), x, y) |
self.oldxy = getMainNode().getXYHit(getOldVS(), x, y) |
334 |
self.node = getMainNode().getNodeOnPlane(getOldVS(), x,y) |
self.node = getNodeOnPlane(x,y) |
335 |
offs = getOffset(self.node, x,y) |
if self.node != None: |
336 |
if dbg: p('old', self.oldxy, self.node, offs) |
offs = getOffset(self.node, x,y) |
337 |
fenPDF.uistate.textScissors.setBegin(self.node, offs) |
if dbg: p('old', self.oldxy, self.node, offs) |
338 |
|
fenPDF.uistate.textScissors.setBegin(self.node, offs) |
339 |
def drag(self, x, y): |
def drag(self, x, y): |
340 |
if self.node != None: |
if self.node != None: |
341 |
offs = getOffset(self.node, x,y) |
offs = getOffset(self.node, x,y) |
345 |
canvasCS = getOldVS().matcher.getCS(getMainNode().getBox2Screen(), 'AreaSelectingView_concat') |
canvasCS = getOldVS().matcher.getCS(getMainNode().getBox2Screen(), 'AreaSelectingView_concat') |
346 |
if dbg: p(getOffsetXYY(self.node, canvasCS, offs)) |
if dbg: p(getOffsetXYY(self.node, canvasCS, offs)) |
347 |
|
|
348 |
v = ff.util.lava.view.getView(getMainNode(), ff.view.AreaSelectingView2D) |
select = fenPDF.views.getAreaSelectView2D() |
349 |
v.setCurrentPlane(getMainNode().getPlane()) |
select.setCurrentPlane(getMainNode().getPlane()) |
350 |
|
select.clear() |
351 |
xy = getMainNode().getXYHit(getOldVS(), x,y) |
xy = getMainNode().getXYHit(getOldVS(), x,y) |
352 |
if not fenPDF.uistate.textScissors.isScissored(self.node): |
if not fenPDF.uistate.textScissors.isScissored(self.node): |
353 |
v.setArea(self.oldxy[0], self.oldxy[1], xy[0], xy[1]) |
select.setArea(self.oldxy[0], self.oldxy[1], xy[0], xy[1]) |
354 |
else: |
else: |
355 |
if dbg: p('begin',fenPDF.uistate.textScissors.begin.offset, |
if dbg: p('begin',fenPDF.uistate.textScissors.begin.offset, |
356 |
'end', fenPDF.uistate.textScissors.end.offset) |
'end', fenPDF.uistate.textScissors.end.offset) |
359 |
end = getOffsetXYY(self.node, canvasCS, |
end = getOffsetXYY(self.node, canvasCS, |
360 |
fenPDF.uistate.textScissors.end.offset) |
fenPDF.uistate.textScissors.end.offset) |
361 |
edge = getTextWidthEdges(self.node, canvasCS) |
edge = getTextWidthEdges(self.node, canvasCS) |
362 |
v.setTextArea(begin[0], begin[1], begin[2], |
select.setTextArea(begin[0], begin[1], begin[2], |
363 |
end[0], end[1], end[2], |
end[0], end[1], end[2], |
364 |
edge[0], edge[1]) |
edge[0], edge[1]) |
365 |
|
|
366 |
context.states.selection.setArea( |
fenPDF.uistate.selection.setArea( |
367 |
(self.oldxy[0], self.oldxy[1], xy[0], xy[1]), |
(self.oldxy[0], self.oldxy[1], xy[0], xy[1]), |
368 |
getMainNode()) |
getMainNode()) |
369 |
|
|
370 |
getMainNode().chgFast(getOldVS(), -1) |
getMainNode().chgFast(getOldVS(), -1) |
371 |
def endDrag(self, x,y): |
def endDrag(self, x,y): |
382 |
self.panMover = panMover |
self.panMover = panMover |
383 |
def pressed(self, x, y): |
def pressed(self, x, y): |
384 |
if dbg: p("OldVS: ", getOldVS()) |
if dbg: p("OldVS: ", getOldVS()) |
385 |
obj = getMainNode().getNodeOnPlane(getOldVS(), x,y) |
obj = getNodeOnPlane(x,y) |
386 |
|
|
387 |
if obj != None and obj == context.states.cursor.getAccursed(): |
if obj != None and obj == fenPDF.uistate.cursor.getAccursed(): |
388 |
if dbg: p('accursed!') |
if dbg: p('accursed!') |
389 |
self.nodeMover.set(obj, x,y) |
self.nodeMover.set(obj, x,y) |
390 |
return self.nodeMover |
return self.nodeMover |
410 |
buoymanager = fenPDF.views.getBuoyManager() |
buoymanager = fenPDF.views.getBuoyManager() |
411 |
p('hit',buoymanager.buoyHit) |
p('hit',buoymanager.buoyHit) |
412 |
fenPDF.uistate.menu.originateFromBuoy(buoymanager.buoyHit) |
fenPDF.uistate.menu.originateFromBuoy(buoymanager.buoyHit) |
413 |
context.mousemenu.showList(x,y, 'buoymenu') |
fenPDF.events.mousemenu.showList(x,y, 'buoymenu') |
414 |
fenPDF.animation.regenerateVS() |
fenPDF.animation.regenerateVS() |
415 |
vob.AbstractUpdateManager.setNoAnimation() |
vob.AbstractUpdateManager.setNoAnimation() |
416 |
|
|
429 |
return res |
return res |
430 |
|
|
431 |
class MouseActions: |
class MouseActions: |
432 |
def __init__(self, fenPDF, context): |
def __init__(self, fenPDF): |
433 |
actions = defineActions(fenPDF,context) |
actions = defineActions(fenPDF) |
434 |
for sym in actions.keys(): |
for sym in actions.keys(): |
435 |
setattr(self, sym, actions[sym]) |
setattr(self, sym, actions[sym]) |
436 |
|
|