def draw_target_path(self) -> None: """Draw solving path.""" pen = QPen() pen.setWidth(self.path_width) for i, n in enumerate(sorted(self.target_path)): path = self.target_path[n] if self.monochrome: line, dot = target_path_style(0) else: line, dot = target_path_style(i + 1) pen.setColor(line) self.painter.setPen(pen) if len(path) == 1: x, y = path[0] p = QPointF(x, -y) * self.zoom self.painter.drawText(p + QPointF(6, -6), f"P{n}") pen.setColor(dot) self.painter.setPen(pen) self.draw_circle(p, self.joint_size) else: painter_path = QPainterPath() for j, (x, y) in enumerate(path): p = QPointF(x, -y) * self.zoom self.draw_circle(p, self.joint_size) if j == 0: self.painter.drawText(p + QPointF(6, -6), f"P{n}") painter_path.moveTo(p) else: x2, y2 = path[j - 1] self.__draw_arrow(x, -y, x2, -y2, zoom=True) painter_path.lineTo(p) pen.setColor(line) self.painter.setPen(pen) self.painter.drawPath(painter_path) for x, y in path: pen.setColor(dot) self.painter.setPen(pen) self.draw_circle( QPointF(x, -y) * self.zoom, self.joint_size) self.painter.setBrush(Qt.NoBrush)
def qwtDrawHexagonSymbols(painter, points, numPoints, symbol): painter.setBrush(symbol.brush()) painter.setPen(symbol.pen()) cos30 = np.cos(30 * np.pi / 180.0) dx = 0.5 * (symbol.size().width() - cos30) dy = 0.25 * symbol.size().height() for pos in points: x = pos.x() y = pos.y() x1 = x - dx y1 = y - 2 * dy x2 = x1 + 1 * dx x3 = x1 + 2 * dx y2 = y1 + 1 * dy y3 = y1 + 3 * dy y4 = y1 + 4 * dy hexa = [ QPointF(x2, y1), QPointF(x3, y2), QPointF(x3, y3), QPointF(x2, y4), QPointF(x1, y3), QPointF(x1, y2), ] painter.drawPolygon(QPolygonF(hexa))
def setCenter(self, lon, lat): """Move the center of the visible area to new coordinates. Update the scene rect. Args: lon(float): New longitude of the center. lat(float): New latitude of the center. """ rect = QRectF(self.sceneRect()) pos = self.posFromLonLat(lon, lat) rect.moveCenter(QPointF(pos[0], pos[1])) self.setSceneRect(rect)
def qwtDrawStar1Symbols(painter, points, numPoints, symbol): size = symbol.size() painter.setPen(symbol.pen()) sqrt1_2 = np.sqrt(0.5) r = QRectF(0, 0, size.width(), size.height()) for pos in points: r.moveCenter(pos.toPoint()) c = QPointF(r.center()) d1 = r.width() / 2.0 * (1.0 - sqrt1_2) painter.drawLine(r.left() + d1, r.top() + d1, r.right() - d1, r.bottom() - d1) painter.drawLine(r.left() + d1, r.bottom() - d1, r.right() - d1, r.top() + d1) painter.drawLine(c.x(), r.top(), c.x(), r.bottom()) painter.drawLine(r.left(), c.y(), r.right(), c.y())
def fit_bezier(points): import numpy as np from scipy.interpolate import splprep, BSpline from itertools import groupby if len(points) < 3: return None coords = np.array([(p.x(), p.y()) for p in points]).transpose() ((t, c, k), _), _, _, _ = splprep(coords, full_output=True) c = np.array(c).transpose() unique_t = [g[0] for g in groupby(t)] b = BSpline(t, c, k) return [QPointF(x, y) for x, y in b(unique_t)]
def enableRoiMode(self, enable): if enable == self._roiMode: return if enable: self._roiPolygon = QPolygonF() self._roiItem.setPolygon(self._roiPolygon) self._tempRoiPolygon = QPolygonF(self._roiPolygon) self._tempRoiPolygon.append(QPointF()) if not enable: self._roiItem.setPolygon(self._roiPolygon) self.roiChanged.emit(self._roiPolygon) self._roiMode = enable self.roiModeChanged.emit(enable)
def paint(self, p, opt, widget): super(SegmentedRectROI, self).paint(p, opt, widget) min_x = self.pos().x() min_y = self.pos().y() max_x = self.size().x() + min_x max_y = self.size().y() + min_y segment_bin_x = (max_x - min_x) / self.segments_h segment_bin_y = (max_y - min_y) / self.segments_v self.currentPen.setStyle(Qt.DashLine) p.setPen(self.currentPen) for i in range(1, self.segments_h): p.drawLine(QPointF(1.0 / self.segments_h * i, 0), QPointF(1 / self.segments_h * i, 1)) for j in range(1, self.segments_v): p.drawLine(QPointF(0, 1 / self.segments_v * j), QPointF(1, 1 / self.segments_v * j)) self.currentPen.setStyle(Qt.SolidLine)
def showTracks(self): # clear self.pathitems self.clearTracks() frame = self.window.imageview.currentIndex if frame < len(self.tracks_by_frame): tracks = self.tracks_by_frame[frame] pen = QPen(Qt.green, .4) pen.setCosmetic(True) pen.setWidth(2) for track_idx in tracks: pathitem = QGraphicsPathItem(self.window.imageview.view) pathitem.setPen(pen) self.window.imageview.view.addItem(pathitem) self.pathitems.append(pathitem) pts = self.txy_pts[self.tracks[track_idx]] x = pts[:, 1] + .5 y = pts[:, 2] + .5 path = QPainterPath(QPointF(x[0], y[0])) for i in np.arange(1, len(pts)): path.lineTo(QPointF(x[i], y[i])) pathitem.setPath(path)
def setCornerRects(self, path): pos = QPointF(0.0, 0.0) for i in range(path.elementCount()): el = path.elementAt(i) if el.type in (QPainterPath.MoveToElement, QPainterPath.LineToElement): pos.setX(el.x) pos.setY(el.y) elif el.type == QPainterPath.CurveToElement: r = QRectF(pos, QPointF(el.x, el.y)) self.clipRects += [r.normalized()] pos.setX(el.x) pos.setY(el.y) elif el.type == QPainterPath.CurveToDataElement: if self.clipRects: r = self.clipRects[-1] r.setCoords( min([r.left(), el.x]), min([r.top(), el.y]), max([r.right(), el.x]), max([r.bottom(), el.y]), ) self.clipRects[-1] = r.normalized()
def draw_icon(self, painter): painter.drawEllipse(QPointF(0.5, 0.5), 0.5, 0.5) pen = painter.pen() pen.setWidthF(pen.width() * 2) pen.setCapStyle(Qt.FlatCap) painter.setPen(pen) r = 0.5 x1 = r + r * math.cos(math.radians(45)) y1 = r + r * math.sin(math.radians(45)) x2 = r + r * math.cos(math.radians(225)) y2 = r + r * math.sin(math.radians(225)) painter.drawLine(QLineF(x1, y1, x2, y2)) painter.drawLine(QLineF(x2, y1, x1, y2))
def draw_icon(self, painter): painter.drawEllipse(QPointF(0.5, 0.5), 0.5, 0.5) painter.drawChord(QRectF(0.0, 0.0, 1.0, 1.0), 45 * 16, -120 * 16) painter.drawChord(QRectF(0.0, 0.0, 1.0, 1.0), 135 * 16, 120 * 16) bottom_arrow_point = QPointF(0.5, 0.8) painter.drawLine(bottom_arrow_point, QPointF(0.5, 0.7)) curve_start = QPointF(0.5, 0.7) bend_angle = 25 curve_end_l = QPointF( 0.4 * math.cos(math.radians(90 + bend_angle)) + 0.5, -0.4 * math.sin(math.radians(90 + bend_angle)) + 0.5) c1 = QPointF(0.5, 0.4) path = QPainterPath(curve_start) path.quadTo(c1, curve_end_l) painter.drawPath(path) curve_end_r = QPointF( 0.4 * math.cos(math.radians(90 - bend_angle)) + 0.5, -0.4 * math.sin(math.radians(90 - bend_angle)) + 0.5) path = QPainterPath(curve_start) path.quadTo(c1, curve_end_r) painter.drawPath(path) # Draw the arrow end-caps painter.setBrush(QBrush(QColor(0, 0, 0))) arrow = QPolygonF( [QPointF(-0.025, 0.0), QPointF(0.025, 0.0), QPointF(0.0, 0.025)]) painter.drawPolygon(arrow.translated(bottom_arrow_point)) t = QTransform() t.rotate(180.0 - 25.0) arrow_l = t.map(arrow) arrow_l = arrow_l.translated(curve_end_l) painter.drawPolygon(arrow_l) t = QTransform() t.rotate(180.0 + 25.0) arrow_r = t.map(arrow) arrow_r = arrow_r.translated(curve_end_r) painter.drawPolygon(arrow_r)
def paintEvent(self, event: QPaintEvent) -> None: """Using a QPainter under 'self', so just change QPen or QBrush before painting. """ if not self.__grab_mode: self.painter.begin(self) self.painter.fillRect(event.rect(), QBrush(Qt.white)) # Translation self.painter.translate(self.ox, self.oy) # Background if not self.background.isNull(): rect = self.background.rect() self.painter.setOpacity(self.background_opacity) self.painter.drawImage( QRectF( self.background_offset * self.zoom, QSizeF(rect.width(), rect.height()) * self.background_scale * self.zoom), self.background, QRectF(rect)) self.painter.setOpacity(1) # Show frame pen = QPen(Qt.blue) pen.setWidth(1) self.painter.setPen(pen) self.painter.setFont(QFont("Arial", self.font_size)) # Draw origin lines if self.show_ticks not in {_TickMark.SHOW, _TickMark.SHOW_NUM}: return pen.setColor(Qt.gray) self.painter.setPen(pen) x_l = -self.ox x_r = self.width() - self.ox self.painter.drawLine(x_l, 0, x_r, 0) y_t = self.height() - self.oy y_b = -self.oy self.painter.drawLine(0, y_b, 0, y_t) def indexing(v: float) -> int: """Draw tick.""" return int(v / self.zoom - v / self.zoom % 5) # Draw tick for x in range(indexing(x_l), indexing(x_r) + 1, 5): if x == 0: continue is_ten = x % 10 == 0 end = QPointF(x * self.zoom, -10 if is_ten else -5) self.painter.drawLine(QPointF(x, 0) * self.zoom, end) if self.show_ticks == _TickMark.SHOW_NUM and is_ten: self.painter.drawText(end + QPointF(0, 3), f"{x}") for y in range(indexing(y_b), indexing(y_t) + 1, 5): if y == 0: continue is_ten = y % 10 == 0 end = QPointF(10 if is_ten else 5, y * self.zoom) self.painter.drawLine(QPointF(0, y) * self.zoom, end) if self.show_ticks == _TickMark.SHOW_NUM and is_ten: self.painter.drawText(end + QPointF(3, 0), f"{-y}")
def paint(self, p, *args): ''' Overrides the default implementation so as to draw a vertical marker. ''' # draw the text # # Note that this actually doesn't work. Commenting out this call to the base # class doesn't prevent the text to be painted on screen regardless. Tests with # the base class itself prove that the base class paint() is not responsible for # painting the text. Even when the base class' code in its paint() method is # replaced by a sole 'pass' statement, the text still shows up on the plot. # Thus there is something else in either pyqtgraph or pyqt that paints the text # even though the entire painting mechanism in the classes is disabled. super(LineIDMarker, self).paint(p, args) # Add marker. Geometry depends on the # text being vertical or horizontal. points = [] bounding_rect = self.boundingRect() if self._orientation == 'vertical': x = bounding_rect.x() y = bounding_rect.y() + bounding_rect.height() / 2. points.append(QPointF(x, y)) points.append(QPointF(x - 20, y)) else: x = bounding_rect.x() + bounding_rect.width() / 2. y = bounding_rect.y() + bounding_rect.height() * 2. points.append(QPointF(x, y)) points.append(QPointF(x, y - 20)) polygon = QPolygonF(points) pen = QPen(QColor(functions.mkColor(self._color))) p.setPen(pen) p.drawPolygon(polygon)
class YEdEdgeItem(QtWidgets.QGraphicsPathItem): _pen = makePen(color='#888', width=1) _polyTri = QtGui.QPolygonF([ QPointF(0, 0), QPointF(-12, -6), QPointF(-12, 6), ]) def __init__(self, *args, **kwargs): super(YEdEdgeItem, self).__init__(*args, **kwargs) self.setPen(YEdEdgeItem._pen) self.edge = None def setEdge(self, edge): self.edge = edge points = edge.getAttr('path', []) self.hasArrow = edge.getAttr('arrow-target', 'none') != 'none' path = QtGui.QPainterPath() head = True for i, p in enumerate(points): if i > 0: path.lineTo(*p) else: path.moveTo(*p) self.setPath(path) def paint(self, painter, option, widget): super(YEdEdgeItem, self).paint(painter, option, widget) #draw arrow if self.hasArrow: path = self.path() midDir = path.angleAtPercent(0.5) midPoint = path.pointAtPercent(0.5) trans = QTransform() trans.translate(midPoint.x(), midPoint.y()) trans.rotate(-midDir) painter.setTransform(trans, True) painter.drawPolygon(YEdEdgeItem._polyTri)
def __init__( self, mechanism: Dict[str, Any], path: Sequence[Sequence[_Coord]], vpoints: List[VPoint] = None, vlinks: List[VLink] = None, parent: QWidget = None ): """Input link and path data.""" super(_DynamicCanvas, self).__init__(parent) self.mechanism = mechanism self.vpoints = vpoints or [] self.vlinks = vlinks or [] self.no_mechanism = not self.vpoints or not self.vlinks use_norm = self.no_mechanism and ( self.mechanism.get('shape_only', False) or self.mechanism.get('wavelet_mode', False)) # Target path same: Dict[int, int] = self.mechanism['same'] target_path: _TargetPath = self.mechanism['target'] for i, p in target_path.items(): for j in range(i): if j in same: i -= 1 self.target_path[i] = norm_path(p) if use_norm else p self.path.path = [] for i, p in enumerate(path): if i in self.target_path and use_norm: self.path.path.append(norm_path(efd_fitting(p))) else: self.path.path.append(p) self.__index = 0 self.__interval = 1 self.__path_count = max(len(path) for path in self.path.path) - 1 self.pos: List[_Coord] = [] # Error self.error = False self.__no_error = 0 if self.no_mechanism: return # Ranges ranges: Dict[int, _Range] = self.mechanism['placement'] self.ranges.update({f"P{i}": QRectF( QPointF(values[0] - values[2], values[1] + values[2]), QSizeF(values[2] * 2, values[2] * 2) ) for i, values in ranges.items()}) # Timer self.__timer = QTimer() self.__timer.timeout.connect(self.__change_index) self.__timer.start(18)
def updatePosition(self, scene): """Update the position of the circle. Args: scene(MapGraphicsScene): Scene to which the circle belongs. """ pos = scene.posFromLonLat(self._lon, self._lat) self.prepareGeometryChange() # This object is centered on the lat lon point, so shift it by half width/height rect = QRectF(pos[0] - self._height // 2, pos[1] - self._width // 2, self._width, self._height) self.setRect(rect) self.setPos(QPointF(0.0, 0.0))
def transform(self, img=None): # Build Quads shape = img.shape a = [(0, shape[-2] - 1), (shape[-1] - 1, shape[-2] - 1), (shape[-1] - 1, 0), (0, 0)] b = [(0, 0), (shape[-1] - 1, 0), (shape[-1] - 1, shape[-2] - 1), (0, shape[-2] - 1)] quad1 = QPolygonF() quad2 = QPolygonF() for p, q in zip(a, b): quad1.append(QPointF(*p)) quad2.append(QPointF(*q)) transform = QTransform() QTransform.quadToQuad(quad1, quad2, transform) for item in self.view.items: if isinstance(item, ImageItem): item.setTransform(transform) self._transform = transform return img, transform
def drawSteps(self, painter, xMap, yMap, canvasRect, from_, to): """ Draw steps :param QPainter painter: Painter :param qwt.scale_map.QwtScaleMap xMap: Maps x-values into pixel coordinates. :param qwt.scale_map.QwtScaleMap yMap: Maps y-values into pixel coordinates. :param QRectF canvasRect: Contents rectangle of the canvas :param int from_: Index of the first point to be painted :param int to: Index of the last point to be painted. If to < 0 the curve will be painted to its last point. .. seealso:: :py:meth:`draw()`, :py:meth:`drawSticks()`, :py:meth:`drawDots()`, :py:meth:`drawLines()` """ polygon = QPolygonF(2 * (to - from_) + 1) inverted = self.orientation() == Qt.Vertical if self.__data.attributes & self.Inverted: inverted = not inverted series = self.data() ip = 0 for i in range(from_, to + 1): sample = series.sample(i) xi = xMap.transform(sample.x()) yi = yMap.transform(sample.y()) if ip > 0: p0 = polygon[ip - 2] if inverted: polygon[ip - 1] = QPointF(p0.x(), yi) else: polygon[ip - 1] = QPointF(xi, p0.y()) polygon[ip] = QPointF(xi, yi) ip += 2 painter.drawPolyline(polygon) if self.__data.brush.style() != Qt.NoBrush: self.fillCurve(painter, xMap, yMap, canvasRect, polygon)
def draw_node_rect(painter: QPainter, geom: NodeGeometry, model: NodeDataModel, graphics_object: NodeGraphicsObject, node_style: NodeStyle): """ Draw node rect Parameters ---------- painter : QPainter geom : NodeGeometry model : NodeDataModel graphics_object : NodeGraphicsObject node_style : NodeStyle """ color = (node_style.selected_boundary_color if graphics_object.isSelected() else node_style.normal_boundary_color ) p = QPen(color, (node_style.hovered_pen_width if geom.hovered else node_style.pen_width)) painter.setPen(p) gradient = QLinearGradient(QPointF(0.0, 0.0), QPointF(2.0, geom.height)) for at_, color in node_style.gradient_colors: gradient.setColorAt(at_, color) painter.setBrush(gradient) diam = node_style.connection_point_diameter boundary = QRectF(-diam, -diam, 2.0 * diam + geom.width, 2.0 * diam + geom.height) radius = 3.0 painter.drawRoundedRect(boundary, radius, radius)
def refresh_pos(self): """ 刷新位置。当节点被拖动的时候,此方法会被触发。 """ y = self.base_rect.y() dy_input = self.base_rect.boundingRect().height() / ( 1 + len(self.input_ports)) dy_output = self.base_rect.boundingRect().height() / ( 1 + len(self.output_ports)) if self.direction == 'E': x_input = self.base_rect.x() + 5 x_output = self.base_rect.x() + self.base_rect.boundingRect( ).width() - 15 elif self.direction == 'W': x_input = self.base_rect.x() + self.base_rect.boundingRect().width( ) - 15 x_output = self.base_rect.x() + 5 else: raise NotImplementedError for i, p in enumerate(self.input_ports): p.setPos(QPointF(x_input, y + int(dy_input * (1 + i)))) for i, p in enumerate(self.output_ports): p.setPos(QPointF(x_output, y + int(dy_output * (1 + i)))) self.canvas.signal_item_dragged.emit('')
def move(self, filter, event): if self.active is None: return self.unselection_pending = False if self.inside: self.active.move_local_shape(self.last_pos, event.pos()) self.undo_action = UndoMoveObject(self.active, event.pos(), self.first_pos) else: ctrl = event.modifiers() & Qt.ControlModifier == Qt.ControlModifier self.active.move_local_point_to(self.handle, event.pos(), ctrl) self.undo_action = UndoMovePoint(self.active, self.first_pos, event.pos(), self.handle, ctrl) self.last_pos = QPointF(event.pos()) filter.plot.replot()
def draw_ranges(self) -> None: """Draw rectangle ranges.""" pen = QPen() pen.setWidth(5) for i, (tag, rect) in enumerate(self.ranges.items()): range_color = QColor(color_num(i + 1)) range_color.setAlpha(30) self.painter.setBrush(range_color) range_color.setAlpha(255) pen.setColor(range_color) self.painter.setPen(pen) cx = rect.x() * self.zoom cy = rect.y() * -self.zoom if rect.width(): self.painter.drawRect( QRectF(QPointF(cx, cy), QSizeF(rect.width(), rect.height()) * self.zoom)) else: self.draw_circle(QPointF(cx, cy), 3) range_color.setAlpha(255) pen.setColor(range_color) self.painter.setPen(pen) self.painter.drawText(QPointF(cx, cy) + QPointF(6, -6), tag) self.painter.setBrush(Qt.NoBrush)
def _arrow_points(startpoint, endpoint, height, width): """ Returns the three points needed to make a triangle with .drawPolygon """ diff_x = startpoint.x() - endpoint.x() diff_y = startpoint.y() - endpoint.y() length = math.sqrt(diff_x ** 2 + diff_y ** 2) norm_x = diff_x / length norm_y = diff_y / length perp_x = -norm_y perp_y = norm_x left_x = endpoint.x() + height * norm_x + width * perp_x left_y = endpoint.y() + height * norm_y + width * perp_y right_x = endpoint.x() + height * norm_x - width * perp_x right_y = endpoint.y() + height * norm_y - width * perp_y left = QPointF(left_x, left_y) right = QPointF(right_x, right_y) return QPolygonF([left, endpoint, right])
def mapfromview(self, x, y, item_key='red'): """ get item coordinates from view coordinates Parameters ---------- x: (float) x coordinate in the view reference frame y: (float) y coordinate in the view refernece frame Returns ------- x: (float) coordinate in the item reference frame y: (float) coordinate in the item reference frame """ point = self._graph_items[item_key].mapFromView(QPointF(x, y)) return point.x(), point.y()
def updatePosition(self, scene): """Update the position of the circle. Args: scene(MapGraphicsScene): Scene to which the circle belongs. """ pos0 = scene.posFromLonLat(self._lon0, self._lat0) pos1 = scene.posFromLonLat(self._lon1, self._lat1) width = abs(int(pos1[0] - pos0[0])) height = abs(int(pos0[1] - pos1[1])) self.prepareGeometryChange() rect = QRectF(pos0[0], pos0[1], width, height) self.setRect(rect) self.setPos(QPointF(0.0, 0.0))
def _appendPointToRoi(self, pos, polygon, replace_last=False): br = self._imageItem.boundingRect() topLeft = br.topLeft() bottomRight = br.bottomRight() # Make sure we stay inside the image boundaries xInBr = max(topLeft.x(), pos.x()) xInBr = min(bottomRight.x(), xInBr) yInBr = max(topLeft.y(), pos.y()) yInBr = min(bottomRight.y(), yInBr) pointInBr = QPointF(xInBr, yInBr) if replace_last: polygon[-1] = pointInBr else: polygon.append(pointInBr)
def draw_icon(self, painter): pen = painter.pen() pen.setWidthF(pen.width() * 2) pen.setCapStyle(Qt.FlatCap) painter.setPen(pen) # Circle parameters radius = 0.3 center = (0.5, 1 - radius) # Draw circle painter.drawEllipse(QPointF(*center), radius, radius) # X pattern quad = math.cos(math.radians(45)) * radius painter.drawLine( QLineF(center[0] + quad, center[1] + quad, center[0] - quad, center[1] - quad)) painter.drawLine( QLineF(center[0] + quad, center[1] - quad, center[0] - quad, center[1] + quad)) # Interlock Icon square_dims = (0.4, 0.2) painter.drawLine(QPointF(center[0], center[1] - radius), QPointF(center[0], square_dims[1])) painter.setBrush(self._interlock_brush) painter.drawRect(QRectF((1 - square_dims[0]) / 2., 0, *square_dims))
def load(self, json_data): import json loaded = json.loads(json_data) self.assert_and_raise(type(loaded) is list) for pose in loaded: pose_parsed = [] self.assert_and_raise(type(pose) is list) self.assert_and_raise(len(pose) == PoseShape.n_pose_points) for i, p in enumerate(pose): if p == -1: pose_parsed.append(None) else: self.assert_and_raise(type(p) is list and len(p) == 2) pose_parsed.append(QPointF(*p)) self.data.append(PoseShape(pose_parsed))
def displayCoordinates(self, pos): if self.view.sceneBoundingRect().contains(pos): mousePoint = self.view.getViewBox().mapSceneToView(pos) pos = QPointF(mousePoint.x(), mousePoint.y()) if self.imageItem.mapRectToView( self.imageItem.boundingRect()).contains( mousePoint): # within bounds # angstrom=QChar(0x00B5) pxpos = self.imageItem.mapFromView(pos) self.formatCoordinates(pxpos, pos) else: self._coordslabel.setText( "<div style='font-size:12pt;'> </div>")
def get_xydata_spread(self, data, roi): xvals = [] yvals = [] data_out = [] for ind in range(data.shape[0]): # invoke the QPainterpath of the ROI (from the shape method) if roi.shape().contains( QPointF(data[ind, 0] - roi.pos().x(), data[ind, 1] - roi.pos().y())): xvals.append(data[ind, 0]) yvals.append(data[ind, 1]) data_out.append(data[ind, 2]) data_out = np.array(data_out) xvals = np.array(xvals) yvals = np.array(yvals) return xvals, yvals, data_out