def get_plot_x_section(obj, apply_lut=False): """ Return plot cross section along x-axis, at the y value defined by 'obj', a Marker/AnnotatedPoint object """ _x0, y0 = get_object_coordinates(obj) plot = obj.plot() xmap = plot.canvasMap(plot.X_BOTTOM) xc0, xc1 = xmap.p1(), xmap.p2() _xc0, yc0 = axes_to_canvas(obj, 0, y0) if plot.get_axis_direction("left"): yc1 = yc0+1 else: yc1 = yc0-1 try: #TODO: eventually add an option to apply interpolation algorithm data = get_image_from_qrect(plot, QPoint(xc0, yc0), QPoint(xc1, yc1), apply_lut=apply_lut, apply_interpolation=False) except (ValueError, ZeroDivisionError, TypeError): return np.array([]), np.array([]) y = data.mean(axis=0) x0, _y0 = canvas_to_axes(obj, QPoint(xc0, yc0)) x1, _y1 = canvas_to_axes(obj, QPoint(xc1, yc1)) x = np.linspace(x0, x1, len(y)) return x, y
def get_plot_y_section(obj, apply_lut=False): """ Return plot cross section along y-axis, at the x value defined by 'obj', a Marker/AnnotatedPoint object """ x0, _y0 = get_object_coordinates(obj) plot = obj.plot() ymap = plot.canvasMap(plot.Y_LEFT) yc0, yc1 = ymap.p1(), ymap.p2() if plot.get_axis_direction("left"): yc1, yc0 = yc0, yc1 xc0, _yc0 = axes_to_canvas(obj, x0, 0) xc1 = xc0 + 1 try: data = get_image_from_qrect(plot, QPoint(xc0, yc0), QPoint(xc1, yc1), apply_lut=apply_lut, apply_interpolation=False) except (ValueError, ZeroDivisionError, TypeError): return np.array([]), np.array([]) y = data.mean(axis=1) _x0, y0 = canvas_to_axes(obj, QPoint(xc0, yc0)) _x1, y1 = canvas_to_axes(obj, QPoint(xc1, yc1)) x = np.linspace(y0, y1, len(y)) return x, y
def get_plot_x_section(obj, apply_lut=False): """ Return plot cross section along x-axis, at the y value defined by 'obj', a Marker/AnnotatedPoint object """ _x0, y0 = get_object_coordinates(obj) plot = obj.plot() xmap = plot.canvasMap(plot.X_BOTTOM) xc0, xc1 = xmap.p1(), xmap.p2() _xc0, yc0 = axes_to_canvas(obj, 0, y0) if plot.get_axis_direction("left"): yc1 = yc0 + 1 else: yc1 = yc0 - 1 try: #TODO: eventually add an option to apply interpolation algorithm data = get_image_from_qrect(plot, QPoint(xc0, yc0), QPoint(xc1, yc1), apply_lut=apply_lut, apply_interpolation=False) except (ValueError, ZeroDivisionError, TypeError): return np.array([]), np.array([]) y = data.mean(axis=0) x0, _y0 = canvas_to_axes(obj, QPoint(xc0, yc0)) x1, _y1 = canvas_to_axes(obj, QPoint(xc1, yc1)) x = np.linspace(x0, x1, len(y)) return x, y
def move_local_shape(self, old_pos, new_pos): old_pt = canvas_to_axes(self, old_pos) new_pt = canvas_to_axes(self, new_pos) self.shape.move_shape(old_pt, new_pt) self.set_label_position() if self.plot(): self.plot().SIG_ITEM_MOVED.emit(self, *(old_pt + new_pt)) self.plot().SIG_ANNOTATION_CHANGED.emit(self)
def move_local_shape(self, old_pos, new_pos): old_pt = canvas_to_axes(self, old_pos) new_pt = canvas_to_axes(self, new_pos) self.shape.move_shape(old_pt, new_pt) self.set_label_position() if self.plot(): self.plot().emit(SIG_ITEM_MOVED, self, *(old_pt+new_pt)) self.plot().emit(SIG_ANNOTATION_CHANGED, self)
def get_plot_y_section(obj, apply_lut=False): """ Return plot cross section along y-axis, at the x value defined by 'obj', a Marker/AnnotatedPoint object """ x0, _y0 = get_object_coordinates(obj) plot = obj.plot() ymap = plot.canvasMap(plot.Y_LEFT) yc0, yc1 = ymap.p1(), ymap.p2() if plot.get_axis_direction("left"): yc1, yc0 = yc0, yc1 xc0, _yc0 = axes_to_canvas(obj, x0, 0) xc1 = xc0+1 try: data = get_image_from_qrect(plot, QPoint(xc0, yc0), QPoint(xc1, yc1), apply_lut=apply_lut, apply_interpolation=False) except (ValueError, ZeroDivisionError, TypeError): return np.array([]), np.array([]) y = data.mean(axis=1) _x0, y0 = canvas_to_axes(obj, QPoint(xc0, yc0)) _x1, y1 = canvas_to_axes(obj, QPoint(xc1, yc1)) x = np.linspace(y0, y1, len(y)) return x, y
def __init__(self, obj, pos1, pos2): self.obj = obj from guiqwt.baseplot import canvas_to_axes self.coords1 = canvas_to_axes(obj, pos1) self.coords2 = canvas_to_axes(obj, pos2)