24 |
import jarray |
import jarray |
25 |
|
|
26 |
import vob |
import vob |
27 |
from org.nongnu.libvob.buoy import BuoyLinkListener |
from org.nongnu.libvob.buoy import BuoyLinkListener, BuoyGeometryConfiguration |
28 |
|
|
29 |
from vob.putil.misc import * |
from vob.putil.misc import * |
30 |
|
|
53 |
def pa(*s): |
def pa(*s): |
54 |
print 'buoymanager::',s |
print 'buoymanager::',s |
55 |
|
|
56 |
|
class DummyGeometryConfiguration(BuoyGeometryConfiguration): |
57 |
|
"""A dummy constant geometry. |
58 |
|
""" |
59 |
|
def __init__(self): |
60 |
|
self.buoyMainViewGeometer = vob.buoy.impl.RatioMainGeometer( |
61 |
|
.2, .25, .6, .5) |
62 |
|
self.buoySizer = vob.buoy.impl.AspectBuoySizer(400, 400, 1.5) |
63 |
|
self.buoyGeometer = vob.buoy.impl.RatioBuoyOnCircleGeometer( |
64 |
|
.1, .1, .8, .8) |
65 |
|
def getMainViewGeometer(self, node): |
66 |
|
return self.buoyMainViewGeometer |
67 |
|
def getSizer(self, node, connector): |
68 |
|
return self.buoySizer |
69 |
|
def getGeometer(self, node, connector): |
70 |
|
return self.buoyGeometer |
71 |
|
def getGeometers(self, node): |
72 |
|
return [self.buoyGeometer] |
73 |
|
|
74 |
pa("LOADING BUOYMANAGER") |
pa("LOADING BUOYMANAGER") |
75 |
class SingleFocusManager(BuoyLinkListener): |
class SingleFocusManager(BuoyLinkListener): |
87 |
self.mainNode = mainNode |
self.mainNode = mainNode |
88 |
self.connectors = connectors |
self.connectors = connectors |
89 |
|
|
90 |
self.buoySizer = vob.buoy.impl.AspectBuoySizer(400, 400, 1.5) |
self.geometryConfiguration = DummyGeometryConfiguration() |
|
self.buoyMainViewGeometer = vob.buoy.impl.RatioMainGeometer( |
|
|
.2, .25, .6, .5) |
|
|
self.buoyGeometer = vob.buoy.impl.RatioBuoyOnCircleGeometer( |
|
|
.1, .1, .8, .8) |
|
91 |
|
|
92 |
def getMainNode(self): |
def getMainNode(self): |
93 |
return self.mainNode |
return self.mainNode |
101 |
self.buoyinto = buoyinto |
self.buoyinto = buoyinto |
102 |
self.cs = { } |
self.cs = { } |
103 |
|
|
104 |
into = self.buoyMainViewGeometer.mainCS(vs, mainboxinto, "K", 1) |
buoyMainViewGeometer = self.geometryConfiguration\ |
105 |
|
.getMainViewGeometer(self.mainNode) |
106 |
self.buoyGeometer.prepare(vs, mainboxinto, "J", 1) |
into = buoyMainViewGeometer.mainCS(vs, mainboxinto, "K", 1) |
107 |
|
|
108 |
|
for buoyGeometer in self.geometryConfiguration\ |
109 |
|
.getGeometers(self.mainNode): |
110 |
|
buoyGeometer.prepare(vs, mainboxinto, buoyGeometer, 1) |
111 |
|
|
112 |
self.vs.activate(into) |
self.vs.activate(into) |
113 |
|
|
114 |
self.mainNode.renderMain(vs, into) |
self.mainNode.renderMain(vs, into) |
115 |
|
|
116 |
self.links = [] |
self.linkCalls = [] |
117 |
for connector in self.connectors: |
for connector in self.connectors: |
118 |
|
self.links = [] |
119 |
connector.addBuoys(vs, into, self.mainNode, self) |
connector.addBuoys(vs, into, self.mainNode, self) |
120 |
for l in self.links: self._linkReally(*l) |
self.linkCalls.append( |
121 |
|
(self.geometryConfiguration.getSizer( |
122 |
|
self.mainNode, connector), |
123 |
|
self.geometryConfiguration.getGeometer( |
124 |
|
self.mainNode, connector), |
125 |
|
self.links)) |
126 |
|
|
127 |
|
for l in self.linkCalls: |
128 |
|
(sizer, geometer, list) = l |
129 |
|
for call in list: |
130 |
|
self._linkReally(sizer, geometer, *call) |
131 |
|
|
132 |
self.cs[into] = None |
self.cs[into] = None |
133 |
|
|
134 |
# Interpolation : old buoy -> to new main vp |
# Interpolation : old buoy -> to new main vp |
142 |
def link(self, *args): |
def link(self, *args): |
143 |
self.links.append(args) |
self.links.append(args) |
144 |
|
|
145 |
def _linkReally(self, direction, anchorCS, otherNode, linkId, otherAnchor, shift=0): |
def _linkReally(self, sizer, geometer, direction, anchorCS, otherNode, linkId, otherAnchor, shift=0): |
146 |
"""Create the real buoy. |
"""Create the real buoy. |
147 |
""" |
""" |
148 |
if dbg: pa('link really') |
if dbg: pa('link really') |
150 |
#### Buoy size |
#### Buoy size |
151 |
obj = otherNode.getSize(linkId, otherAnchor, size) |
obj = otherNode.getSize(linkId, otherAnchor, size) |
152 |
|
|
153 |
sca = self.buoySizer.getBuoySize(size[0], size[1], size) |
sca = sizer.getBuoySize(size[0], size[1], size) |
154 |
|
|
155 |
w = size[0] |
w = size[0] |
156 |
h = size[1] |
h = size[1] |
157 |
|
|
158 |
if dbg: pa("BuoyScaling: ",w, h, sca) |
if dbg: pa("BuoyScaling: ",w, h, sca) |
159 |
|
|
160 |
into = self.buoyGeometer.buoyCS(self.vs, anchorCS, direction, |
into = geometer.buoyCS(self.vs, anchorCS, direction, |
161 |
(linkId, direction), |
(linkId, direction), |
162 |
shift, 1, |
shift, 1, |
163 |
w, h, sca) |
w, h, sca) |