当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.QPolygonF类代码示例

本文整理汇总了Python中PyQt5.QtGui.QPolygonF的典型用法代码示例。如果您正苦于以下问题:Python QPolygonF类的具体用法?Python QPolygonF怎么用?Python QPolygonF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QPolygonF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Shape

class Shape():
	def __init__(self, nbp, list_of_points):
		self.shape = QPolygonF(nbp)
		for i in range(nbp):
			pt = list_of_points[i]
			self.shape.replace(i, QPointF(pt[0], pt[1]))
		self.nbp = nbp
开发者ID:ensta-bretagne-yetibot,项目名称:CDF2016,代码行数:7,代码来源:simu.py

示例2: drawZig

 def drawZig(qp, x, y, width, height):
     qp = qp  # type: QPainter
     pointsCoord = [[x, y + height], [x + width * 0.33, y], [x + width * 0.66, y + height], [x + width, y]]
     trianglePolygon = QPolygonF()
     for i in pointsCoord:
         trianglePolygon.append(QPointF(i[0], i[1]))
     qp.drawPolygon(trianglePolygon)
开发者ID:woellij,项目名称:wiimote-musicmaker,代码行数:7,代码来源:drawHelper.py

示例3: paint

    def paint(self, painter, option, widget):
        if self.line().length() == 0:
            return

        pen = self.pen()
        pen.setColor(constants.LINECOLOR)
        painter.setPen(pen)
        painter.setBrush(constants.LINECOLOR)

        arrow_size = 10.0

        angle = math.acos(self.line().dx() / self.line().length())

        if self.line().dy() >= 0:
            angle = (math.pi * 2) - angle

        arrow_p1 = self.line().p2() - QPointF(math.sin(angle + math.pi / 2.5) * arrow_size,
                                              math.cos(angle + math.pi / 2.5) * arrow_size)

        arrow_p2 = self.line().p2() - QPointF(math.sin(angle + math.pi - math.pi / 2.5) * arrow_size,
                                              math.cos(angle + math.pi - math.pi / 2.5) * arrow_size)

        arrow_head = QPolygonF()
        arrow_head.append(self.line().p2())
        arrow_head.append(arrow_p1)
        arrow_head.append(arrow_p2)

        painter.drawLine(self.line())
        painter.drawPolygon(arrow_head)
开发者ID:jopohl,项目名称:urh,代码行数:29,代码来源:MessageItem.py

示例4: __readPolygon

    def __readPolygon(self):
        atts = self.xml.attributes()
        points = atts.value("points")
        pointsList = list(filter(lambda x:x.strip()!='', points.split(' ')))
        polygon = QPolygonF()
        ok = True
        for point in pointsList:
            try:
                x, y = point.split(',')
            except:
                ok = False
                break
            
            x, ok = Float2(x)
            if (not ok):
                break

            y, ok = Float2(y)
            if (not ok):
                break
            polygon.append(QPointF(x, y))

        if (not ok):
            self.xml.raiseError(self.tr("Invalid points data for polygon"))
        self.xml.skipCurrentElement()
        return polygon
开发者ID:theall,项目名称:Python-Tiled,代码行数:26,代码来源:mapreader.py

示例5: toPolygon

 def toPolygon(self, variant):
     polygon = QPolygonF()
     for pointVariant in variant:
         pointVariantMap = pointVariant
         pointX = pointVariantMap.get("x",0.0)
         pointY = pointVariantMap.get("y",0.0)
         polygon.append(QPointF(pointX, pointY))
     
     return polygon
开发者ID:theall,项目名称:Python-Tiled,代码行数:9,代码来源:varianttomapconverter.py

示例6: pixelRectToScreenPolygon

 def pixelRectToScreenPolygon(self, rect):
     polygon = QPolygonF()
     polygon.append(QPointF(self.pixelToScreenCoords_(rect.topLeft())))
     polygon.append(QPointF(self.pixelToScreenCoords_(rect.topRight())))
     polygon.append(QPointF(self.pixelToScreenCoords_(rect.bottomRight())))
     polygon.append(QPointF(self.pixelToScreenCoords_(rect.bottomLeft())))
     return polygon
开发者ID:theall,项目名称:Python-Tiled,代码行数:7,代码来源:isometricrenderer.py

示例7: startNewMapObject

 def startNewMapObject(self, pos, objectGroup):
     super().startNewMapObject(pos, objectGroup)
     newMapObject = self.mNewMapObjectItem.mapObject()
     polygon = QPolygonF()
     polygon.append(QPointF())
     newMapObject.setPolygon(polygon)
     polygon.append(QPointF()) # The last point is connected to the mouse
     self.mOverlayPolygonObject.setPolygon(polygon)
     self.mOverlayPolygonObject.setShape(newMapObject.shape())
     self.mOverlayPolygonObject.setPosition(pos)
     self.mOverlayPolygonItem = MapObjectItem(self.mOverlayPolygonObject, self.mapDocument(), self.mObjectGroupItem)
开发者ID:theall,项目名称:Python-Tiled,代码行数:11,代码来源:createmultipointobjecttool.py

示例8: tileRectToScreenPolygon

 def tileRectToScreenPolygon(self, rect):
     tileWidth = self.map().tileWidth()
     tileHeight = self.map().tileHeight()
     topRight = self.tileToScreenCoords_(rect.topRight())
     bottomRight = self.tileToScreenCoords_(rect.bottomRight())
     bottomLeft = self.tileToScreenCoords_(rect.bottomLeft())
     polygon = QPolygonF()
     polygon.append(QPointF(self.tileToScreenCoords_(rect.topLeft())))
     polygon.append(QPointF(topRight.x() + tileWidth / 2, topRight.y() + tileHeight / 2))
     polygon.append(QPointF(bottomRight.x(), bottomRight.y() + tileHeight))
     polygon.append(QPointF(bottomLeft.x() - tileWidth / 2, bottomLeft.y() + tileHeight / 2))
     return polygon
开发者ID:theall,项目名称:Python-Tiled,代码行数:12,代码来源:isometricrenderer.py

示例9: _setSpeeds

    def _setSpeeds(self, speeds):
        polygon = QPolygonF()
        polygon.append(QPointF(0, self.SIZE[1])) # start the polygon

        nSamples = len(speeds)
        xPerSample = self.SIZE[0] / nSamples

        for i, speed in enumerate(speeds):
            y = self._translateSpeedToPosY(speed)
            polygon.append(QPointF(xPerSample * i, y))
            polygon.append(QPointF(xPerSample * (i+1), y))
        polygon.append(QPointF(*self.SIZE)) # close the polygon

        self._speedsPolygon.setPolygon(polygon)
开发者ID:mimers,项目名称:XwareDesktop,代码行数:14,代码来源:MonitorGraphicsView.py

示例10: paint

 def paint(self, painter, option, widget=None):
     """
     Public method to paint the item in local coordinates.
     
     @param painter reference to the painter object (QPainter)
     @param option style options (QStyleOptionGraphicsItem)
     @param widget optional reference to the widget painted on (QWidget)
     """
     if (option.state & QStyle.State_Selected) == \
             QStyle.State(QStyle.State_Selected):
         width = 2
     else:
         width = 1
     
     # draw the line first
     line = QLineF(self._origin, self._end)
     painter.setPen(
         QPen(Qt.black, width, Qt.SolidLine, Qt.FlatCap, Qt.MiterJoin))
     painter.drawLine(line)
     
     # draw the arrow head
     arrowAngle = self._type * ArrowheadAngleFactor
     slope = math.atan2(line.dy(), line.dx())
     
     # Calculate left arrow point
     arrowSlope = slope + arrowAngle
     a1 = QPointF(self._end.x() - self._halfLength * math.cos(arrowSlope),
                  self._end.y() - self._halfLength * math.sin(arrowSlope))
     
     # Calculate right arrow point
     arrowSlope = slope - arrowAngle
     a2 = QPointF(self._end.x() - self._halfLength * math.cos(arrowSlope),
                  self._end.y() - self._halfLength * math.sin(arrowSlope))
     
     if self._filled:
         painter.setBrush(Qt.black)
     else:
         painter.setBrush(Qt.white)
     polygon = QPolygonF()
     polygon.append(line.p2())
     polygon.append(a1)
     polygon.append(a2)
     painter.drawPolygon(polygon)
开发者ID:pycom,项目名称:EricShort,代码行数:43,代码来源:E5ArrowItem.py

示例11: __init__

    def __init__(self, start_item, end_item, parent=None):
        super(Arrow, self).__init__(parent)

        self.arrowHead = QPolygonF()

        self.my_start_item = start_item
        self.my_end_item = end_item
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
        self.my_color = Qt.black
        self.setPen(QPen(self.my_color, 2, Qt.SolidLine, Qt.RoundCap,
                         Qt.RoundJoin))
开发者ID:ADobrodey,项目名称:Apache-Flume-Editor,代码行数:11,代码来源:_arrow.py

示例12: _createPreXoverPainterPath

def _createPreXoverPainterPath( elements: List[List[QPointF]],
                                end_poly: QPolygonF = None,
                                is_fwd: bool = True) -> QPainterPath:
    path = QPainterPath()

    next_pt = None
    for element in elements:
        start_pt = element[0]
        path.moveTo(start_pt)
        for next_pt in element[1:]:
            path.lineTo(next_pt)

    if end_poly is not None:
        h = end_poly.boundingRect().height()/2
        xoffset = -h if is_fwd else h
        w = end_poly.boundingRect().width()
        yoffset = w if is_fwd else -w
        angle = -90 if is_fwd else 90
        T = QTransform()
        T.translate(next_pt.x()+xoffset, next_pt.y()+yoffset)
        T.rotate(angle)
        path.addPolygon(T.map(end_poly))
    return path
开发者ID:cadnano,项目名称:cadnano2.5,代码行数:23,代码来源:pathextras.py

示例13: image

    def image(cls, **kwargs):
        """
        Returns an image suitable for the palette.
        :rtype: QPixmap
        """
        # INITIALIZATION
        pixmap = QPixmap(kwargs['w'], kwargs['h'])
        pixmap.fill(Qt.transparent)
        painter = QPainter(pixmap)

        polygon = QPolygonF([
            QPointF(+27 - 10, -17),  # 0
            QPointF(-27, -17),       # 1
            QPointF(-27, +17),       # 2
            QPointF(+27, +17),       # 3
            QPointF(+27, -17 + 10),  # 4
            QPointF(+27 - 10, -17),  # 5
        ])
        
        fold = QPolygonF([
            QPointF(polygon[cls.indexTR].x(), polygon[cls.indexTR].y()),
            QPointF(polygon[cls.indexTR].x(), polygon[cls.indexTR].y() + 10),
            QPointF(polygon[cls.indexRT].x(), polygon[cls.indexRT].y()),
            QPointF(polygon[cls.indexTR].x(), polygon[cls.indexTR].y()),
        ])

        # ITEM SHAPE
        painter.setPen(QPen(QColor(0, 0, 0), 1.0, Qt.SolidLine))
        painter.setBrush(QColor(252, 252, 252))
        painter.translate(kwargs['w'] / 2, kwargs['h'] / 2)
        painter.drawPolygon(polygon)
        painter.drawPolygon(fold)
        # TEXT WITHIN THE SHAPE
        painter.setFont(Font('Arial', 10, Font.Light))
        painter.drawText(polygon.boundingRect(), Qt.AlignCenter, 'value\nrestriction')
        return pixmap
开发者ID:gitter-badger,项目名称:eddy,代码行数:36,代码来源:value_restriction.py

示例14: __init__

    def __init__(self, parent=None):
        super(MovableArrow, self).__init__(parent)
        self.setZValue(1000)

        self.arrowHead = QPolygonF()
        self.begin = np.array([0.0, 0.0])
        self.end =np.array([10.0, 10.0])

        self.myColor = Qt.black
        self.setPen(QPen(self.myColor, 5))
        self.arrowSize = 7
        self.setOpacity(0.5)

        self.isMousePressed = False
        self.setFlags(QGraphicsItem.ItemIsSelectable |
                      QGraphicsItem.ItemIsFocusable |
                      #QGraphicsItem.ItemIsMovable |
                      QGraphicsItem.ItemSendsGeometryChanges
                      )
开发者ID:Licht-T,项目名称:UMATracker-Detect-Center,代码行数:19,代码来源:movable_arrow.py

示例15: updatePath

    def updatePath(self):
        try:
            attrs = self.stackedWidget.currentWidget().get_attributes()
            attrs.keys()
        except Exception as e:
            msg = 'Tracking Lib. Attributes Error:\n{}'.format(e)
            self.generateCriticalMessage(msg)
            return

        if 'position' in attrs:
            self.trackingPathGroup.setPoints(self.currentFrameNo)

        if 'arrow' in attrs:
            for i, arrow_item in enumerate(self.item_dict['arrow']):
                begin = self.df['position'].loc[self.currentFrameNo, i].as_matrix()
                end = self.df['arrow'].loc[self.currentFrameNo, i].as_matrix()
                arrow_item.setPosition(begin, end)

        if 'path' in attrs:
            for path_item, path_data in zip(self.item_dict['path'], self.data_dict['path'][self.currentFrameNo]):
                poly = QPolygonF()
                for p in path_data:
                    poly.append(QPointF(*p))

                painter_path = QPainterPath()
                painter_path.addPolygon(poly)
                path_item.setPath(painter_path)

                pen = QPen(Qt.blue)
                pen.setWidth(2)
                path_item.setPen(pen)

        if 'polygon' in attrs:
            for path_item, path_data in zip(self.item_dict['polygon'], self.data_dict['polygon'][self.currentFrameNo]):
                poly = QPolygonF()
                for p in path_data:
                    poly.append(QPointF(*p))

                painter_path = QPainterPath()
                painter_path.addPolygon(poly)
                path_item.setPath(painter_path)

                pen = QPen(Qt.black)
                pen.setWidth(1)
                path_item.setPen(pen)

        if 'rect' in attrs:
            for rect_item, rect in zip(self.item_dict['rect'], self.data_dict['rect'][self.currentFrameNo]):
                rect_item.setRect(QRectF(QPointF(*rect[0]), QPointF(*rect[1])))
开发者ID:Licht-T,项目名称:UMATracker-Detect-Center,代码行数:49,代码来源:main.py


注:本文中的PyQt5.QtGui.QPolygonF类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。