def myfn(self, arg): Newton.myfn(self, arg) # check for buffered adds for body in self._add_list: self.add_body(body) self._add_list = [] # check for buffered deletes for body in self._delete_list: self.remove_body(body) self._delete_list = [] # check for output in the buffers of incoming flows inputs = self.inputs() for p in range(len(inputs)): if len(inputs[p].output_buffer) > 0: body = inputs[p].output_buffer[0] body.position = (self.input_x, self.input_y) #print body.position self.add_body(body) inputs[p].output_buffer.remove(body) # check for obects to be stuck into the output_buffer # TODO -> Move refs in Newton to remove_list to Reactor if len(self.outputs()) > 0: for body in self._remove_list: self.remove_body(body) self.output_buffer.append(body) else: for body in self._remove_list: self.remove_body(body) self._remove_list = []
def draw(self, canvas): Newton.draw(self, canvas) canvas.set_line_width(0.0) canvas.set_source_rgba(0.5, 0.5, 1.0, 0.9) canvas.rectangle(self.left, self.top, self.width, self.height) canvas.fill()
def __init__(self, x, y, width = 30.0, height = 30.0, do_reaction = False): Newton.__init__(self, x, y, width, height) Process.__init__(self, x, y, width, height) self.__ode_walls = [] self.__rotor = None self.__reactor_output = None self.render_walls = True self.render_valves = True self.mouse_over_property= False self.bounds_check = True self.do_reaction = do_reaction self._delete_list = [] # for buffering removals during ode reaction collision callback
def hit_test(self, pointer_x, pointer_y): # translate to local coords (x, y) = self._translate_pointer_local(pointer_x, pointer_y) self.mouse_over_property = MathLib.rect_test(x, y, 0.0, -self.world_height-(self.decorator_size/4.0), self.decorator_size, self.decorator_size/2.0) return Newton.hit_test(self, pointer_x, pointer_y)
def __init__(self, x, y): Newton.__init__(self, x, y, SIZE, SIZE) self.scale_to_container = True