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


Python QGraphicsPolygonItem.setPolygon方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QGraphicsPolygonItem.setPolygon方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsPolygonItem.setPolygon方法的具体用法?Python QGraphicsPolygonItem.setPolygon怎么用?Python QGraphicsPolygonItem.setPolygon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QGraphicsPolygonItem的用法示例。


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

示例1: _add_selection

# 需要导入模块: from PyQt4.QtGui import QGraphicsPolygonItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsPolygonItem import setPolygon [as 别名]
    def _add_selection(self, item):
        """Add selection rooted at item
        """
        outline = self._selection_poly(item)
        selection_item = QGraphicsPolygonItem(self)
#         selection_item = QGraphicsPathItem(self)
        selection_item.setPos(self.contentsRect().topLeft())
#         selection_item.setPen(QPen(Qt.NoPen))
        selection_item.setPen(make_pen(width=1, cosmetic=True))

        transform = self._itemgroup.transform()
        path = transform.map(outline)
        margin = 4
        if item.node.is_leaf:
            path = QPolygonF(path.boundingRect()
                             .adjusted(-margin, -margin, margin, margin))
        else:
            pass
#             ppath = QPainterPath()
#             ppath.addPolygon(path)
#             path = path_outline(ppath, width=margin).toFillPolygon()

        selection_item.setPolygon(path)
#         selection_item.setPath(path_outline(path, width=4))
        selection_item.unscaled_path = outline
        self._selection[item] = selection_item
        item.setSelected(True)
开发者ID:jujuefengliu,项目名称:orange3,代码行数:29,代码来源:owhierarchicalclustering.py

示例2: PolygonCurve

# 需要导入模块: from PyQt4.QtGui import QGraphicsPolygonItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsPolygonItem import setPolygon [as 别名]
class PolygonCurve(OWCurve):
    """
        A plot item that shows a filled or empty polygon.

        :param pen: The pen used to draw the polygon's outline
        :type pen: :obj:`.QPen`

        :param brush: The brush used to paint the polygon's inside
        :type brush: :obj:`.QBrush`

        :param xData: The list of x coordinates
        :type xData: list of float

        :param yData: The list of y coordinates
        :type yData: list of float

        :param tooltip: The tool tip shown when hovering over this curve
        :type tooltip: str
    """

    def __init__(self, pen=QPen(Qt.black), brush=QBrush(Qt.white), xData=[], yData=[], tooltip=None):
        OWCurve.__init__(self, xData, yData, tooltip=tooltip)
        self._data_polygon = self.polygon_from_data(xData, yData)
        self._polygon_item = QGraphicsPolygonItem(self)
        self.set_pen(pen)
        self.set_brush(brush)

    def update_properties(self):
        self._polygon_item.setPolygon(self.graph_transform().map(self._data_polygon))
        self._polygon_item.setPen(self.pen())
        self._polygon_item.setBrush(self.brush())

    @staticmethod
    def polygon_from_data(xData, yData):
        """
            Creates a polygon from a list of x and y coordinates.

            :returns: A polygon with point corresponding to ``xData`` and ``yData``.
            :rtype: QPolygonF
        """
        if xData and yData:
            n = min(len(xData), len(yData))
            p = QPolygonF(n + 1)
            for i in range(n):
                p[i] = QPointF(xData[i], yData[i])
            p[n] = QPointF(xData[0], yData[0])
            return p
        else:
            return QPolygonF()

    def set_data(self, xData, yData):
        self._data_polygon = self.polygon_from_data(xData, yData)
        OWCurve.set_data(self, xData, yData)
开发者ID:kereturn,项目名称:orange3,代码行数:55,代码来源:owtools.py

示例3: ParallelCoordinatePolygon

# 需要导入模块: from PyQt4.QtGui import QGraphicsPolygonItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsPolygonItem import setPolygon [as 别名]
class ParallelCoordinatePolygon(OWPlotItem):
    def __init__(self, i, mu1, mu2, sigma1, sigma2, phi, color):
        OWPlotItem.__init__(self)
        self.outer_box = QGraphicsPolygonItem(self)
        self.inner_box = QGraphicsPolygonItem(self)

        self.i = i
        self.mu1 = mu1
        self.mu2 = mu2
        self.sigma1 = sigma1
        self.sigma2 = sigma2
        self.phi = phi

        self.twosigmapolygon = QPolygonF([
            QPointF(i, mu1 - sigma1), QPointF(i, mu1 + sigma1),
            QPointF(i + 1, mu2 + sigma2), QPointF(i + 1, mu2 - sigma2),
            QPointF(i, mu1 - sigma1)
        ])

        self.sigmapolygon = QPolygonF([
            QPointF(i, mu1 - .5 * sigma1), QPointF(i, mu1 + .5 * sigma1),
            QPointF(i + 1, mu2 + .5 * sigma2), QPointF(i + 1, mu2 - .5 * sigma2),
            QPointF(i, mu1 - .5 * sigma1)
        ])

        if isinstance(color, tuple):
            color = QColor(*color)
        color.setAlphaF(.3)
        self.outer_box.setBrush(color)
        self.outer_box.setPen(QColor(0, 0, 0, 0))
        self.inner_box.setBrush(color)
        self.inner_box.setPen(color)

    def update_properties(self):
        self.outer_box.setPolygon(self.graph_transform().map(self.twosigmapolygon))
        self.inner_box.setPolygon(self.graph_transform().map(self.sigmapolygon))
开发者ID:r0k3,项目名称:orange3,代码行数:38,代码来源:owparallelgraph.py


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