Python PyQt5.QtGui.QPolygonF() Examples

The following are 30 code examples for showing how to use PyQt5.QtGui.QPolygonF(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may want to check out the right sidebar which shows the related API usage.

You may also want to check out all available functions/classes of the module PyQt5.QtGui , or try the search function .

Example 1
Project: phidl   Author: amccaugh   File: quickplotter.py    License: MIT License 6 votes vote down vote up
def add_polygons(self, polygons, color = '#A8F22A', alpha = 1):
        qcolor = QColor()
        qcolor.setNamedColor(color)
        qcolor.setAlphaF(alpha)
        for points in polygons:
            qpoly = QPolygonF( [QPointF(p[0], p[1]) for p in points] )
            scene_poly = self.scene.addPolygon(qpoly)
            scene_poly.setBrush(qcolor)
            scene_poly.setPen(self.pen)
            self.scene_polys.append(scene_poly)
            # Update custom bounding box
            sr = scene_poly.sceneBoundingRect()
            if len(self.scene_polys) == 1:
                self.scene_xmin = sr.left()
                self.scene_xmax = sr.right()
                self.scene_ymin = sr.top()
                self.scene_ymax = sr.bottom()
            else:
                self.scene_xmin = min(self.scene_xmin, sr.left())
                self.scene_xmax = max(self.scene_xmax, sr.right())
                self.scene_ymin = min(self.scene_ymin, sr.top())
                self.scene_ymax = max(self.scene_ymax, sr.bottom()) 
Example 2
Project: eddy   Author: danielepantaleone   File: common.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, geometry=QtGui.QPolygonF(),
         brush=QtGui.QBrush(QtCore.Qt.NoBrush),
         pen=QtGui.QPen(QtCore.Qt.NoPen)):
        """
        Initialize the polygon.
        :type geometry: T <= QRectF|QtGui.QPolygonF|QPainterPath
        :type brush: QBrush
        :type pen: QPen
        """
        self._geometry = geometry
        self._brush = brush
        self._pen = pen

    #############################################
    #   INTERFACE
    ################################# 
Example 3
Project: pyNMS   Author: afourmy   File: geographical_view.py    License: GNU General Public License v3.0 6 votes vote down vote up
def draw_polygons(self):
        sf = shapefile.Reader(self.shapefile)       
        polygons = sf.shapes() 
        for polygon in polygons:
            # convert shapefile geometries into shapely geometries
            # to extract the polygons of a multipolygon
            polygon = shapely.geometry.shape(polygon)
            # if it is a polygon, we use a list to make it iterable
            if polygon.geom_type == 'Polygon':
                polygon = [polygon]
            for land in polygon:
                qt_polygon = QtGui.QPolygonF() 
                longitudes, latitudes = land.exterior.coords.xy
                for lon, lat in zip(longitudes, latitudes):
                    px, py = self.to_canvas_coordinates(lon, lat)
                    if px > 1e+10:
                        continue
                    qt_polygon.append(QtCore.QPointF(px, py))
                polygon_item = QtWidgets.QGraphicsPolygonItem(qt_polygon)
                polygon_item.setBrush(self.land_brush)
                polygon_item.setPen(self.land_pen)
                polygon_item.setZValue(1)
                yield polygon_item 
Example 4
Project: picasso   Author: jungmannlab   File: design.py    License: MIT License 6 votes vote down vote up
def __init__(self, y, x):
        hex_center_x, hex_center_y = indextoHex(y, x)
        center = QtCore.QPointF(hex_center_x, hex_center_y)
        points = [
            HEX_SCALE * HEX_SIDE_HALF * QtCore.QPointF(-1, 0) + center,
            HEX_SCALE * HEX_SIDE_HALF * QtCore.QPointF(-0.5, sqrt(3) / 2)
            + center,
            HEX_SCALE * HEX_SIDE_HALF * QtCore.QPointF(0.5, sqrt(3) / 2)
            + center,
            HEX_SCALE * HEX_SIDE_HALF * QtCore.QPointF(1, 0) + center,
            HEX_SCALE * HEX_SIDE_HALF * QtCore.QPointF(0.5, -sqrt(3) / 2)
            + center,
            HEX_SCALE * HEX_SIDE_HALF * QtCore.QPointF(-0.5, -sqrt(3) / 2)
            + center,
        ]

        hexagonPointsF = QtGui.QPolygonF(points)
        super().__init__(hexagonPointsF)
        self.setPen(HEX_PEN)
        self.setBrush(defaultcolor)  # initialize all as grey 
Example 5
Project: tierpsy-tracker   Author: ver228   File: MWTrackerViewer.py    License: MIT License 6 votes vote down vote up
def draw_food_contour(self, image):
        if self.food_coordinates is None or not self.ui.checkBox_showFood.isChecked():
            return

        painter = QPainter()
        painter.begin(image)

        penwidth = max(1, max(image.height(), image.width()) // 800)
        col = Qt.darkMagenta
        p = QPolygonF()
        for x,y in self.food_coordinates:
            p.append(QPointF(x,y))
            
        pen = QPen()
        pen.setWidth(penwidth)
        pen.setColor(col)
        painter.setPen(pen)

        painter.drawPolyline(p)
        painter.end() 
Example 6
Project: PyQt   Author: PyQt5   File: RewriteHandle.py    License: GNU General Public License v3.0 6 votes vote down vote up
def paintEvent(self, event):
        # 绘制默认的样式
        super(SplitterHandle, self).paintEvent(event)
        # 绘制顶部扩展按钮
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setPen(Qt.red)
        # 画矩形
        painter.drawRect(0, 0, self.width(), 24)
        # 画三角形
        painter.setBrush(Qt.red)
        painter.drawPolygon(QPolygonF([
            QPointF(0, (24 - 8) / 2),
            QPointF(self.width() - 2, 24 / 2),
            QPointF(0, (24 + 8) / 2)
        ])) 
Example 7
Project: phidl   Author: amccaugh   File: quickplotter.py    License: MIT License 5 votes vote down vote up
def add_port(self, port, is_subport = False):
        if (port.width is None) or (port.width == 0):
            x,y = port.midpoint
            cs = 1 # cross size
            pn = QPointF(x, y+cs)
            ps = QPointF(x, y-cs)
            pe = QPointF(x+cs, y)
            pw = QPointF(x-cs, y)
            qline1 = self.scene.addLine(QLineF(pn, ps))
            qline2 = self.scene.addLine(QLineF(pw, pe))
            port_shapes = [qline1,qline2]
        else:
            point1, point2 = port.endpoints
            point1 = QPointF(point1[0], point1[1])
            point2 = QPointF(point2[0], point2[1])
            qline = self.scene.addLine(QLineF(point1, point2))
            arrow_points = np.array([[0,0],[10,0],[6,4],[6,2],[0,2]])/(40)*port.width
            arrow_qpoly = QPolygonF( [QPointF(p[0], p[1]) for p in arrow_points] )
            port_scene_poly = self.scene.addPolygon(arrow_qpoly)
            port_scene_poly.setRotation(port.orientation)
            port_scene_poly.moveBy(port.midpoint[0], port.midpoint[1])
            port_shapes = [qline,port_scene_poly]
        qtext = self.scene.addText(str(port.name), self.portfont)
        port_items = port_shapes + [qtext]
        rad = port.orientation*np.pi/180
        x,y = port.endpoints[0]*1/4 +  port.endpoints[1]*3/4 + np.array([np.cos(rad), np.sin(rad)])*port.width/8
#        x,y = port.midpoint[0], port.midpoint[1]
#        x,y  = x - qtext.boundingRect().width()/2, y - qtext.boundingRect().height()/2
        qtext.setPos(QPointF(x,y))
        qtext.setFlag(QGraphicsItem.ItemIgnoresTransformations)

        if not is_subport:
            [shape.setPen(self.portpen) for shape in port_shapes]
            qtext.setDefaultTextColor(self.portfontcolor)
            self.portitems += port_items
        else:
            [shape.setPen(self.subportpen) for shape in port_shapes]
            qtext.setDefaultTextColor(self.subportfontcolor)
            self.subportitems += port_items
#        self.portlabels.append(qtext) 
Example 8
Project: Computer-graphics   Author: Panda-Lewandowski   File: lab2.py    License: MIT License 5 votes vote down vote up
def turn():
    global epi_x, epi_y, p1, p2, p3, p4, rect
    write_log()
    teta = math.radians(window.spin_deg.value())
    t_x = window.spin_turn_x.value()
    t_y = window.spin_turn_y.value()
    scene.clear()

    rect_t = QPolygonF(4)
    p1 = [t_x + (p1[0] - t_x) * math.cos(teta) + (p1[1] - t_y) * math.sin(teta),
          t_y - (p1[0] - t_x) * math.sin(teta) + (p1[1] - t_y) * math.cos(teta)]
    p2 = [t_x + (p2[0] - t_x) * math.cos(teta) + (p2[1] - t_y) * math.sin(teta),
          t_y - (p2[0] - t_x) * math.sin(teta) + (p2[1] - t_y) * math.cos(teta)]
    p3 = [t_x + (p3[0] - t_x) * math.cos(teta) + (p3[1] - t_y) * math.sin(teta),
          t_y - (p3[0] - t_x) * math.sin(teta) + (p3[1] - t_y) * math.cos(teta)]
    p4 = [t_x + (p4[0] - t_x) * math.cos(teta) + (p4[1] - t_y) * math.sin(teta),
          t_y - (p4[0] - t_x) * math.sin(teta) + (p4[1] - t_y) * math.cos(teta)]
    rect[0] = QPointF(p1[0], p1[1])
    rect[1] = QPointF(p2[0], p2[1])
    rect[2] = QPointF(p3[0], p3[1])
    rect[3] = QPointF(p4[0], p4[1])
    scene.addPolygon(rect, pen=p, brush=b)
    l = len(epi_x)
    for i in range(l):
        x1 = t_x + (epi_x[i] - t_x) * math.cos(teta) + (epi_y[i] - t_y) * math.sin(teta)
        y1 = t_y - (epi_x[i] - t_x) * math.sin(teta) + (epi_y[i] - t_y) * math.cos(teta)
        epi_x[i] = x1
        epi_y[i] = y1
        scene.addLine(epi_x[i], epi_y[i], epi_x[i] + 0.01, epi_y[i] + 0.01, pen=p) 
Example 9
Project: Computer-graphics   Author: Panda-Lewandowski   File: lab9.py    License: MIT License 5 votes vote down vote up
def sutherland_hodgman(clip, pol, norm):
    # дублируем начальную вершину отсекателя в конец
    clip.append(clip[0])

    s = None
    f = None
    # цикл по вершинам отсекателя
    for i in range(len(clip) - 1):
        new = []  # новый массив вершин
        for j in range(len(pol)):    # цикл по вершинам многоугольника
            if j == 0:
                f = pol[j]
            else:
                t = is_intersection([s, pol[j]], [clip[i], clip[i + 1]], norm)
                if t:
                    new.append(t)

            s = pol[j]
            if is_visiable(s,  clip[i], clip[i + 1], norm):
                    new.append(s)

        if len(new) != 0:
            t = is_intersection([s, f], [clip[i], clip[i + 1]], norm)
            if t:
                new.append(t)

        pol = copy.deepcopy(new)

    if len(pol) == 0:
        return False
    else:
        return QPolygonF(pol) 
Example 10
Project: eddy   Author: danielepantaleone   File: geometry.py    License: GNU General Public License v3.0 5 votes vote down vote up
def createArea(p1, p2, degrees, size):
    """
    Creates an area between the given QPointF and according to the given angle and size.
    :type p1: QPointF
    :type p2: QPointF
    :type degrees: float
    :type size: int
    :rtype: QPolygonF
    """
    rad = math.radians(degrees)
    x = size / 2 * math.sin(rad)
    y = size / 2 * math.cos(rad)
    a = QtCore.QPointF(+x, +y)
    b = QtCore.QPointF(-x, -y)
    return QtGui.QPolygonF([p1 + a, p1 + b, p2 + b, p2 + a]) 
Example 11
Project: eddy   Author: danielepantaleone   File: equivalence.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, **kwargs):
        """
        Initialize the edge.
        """
        super().__init__(**kwargs)
        self.tail = Polygon(QtGui.QPolygonF())

    #############################################
    #   INTERFACE
    ################################# 
Example 12
Project: eddy   Author: danielepantaleone   File: equivalence.py    License: GNU General Public License v3.0 5 votes vote down vote up
def createHead(p1, angle, size):
        """
        Create the head polygon.
        :type p1: QPointF
        :type angle: float
        :type size: int
        :rtype: QPolygonF
        """
        rad = radians(angle)
        p2 = p1 - QtCore.QPointF(sin(rad + M_PI / 3.0) * size, cos(rad + M_PI / 3.0) * size)
        p3 = p1 - QtCore.QPointF(sin(rad + M_PI - M_PI / 3.0) * size, cos(rad + M_PI - M_PI / 3.0) * size)
        return QtGui.QPolygonF([p1, p2, p3]) 
Example 13
Project: eddy   Author: danielepantaleone   File: equivalence.py    License: GNU General Public License v3.0 5 votes vote down vote up
def createTail(p1, angle, size):
        """
        Create the tail polygon.
        :type p1: QPointF
        :type angle: float
        :type size: int
        :rtype: QPolygonF
        """
        rad = radians(angle)
        p2 = p1 + QtCore.QPointF(sin(rad + M_PI / 3.0) * size, cos(rad + M_PI / 3.0) * size)
        p3 = p1 + QtCore.QPointF(sin(rad + M_PI - M_PI / 3.0) * size, cos(rad + M_PI - M_PI / 3.0) * size)
        return QtGui.QPolygonF([p1, p2, p3]) 
Example 14
Project: eddy   Author: danielepantaleone   File: input.py    License: GNU General Public License v3.0 5 votes vote down vote up
def createHead(p1, angle, size):
        """
        Create the head polygon.
        :type p1: QPointF
        :type angle: float
        :type size: int
        :rtype: QPolygonF
        """
        rad = radians(angle)
        p2 = p1 - QtCore.QPointF(sin(rad + M_PI / 4.0) * size, cos(rad + M_PI / 4.0) * size)
        p3 = p2 - QtCore.QPointF(sin(rad + 3.0 / 4.0 * M_PI) * size, cos(rad + 3.0 / 4.0 * M_PI) * size)
        p4 = p3 - QtCore.QPointF(sin(rad - 3.0 / 4.0 * M_PI) * size, cos(rad - 3.0 / 4.0 * M_PI) * size)
        return QtGui.QPolygonF([p1, p2, p3, p4]) 
Example 15
Project: eddy   Author: danielepantaleone   File: base.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, source, target=None, breakpoints=None, **kwargs):
        """
        Initialize the edge.
        :type source: AbstractNode
        :type target: AbstractNode
        :type breakpoints: list
        """
        super().__init__(**kwargs)

        self.source = source
        self.target = target

        self.anchors = {} # {AbstractNode: Polygon}
        self.breakpoints = breakpoints or [] # [QtCore.QPointF]
        self.handles = [] # [Polygon]
        self.head = Polygon(QtGui.QPolygonF())
        self.path = Polygon(QtGui.QPainterPath())
        self.selection = Polygon(QtGui.QPainterPath())

        self.mp_AnchorNode = None
        self.mp_AnchorNodePos = None
        self.mp_BreakPoint = None
        self.mp_BreakPointPos = None
        self.mp_Pos = None

        self.setAcceptHoverEvents(True)
        self.setCacheMode(AbstractItem.DeviceCoordinateCache)
        self.setFlag(AbstractItem.ItemIsSelectable, True)

    #############################################
    #   INTERFACE
    ################################# 
Example 16
Project: eddy   Author: danielepantaleone   File: membership.py    License: GNU General Public License v3.0 5 votes vote down vote up
def createHead(p1, angle, size):
        """
        Create the head polygon.
        :type p1: QPointF
        :type angle: float
        :type size: int
        :rtype: QPolygonF
        """
        rad = radians(angle)
        p2 = p1 - QtCore.QPointF(sin(rad + M_PI / 3.0) * size, cos(rad + M_PI / 3.0) * size)
        p3 = p1 - QtCore.QPointF(sin(rad + M_PI - M_PI / 3.0) * size, cos(rad + M_PI - M_PI / 3.0) * size)
        return QtGui.QPolygonF([p1, p2, p3]) 
Example 17
Project: eddy   Author: danielepantaleone   File: individual.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, width=60, height=60, brush=None, **kwargs):
        """
        Initialize the node.
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(**kwargs)

        w = max(width, 60)
        h = max(height, 60)
        brush = brush or IndividualNode.DefaultBrush
        pen = IndividualNode.DefaultPen

        createPolygon = lambda x, y: QtGui.QPolygonF([
            QtCore.QPointF(-(x / 2), -((y / (1 + math.sqrt(2))) / 2)),
            QtCore.QPointF(-(x / 2), +((y / (1 + math.sqrt(2))) / 2)),
            QtCore.QPointF(-((x / (1 + math.sqrt(2))) / 2), +(y / 2)),
            QtCore.QPointF(+((x / (1 + math.sqrt(2))) / 2), +(y / 2)),
            QtCore.QPointF(+(x / 2), +((y / (1 + math.sqrt(2))) / 2)),
            QtCore.QPointF(+(x / 2), -((y / (1 + math.sqrt(2))) / 2)),
            QtCore.QPointF(+((x / (1 + math.sqrt(2))) / 2), -(y / 2)),
            QtCore.QPointF(-((x / (1 + math.sqrt(2))) / 2), -(y / 2)),
            QtCore.QPointF(-(x / 2), -((y / (1 + math.sqrt(2))) / 2)),
        ])

        self.background = Polygon(createPolygon(w + 8, h + 8))
        self.selection = Polygon(createPolygon(w + 8, h + 8))
        self.polygon = Polygon(createPolygon(w, h), brush, pen)
        self.label = NodeLabel(template='individual', pos=self.center, parent=self)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.updateNode()
        self.updateTextPos()

    #############################################
    #   PROPERTIES
    ################################# 
Example 18
Project: eddy   Author: danielepantaleone   File: role.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, width=70, height=50, brush=None, **kwargs):
        """
        Initialize the node.
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(**kwargs)
        
        w = max(width, 70)
        h = max(height, 50)
        brush = brush or RoleNode.DefaultBrush
        pen = RoleNode.DefaultPen

        createPolygon = lambda x, y: QtGui.QPolygonF([
            QtCore.QPointF(-x / 2, 0),
            QtCore.QPointF(0, +y / 2),
            QtCore.QPointF(+x / 2, 0),
            QtCore.QPointF(0, -y / 2),
            QtCore.QPointF(-x / 2, 0)
        ])

        self.fpolygon = Polygon(QtGui.QPainterPath())
        self.ipolygon = Polygon(QtGui.QPainterPath())
        self.background = Polygon(createPolygon(w + 8, h + 8))
        self.selection = Polygon(createPolygon(w + 8, h + 8))
        self.polygon = Polygon(createPolygon(w, h), brush, pen)
        self.label = NodeLabel(template='role', pos=self.center, parent=self)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.updateNode()
        self.updateTextPos()

    #############################################
    #   INTERFACE
    ################################# 
Example 19
Project: eddy   Author: danielepantaleone   File: facet.py    License: GNU General Public License v3.0 5 votes vote down vote up
def createPolygon(w, h):
        """
        Returns the initialized polygon according to the given width/height.
        :type w: int
        :type h: int
        :rtype: QtGui.QPolygonF
        """
        return QtGui.QPolygonF([
            QtCore.QPointF(-w / 2 + 10, -h / 2),
            QtCore.QPointF(+w / 2, -h / 2),
            QtCore.QPointF(+w / 2 - 10, +h / 2),
            QtCore.QPointF(-w / 2, +h / 2),
            QtCore.QPointF(-w / 2 + 10, -h / 2),
        ]) 
Example 20
Project: eddy   Author: danielepantaleone   File: facet.py    License: GNU General Public License v3.0 5 votes vote down vote up
def createPolygonB(w, h):
        """
        Returns the initialized bottom-half polygon according to the given width/height.
        :type w: int
        :type h: int
        :rtype: QtGui.QPolygonF
        """
        return QtGui.QPolygonF([
            QtCore.QPointF(-w / 2 + 10 / 2, 0),
            QtCore.QPointF(+w / 2 - 10 / 2, 0),
            QtCore.QPointF(+w / 2 - 10, +h / 2),
            QtCore.QPointF(-w / 2, +h / 2),
            QtCore.QPointF(-w / 2 + 10 / 2, 0),
        ]) 
Example 21
Project: eddy   Author: danielepantaleone   File: facet.py    License: GNU General Public License v3.0 5 votes vote down vote up
def geometryA(self):
        """
        Returns the geometry of the shape A of this node.
        :rtype: QtGui.QPolygonF
        """
        return self.polygonA.geometry() 
Example 22
Project: eddy   Author: danielepantaleone   File: facet.py    License: GNU General Public License v3.0 5 votes vote down vote up
def geometryB(self):
        """
        Returns the geometry of the shape B of this node.
        :rtype: QtGui.QPolygonF
        """
        return self.polygonB.geometry() 
Example 23
Project: eddy   Author: danielepantaleone   File: operator.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, width=50, height=30, brush=None, **kwargs):
        """
        Initialize the node.
        :type width: int
        :type height: int
        :type brush: QBrush
        """
        super().__init__(**kwargs)

        createPolygon = lambda x, y: QtGui.QPolygonF([
            QtCore.QPointF(-x / 2, 0),
            QtCore.QPointF(-x / 2 + 6, +y / 2),
            QtCore.QPointF(+x / 2 - 6, +y / 2),
            QtCore.QPointF(+x / 2, 0),
            QtCore.QPointF(+x / 2 - 6, -y / 2),
            QtCore.QPointF(-x / 2 + 6, -y / 2),
            QtCore.QPointF(-x / 2, 0),
        ])

        self.background = Polygon(createPolygon(58, 38))
        self.selection = Polygon(createPolygon(58, 38))
        self.polygon = Polygon(createPolygon(50, 30), brush or OperatorNode.DefaultBrush, OperatorNode.DefaultPen)

    #############################################
    #   INTERFACE
    ################################# 
Example 24
Project: eddy   Author: danielepantaleone   File: base.py    License: GNU General Public License v3.0 5 votes vote down vote up
def geometry(self):
        """
        Returns the geometry of the shape of this node.
        :rtype: QtGui.QPolygonF
        """
        return self.polygon.geometry() 
Example 25
Project: eddy   Author: danielepantaleone   File: common.py    License: GNU General Public License v3.0 5 votes vote down vote up
def geometry(self):
        """
        Returns the polygon geometry.
        :rtype: T <= QRectF | QPolygonF | QPainterPath
        """
        return self._geometry 
Example 26
Project: eddy   Author: danielepantaleone   File: common.py    License: GNU General Public License v3.0 5 votes vote down vote up
def setGeometry(self, geometry):
        """
        Set the shape polygon.
        :type geometry: T <= QRectF | QPolygonF | QPainterPath
        """
        self._geometry = geometry 
Example 27
Project: CvStudio   Author: haruiz   File: items.py    License: MIT License 5 votes vote down vote up
def addPoint(self, p):
        self._points.append(p)
        item = EditablePolygonPoint(len(self._points) - 1)
        item.brush_color = self._brush_color
        item.pen_color = self._pen_color
        item.pen_width = self._pen_width
        item.signals.moved.connect(self.point_moved_slot)
        item.signals.deleted.connect(self.point_deleted_slot)
        item.signals.doubleClicked.connect(self.point_double_clicked)
        self.scene().addItem(item)
        item.setPos(p)
        self._controls.append(item)
        self.setPolygon(QtGui.QPolygonF(self.points)) 
Example 28
Project: CvStudio   Author: haruiz   File: items.py    License: MIT License 5 votes vote down vote up
def insertPoint(self, index, p):
        self.points.insert(index, p)
        item = EditablePolygonPoint(index)
        item.brush_color = self._brush_color
        item.pen_color = self._pen_color
        item.signals.moved.connect(self.point_moved_slot)
        item.signals.deleted.connect(self.point_deleted_slot)
        item.signals.doubleClicked.connect(self.point_double_clicked)
        self.scene().addItem(item)
        item.setPos(p)
        self.controls.insert(index, item)
        self.setPolygon(QtGui.QPolygonF(self.points)) 
Example 29
Project: CvStudio   Author: haruiz   File: items.py    License: MIT License 5 votes vote down vote up
def point_moved_slot(self, item: EditablePolygonPoint, pos: QPointF):
        self.points[item.index] = self.mapFromScene(pos)
        self.setPolygon(QtGui.QPolygonF(self.points)) 
Example 30
Project: CvStudio   Author: haruiz   File: items.py    License: MIT License 5 votes vote down vote up
def point_deleted_slot(self, index: int):
        del self.points[index]
        del self.controls[index]
        self.setPolygon(QtGui.QPolygonF(self.points))
        self.update_indexes()