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


Python QPointF.x方法代码示例

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


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

示例1: __getAttributePosition

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
    def __getAttributePosition(self, attrType):

        attr_x_pos = 0

        if attrType.match(EAttribute.kTypeOutput):

            attr_x_pos = self.__titleRect.width() - self.__attrRect.width()
            rect = self.__attrRect.translated(
                QPointF(attr_x_pos, self.__out_attr_step))

            point = QPointF((rect.topRight() + rect.bottomRight()) / 2)
            point.setX(point.x() + self.pen().width() * 2)

            self.__out_attr_step += self.__attrRect.width() + self.pen().width(
            )

            return [rect, point]

        rect = self.__attrRect.translated(
            QPointF(attr_x_pos, self.__in_attr_step))
        point = QPointF((rect.topLeft() + rect.bottomLeft()) / 2)
        point.setX(point.x() - self.pen().width() * 2)

        self.__in_attr_step += self.__attrRect.width() + self.pen().width()

        return [rect, point]
开发者ID:shrimo,项目名称:node_image_tools,代码行数:28,代码来源:enode.py

示例2: paint

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
 def paint(self, painter, option, widget=None):
     pt = QPointF(-self.WIDTH / 2, -self.HEIGHT / 2) + self.position
     rect = QRectF(pt.x(), pt.y(), self.WIDTH, self.HEIGHT)
     if self.isIn:
         painter.setPen(QPen(Qt.transparent, 1))
         painter.setBrush(QBrush(Qt.lightGray, Qt.SolidPattern))
     else:
         painter.setPen(QPen(Qt.transparent, 1))
         painter.setBrush(QBrush(Qt.transparent, Qt.SolidPattern))
     painter.drawRect(rect)
     painter.drawPixmap(pt.x(), pt.y(), self.pixmap)
开发者ID:olivierdalang,项目名称:QGIS,代码行数:13,代码来源:ModelerGraphicItem.py

示例3: drawPipeline

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
    def drawPipeline(self, qp):
        """Called by paintEvent, it draws figures and link between them.
        Parameters
        ----------
        qp : QtGui.QPainter
            Performs low-level painting
        """
        # If self.levels is empty, indeed, it does not make sense to draw
        # something.
        if self.levels is None:
            return
        # define Rep position because they change whan resising main windows

        width = self.size().width()
        height = self.size().height()

        if len(self.levels) != 0:
            total_height = (len(self.levels) - 1) * (
                STAGE_SIZE_Y + ROUTER_SIZE_Y)
            self.zoom = height / total_height
        else:
            self.zoom = 1

        #  center figures on screen
        last_point = QPointF(width / 2, -GAP_Y / 2 * self.zoom)
        for level in self.levels:
            total_x = len(level) * STAGE_SIZE_X * self.zoom + (
                len(level) - 1 * STAGE_GAP_X * self.zoom)
            last_point.setX(width / 2 - total_x / 2)
            last_point.setY(last_point.y() + GAP_Y * self.zoom)
            for figure in level:
                figure.setCenter(QPointF(last_point))
                last_point.setX(last_point.x() + STAGE_GAP_X * self.zoom)
        # Start to paint
        size = self.size()
        lines = list()
        last_level_pt = list()
        for level in self.levels:
            current_level_pt = list()
            for figure in level:
                figure.draw(qp, zoom=self.zoom)
                connexion_pt = QPointF(figure.center.x(), figure.center.y()
                                       - figure.size_y / 2 * self.zoom)
                current_level_pt.append(QPointF(connexion_pt.x(),
                                                connexion_pt.y() + figure.size_y * self.zoom))
                # Link to previous level connexion point(s)
                for point in last_level_pt:
                    lines.append(QLineF(point, connexion_pt))
            # Keep points for next level
            last_level_pt = list(current_level_pt)
        for line in lines:
            qp.setPen(QtGui.QPen(self.blue_cta, 1, QtCore.Qt.SolidLine))
            qp.drawLine(line)
开发者ID:rdelosreyes,项目名称:ctapipe,代码行数:55,代码来源:pipelinedrawer.py

示例4: draw

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
 def draw(self, qpainter, zoom=1):
     """Draw this figure
     Parameters
     ----------
     qpainter: PySide.QtGui.QPainter
     """
     size_x = self.size_x * zoom
     size_y = self.size_y * zoom
     pensize = 3
     qpainter.setPen(
         QtGui.QPen(PipelineDrawer.blue_cta, pensize, QtCore.Qt.SolidLine))
     text_pos = QPointF(self.center)
     text_pos.setX(text_pos.x() - size_x / 2 + 2)
     text_pos.setY(text_pos.y() + pensize)
     qpainter.drawText(text_pos, str(self.nb_job_done))
     pt = QPointF(self.center)
     pt.setX(5)
     pos = self.name.find("$$thread_number$$")
     if pos != -1:
         name = self.name[0:pos]
     else:
         name = self.name
     qpainter.drawText(pt, name)
     if self.running == True:
         qpainter.setPen(
             QtGui.QPen(PipelineDrawer.mygreen, 3, QtCore.Qt.SolidLine))
     else:
         qpainter.setPen(
             QtGui.QPen(PipelineDrawer.blue_cta, 3, QtCore.Qt.SolidLine))
     x1 = self.center.x() - (size_x / 2)
     y1 = self.center.y() - (size_y / 2)
     qpainter.drawRoundedRect(x1, y1, size_x, size_y, 12.0, 12.0)
开发者ID:rdelosreyes,项目名称:ctapipe,代码行数:34,代码来源:pipelinedrawer.py

示例5: paint

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
    def paint(self, painter, option, widget=None):
        myPen = self.pen()
        myPen.setColor(self.myColor)
        painter.setPen(myPen)
        painter.setBrush(self.myColor)

        controlPoints = []
        endPt = self.endItem.getLinkPointForParameter(self.endIndex)
        startPt = self.startItem.getLinkPointForOutput(self.startIndex)
        if isinstance(self.startItem.element, Algorithm):
            if self.startIndex != -1:
                controlPoints.append(self.startItem.pos() + startPt)
                controlPoints.append(self.startItem.pos() + startPt
                        + QPointF(ModelerGraphicItem.BOX_WIDTH / 2, 0))
                controlPoints.append(self.endItem.pos() + endPt
                        - QPointF(ModelerGraphicItem.BOX_WIDTH / 2, 0))
                controlPoints.append(self.endItem.pos() + endPt)
                pt = QPointF(self.startItem.pos() + startPt
                        + QPointF(-3, -3))
                painter.drawEllipse(pt.x(), pt.y(), 6, 6)
                pt = QPointF(self.endItem.pos() + endPt +
                        QPointF(-3, -3))
                painter.drawEllipse(pt.x(), pt.y(), 6, 6)
            else:
                # Case where there is a dependency on an algorithm not
                # on an output
                controlPoints.append(self.startItem.pos() + startPt)
                controlPoints.append(self.startItem.pos() + startPt
                        + QPointF(ModelerGraphicItem.BOX_WIDTH / 2, 0))
                controlPoints.append(self.endItem.pos() + endPt
                        - QPointF(ModelerGraphicItem.BOX_WIDTH / 2, 0))
                controlPoints.append(self.endItem.pos() + endPt)
        else:
            controlPoints.append(self.startItem.pos())
            controlPoints.append(self.startItem.pos()
                    + QPointF(ModelerGraphicItem.BOX_WIDTH / 2, 0))
            controlPoints.append(self.endItem.pos() + endPt
                    - QPointF(ModelerGraphicItem.BOX_WIDTH / 2, 0))
            controlPoints.append(self.endItem.pos() + endPt)
            pt = QPointF(self.endItem.pos() + endPt + QPointF(-3, -3))
            painter.drawEllipse(pt.x(), pt.y(), 6, 6)

        path = QPainterPath()
        path.moveTo(controlPoints[0])
        path.cubicTo(*controlPoints[1:])
        painter.strokePath(path, painter.pen())
        self.setPath(path)
开发者ID:Ariki,项目名称:QGIS,代码行数:49,代码来源:ModelerArrowItem.py

示例6: distToLine

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
def distToLine(pt,  p1,  p2):
    """
    Compute the distance from the point `pt` to the line segment [p1,p2]
    """
    u = p2-p1
    lu = u.x()*u.x() + u.y()*u.y()
    pmax = QPointF(max(abs(p1.x()), abs(p2.x())), max(abs(p1.y()), abs(p2.y())))
    if lu / (pmax.x()*pmax.x() + pmax.y()*pmax.y()) < 1e-10:
        diff = u - p1
        return sqrt(diff.x()*diff.x() + diff.y()*diff.y())
    dp = pt-p1
    proj = (u.x()*dp.x() + u.y()*dp.y())
    if proj >= 0 and proj <= lu:
        return abs(dp.x()*u.y() - u.x()*dp.y())/sqrt(lu)
    elif proj < 0:
        return dp.x()*dp.x() + dp.y()*dp.y()
    else:
        return dist(pt,  p2)
开发者ID:PierreBdR,项目名称:point_tracker,代码行数:20,代码来源:geometry.py

示例7: updateSmooth

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
    def updateSmooth(self):
        if self.m_smooth:
            if self.m_cursor.x() != self.m_smooth_x or self.m_cursor.y() != self.m_smooth_y:
                if abs(self.m_cursor.x() - self.m_smooth_x) <= 0.001:
                    self.m_smooth_x = self.m_cursor.x()
                    return
                elif abs(self.m_cursor.y() - self.m_smooth_y) <= 0.001:
                    self.m_smooth_y = self.m_cursor.y()
                    return

                new_x = (self.m_smooth_x + self.m_cursor.x() * 3) / 4
                new_y = (self.m_smooth_y + self.m_cursor.y() * 3) / 4
                pos = QPointF(new_x, new_y)

                self.m_cursor.setPos(pos)
                self.m_lineH.setY(pos.y())
                self.m_lineV.setX(pos.x())

                xp = pos.x() / (self.p_size.x() + self.p_size.width())
                yp = pos.y() / (self.p_size.y() + self.p_size.height())

                self.sendMIDI(xp, yp)
                self.emit(SIGNAL("cursorMoved(double, double)"), xp, yp)
开发者ID:kayosiii,项目名称:Cadence,代码行数:25,代码来源:xycontroller.py

示例8: movePoints

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
 def movePoints(self, image_name, pt_ids):
     if image_name == self.image_name:
         data = self.current_data
         dm = self.data_manager
         points = self.points
         cells = self.cells
         for pt_id in pt_ids:
             pos = data[pt_id]
             pos = QPointF(pos.x() / self.min_scale, pos.y() / self.min_scale)
             points[pt_id].setPos(pos)
             for cid in dm.cell_points[pt_id]:
                 cell = cells.get(cid, None)
                 if cell is not None and cell.isVisible():
                     cell.setGeometry()
开发者ID:PierreBdR,项目名称:point_tracker,代码行数:16,代码来源:tracking_scene.py

示例9: path_link_disabled

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
def path_link_disabled(basepath):
    """
    Return a QPainterPath 'styled' to indicate a 'disabled' link.

    A disabled link is displayed with a single disconnection symbol in the
    middle (--||--)

    Parameters
    ----------
    basepath : QPainterPath
        The base path (a simple curve spine).

    Returns
    -------
    path : QPainterPath
        A 'styled' link path
    """
    segmentlen = basepath.length()
    px = 5

    if segmentlen < 10:
        return QPainterPath(basepath)

    t = (px / 2) / segmentlen
    p1, _ = qpainterpath_simple_split(basepath, 0.50 - t)
    _, p2 = qpainterpath_simple_split(basepath, 0.50 + t)

    angle = -basepath.angleAtPercent(0.5) + 90
    angler = math.radians(angle)
    normal = QPointF(math.cos(angler), math.sin(angler))

    end1 = p1.currentPosition()
    start2 = QPointF(p2.elementAt(0).x, p2.elementAt(0).y)
    p1.moveTo(start2.x(), start2.y())
    p1.addPath(p2)

    def QPainterPath_addLine(path, line):
        path.moveTo(line.p1())
        path.lineTo(line.p2())

    QPainterPath_addLine(p1, QLineF(end1 - normal * 3, end1 + normal * 3))
    QPainterPath_addLine(p1, QLineF(start2 - normal * 3, start2 + normal * 3))
    return p1
开发者ID:tomazc,项目名称:orange3,代码行数:45,代码来源:linkitem.py

示例10: paint

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
    def paint(self, painter, option, widget):

        arc_rect = 10
        connector_length = 5

        painter.setPen(self.pen)
        path = QtGui.QPainterPath()

        if self.source.x() == self.dest.x():
            path.moveTo(self.source.x(), self.source.y())
            path.lineTo(self.dest.x(), self.dest.y())
            painter.drawPath(path)

        else:

            #Define points starting from source
            point1 = QPointF(self.source.x(), self.source.y())
            point2 = QPointF(point1.x(), point1.y() - connector_length)
            point3 = QPointF(point2.x() + arc_rect, point2.y() - arc_rect)

            #Define points starting from dest
            point4 = QPointF(self.dest.x(), self.dest.y())
            point5 = QPointF(point4.x(),point3.y() - arc_rect)
            point6 = QPointF(point5.x() - arc_rect, point5.y() + arc_rect)

            start_angle_arc1 = 180
            span_angle_arc1 = 90
            start_angle_arc2 = 90
            span_angle_arc2 = -90

            # If the dest is at the left of the source, then we
            # need to reverse some values
            if self.source.x() > self.dest.x():
                point5 = QPointF(point4.x(), point4.y() + connector_length)
                point6 = QPointF(point5.x() + arc_rect, point5.y() + arc_rect)
                point3 = QPointF(self.source.x() - arc_rect, point6.y())
                point2 = QPointF(self.source.x(), point3.y() + arc_rect)

                span_angle_arc1 = 90

            path.moveTo(point1)
            path.lineTo(point2)
            path.arcTo(QRectF(point2, point3),
                       start_angle_arc1, span_angle_arc1)
            path.lineTo(point6)
            path.arcTo(QRectF(point6, point5),
                       start_angle_arc2, span_angle_arc2)
            path.lineTo(point4)
            painter.drawPath(path)
开发者ID:B-Rich,项目名称:git-cola,代码行数:51,代码来源:dag.py

示例11: drawArrow

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
 def drawArrow(self, paint, x1, y1, x2, y2):
     m = paint.worldMatrix()
     paint.translate(x1,y1)
     pi = 3.1415926
     if abs(x2 - x1) > 0:
         alpha = math.atan(abs(y2-y1)/abs(x2-x1)) * 180 / pi
     else:
         alpha = 90
     if y2 > y1:
         if x2 > x1:
             paint.rotate(alpha)
         else:
             paint.rotate(180-alpha)
     else:
         if x2 > x1:
             paint.rotate(-alpha)
         else:
             paint.rotate(alpha-180)
     endcoord = math.sqrt((x2-x1)**2 + (y2-y1)**2)
     p1 = QPointF(endcoord , 0)
     paint.drawLine(0, 0, p1.x(), 0)
     paint.setWorldMatrix(m)
开发者ID:DanielZorin,项目名称:DataCenters,代码行数:24,代码来源:TenantCanvas.py

示例12: TracepointWaveScene

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
class TracepointWaveScene(QtGui.QGraphicsScene):
    '''QGraphicsView for wave'''
    def __init__(self, type_, values, duration):
        '''CTOR
           @param type_: string, must be in supported types
           @param values: list of values of variable
           @param duration: integer, holds stepwidth of wave
        '''
        QtGui.QGraphicsScene.__init__(self)
        self.supportedTypes = ["bool", "int", "float", "double"]
        self.vSpace = 10
        self.values = []
        self.curPos = QPointF(0, 2)
        self.type = type_
        self.width = duration
        self.valFont = QtGui.QFont("Arial", 7)
        self.valFontColor = QtGui.QColor()
        self.valFontColor.setGreen(100)
        self.setSceneRect(0, 0, self.width, 15)

        for v in values:
            self.appendValue(v, duration)

    def getSupportedTypes(self):
        ''' Returns supported waveform types
            @return list[string]
        '''
        return self.supportedTypes

    def getType(self):
        ''' @return string identifying type of TracepointWaveScene'''
        return self.type

    def appendValue(self, value, duration):
        ''' Append value to wave
            @param value: value to add
            @param duration: integer, defines duration(length) of value in wave
        '''
        drawEdge = len(self.values) > 0 and self.values[len(self.values) - 1] != value
        if drawEdge:
            self.__drawEdge()

        self.values.append(value)
        self.__drawLine(value, duration, drawEdge or len(self.values) == 1)
        self.setSceneRect(0, 0, self.width, 15)

    def __drawEdge(self):
        ''' Draws an edge depending on the type of the waveform. '''
        if self.type == "bool":
            self.addItem(QtGui.QGraphicsLineItem(QLineF(self.curPos, QPointF(self.curPos.x(), self.curPos.y() + self.vSpace))))
        elif self.type in self.supportedTypes:
            self.addItem(QtGui.QGraphicsLineItem(QLineF(self.curPos, QPointF(self.curPos.x() + 2, self.curPos.y() + self.vSpace))))
            self.addItem(QtGui.QGraphicsLineItem(QLineF(QPointF(self.curPos.x() + 2, self.curPos.y()), QPointF(self.curPos.x(), self.curPos.y() + self.vSpace))))

    def __drawLine(self, value, duration, printvalue=True):
        ''' Draws a line depending on the type of the waveform.
            @param value: value to add to wave
            @param duration: integer, defines duration(length) of value in wave
            @param printvalue: bool, add values to waveform (for value-type waveforms only)
        '''
        self.width = self.width + duration
        tmp = self.curPos
        self.curPos = QPointF(self.curPos.x() + duration, self.curPos.y())
        if self.type == "bool":
            if value:
                self.addItem(QtGui.QGraphicsLineItem(QLineF(tmp, self.curPos)))
            else:
                self.addItem(QtGui.QGraphicsLineItem(tmp.x(), tmp.y() + self.vSpace, self.curPos.x(), self.curPos.y() + self.vSpace))
        elif self.type in self.supportedTypes:
            if printvalue:
                text = QtGui.QGraphicsTextItem(str(value))
                text.setFont(self.valFont)
                text.setDefaultTextColor(self.valFontColor)
                text.setPos(QPointF(tmp.x() + 4, tmp.y() - 5))
                self.addItem(text)

            self.addItem(QtGui.QGraphicsLineItem(QLineF(tmp, self.curPos)))
            self.addItem(QtGui.QGraphicsLineItem(tmp.x(), tmp.y() + self.vSpace, self.curPos.x(), self.curPos.y() + self.vSpace))
开发者ID:mprska,项目名称:ricodebug,代码行数:80,代码来源:tracepointwavemodel.py

示例13: paint

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
    def paint(self, painter, _1, _2):
        """ Main-Method of the Pointer-Class <br>
            calculates/renders/draws the Lines of the Arrow
        """
        if self.fromView.collidesWithItem(self.toView):
            return

        # antialiasing makes things look nicer :)
        painter.setRenderHint(QPainter.Antialiasing)

        self.toView.x()
        pM1 = QPointF(self.fromView.x() + self.fromView.size().width() / 2,
                      self.fromView.y() + self.fromView.size().height() / 2)
        pM2 = QPointF(self.toView.x() + self.toView.size().width() / 2,
                      self.toView.y() + self.toView.size().height() / 2)
        deltaX = pM2.x() - pM1.x()
        deltaY = pM2.y() - pM1.y()
        if deltaX == 0:
            deltaX = 0.01
        if deltaY == 0:
            deltaY = 0.01
        if deltaX >= 0:
            if deltaY >= 0:
                # rechts unten
                if deltaX / deltaY >= self.fromView.size().width() / self.fromView.size().height():
                    # Start von rechter Seite
                    pStart = QPointF(pM1.x() + self.fromView.size().width() / 2,
                                     pM1.y() + (self.fromView.size().width() / 2) * (deltaY / deltaX))
                else:
                    # Start von unterer Seite
                    pStart = QPointF(pM1.x() + (self.fromView.size().height() / 2) * (deltaX / deltaY),
                                     pM1.y() + self.fromView.size().height() / 2)

                if deltaX / deltaY >= self.toView.size().width() / self.toView.size().height():
                    # Ende bei linker Seite
                    pEnd = QPointF(pM2.x() - self.toView.size().width() / 2,
                                   pM2.y() - (self.toView.size().width() / 2) * (deltaY / deltaX))
                else:
                    # Ende bei oberer Seite
                    pEnd = QPointF(pM2.x() - (self.toView.size().height() / 2) * (deltaX / deltaY),
                                   pM2.y() - self.toView.size().height() / 2)
            else:
                # rechts oben
                if deltaX / deltaY * -1 >= self.fromView.size().width() / self.fromView.size().height():
                    # Start von rechter Seite
                    pStart = QPointF(pM1.x() + self.fromView.size().width() / 2,
                                     pM1.y() + (self.fromView.size().width() / 2) * (deltaY / deltaX))
                else:
                    # Start von oberer Seite
                    pStart = QPointF(pM1.x() - (self.fromView.size().height() / 2) * (deltaX / deltaY),
                                     pM1.y() - self.fromView.size().height() / 2)

                if deltaX / deltaY * -1 >= self.toView.size().width() / self.toView.size().height():
                    # Ende bei linker Seite
                    pEnd = QPointF(pM2.x() - self.toView.size().width() / 2,
                                   pM2.y() - (self.toView.size().width() / 2) * (deltaY / deltaX))
                else:
                    # Ende bei unterer Seite
                    pEnd = QPointF(pM2.x() + (self.toView.size().height() / 2) * (deltaX / deltaY),
                                   pM2.y() + self.toView.size().height() / 2)
        else:
            if deltaY >= 0:
                # links unten
                if deltaX / deltaY * -1 >= self.fromView.size().width() / self.fromView.size().height():
                    # Start von linker Seite
                    pStart = QPointF(pM1.x() - self.fromView.size().width() / 2,
                                     pM1.y() - (self.fromView.size().width() / 2) * (deltaY / deltaX))
                else:
                    # Start von unterer Seite
                    pStart = QPointF(pM1.x() + (self.fromView.size().height() / 2) * (deltaX / deltaY),
                                     pM1.y() + self.fromView.size().height() / 2)

                if deltaX / deltaY * -1 >= self.toView.size().width() / self.toView.size().height():
                    # Ende bei rechten Seite
                    pEnd = QPointF(pM2.x() + self.toView.size().width() / 2,
                                   pM2.y() + (self.toView.size().width() / 2) * (deltaY / deltaX))
                else:
                    # Ende bei oberer Seite
                    pEnd = QPointF(pM2.x() - (self.toView.size().height() / 2) * (deltaX / deltaY),
                                   pM2.y() - self.toView.size().height() / 2)
            else:
                # links oben
                if deltaX / deltaY >= self.fromView.size().width() / self.fromView.size().height():
                    # Start von linker Seite
                    pStart = QPointF(pM1.x() - self.fromView.size().width() / 2,
                                     pM1.y() - (self.fromView.size().width() / 2) * (deltaY / deltaX))
                else:
                    # Start von oberer Seite
                    pStart = QPointF(pM1.x() - (self.fromView.size().height() / 2) * (deltaX / deltaY),
                                     pM1.y() - self.fromView.size().height() / 2)

                if deltaX / deltaY >= self.toView.size().width() / self.toView.size().height():
                    # Ende bei rechter Seite
                    pEnd = QPointF(pM2.x() + self.toView.size().width() / 2,
                                   pM2.y() + (self.toView.size().width() / 2) * (deltaY / deltaX))
                else:
                    # Ende bei unterer Seite
                    pEnd = QPointF(pM2.x() + (self.toView.size().height() / 2) * (deltaX / deltaY),
                                   pM2.y() + self.toView.size().height() / 2)

#.........这里部分代码省略.........
开发者ID:gledr,项目名称:ricodebug,代码行数:103,代码来源:pointer.py

示例14: drawCorner

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
    def drawCorner(self, painter, position, cornerType, maxRadius=None):
        #logging.debug(self.__class__.__name__ +": drawCorner() "+ self.cornerTypeString(cornerType))
        thickness = self.CONNECTION_THICKNESS * self.zoomFactor()
        halfthick = thickness / 2
        cornerRoundness = halfthick ** 0.5
        cornerOffset = halfthick * (cornerRoundness)
        innerCorner = halfthick * (cornerRoundness - 1)
        outerCorner = halfthick * (cornerRoundness + 1)
        innerWidth = halfthick * (cornerRoundness - 1)
        radius = halfthick * (cornerRoundness + 1)
        if maxRadius:
            maxRadius = max(maxRadius, thickness)
            radius = min(radius, maxRadius)

        if cornerType == self.CornerType.TOP_RIGHT:
            startAngle = 0

            outerCorner = QPointF(position.x() + halfthick - 2 * radius, position.y() - halfthick)
            innerCorner = QPointF(outerCorner.x(), outerCorner.y() + (thickness))
            center = QPointF(outerCorner.x() + radius, outerCorner.y() + radius)
            
            outerRect = QRectF(outerCorner, QSizeF(2 * radius, 2 * radius))
            innerRect = QRectF(innerCorner, QSizeF((2 * radius - thickness), (2 * radius - thickness)))
            
            outerStart = QPointF(outerCorner.x() + 2 * radius, outerCorner.y() + (radius + halfthick))
            innerStart = QPointF(outerCorner.x() + (radius - halfthick), outerCorner.y())
            
        elif cornerType == self.CornerType.TOP_LEFT:
            startAngle = 90
            
            outerCorner = QPointF(position.x() - halfthick, position.y() - halfthick)
            innerCorner = QPointF(outerCorner.x() + (thickness), outerCorner.y() + (thickness))
            center = QPointF(outerCorner.x() + radius, outerCorner.y() + radius)
            
            outerRect = QRectF(outerCorner, QSizeF(2 * radius, 2 * radius))
            innerRect = QRectF(innerCorner, QSizeF((2 * radius - thickness), (2 * radius - thickness)))
            
            outerStart = QPointF(outerCorner.x() + (radius + halfthick), outerCorner.y())
            innerStart = QPointF(outerCorner.x(), outerCorner.y() + (radius + halfthick))
            
        elif cornerType == self.CornerType.BOTTOM_LEFT:
            startAngle = 180
            
            outerCorner = QPointF(position.x() - halfthick, position.y() + halfthick - 2 * radius)
            innerCorner = QPointF(outerCorner.x() + (thickness), outerCorner.y())
            center = QPointF(outerCorner.x() + radius, outerCorner.y() + radius)
            
            outerRect = QRectF(outerCorner, QSizeF(2 * radius, 2 * radius))
            innerRect = QRectF(innerCorner, QSizeF((2 * radius - thickness), (2 * radius - thickness)))
            
            outerStart = QPointF(outerCorner.x(), outerCorner.y() + (radius - halfthick))
            innerStart = QPointF(outerCorner.x() + (radius + halfthick), outerCorner.y() + (2 * radius))
            
        elif cornerType == self.CornerType.BOTTOM_RIGHT:
            startAngle = 270
            
            outerCorner = QPointF(position.x() + halfthick - 2 * radius, position.y() + halfthick - 2 * radius)
            innerCorner = QPointF(outerCorner.x(), outerCorner.y())
            center = QPointF(outerCorner.x() + radius, outerCorner.y() + radius)
            
            outerRect = QRectF(outerCorner, QSizeF(2 * radius, 2 * radius))
            innerRect = QRectF(innerCorner, QSizeF((2 * radius - thickness), (2 * radius - thickness)))
            
            outerStart = QPointF(outerCorner.x() + (radius - halfthick), outerCorner.y() + 2 * radius)
            innerStart = QPointF(outerCorner.x() + 2 * radius, outerCorner.y() + (radius - halfthick))
            
        else:
            # No defined corner, so nothing to draw.
            #print "PointToPointConnection.drawCorner() - No valid corner, aborting..."
            return
        
        if painter.redirected(painter.device()):
            # e.q. QPixmap.grabWidget()
            painter.setBrush(self.FILL_COLOR1)
        else:
            brush = QRadialGradient(center, radius)
            if radius >= thickness:
                brush.setColorAt((radius - thickness) / radius, self.FILL_COLOR1)   # inner border 
                brush.setColorAt((radius - halfthick + 1) / radius, self.FILL_COLOR2)   # center of line
            else:
                # If zoom is too small use single color
                brush.setColorAt(0, self.FILL_COLOR1)    
            brush.setColorAt(1, self.FILL_COLOR1)                                   # outer border
            painter.setBrush(brush)
        
        path = QPainterPath()
        path.moveTo(outerStart)
        path.arcTo(outerRect, startAngle, 90)
        path.lineTo(innerStart)
        path.arcTo(innerRect, startAngle + 90, - 90)
        path.closeSubpath()
            
        #painter.setPen(Qt.NoPen)
        painter.drawPath(path)
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:96,代码来源:PortConnection.py

示例15: EEdge

# 需要导入模块: from PyQt4.QtCore import QPointF [as 别名]
# 或者: from PyQt4.QtCore.QPointF import x [as 别名]
class EEdge(QGraphicsObject):
    def __init__(self, head, tail, uuid):
        QGraphicsObject.__init__(self)

        if not issubclass(head.__class__, dict) and not isinstance(tail.__class__, dict):
            raise AttributeError

        self.setZValue(0.0)

        self.__kId = uuid
        self.__head = head
        self.__tail = tail

        if  head[ENode.kGuiAttributeType].match(EAttribute.kTypeInput):
            self.__head = tail
            self.__tail = head

        self.__head[ENode.kGuiAttributeParent].onMove.connect(self.update)
        self.__tail[ENode.kGuiAttributeParent].onMove.connect(self.update)

        self.__headPoint = QPointF(0.0, 0.0)
        self.__tailPoint = QPointF(0.0, 0.0)

        self.__pen = QPen(QColor(43, 43, 43), 2, Qt.SolidLine)

        self.update()

    @property
    def Id(self):
        return self.__kId

    @property
    def Head(self):
        return self.__head

    @property
    def Tail(self):
        return self.__tail

    def pen(self):
        return self.__pen

    def setPen(self, pen):
        if not isinstance(pen, QPen):
            raise AttributeError

        self.__pen = pen

    def update(self):

        QGraphicsObject.prepareGeometryChange(self)

        self.__headPoint = self.mapFromItem(self.__head[ENode.kGuiAttributeParent],
                                            self.__head[ENode.kGuiAttributePlug])

        self.__tailPoint = self.mapFromItem(self.__tail[ENode.kGuiAttributeParent],
                                            self.__tail[ENode.kGuiAttributePlug])

        self.__headOffsetLine = QLineF(self.__headPoint, QPointF(self.__headPoint.x() + 15, self.__headPoint.y()))
        self.__tailOffsetLine = QLineF(self.__tailPoint, QPointF(self.__tailPoint.x() - 15, self.__tailPoint.y()))

        line = QLineF(self.__headPoint, self.__tailPoint)
        self.__line = line

    def boundingRect(self):
        extra = (self.pen().width() * 64) / 2
        return QRectF(self.__line.p1(),
                      QSizeF(self.__line.p2().x() - self.__line.p1().x(),
                             self.__line.p2().y() - self.__line.p1().y())).normalized().adjusted(-extra,
                                                                                                 -extra,
                                                                                                 extra,
                                                                                                 extra)

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

    def drawPath(self, startPoint, endPoint):
        path = QPainterPath()

        one = (QPointF(endPoint.x(), startPoint.y()) + startPoint) / 2
        two = (QPointF(startPoint.x(), endPoint.y()) + endPoint) / 2

        path.moveTo(startPoint)

        angle = math.pi / 2
        bLine1 = QLineF()
        bLine1.setP1(startPoint)

        if startPoint.x() > endPoint.x():
            dist = startPoint.x() - endPoint.x()
            one = (bLine1.p1() + QPointF(math.sin(angle) * dist,  math.cos(angle) * dist))
            bLine1.setP1(endPoint)
            two = (bLine1.p1() + QPointF(math.sin(angle) * dist,  math.cos(angle) * dist))

        path.cubicTo(one, two,  endPoint)
        return path, QLineF(one, two)

    def paint(self, painter, option, widget=None):

        painter.setPen(self.pen())
#.........这里部分代码省略.........
开发者ID:raiscui,项目名称:edd,代码行数:103,代码来源:eedge.py


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