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


Python QPainterPath.addEllipse方法代码示例

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


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

示例1: set_shape

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addEllipse [as 别名]
 def set_shape(self, width, height):
     ''' Define the bouding rectangle of the JOIN symbol '''
     circ = min(width, height)
     path = QPainterPath()
     path.addEllipse(0, 0, circ, circ)
     self.setPath(path)
     super(Join, self).set_shape(width, height)
开发者ID:Kampbell,项目名称:opengeode,代码行数:9,代码来源:sdlSymbols.py

示例2: setupPaint

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addEllipse [as 别名]
 def setupPaint(self):
     """Offscreen rather than onscreen redraw (few changes)."""
     path = QPainterPath()
     if self.data.isInput:
         path.addEllipse(
             self.pinW / 2, self.pinW / 2, self.bodyW, self.bodyW)
     else:
         path.addRect(
             3 * self.pinW / 2 + 1, self.pinW / 2, self.bodyW, self.bodyW)
     path.addPath(self.pinPath)
     self.setPath(path)
     self.name.setVisible(self.showName)
     self.name.setText(self.data.name)
     br = self.mapToScene(self.boundingRect())
     w = self.boundingRect().width()
     h = self.boundingRect().height()
     realX = min([i.x() for i in br])
     realY = min([i.y() for i in br])
     self.name.setPos(self.mapFromScene(
         realX, realY + (w if self.rotation() % 180 else h) + 1))
     self.value.setText(
         str(int(self.data.value)) if self.data.value is not None else 'E')
     self.value.setPos(self.mapFromScene(realX + w / 3, realY + h / 3))
     self.value.setBrush(QColor('green' if self.data.value else 'red'))
     self.update()       # Force onscreen redraw after changes.
开发者ID:pouzzler,项目名称:IED-Logic-Simulator,代码行数:27,代码来源:graphicitem.py

示例3: animate

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addEllipse [as 别名]
 def animate(self, shapes):
     self.start_signal.emit()
     time.sleep(self.start_delay)
     self.running = True
     self.ended = False
     max_radius = []
     original_clips = []
     centers = []
     animating_radius = []
     inc_rate = []
     for s in shapes:
         # Setting max of width or height as radius, ergo "circular" reveal,
         # not "oval" reveal
         target = max(s.width, s.height)
         max_radius.append(target)
         # Starting from the zero reaching the max
         animating_radius.append(0)
         # Getting the original masks; Used in case of cancelation
         original_clips.append(s.clip)
         # Center of the shape, considering margin
         centers.append(QPoint((s.width / 2) + s.margin_start, (s.height / 2) + s.margin_top))
         # Calculating the increase rate using the good ol' formula
         inc_rate.append((target / self.fps) * (1000 / self.duration))
     while self.running or self.paused:
         if self.canceled:
             for i, s in enumerate(shapes):
                 s.clip = original_clips[i]
             self.cancel_signal.emit()
             return
         elif self.ended:
             self.end_signal.emit()
             return
         elif self.paused:
             # Handling the pause
             self.pause_signal.emit()
             while not self.paused:
                 pass
             self.resume_signal.emit()
         else:
             # Setting FPS from the animator
             time.sleep(1 / self.fps)
             completed = False
             for i, s in enumerate(shapes):
                 if animating_radius[i] < max_radius[i]:
                     path = QPainterPath()
                     path.addEllipse(centers[i], animating_radius[i], animating_radius[i])
                     s.clip = path
                     s.update()
                     QApplication.processEvents()
                     animating_radius[i] += inc_rate[i]
                 else:
                     completed = True
             # No need to check on every iteration, duration is same so
             # all objects are gonna end at the same time
             if completed:
                 self.end_signal.emit()
                 self.started = False
                 self.ended = True
                 return
开发者ID:nicolas-raoul,项目名称:PyMaterial,代码行数:61,代码来源:MCircularReveal.py

示例4: __init__

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addEllipse [as 别名]
 def __init__(self, pos, edge):
     ''' Set the original control point - with color, shape '''
     path = QPainterPath()
     path.addEllipse(pos.x() - 5, pos.y() - 5, 10, 10)
     super(Controlpoint, self).__init__(path, parent=edge)
     self.setPen(QColor(50, 100, 120, 200))
     self.setBrush(QColor(200, 200, 210, 120))
     self.setFlags(QGraphicsItem.ItemIsSelectable |
                   QGraphicsItem.ItemIsMovable)
     self.edge = edge
     self.hide()
开发者ID:dbrabera,项目名称:opengeode,代码行数:13,代码来源:Connectors.py

示例5: fillEllipse

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addEllipse [as 别名]
 def fillEllipse(
     self,
     painter,
     x,
     y,
     size,
     brush,
     ):
     path = QPainterPath()
     path.addEllipse(x, y, size, size)
     painter.fillPath(path, brush)
开发者ID:Jonney,项目名称:Khweeteur,代码行数:13,代码来源:qbadgebutton.py

示例6: __init__

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addEllipse [as 别名]
 def __init__(self, parent):
     super(QNEOutputPort, self).__init__(parent)
     self.parent = parent
     
     self.setPen(self.parent.pen())
     self.setBrush(self.parent.brush())
     
     radius_ = parent.radius_
     
     path = QPainterPath()
     path.addEllipse(0, -radius_, 2*radius_, 2*radius_)
     self.setPath(path)
开发者ID:fieldOfView,项目名称:pyZNodeEditor,代码行数:14,代码来源:qneport.py

示例7: setCanConnect

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addEllipse [as 别名]
    def setCanConnect(self, hasInput, hasOutput):
        self.hasInput_ = hasInput
        self.hasOutput_ = hasOutput

        if self.hasOutput_:
            self.outputPort.setVisible(True)
        else:
            self.outputPort.setVisible(False)

        path = QPainterPath()
        if self.hasInput_:
            path.addEllipse(0, -self.radius_, 2*self.radius_, 2*self.radius_)
        else:
            pass
        self.setPath(path)
开发者ID:fieldOfView,项目名称:pyZNodeEditor,代码行数:17,代码来源:qneport.py

示例8: __init__

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addEllipse [as 别名]
    def __init__(self, parent):
        super(QNEPort, self).__init__(parent)

        self.label = QGraphicsTextItem(self)
        self.radius_ = 4
        self.margin = 3

        path = QPainterPath()
        path.addEllipse(-self.radius_, -self.radius_, 2*self.radius_, 2*self.radius_);
        self.setPath(path)

        self.setPen(QPen(Qt.darkRed))
        self.setBrush(Qt.red)

        self.setFlag(QGraphicsItem.ItemSendsScenePositionChanges)

        self.m_portFlags = 0
        self.isOutput_ = False

        self.m_block = None
        self.m_connections = []
开发者ID:fieldOfView,项目名称:pyQNodesEditor,代码行数:23,代码来源:qneport.py

示例9: updateLeader

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addEllipse [as 别名]
    def updateLeader(self):
        """
        TOWRITE
        """
        arrowStyle = Closed     # int # TODO: Make this customizable
        arrowStyleAngle = 15.0  # qreal # TODO: Make this customizable
        arrowStyleLength = 1.0  # qreal # TODO: Make this customizable
        self.lineStyleAngle = 45.0   # qreal # TODO: Make this customizable
        self.lineStyleLength = 1.0   # qreal # TODO: Make this customizable

        lyne = self.line()  # QLineF
        angle = lyne.angle()  # qreal
        ap0 = lyne.p1()  # QPointF
        lp0 = lyne.p2()  # QPointF

        # Arrow
        lynePerp = QLineF(lyne.pointAt(arrowStyleLength / lyne.length()), lp0)
        lynePerp.setAngle(angle + 90)
        lyne1 = QLineF(ap0, lp0)
        lyne2 = QLineF(ap0, lp0)
        lyne1.setAngle(angle + arrowStyleAngle)
        lyne2.setAngle(angle - arrowStyleAngle)
        # ap1 = QPointF()
        # ap2 = QPointF()
        _, ap1 = lynePerp.intersect(lyne1)
        _, ap2 = lynePerp.intersect(lyne2)

        # Math Diagram
        #                  .(ap1)                     .(lp1)
        #                 /|                         /|
        #                / |                        / |
        #               /  |                       /  |
        #              /   |                      /   |
        #             /    |                     /    |
        #            /     |                    /     |
        #           /      |                   /      |
        #          /       |                  /       |
        #         /+(aSA)  |                 /+(lSA)  |
        #  (ap0)./__(aSL)__|__________(lp0)./__(lSL)__|
        #        \ -(aSA)  |                \ -(lSA)  |
        #         \        |                 \        |
        #          \       |                  \       |
        #           \      |                   \      |
        #            \     |                    \     |
        #             \    |                     \    |
        #              \   |                      \   |
        #               \  |                       \  |
        #                \ |                        \ |
        #                 \|                         \|
        #                  .(ap2)                     .(lp2)

        if arrowStyle == Open:
            arrowStylePath = QPainterPath()
            arrowStylePath.moveTo(ap1)
            arrowStylePath.lineTo(ap0)
            arrowStylePath.lineTo(ap2)
            arrowStylePath.lineTo(ap0)
            arrowStylePath.lineTo(ap1)
        elif arrowStyle == Closed:
            arrowStylePath = QPainterPath()
            arrowStylePath.moveTo(ap1)
            arrowStylePath.lineTo(ap0)
            arrowStylePath.lineTo(ap2)
            arrowStylePath.lineTo(ap1)
        elif arrowStyle == Dot:
            arrowStylePath = QPainterPath()
            arrowStylePath.addEllipse(ap0, arrowStyleLength, arrowStyleLength)
        elif arrowStyle == Box:
            arrowStylePath = QPainterPath()
            side = QLineF(ap1, ap2).length()  # qreal
            ar0 = QRectF(0, 0, side, side)
            ar0.moveCenter(ap0)
            arrowStylePath.addRect(ar0)
        elif arrowStyle == Tick:
            pass  #TODO/PORT# Is this supposed to be empty?

        lineStylePath = QPainterPath()
        lineStylePath.moveTo(ap0)
        lineStylePath.lineTo(lp0)
开发者ID:Metallicow,项目名称:Embroidermodder,代码行数:81,代码来源:object_dimleader.py

示例10: animate

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addEllipse [as 别名]
    def animate(self, shapes):
        self.start_signal.emit()
        time.sleep(self.start_delay)
        self.running = True
        self.ended = False
        target_radius = []
        original_clips = []
        centers = []
        animating_radius = []
        rate_of_change = []
        for s in shapes:
            if self.target.startswith("show"):
                # Setting max of width or height as radius, ergo "circular" reveal,
                # not "oval" reveal
                target = max(s.width, s.height)
                # Starting from the zero reaching the max
                animating_radius.append(0)
                rate_of_change.append((target / self.fps) * (1000 / self.duration))
            elif self.target.startswith("hide"):
                # You know why...
                target = 0
                # Starting from the max reaching the 0
                animating_radius.append(max(s.width, s.height))
                rate_of_change.append(((target - max(s.width, s.height)) / self.fps) * (1000 / self.duration))
            else:
                raise ValueError("Target should be either 'reveal' or 'hide'")
            target_radius.append(target)
            # Getting the original masks; Used in case of cancelation
            original_clips.append(s.clip)
            # Center of the shape, considering margin
            centers.append(QPoint((s.width / 2) + s.margin_left, (s.height / 2) + s.margin_top))
            # Calculating the increase rate using the good ol' formula
        while self.running or self.paused:
            if self.canceled and not self.paused:
                for i, s in enumerate(shapes):
                    s.clip = original_clips[i]
                self.cancel_signal.emit()
                return
            elif self.ended:
                self.end_signal.emit()
                return
            elif self.paused:
                # Handling the pause
                self.pause_signal.emit()
                while self.paused:
                    # If you want the current state, pause the
                    # animation and then cancel it
                    print("paused")
                    if self.canceled:
                        print("canceled")
                        self.ended = True
                        self.started = False
                        self.cancel_signal.emit()
                        return
                self.resume_signal.emit()
            else:
                # Setting FPS from the animator
                time.sleep(1 / self.fps)
                completed = False
                for i, s in enumerate(shapes):
                    if rate_of_change[i] > 0:
                        if not animating_radius[i] < target_radius[i]:
                            completed = True
                    else:
                        if not animating_radius[i] > target_radius[i]:
                            completed = True
                    if not completed:
                        animating_radius[i] += rate_of_change[i]
                    path = QPainterPath()
                    if self.target.endswith("circle"):
                        path.addEllipse(
                            QPointF((s.width / 2) + s.margin_left,
                            (s.height / 2) + s.margin_top),
                            animating_radius[i] / 2,
                            animating_radius[i] / 2
                        )
                    else:
                        path.addEllipse(
                            QPointF((s.width / 2) + s.margin_left,
                            (s.height / 2) + s.margin_top),
                            animating_radius[i],
                            animating_radius[i]
                        )

                    s.clip = path
                    s.update()
                    QApplication.processEvents()
                # No need to check on every iteration, duration is same so
                # all objects are gonna end at the same time
                if completed:
                    self.end_signal.emit()
                    self.started = False
                    self.ended = True
                    return
开发者ID:Python-PyBD,项目名称:PyMaterial,代码行数:96,代码来源:MCircularReveal.py

示例11: handleAtPos

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addEllipse [as 别名]
 def handleAtPos(self, pos):
     """Is there an interactive handle where the mouse is?"""
     if not self.complete:
         path = QPainterPath()
         path.addEllipse(self.data['points'][-1], self.radius, self.radius)
         return path.contains(pos)
开发者ID:pouzzler,项目名称:IED-Logic-Simulator,代码行数:8,代码来源:graphicitem.py

示例12: PlugItem

# 需要导入模块: from PySide.QtGui import QPainterPath [as 别名]
# 或者: from PySide.QtGui.QPainterPath import addEllipse [as 别名]
class PlugItem(QGraphicsPathItem):
    """Graphical wrapper around the engine Plug class."""

    bodyW = 30
    """The width of the body of plugs."""
    pinW = 10
    """The width of the pin part of plugs."""

    def __init__(self, plug):
        super(PlugItem, self).__init__()
        self.data = plug
        """The real info. The class PlugItem is just a graphical container
        around it. data is saved / loaded to / from file.
        """
        self.showName = False
        """Is the name of the item shown on screen?"""
        self.setFlag(QGraphicsItem.ItemIsMovable)
        self.setFlag(QGraphicsItem.ItemIsSelectable)
        self.setFlag(QGraphicsItem.ItemSendsGeometryChanges)
        self.setAcceptsHoverEvents(True)
        self.setPen(QPen(QBrush(QColor(QColor('black'))), 2))
        # This path is needed at each mouse over event, to check if
        # the mouse is over a pin. We save it as an instance field,
        # rather than recreate it at each event.
        self.pinPath = QPainterPath()
        if self.data.isInput:
            self.pinPath.addEllipse(
                self.bodyW + self.pinW / 2, self.bodyW / 2,
                self.pinW, self.pinW)
        else:
            self.pinPath.addEllipse(
                self.pinW / 2, self.bodyW / 2, self.pinW, self.pinW)
        f = QFont('Times', 12, 75)
        # Name and value text labels.
        self.name = QGraphicsSimpleTextItem(self)
        # that won't rotate when the PlugItem is rotated by the user.
        self.name.setFlag(QGraphicsItem.ItemIgnoresTransformations)
        self.name.setText(self.data.name)
        self.name.setFont(f)
        self.value = QGraphicsSimpleTextItem(self)
        self.value.setFlag(QGraphicsItem.ItemIgnoresTransformations)
        # Or else value would get the clicks, instead of the PlugItem.
        self.value.setFlag(QGraphicsItem.ItemStacksBehindParent)
        self.value.setFont(f)
        self.setupPaint()

    def handleAtPos(self, pos):
        """Is there an interactive handle where the mouse is?
        Also return the Plug under this handle.
        """
        return self.data if self.pinPath.contains(pos) else None

    def itemChange(self, change, value):
        """Warning view it will soon have to correct pos."""
        if change == QGraphicsItem.ItemPositionHasChanged:
            # Restart till we stop moving.
            self.scene().views()[0].timer.start()
        return QGraphicsItem.itemChange(self, change, value)

    def setAndUpdate(self):
        """Change the undelying plug's value, and force updates items."""
        self.data.set(not self.data.value)
        for i in self.scene().items():
            if isinstance(i, PlugItem) or isinstance(i, WireItem):
                i.setupPaint()

    def setNameVisibility(self, isVisible):
        """Shows/Hide the item name in the graphical view."""
        self.showName = isVisible
        self.setupPaint()

    def setupPaint(self):
        """Offscreen rather than onscreen redraw (few changes)."""
        path = QPainterPath()
        if self.data.isInput:
            path.addEllipse(
                self.pinW / 2, self.pinW / 2, self.bodyW, self.bodyW)
        else:
            path.addRect(
                3 * self.pinW / 2 + 1, self.pinW / 2, self.bodyW, self.bodyW)
        path.addPath(self.pinPath)
        self.setPath(path)
        self.name.setVisible(self.showName)
        self.name.setText(self.data.name)
        br = self.mapToScene(self.boundingRect())
        w = self.boundingRect().width()
        h = self.boundingRect().height()
        realX = min([i.x() for i in br])
        realY = min([i.y() for i in br])
        self.name.setPos(self.mapFromScene(
            realX, realY + (w if self.rotation() % 180 else h) + 1))
        self.value.setText(
            str(int(self.data.value)) if self.data.value is not None else 'E')
        self.value.setPos(self.mapFromScene(realX + w / 3, realY + h / 3))
        self.value.setBrush(QColor('green' if self.data.value else 'red'))
        self.update()       # Force onscreen redraw after changes.
开发者ID:pouzzler,项目名称:IED-Logic-Simulator,代码行数:98,代码来源:graphicitem.py


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