55 |
|
|
56 |
|
|
57 |
pa("LOADING BUOYMANAGER") |
pa("LOADING BUOYMANAGER") |
58 |
class RealBuoyManager(BuoyLinkListener): |
class AbstractBuoyManager(BuoyLinkListener): |
59 |
"""Manage buoys through the new APIs |
"""Manage buoys through the new APIs |
60 |
|
|
61 |
This is a demo "scene" |
This is a demo "scene" |
74 |
n = self.vs.coords.nadirUnitSq(cs, self.nadirCS) |
n = self.vs.coords.nadirUnitSq(cs, self.nadirCS) |
75 |
self.vs.matcher.add(cs, n, "NADIR") |
self.vs.matcher.add(cs, n, "NADIR") |
76 |
return n |
return n |
77 |
def scene(self, vs): |
def drawscene(self, vs, into, buoyinto): |
|
if self.replaceScene: |
|
|
sc = self.replaceScene |
|
|
self.replaceScene = None |
|
|
return sc |
|
78 |
self.vs = vs |
self.vs = vs |
79 |
self.cs = { } |
self.cs = { } |
80 |
|
|
|
self.ctrx = vs.size.width / 2 |
|
|
self.ctry = vs.size.height * .485 # A *little* above real ctr |
|
|
|
|
|
mainsize = vs.size.width * .6 |
|
|
|
|
|
self.nadirCS = vs.translateCS(0, "NADIRORIGIN", self.ctrx, |
|
|
2.5 * vs.size.height) |
|
|
|
|
|
vs.put(background((.36, .74, 1.0))) |
|
|
|
|
|
# rule 1) this translate is 'FocusCenter' |
|
|
center = vs.translateCS(0, "FocusCenter", self.ctrx, self.ctry) |
|
|
#center = vs.affineCS(0, "FocusCenter", 0, self.ctrx, self.ctry, |
|
|
# .6, .3, -.3, .9) |
|
|
|
|
|
# rule 2) this box is 'FocusFrame' |
|
|
into = vs.orthoBoxCS(center, "FocusFrame", 0, |
|
|
-mainsize/2, -mainsize/2, 1, 1, mainsize, mainsize) |
|
|
|
|
81 |
self.vs.activate(into) |
self.vs.activate(into) |
82 |
|
|
83 |
self.mainNode.renderMain(vs, into) |
self.mainNode.renderMain(vs, into) |
85 |
self.links = [] |
self.links = [] |
86 |
for connector in self.connectors: |
for connector in self.connectors: |
87 |
connector.addBuoys(vs, into, self.mainNode, self) |
connector.addBuoys(vs, into, self.mainNode, self) |
88 |
for l in self.links: self._linkReally(*l) |
for l in self.links: self._linkReally(buoyinto, *l) |
89 |
self.cs[into] = None |
self.cs[into] = None |
90 |
|
|
91 |
# Interpolation : old buoy -> to new main vp |
# Interpolation : old buoy -> to new main vp |
98 |
|
|
99 |
def link(self, *args): |
def link(self, *args): |
100 |
self.links.append(args) |
self.links.append(args) |
101 |
def _linkReally(self, direction, anchorCS, otherNode, linkId, otherAnchor): |
def _linkReally(self, buoyinto, direction, anchorCS, otherNode, linkId, otherAnchor): |
102 |
if dbg: pa('link really') |
if dbg: pa('link really') |
103 |
|
|
104 |
anchorUnit = self.vs.unitSqCS(anchorCS, "UN") |
buoy = self.vs.coords.buoyOnCircle2(buoyinto, anchorCS, |
105 |
anchorCenter = self.vs.translateCS(anchorUnit, "TR55", .5, .5) |
direction, 10) |
|
x = self.ctrx |
|
|
r = self.ctry * 1.05 |
|
|
if dbg: pa("Buoy: ",self.ctrx, self.ctry, x, r) |
|
|
if direction > 0: |
|
|
buoy = self.vs.coords.buoyOnCircle1(0, anchorCenter, |
|
|
x, self.ctry, r, |
|
|
x-r, self.ctry, |
|
|
.1) |
|
|
else: |
|
|
buoy = self.vs.coords.buoyOnCircle1(0, anchorCenter, |
|
|
x, self.ctry, r, |
|
|
x+r, self.ctry, |
|
|
.1) |
|
106 |
self.vs.matcher.add(buoy, linkId) |
self.vs.matcher.add(buoy, linkId) |
107 |
if dbg: pa(otherNode) |
if dbg: pa(otherNode) |
108 |
obj = otherNode.getSize(linkId, otherAnchor, size) |
obj = otherNode.getSize(linkId, otherAnchor, size) |
131 |
otherAnchorCS = otherNode.renderBuoy(self.vs, into, linkId, otherAnchor, None) |
otherAnchorCS = otherNode.renderBuoy(self.vs, into, linkId, otherAnchor, None) |
132 |
self.cs[into] = (otherNode, linkId, otherAnchor, into) |
self.cs[into] = (otherNode, linkId, otherAnchor, into) |
133 |
|
|
134 |
self.vs.map.put(lineconn, anchorUnit, |
self.vs.map.put(lineconn, self.vs.unitSqCS(anchorCS, "UN"), |
135 |
self.vs.unitSqCS(otherAnchorCS, "UN")) |
self.vs.unitSqCS(otherAnchorCS, "UN")) |
136 |
|
|
137 |
|
|
195 |
|
|
196 |
def getVs(self): |
def getVs(self): |
197 |
return self.vs; |
return self.vs; |
198 |
|
|
199 |
|
class RealBuoyManager(AbstractBuoyManager): |
200 |
|
def __init__(self, mainNode, connectors): |
201 |
|
AbstractBuoyManager.__init__(self, mainNode, connectors) |
202 |
|
|
203 |
|
def scene(self, vs): |
204 |
|
if self.replaceScene: |
205 |
|
sc = self.replaceScene |
206 |
|
self.replaceScene = None |
207 |
|
return sc |
208 |
|
|
209 |
|
|
210 |
|
self.ctrx = vs.size.width / 2 |
211 |
|
self.ctry = vs.size.height * .485 # A *little* above real ctr |
212 |
|
|
213 |
|
self.nadirCS = vs.translateCS(0, "NADIRORIGIN", self.ctrx, |
214 |
|
2.5 * vs.size.height) |
215 |
|
|
216 |
|
vs.put(background((.36, .74, 1.0))) |
217 |
|
|
218 |
|
center = vs.translateCS(0, "FocusCenter", self.ctrx, self.ctry) |
219 |
|
|
220 |
|
mainsize = vs.size.width * .6 |
221 |
|
buoywidth = vs.size.width * .8 |
222 |
|
buoyheight = vs.size.height * .8 |
223 |
|
|
224 |
|
into = vs.orthoBoxCS(center, "FocusFrame", 0, |
225 |
|
-mainsize/2, -mainsize/2, 1, 1, mainsize, mainsize) |
226 |
|
|
227 |
|
buoyinto = vs.orthoBoxCS(center, "BuoyFrame", 0, |
228 |
|
-buoywidth/2, -buoyheight/2, 1, 1, |
229 |
|
buoywidth, buoyheight) |
230 |
|
|
231 |
|
self.drawscene(vs, into, buoyinto) |
232 |
|
|
233 |
|
|
234 |
|
|