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


Python QLineF.angle方法代码示例

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


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

示例1: paint

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

        painter.setPen(EDraw.EColor.DefaultEnterHoverPen)

        lineX = QLineF(QPointF(self.__gridSize, 0.0), QPointF(0.0, 0.0)).translated(-self.scenePos())
        lineY = QLineF(QPointF(0.0, -self.__gridSize), QPointF(0.0, 0.0)).translated(-self.scenePos())
        painter.drawLines([lineX, lineY])

        self.__snapPoint = QPointF(self.__gridSize * round(self.scenePos().x() / self.__gridSize),
                                   self.__gridSize * round(self.scenePos().y() / self.__gridSize))

        if self.__isSnapMode:
            painter.drawPolygon(self.__polygon.translated(self.__snapPoint - self.scenePos()))

        self.__angle = 0.0

        if self.__editPointOne is not None:
            painter.drawPolygon(EDraw.Circle(20, 24).translated(-(self.scenePos()) + self.__BBTemp))
            painter.drawLine(QLineF(QPointF(-(self.scenePos()) + self.__BBTemp), QPointF(0.0, 0.0)))

            dummyLine = QLineF(QPointF(-(self.scenePos()) + self.__BBTemp), QPointF(0.0, 0.0))

            painter.drawLine(QLineF(ETransform.rotatePoint(20, dummyLine.angle() + 180),
                                    QPointF()).translated(-(self.scenePos()) + self.__BBTemp))
            painter.drawLine(QLineF(ETransform.rotatePoint(20, dummyLine.angle() + 360),
                                    QPointF()).translated(-(self.scenePos()) + self.__BBTemp))

            self.__angle = dummyLine.angle()

        painter.drawPolygon(self.__polygon)
        painter.drawLine(self.__dummyLine)
开发者ID:shrimo,项目名称:node_image_tools,代码行数:33,代码来源:edummy.py

示例2: draw_arrow

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import angle [as 别名]
 def draw_arrow(self, line, width, color):
     (x1, y1), (x2, y2) = line
     # compute points
     line = QLineF(x1, y1, x2, y2)
     # If the line is very small, we make our arrowhead smaller
     arrowsize = min(14, line.length())
     lineangle = radians(line.angle())
     arrowpt1 = line.p2() + QPointF(sin(lineangle - (pi/3)) * arrowsize, cos(lineangle - (pi/3)) * arrowsize)
     arrowpt2 = line.p2() + QPointF(sin(lineangle - pi + (pi/3)) * arrowsize, cos(lineangle - pi + (pi/3)) * arrowsize)
     head = QPolygonF([line.p2(), arrowpt1, arrowpt2])
     # We have to draw the actual line a little short for the tip of the arrowhead not to be too wide
     adjustedLine = QLineF(line)
     adjustedLine.setLength(line.length() - arrowsize/2)
     
     # draw line
     painter = self.current_painter
     color = COLORS[color]
     painter.save()
     pen = QPen(painter.pen())
     pen.setColor(color)
     pen.setWidthF(width)
     painter.setPen(pen)
     painter.drawLine(adjustedLine)
     
     # draw arrowhead
     painter.setPen(Qt.NoPen)
     brush = painter.brush()
     brush.setColor(color)
     brush.setStyle(Qt.SolidPattern)
     painter.setBrush(brush)
     painter.drawPolygon(head)
     painter.restore()
开发者ID:hsoft,项目名称:pdfmasher,代码行数:34,代码来源:page_repr.py

示例3: paint

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import angle [as 别名]
 def paint(self, painter):
     pen = QPen(Qt.black)
     pen.setWidthF(2.5)
     painter.setPen(pen)
     line = QLineF(self.startPoint, self.pos)
     painter.drawLine(line)
     if self.pos != self.startPoint:
         #draw arrowhead
         a = line.angle()
         l1 = QLineF.fromPolar(25, a - 155)
         l1.translate(self.pos)
         l2 = QLineF.fromPolar(25, a + 155)
         l2.translate(self.pos)
         painter.drawLine(l1)
         painter.drawLine(l2)
开发者ID:dhrosa,项目名称:empyre_old,代码行数:17,代码来源:animations.py

示例4: arrow_path_concave

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import angle [as 别名]
def arrow_path_concave(line, width):
    """
    Return a :class:`QPainterPath` of a pretty looking arrow.
    """
    path = QPainterPath()
    p1, p2 = line.p1(), line.p2()

    if p1 == p2:
        return path

    baseline = QLineF(line)
    # Require some minimum length.
    baseline.setLength(max(line.length() - width * 3, width * 3))

    start, end = baseline.p1(), baseline.p2()
    mid = (start + end) / 2.0
    normal = QLineF.fromPolar(1.0, baseline.angle() + 90).p2()

    path.moveTo(start)
    path.lineTo(start + (normal * width / 4.0))

    path.quadTo(mid + (normal * width / 4.0),
                end + (normal * width / 1.5))

    path.lineTo(end - (normal * width / 1.5))
    path.quadTo(mid - (normal * width / 4.0),
                start - (normal * width / 4.0))
    path.closeSubpath()

    arrow_head_len = width * 4
    arrow_head_angle = 50
    line_angle = line.angle() - 180

    angle_1 = line_angle - arrow_head_angle / 2.0
    angle_2 = line_angle + arrow_head_angle / 2.0

    points = [p2,
              p2 + QLineF.fromPolar(arrow_head_len, angle_1).p2(),
              baseline.p2(),
              p2 + QLineF.fromPolar(arrow_head_len, angle_2).p2(),
              p2]

    poly = QPolygonF(points)
    path_head = QPainterPath()
    path_head.addPolygon(poly)
    path = path.united(path_head)
    return path
开发者ID:CHANAYA,项目名称:orange3,代码行数:49,代码来源:annotationitem.py

示例5: overlay_for

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import angle [as 别名]
    def overlay_for(pt1, pt2, frequency):
        # Construct the line-geometry, we'll use this to construct the ellipsoid
        line = QLineF(pt1, pt2)

        # Determine the radius for the ellipsoid
        radius = fresnel_radius(line.length(), frequency)

        # Draw the ellipsoid
        zone = QPainterPath()
        zone.addEllipse(QPointF(0., 0.), line.length() / 2, radius)

        # Rotate the ellipsoid - same angle as the line
        transform = QTransform()
        transform.rotate(-line.angle())
        zone = transform.map(zone)

        # Center the zone over the line
        lc = QRectF(pt1, pt2).center()
        zc = zone.boundingRect().center()
        zone.translate(lc.x() - zc.x(), lc.y() - zc.y())

        return line, zone
开发者ID:JamesFysh,项目名称:eleview,代码行数:24,代码来源:ElevationScene.py

示例6: update

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import angle [as 别名]
    def update(self, zoom_only = False):
        self.update_ticks()
        line_color = self.plot.color(OWPalette.Axis)
        text_color = self.plot.color(OWPalette.Text)
        if not self.graph_line or not self.scene():
            return
        self.line_item.setLine(self.graph_line)
        self.line_item.setPen(line_color)
        if self.title:
            self.title_item.setHtml('<b>' + self.title + '</b>')
            self.title_item.setDefaultTextColor(text_color)
        if self.title_location == AxisMiddle:
            title_p = 0.5
        elif self.title_location == AxisEnd:
            title_p = 0.95
        else:
            title_p = 0.05
        title_pos = self.graph_line.pointAt(title_p)
        v = self.graph_line.normalVector().unitVector()

        dense_text = False
        if hasattr(self, 'title_margin'):
            offset = self.title_margin
        elif self._ticks:
            if self.should_be_expanded():
                offset = 55
                dense_text = True
            else:
                offset = 35
        else:
            offset = 10

        if self.title_above:
            title_pos = title_pos + (v.p2() - v.p1())*(offset + QFontMetrics(self.title_item.font()).height())
        else:
            title_pos = title_pos - (v.p2() - v.p1())*offset
        ## TODO: Move it according to self.label_pos
        self.title_item.setVisible(self.show_title)
        self.title_item.setRotation(-self.graph_line.angle())
        c = self.title_item.mapToParent(self.title_item.boundingRect().center())
        tl = self.title_item.mapToParent(self.title_item.boundingRect().topLeft())
        self.title_item.setPos(title_pos - c + tl)

        ## Arrows
        if not zoom_only:
            if self.start_arrow_item:
                self.scene().removeItem(self.start_arrow_item)
                self.start_arrow_item = None
            if self.end_arrow_item:
                self.scene().removeItem(self.end_arrow_item)
                self.end_arrow_item = None

        if self.arrows & AxisStart:
            if not zoom_only or not self.start_arrow_item:
                self.start_arrow_item = QGraphicsPathItem(self.arrow_path, self)
            self.start_arrow_item.setPos(self.graph_line.p1())
            self.start_arrow_item.setRotation(-self.graph_line.angle() + 180)
            self.start_arrow_item.setBrush(line_color)
            self.start_arrow_item.setPen(line_color)
        if self.arrows & AxisEnd:
            if not zoom_only or not self.end_arrow_item:
                self.end_arrow_item = QGraphicsPathItem(self.arrow_path, self)
            self.end_arrow_item.setPos(self.graph_line.p2())
            self.end_arrow_item.setRotation(-self.graph_line.angle())
            self.end_arrow_item.setBrush(line_color)
            self.end_arrow_item.setPen(line_color)

        ## Labels

        n = len(self._ticks)
        resize_plot_item_list(self.label_items, n, QGraphicsTextItem, self)
        resize_plot_item_list(self.label_bg_items, n, QGraphicsRectItem, self)
        resize_plot_item_list(self.tick_items, n, QGraphicsLineItem, self)

        test_rect = QRectF(self.graph_line.p1(),  self.graph_line.p2()).normalized()
        test_rect.adjust(-1, -1, 1, 1)

        n_v = self.graph_line.normalVector().unitVector()
        if self.title_above:
            n_p = n_v.p2() - n_v.p1()
        else:
            n_p = n_v.p1() - n_v.p2()
        l_v = self.graph_line.unitVector()
        l_p = l_v.p2() - l_v.p1()
        for i in range(n):
            pos, text, size, step = self._ticks[i]
            hs = 0.5 * step
            tick_pos = self.map_to_graph( pos )
            if not test_rect.contains(tick_pos):
                self.tick_items[i].setVisible(False)
                self.label_items[i].setVisible(False)
                continue
            item = self.label_items[i]
            item.setVisible(True)
            if not zoom_only:
                if self.id in XAxes or getattr(self, 'is_horizontal', False):
                    item.setHtml( '<center>' + Qt.escape(text.strip()) + '</center>')
                else:
                    item.setHtml(Qt.escape(text.strip()))

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

示例7: calcArrow

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import angle [as 别名]
def calcArrow(srcdes_list,itemignoreZooming,iconScale):
    ''' if PoolItem then boundingrect should be background rather than graphicsobject '''
    src = srcdes_list[0]
    des = srcdes_list[1]
    endtype = srcdes_list[2]
    order = srcdes_list[3]
    # print("Source => ", src)
    compartment = src.parentItem()
    srcobj = src.gobj
    desobj = des.gobj
    if isinstance(src,PoolItem):
        srcobj = src.bg
    if isinstance(des,PoolItem):
        desobj = des.bg
            
    # if itemignoreZooming:
    #     srcRect = self.recalcSceneBoundingRect(srcobj)
    #     desRect = self.recalcSceneBoundingRect(desobj)
    # else:
    srcRect = compartment.mapFromScene(srcobj.sceneBoundingRect()).boundingRect()
    desRect = compartment.mapFromScene(desobj.sceneBoundingRect()).boundingRect()
    arrow = QPolygonF()
    if srcRect.intersects(desRect):                
        ''' This is created for getting a emptyline reference \
            because 'lineCord' function keeps a reference between qgraphicsline and its src and des
        '''
        arrow.append(QPointF(0,0))
        arrow.append(QPointF(0,0))
        return arrow
    if (order == 0):
        tmpLine = QLineF(srcRect.center().x(),
                                srcRect.center().y(),
                                desRect.center().x(),
                                desRect.center().y())
    elif(order > 0):
        dx = desRect.center().x()- srcRect.center().x()
        dy = desRect.center().y()- srcRect.center().y()
        dx0 = dy
        dy0 = -dx
        tetha1 = (math.atan2(dy0,dx0))
        a0 = 4 *(math.cos(tetha1))
        b0 = 4 *(math.sin(tetha1))
        ''' Higher order ( > 4) connectivity will not be done'''
        if ((order == 3) or (order == 4)):
            a0 = a0*2
            b0 = b0*2
        if(order %2 == 0):
            srcCentera0 = srcRect.center().x()-a0
            srcCenterb0 = srcRect.center().y()-b0
            desCentera0 = desRect.center().x()-a0
            desCenterb0 = desRect.center().y()-b0
        else:
            srcCentera0 = srcRect.center().x()+a0
            srcCenterb0 = srcRect.center().y()+b0
            desCentera0 = desRect.center().x()+a0
            desCenterb0 = desRect.center().y()+b0
        pointa = QPointF(srcCentera0,srcCenterb0)
        pointb = QPointF(desCentera0,desCenterb0)
        tmpLine = QLineF(srcCentera0,srcCenterb0,desCentera0,desCenterb0)

    srcIntersects, lineSrcPoint = calcLineRectIntersection(srcRect, tmpLine)
    destIntersects, lineDestPoint = calcLineRectIntersection(desRect, tmpLine)

    if not srcIntersects:
        print 'Source does not intersect line. Arrow points:',lineSrcPoint,src.mobj.name, src.mobj.className
    if not destIntersects:
        print 'Dest does not intersect line. Arrow points:', lineDestPoint,  des.mobj.name, des.mobj.className

    '''src and des are connected with line co-ordinates
       Arrow head is drawned if the distance between src and des line is >8 just for clean appeareance
    '''
    if (abs(lineSrcPoint.x()-lineDestPoint.x()) > 8 or abs(lineSrcPoint.y()-lineDestPoint.y())>8):
        srcAngle = tmpLine.angle()
        if endtype == 'p' or endtype == 'stp':
            ''' Arrow head for Destination is calculated'''
            arrow.append(lineSrcPoint)
            arrow.append(lineDestPoint)
            degree = -60
            srcXArr1,srcYArr1= arrowHead(srcAngle,degree,lineDestPoint,iconScale)
            arrow.append(QPointF(srcXArr1,srcYArr1))
            arrow.append(QPointF(lineDestPoint.x(),lineDestPoint.y()))
                
            degree = -120
            srcXArr2,srcYArr2 = arrowHead(srcAngle,degree,lineDestPoint,iconScale)
            arrow.append(QPointF(srcXArr2,srcYArr2))                    
            arrow.append(QPointF(lineDestPoint.x(),lineDestPoint.y()))
 
        elif endtype == 'st':
            ''' Arrow head for Source is calculated'''
            arrow.append(lineDestPoint)
            arrow.append(lineSrcPoint)
            degree = 60
            srcXArr2,srcYArr2 = arrowHead(srcAngle,degree,lineSrcPoint,iconScale)
            arrow.append(QPointF(srcXArr2,srcYArr2))                    
            arrow.append(QPointF(lineSrcPoint.x(),lineSrcPoint.y()))

            degree = 120
            srcXArr1,srcYArr1= arrowHead(srcAngle,degree,lineSrcPoint,iconScale)
            arrow.append(QPointF(srcXArr1,srcYArr1))
            arrow.append(QPointF(lineSrcPoint.x(),lineSrcPoint.y()))
#.........这里部分代码省略.........
开发者ID:NeuroArchive,项目名称:moose,代码行数:103,代码来源:kkitCalcArrow.py


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