Package SmootLight :: Package behaviors :: Module Oval
[hide private]
[frames] | no frames]

Source Code for Module SmootLight.behaviors.Oval

 1  from operationscore.Behavior import * 
2 -class Oval(Behavior):
3 - def processResponse(self, sensors, recurs):
4 ret = [] 5 for data in sensors: 6 #import pdb; pdb.set_trace() 7 height = width = 1 8 if 'Height' in self: 9 height = 1/float(self['Height']) 10 if 'Width' in self: 11 width = 1/float(self['Width']) 12 if 'CenterLoc' in data: 13 xLoc = data['CenterLoc'][0] 14 yLoc = data['CenterLoc'][1] 15 else: 16 data['CenterLoc'] = tuple(data['Location']) 17 xLoc = data['Location'][0] 18 yLoc = data['Location'][1] 19 if not self['Id']+'Radius' in data: 20 data[self['Id']+'Radius'] = self['Radius'] 21 rad = data[self['Id']+'Radius'] 22 cond = '>=' if self['Outside'] else '<=' 23 circleStr = \ 24 'math.sqrt((({x}-%(xLoc)d))**2*%(width)d+(({y}-%(yLoc)d)**2)*%(height)d)%(cond)s%(rad)d' % \ 25 locals() 26 if self['Combine']: 27 data['Location'] += ',' + circleStr 28 else: 29 data['Location'] = circleStr 30 ret.append(data) 31 return (ret, [])
32 - def setLastOutput(self, output):
33 coutput = Behavior.deepCopyPacket(output) 34 for data in coutput: 35 data['Location'] = data['CenterLoc'] 36 return coutput
37