def plot_polygon(rw, tck, width_tck, rgba): '''Plot the full polygon on RisWidget Parameters: ------------ rw: RisWidget Object Reference to the RisWidget object you want to display the spline on tck: parametric spline tuple Spline tuple of the centerline to plot width_tck: nonparametric spline tuple Spline tuple of the widths along the centerline to plot rgba: 3-d tuple of ints RGBA values to color the spline Returns: ----------- display_path: QGraphicsPathItem Reference to the display item displaying the spline ''' left, right, outline = spline_geometry.outline(tck, width_tck) #print(left) path = Qt.QPainterPath() path.moveTo(*outline[0]) for x, y in outline: path.lineTo(x, y) path.closeSubpath() display_path = Qt.QGraphicsPathItem(path, parent=rw.image_scene.layer_stack_item) pen = Qt.QBrush(Qt.QColor(*rgba, 90)) #pen.setColor(Qt.QColor(*rgba)) #pen.setWidth(1) #pen.setCosmetic(True) display_path.setBrush(pen) return display_path
def plot_spline(rw, tck, rgba): '''Plot the spline on RisWidget Parameters: ------------ rw: RisWidget Object Reference to the RisWidget object you want to display the spline on tck: parametric spline tuple Spline tuple to plot rgba: 3-d tuple of ints RGBA values to color the spline Returns: ----------- display_path: QGraphicsPathItem Reference to the display item displaying the spline ''' bezier_elements = interpolate.spline_to_bezier(tck) path = Qt.QPainterPath() path.moveTo(*bezier_elements[0][0]) for (sx, sy), (c1x, c1y), (c2x, c2y), (ex, ey) in bezier_elements: path.cubicTo(c1x, c1y, c2x, c2y, ex, ey) display_path = Qt.QGraphicsPathItem(path, parent=rw.image_scene.layer_stack_item) pen = Qt.QPen(Qt.QColor(*rgba, 100)) pen.setWidth(2) pen.setCosmetic(True) display_path.setPen(pen) return display_path
def __init__(self, general_view, parent_item): super().__init__(parent_item) self.view = general_view self.path_item = Qt.QGraphicsPathItem(parent_item) pen = Qt.QPen(Qt.Qt.green) pen.setWidth(5) pen.setCosmetic(True) self.path_item.setPen(pen) self.path = Qt.QPainterPath() self.points = [] parent_item.installSceneEventFilter(self)
def __init__(self, ris_widget, pen=None, geometry=None): self._tck_x = numpy.linspace(0, 1, self.SPLINE_POINTS) self.image_shape = None super().__init__(ris_widget, pen, geometry) self.layer = None self.draw_midline = True self.midline = Qt.QGraphicsPathItem(self.parentItem()) midline_pen = Qt.QPen(self.display_pen) midline_pen.setStyle(Qt.Qt.DotLine) self.midline.setPen(midline_pen) self.parentItem().bounding_rect_changed.connect( self._update_image_shape) self._update_image_shape()
def plot_spline(rw, points, smoothing, rgba): tck = interpolate.fit_spline(points, smoothing=smoothing) bezier_elements = interpolate.spline_to_bezier(tck) path = Qt.QPainterPath() path.moveTo(*bezier_elements[0][0]) for (sx, sy), (c1x, c1y), (c2x, c2y), (ex, ey) in bezier_elements: path.cubicTo(c1x, c1y, c2x, c2y, ex, ey) display_path = Qt.QGraphicsPathItem(path, parent=rw.image_scene.layer_stack_item) pen = Qt.QPen(Qt.QColor(*rgba)) pen.setWidth(2) pen.setCosmetic(True) display_path.setPen(pen) return tck, display_path