def __init__(self, window, x, y, params={}): PatchElement.__init__(self, window, x, y) self.param_list.extend( ['x_min', 'x_max', 'y_min', 'y_max', 'style', 'plot_type']) # display elements self.rect = None self.label = None self.label_text = None self.xyplot = None # display bounds self.x_min = 0.0 self.x_max = 6.28 self.y_min = -1.0 self.y_max = 1.0 self.min_interval = 75 self.last_draw = None # create display width = self.INIT_WIDTH + self.WIDTH_PAD height = self.INIT_HEIGHT + self.LABEL_SPACE + self.HEIGHT_PAD self.create_display(width, height) self.set_size(width, height) self.move(x, y) self.update()
def configure(self, params): if params.get('value') is not None: new_text = params.get('value') if new_text != self.value: self.value = new_text self.set_text() if params.get('clickchange') is not None: self.clickchange = params['clickchange'] if params.get('default') is not None: self.default = params['default'] newsize = None if params.get('style') is not None: newstyle = params.get('style') if newstyle.get('canvas-size') is not None: newsize = newstyle.get('canvas-size') params['width'] = newsize[0] params['height'] = newsize[1] if params.get('border') is not None: self.border = params.get('border') PatchElement.configure(self, params) if newsize: self.set_size(*newsize) self.update()
def configure(self, params): if "plot_type" in params and self.xyplot is None: if params["plot_type"] == "scatter": self.xyplot = ScatterPlot(self.INIT_WIDTH, self.INIT_HEIGHT) elif params["plot_type"] == "scope": self.xyplot = ScopePlot(self.INIT_WIDTH, self.INIT_HEIGHT, MFPApp().samplerate) self.xyplot.draw_complete_cb = self.draw_complete_cb if self.xyplot: self.add_actor(self.xyplot) self.xyplot.set_position(3, self.LABEL_SPACE) if self.obj_args is None: self.label.set_text("%s" % (self.obj_type, )) else: self.label.set_text("%s %s" % (self.obj_type, self.obj_args)) x_min = params.get('x_min', self.x_min) x_max = params.get('x_max', self.x_max) y_min = params.get('y_min', self.y_min) y_max = params.get('y_max', self.y_max) self.set_bounds(x_min, y_min, x_max, y_max) if self.xyplot is not None: self.xyplot.configure(params) PatchElement.configure(self, params)
def __init__(self, window, x, y, params={}): PatchElement.__init__(self, window, x, y) self.param_list.extend(['x_min', 'x_max', 'y_min', 'y_max', 'plot_style', 'plot_type']) # display elements self.rect = None self.label = None self.label_text = None self.xyplot = None # display bounds self.x_min = 0.0 self.x_max = 6.28 self.y_min = -1.0 self.y_max = 1.0 self.min_interval = 75 self.last_draw = None # create display width = self.INIT_WIDTH + self.WIDTH_PAD height = self.INIT_HEIGHT + self.LABEL_SPACE + self.HEIGHT_PAD self.create_display(width, height) self.set_size(width, height) self.move(x, y) self.update()
def configure(self, params): if "plot_type" in params and self.xyplot is None: if params["plot_type"] == "scatter": self.xyplot = ScatterPlot(self, self.INIT_WIDTH, self.INIT_HEIGHT) elif params["plot_type"] == "scope": self.xyplot = ScopePlot(self, self.INIT_WIDTH, self.INIT_HEIGHT, MFPApp().samplerate) self.xyplot.draw_complete_cb = self.draw_complete_cb if self.xyplot: self.add_actor(self.xyplot) self.xyplot.set_position(3, self.LABEL_SPACE) if self.obj_args is None: self.label.set_text("%s" % (self.obj_type,)) else: self.label.set_text("%s %s" % (self.obj_type, self.obj_args)) x_min = params.get('x_min', self.x_min) x_max = params.get('x_max', self.x_max) y_min = params.get('y_min', self.y_min) y_max = params.get('y_max', self.y_max) self.set_bounds(x_min, y_min, x_max, y_max) if self.xyplot is not None: self.xyplot.configure(params) PatchElement.configure(self, params)
def configure(self, params): if params.get('value') is not None: new_text = params.get('value') if new_text != self.value: self.value = new_text self.label.set_markup(self.value) PatchElement.configure(self, params) self.update()
def __init__(self, window, x, y): PatchElement.__init__(self, window, x, y) self.value = '' self.param_list.append('value') # configure label self.label = Clutter.Text() self.label.set_color(window.color_unselected) self.add_actor(self.label) self.update_required = True self.set_size(12, 12) self.move(x, y) self.set_reactive(True) self.label_changed_cb = self.label.connect('text-changed', self.text_changed_cb)
def command(self, action, data): if self.xyplot.command(action, data): return True elif action == "clear": self.xyplot.clear(data) return True elif action == "bounds": self.set_bounds(*data) return True elif PatchElement.command(self, action, data): return True return False
def __init__(self, window, x, y): PatchElement.__init__(self, window, x, y) self.value = '' self.clickchange = False self.default = '' self.param_list.extend(['value', 'clickchange', 'default']) self.texture = Clutter.CairoTexture.new(12, 12) self.texture.connect("draw", self.draw_cb) self.add_actor(self.texture) self.label = Clutter.Text() self.label.set_color(self.get_color('text-color')) self.label.set_font_name(self.get_fontspec()) self.label.set_position(3, 3) self.add_actor(self.label) self.update_required = True self.set_size(12, 12) self.move(x, y) self.set_reactive(True) self.label_changed_cb = self.label.connect('text-changed', self.text_changed_cb)
def draw_ports(self): if self.selected: PatchElement.draw_ports(self)
def set_size(self, w, h): PatchElement.set_size(self, w, h) self.texture.set_size(w, h) self.texture.set_surface_size(w, h) self.texture.invalidate()
def unselect(self, *args): PatchElement.unselect(self) self.label.set_color(self.get_color('text-color')) self.texture.invalidate() self.hide_ports()
def select(self, *args): PatchElement.select(self) self.label.set_color(self.stage.color_selected) self.draw_ports()
def unselect(self, *args): PatchElement.unselect(self) self.label.set_color(self.stage.color_unselected) self.hide_ports()
def end_edit(self): PatchElement.end_edit(self) self.set_text()
def set_size(self, width, height): PatchElement.set_size(self, width, height) self.rect.set_size(width, height) if self.xyplot: self.xyplot.set_size(width-self.WIDTH_PAD, height-self.LABEL_SPACE-self.WIDTH_PAD)
def unselect(self): PatchElement.unselect(self) self.rect.set_border_color(self.stage.color_unselected)
def delete(self): for c in self.connections_out + self.connections_in: c.delete() PatchElement.delete(self)
def set_size(self, width, height): PatchElement.set_size(self, width, height) self.rect.set_size(width, height) if self.xyplot: self.xyplot.set_size(width - self.WIDTH_PAD, height - self.LABEL_SPACE - self.WIDTH_PAD)