37 |
|
|
38 |
# Define the actions. |
# Define the actions. |
39 |
|
|
40 |
def defineActions(context): |
def defineActions(fenPDF, context): |
41 |
def getMainNode(): |
def getMainNode(): |
42 |
return context.states.buoymanager.getLastMain() |
return context.states.buoymanager.getLastMain() |
43 |
def getOldVS(): |
def getOldVS(): |
44 |
return context.states.buoymanager.getVs() |
return fenPDF.uistate.lastVs |
45 |
|
|
46 |
# Inside the action, we have the following symbols usable: |
# Inside the action, we have the following symbols usable: |
47 |
|
# fenPDF - the main FenPDF object |
48 |
# context - the context object |
# context - the context object |
49 |
# getMainNode() - get the main node that was hit last |
# getMainNode() - get the main node that was hit last |
50 |
# getOldVS() - get the previous vobScene. |
# getOldVS() - get the previous vobScene. |
51 |
|
|
52 |
|
# Note that the default is that the old vobscene is reused. |
53 |
|
# If an action needs regeneration, it has to explicitly call for |
54 |
|
# that by fenPDF.uistate.regenerateVs() |
55 |
|
|
56 |
######## Actions to control pan of main nodes etc. |
######## Actions to control pan of main nodes etc. |
57 |
|
|
58 |
class PanMover(vob.mouse.RelativeAdapter, |
class PanMover(vob.mouse.RelativeAdapter, |
59 |
vob.input.RelativeAxisListener): |
vob.input.RelativeAxisListener): |
60 |
def changedRelative(self, x,y='foo'): |
def changedRelative(self, x,y='foo'): |
|
context.states.fastChg = 1 |
|
61 |
# grrr.. pythonism, overloading of own method is sicknes |
# grrr.. pythonism, overloading of own method is sicknes |
62 |
if y=='foo': return self._changedRelative(x) |
if y=='foo': return self._changedRelative(x) |
63 |
f = getMainNode().getFocus() |
f = getMainNode().getFocus() |
77 |
obj = getMainNode().getNodeOnPlane(getOldVS(), x,y) |
obj = getMainNode().getNodeOnPlane(getOldVS(), x,y) |
78 |
context.states.cursor.setAccursed(obj) |
context.states.cursor.setAccursed(obj) |
79 |
getMainNode().moveToPoint(int(x),int(y), getOldVS()) |
getMainNode().moveToPoint(int(x),int(y), getOldVS()) |
80 |
context.states.fastChg = 0 |
fenPDF.uistate.regenerateVS() |
81 |
|
|
82 |
|
|
83 |
class ZoomPan(vob.input.RelativeAxisListener): |
class ZoomPan(vob.input.RelativeAxisListener): |
84 |
def changedRelative(self, x): |
def changedRelative(self, x): |
85 |
getMainNode().changeZoom(x) |
getMainNode().changeZoom(x) |
86 |
getMainNode().chgFast(getOldVS(), -1) |
getMainNode().chgFast(getOldVS(), -1) |
|
context.states.fastChg = 1 |
|
87 |
|
|
88 |
class ChangeSize(vob.input.RelativeAxisListener): |
class ChangeSize(vob.input.RelativeAxisListener): |
89 |
def changedRelative(self, x): |
def changedRelative(self, x): |
90 |
getMainNode().changeSize(x) |
getMainNode().changeSize(x) |
91 |
getMainNode().chgFast(getOldVS(), -1) |
getMainNode().chgFast(getOldVS(), -1) |
|
context.states.fastChg = 1 |
|
92 |
|
|
93 |
class IfSelectNodeOnPlane(vob.mouse.MouseClickListener): |
class IfSelectNodeOnPlane(vob.mouse.MouseClickListener): |
94 |
def clicked(self, x, y): |
def clicked(self, x, y): |
95 |
obj = getMainNode().getNodeOnPlane(getOldVS(), x,y) |
obj = getMainNode().getNodeOnPlane(getOldVS(), x,y) |
96 |
context.states.cursor.setAccursed(obj) |
context.states.cursor.setAccursed(obj) |
97 |
context.states.fastChg = 0 |
fenPDF.uistate.regenerateVS() |
98 |
|
|
99 |
class MouseMenu(vob.mouse.MouseClickListener): |
class MouseMenu(vob.mouse.MouseClickListener): |
100 |
def clicked(self, x, y): |
def clicked(self, x, y): |
104 |
context.mousemenu.link = 1 |
context.mousemenu.link = 1 |
105 |
else: context.mousemenu.link = 0 |
else: context.mousemenu.link = 0 |
106 |
context.mousemenu.showList(x,y,'mainmenu') |
context.mousemenu.showList(x,y,'mainmenu') |
107 |
context.states.fastChg = 0 |
fenPDF.uistate.regenerateVS() |
108 |
vob.AbstractUpdateManager.setNoAnimation() |
vob.AbstractUpdateManager.setNoAnimation() |
109 |
|
|
110 |
####### Actions to control nodes on main node plane |
####### Actions to control nodes on main node plane |
127 |
oy = ff.util.RDFUtil.getFloat(g, self.node, CANVAS2D.y) |
oy = ff.util.RDFUtil.getFloat(g, self.node, CANVAS2D.y) |
128 |
self.pp.moveNote(self.node, ox+x/f.zoom, oy+y/f.zoom ) |
self.pp.moveNote(self.node, ox+x/f.zoom, oy+y/f.zoom ) |
129 |
getMainNode().chgFast(getOldVS(), -1) |
getMainNode().chgFast(getOldVS(), -1) |
|
context.states.fastChg = 1 |
|
130 |
|
|
131 |
|
|
132 |
|
|
151 |
getMainNode()) |
getMainNode()) |
152 |
|
|
153 |
getMainNode().chgFast(getOldVS(), -1) |
getMainNode().chgFast(getOldVS(), -1) |
|
context.states.fastChg = 1 |
|
154 |
def endDrag(self, x,y): |
def endDrag(self, x,y): |
155 |
self.drag(x,y) |
self.drag(x,y) |
156 |
|
|
164 |
self.nodeMover = nodeMover |
self.nodeMover = nodeMover |
165 |
self.panMover = panMover |
self.panMover = panMover |
166 |
def pressed(self, x, y): |
def pressed(self, x, y): |
167 |
|
p("OldVS: ", getOldVS()) |
168 |
obj = getMainNode().getNodeOnPlane(getOldVS(), x,y) |
obj = getMainNode().getNodeOnPlane(getOldVS(), x,y) |
169 |
|
|
170 |
if obj != None and obj == context.states.cursor.getAccursed(): |
if obj != None and obj == context.states.cursor.getAccursed(): |
193 |
buoymanager = context.states.buoymanager |
buoymanager = context.states.buoymanager |
194 |
p('hit',buoymanager.buoyHit) |
p('hit',buoymanager.buoyHit) |
195 |
context.mousemenu.showList(x,y, 'buoymenu') |
context.mousemenu.showList(x,y, 'buoymenu') |
196 |
context.states.fastChg = 0 |
fenPDF.uistate.regenerateVS() |
197 |
vob.AbstractUpdateManager.setNoAnimation() |
vob.AbstractUpdateManager.setNoAnimation() |
198 |
|
|
199 |
class BuoyFollowClick(vob.mouse.MouseClickListener): |
class BuoyFollowClick(vob.mouse.MouseClickListener): |
201 |
buoymanager = context.states.buoymanager |
buoymanager = context.states.buoymanager |
202 |
p('hit',buoymanager.buoyHit, buoymanager.buoyHit.single) |
p('hit',buoymanager.buoyHit, buoymanager.buoyHit.single) |
203 |
buoymanager.buoyHit.single.followLink(buoymanager.buoyHit.link) |
buoymanager.buoyHit.single.followLink(buoymanager.buoyHit.link) |
204 |
context.states.fastChg = 0 |
fenPDF.uistate.regenerateVS() |
205 |
|
|
206 |
# Return a map of symbols |
# Return a map of symbols |
207 |
res = { } |
res = { } |
211 |
return res |
return res |
212 |
|
|
213 |
class MouseActions: |
class MouseActions: |
214 |
def __init__(self, context): |
def __init__(self, fenPDF, context): |
215 |
actions = defineActions(context) |
actions = defineActions(fenPDF,context) |
216 |
for sym in actions.keys(): |
for sym in actions.keys(): |
217 |
setattr(self, sym, actions[sym]) |
setattr(self, sym, actions[sym]) |
218 |
|
|