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


Python QPolygonF.boundingRect方法代码示例

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


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

示例1: _add_selection

# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import boundingRect [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: on_actionGotoCell_triggered

# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import boundingRect [as 别名]
 def on_actionGotoCell_triggered(self):
     cells = [str(cid) for cid in self._data.cells]
     selected, ok = QInputDialog.getItem(self, "Goto cell", "Select the cell to go to", cells, 0)
     if ok:
         cid = int(selected)
         self.ui.actionAdd_cell.setChecked(True)
         data = self._data
         if cid not in data.cells:
             return
         ls = data.cells_lifespan[cid]
         prev_pos = self._previousScene.current_data._current_index
         cur_pos = self._currentScene.current_data._current_index
         full_poly = data.cells[cid]
         poly = [pid for pid in full_poly if pid in data[prev_pos]]
         #log_debug("Cell %d on time %d: %s" % (cid, prev_pos, poly))
         if prev_pos < ls.start or prev_pos >= ls.end or not poly:
             for i in range(*ls.slice().indices(len(data))):
                 poly = [pid for pid in full_poly if pid in data[i]]
                 if poly:
                     log_debug("Found cell %d on image %d with polygon %s" % (cid, i, poly))
                     new_prev_pos = i
                     break
             else:
                 log_debug("Cell %d found nowhere in range %s!!!" % (cid, ls.slice()))
         else:
             new_prev_pos = prev_pos
         new_cur_pos = min(max(cur_pos + new_prev_pos - prev_pos, 0), len(data))
         self.ui.previousState.setCurrentIndex(new_prev_pos)
         self.ui.currentState.setCurrentIndex(new_cur_pos)
         self._previousScene.current_cell = cid
         self._currentScene.current_cell = cid
         prev_data = self._previousScene.current_data
         poly = data.cells[cid]
         prev_poly = QPolygonF([prev_data[ptid] for ptid in poly if ptid in prev_data])
         prev_bbox = prev_poly.boundingRect()
         log_debug("Previous bounding box = %dx%d+%d+%d" % (prev_bbox.width(), prev_bbox.height(),
                                                            prev_bbox.left(), prev_bbox.top()))
         self.ui.previousData.ensureVisible(prev_bbox)
开发者ID:PierreBdR,项目名称:point_tracker,代码行数:40,代码来源:tracking_window.py

示例3: EPoint

# 需要导入模块: from PyQt4.QtGui import QPolygonF [as 别名]
# 或者: from PyQt4.QtGui.QPolygonF import boundingRect [as 别名]
class EPoint(ENode):

    def __init__(self, ENodeHandle):
        ENode.__init__(self, ENodeHandle)

        self.__polygon = QPolygonF(QRectF(-50, -15, 100, 30))

        self.__updateShape()

        self.__attributes = {}
        self.__hiddenAttributes = {}

        self.__group = QGraphicsItemGroup()
        self.__group.addToGroup(QGraphicsPolygonItem(self.__polygon))

        self.__buildAttributes(self.Handle.lsInputAttributes())
        self.__buildAttributes(self.Handle.lsOutputAttributes(), True)

        self.__muted = None

    def __updateShape(self):

        fBBox = QFontMetrics(self.Font).boundingRect(self.Name)

        if self.__polygon.boundingRect().width() < fBBox.width():
            self.__polygon = QPolygonF(QRectF(fBBox).normalized().adjusted(-fBBox.width() / 4,
                                                                           -fBBox.height() / 4,
                                                                           fBBox.height(),
                                                                           fBBox.height() / 2))

    def __buildAttributes(self, attributes, opposite=False):

        rotation = 90

        for index, point in enumerate(self.getPoints(len(attributes), opposite)):

            switch = {0: point.y() - (8 + self.pen().width()), 1: point.y() + (5 + self.pen().width())}

            connSlot = EDraw.Circle(8, 3, rotation).translated(QPointF(point.x(), switch[opposite]))

            self.__group.addToGroup(QGraphicsPolygonItem(connSlot))

            self.__attributes[connSlot] = dict({self.kGuiAttributeId: attributes[index].Id,
                                               self.kGuiAttributeType: attributes[index].Type,
                                               self.kGuiAttributeParent: self,
                                               self.kGuiAttributePlug: self.Polygon.boundingRect().center(),
                                               self.kGuiAttributeLongName: attributes[index].Name})

        return

    @property
    def Polygon(self):
        return self.__polygon

    @property
    def BoundPolygon(self):
        return self.__polygon.boundingRect()

    def mute(self, uuid):
        self.__muted = uuid

    def togglePlug(self, plugId):

        hiddenId = self.mapFromId(plugId)[ENode.kGuiAttributeId]

        if self.__hiddenAttributes.has_key(hiddenId):
            self.__hiddenAttributes.pop(hiddenId, None)
            return

        self.__hiddenAttributes[self.mapFromId(plugId)[ENode.kGuiAttributeId]] = []

    def mapFromPoint(self, QPoint):

        for attrRect, attrValues in self.__attributes.iteritems():
            if attrRect.boundingRect().contains(self.mapFromScene(QPoint)):
                return attrValues[self.kGuiAttributeId], self.scenePos()

        return self.Handle.Id, None

    def mapFromId(self, attrId):

        for attrValue in self.__attributes.itervalues():
            if attrValue[self.kGuiAttributeId] == attrId:
                return attrValue

        return None

    def boundingRect(self):
        extra = self.pen().width()

        return self.__group.boundingRect().normalized().adjusted(-extra, -extra, extra, extra)

    def shape(self):
        return QGraphicsItem.shape(self)

    def getLines(self, count, opposite=False):

        angleOffset = 25

        inputLines = []
#.........这里部分代码省略.........
开发者ID:feeling1982113,项目名称:edd,代码行数:103,代码来源:epoint.py


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