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


Python QLineF.pointAt方法代码示例

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


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

示例1: getPoints

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import pointAt [as 别名]
    def getPoints(self, count, opposite=False):
        result = []

        line = QLineF(self.__polygon.boundingRect().topLeft(), self.__polygon.boundingRect().topRight())

        if opposite:
            line = QLineF(self.__polygon.boundingRect().bottomLeft(), self.__polygon.boundingRect().bottomRight())

        step = 1.0 / (count + 1)
        currentStep = step

        for x in range(0, count):
            result.append(line.pointAt(currentStep))
            currentStep += step

        return result
开发者ID:feeling1982113,项目名称:edd,代码行数:18,代码来源:epoint.py

示例2: paint

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import pointAt [as 别名]
    def paint(self, painter, option, widget=None):
        color, _ = Edge.Color.SELECTED if self.selected else Edge.Color.DEFAULT
        pen = self.pen()
        pen.setColor(color)
        pen.setBrush(QBrush(color))
        pen.setWidth(np.clip(2 * self.weight(), .5, 4))
        painter.setPen(pen)
        self.setPen(pen)

        if self.source == self.dest:
            return self.paintArc(painter, option, widget)
        if self.source.collidesWithItem(self.dest):
            return

        have_two_edges = len([edge for edge in self.source.edges
                              if self.source in edge and self.dest in edge and edge is not self])

        source_pos = self.source.pos()
        dest_pos = self.dest.pos()

        color = self.pen().color()
        painter.setBrush(color)

        point = shape_line_intersection(self.dest.shape(), dest_pos,
                                        QLineF(source_pos, dest_pos))
        line = QLineF(source_pos, point)
        if have_two_edges:
            normal = line.normalVector()
            normal.setLength(15)
            line = QLineF(normal.p2(), point)
            self.label.setPos(line.pointAt(.5))
            self.squares.placeBelow(self.label)

        self.setLine(line)
        painter.drawLine(line)

        # Draw arrow head
        self.arrowHead.clear()
        for point in self._arrowhead_points(line):
            self.arrowHead.append(point)
        painter.drawPolygon(self.arrowHead)
开发者ID:strategist922,项目名称:orange3-datafusion,代码行数:43,代码来源:graphview.py

示例3: Line

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import pointAt [as 别名]
class Line( QGraphicsLineItem ):
    """Defines a line by two points. If points are moved, line follows these movements."""
    
    def __init__( self, startPoint, endPoint, ccs, paintToBorder = False, showIncline = False, color = 'orange', minLength = 0 ):
        super( Line, self ).__init__( ccs )
        
        self.startPoint     = startPoint
        self.endPoint       = endPoint
        self.ccs            = ccs
        self.paintToBorder  = paintToBorder
        self.showIncline    = showIncline
        self.color          = color
        
        self.visible        = True
        
        # by default we only want to draw lines if its two
        # defining points are not too close together
        self.drawAlways     = False
        self.minLength      = minLength # pixel
        
        # grmbl. Line was designed to be defined by two Point.Points. Now I want to be able to define
        # lines as well from QPointFs. 
        try:
            self.Rect = QRectF( self.startPoint.x, self.startPoint.y, self.endPoint.x, self.endPoint.y )
        except:
            self.Rect = QRectF( self.startPoint.x(), self.startPoint.y(), self.endPoint.x(), self.endPoint.y() )

    def boundingRect( self ):
        return self.Rect

    def paint( self, painter, option, widget=None ):
        if self.visible == True:
            painter.setPen( QColor( self.color ) )
            
            # see try-catch (pardon me) above
            try:
                self.sp = CST.toCcsCoord( self.ccs, self.startPoint.x, self.startPoint.y )
                self.ep = CST.toCcsCoord( self.ccs, self.endPoint.x, self.endPoint.y )
            except:
                self.sp = CST.toCcsCoord( self.ccs, self.startPoint.x(), self.startPoint.y() )
                self.ep = CST.toCcsCoord( self.ccs, self.endPoint.x(), self.endPoint.y() )
            
            self.Rect = QRectF( self.sp, self.ep )
            self.line = QLineF( self.sp, self.ep )
            
            if self.line.length() > self.minLength or self.drawAlways == True:
                
                painter.drawLine( self.line )
            
                if self.paintToBorder == True:

                    # paint line to approximately the edge of the ccs.
                    ep2 = self.line.pointAt( self.ccs.width / self.line.length() * 2)
                    painter.drawLine(self.ep,ep2)
                    sp2 = self.line.pointAt(-self.ccs.width / self.line.length() * 2)
                    painter.drawLine(self.sp,sp2)
            
                if self.showIncline == True:
                    incline = ( self.endPoint.y - self.startPoint.y ) / ( self.endPoint.x - self.startPoint.x )
                    # print text limited to 2 decimal digits.
                    painter.setBackground ( QBrush ( QColor( 'lightGrey' ) ) )
                    painter.setBackgroundMode (Qt.BGMode(1))
                    painter.setPen( QColor( 'black' ) )
                    #~ painter.drawText( self.ep.x() + 10, self.ep.y() + 10, QString ( '%.2f' %(incline) ) )
                
    def setVisible( self, value ):
        self.visible = value
        
    def setPosition( self, startPoint, endPoint ):
        self.startPoint = startPoint
        self.endPoint   = endPoint
        
    def updateYourself( self, xDelta, yDelta ):
        # There is no action needed, as a line gets its information
        # from startPoint and endPoint
        # Just adjust self.Rect to avoid case where line disappears mysteriously and after then,
        # paint() is never called again
        self.Rect = QRectF( self.startPoint.x, self.startPoint.y, self.endPoint.x, self.endPoint.y )
开发者ID:maettu,项目名称:ala,代码行数:80,代码来源:Line.py

示例4: adjust

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import pointAt [as 别名]
 def adjust(self):
     line = QLineF(self.mapFromItem(self.source, 0, 0),
                   self.mapFromItem(self.dest, 0, 0))
     self.label.setPos(line.pointAt(.5))
     self.setLine(self.__transform().map(line))
开发者ID:biolab,项目名称:orange3-network,代码行数:7,代码来源:graphview.py

示例5: __getSelectedCenter

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import pointAt [as 别名]
    def __getSelectedCenter(self):
        tLine = QLineF(self.__selected.mapToScene(self.__selected.boundingRect().topLeft()),
                       self.__selected.mapToScene(self.__selected.boundingRect().topRight()))

        return tLine.pointAt(0.5)
开发者ID:kishxn,项目名称:edd,代码行数:7,代码来源:escene.py

示例6: adjust

# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import pointAt [as 别名]
 def adjust(self):
     line = QLineF(self.source.pos(), self.dest.pos())
     self.setLine(line)
     self.label.setPos(line.pointAt(.5) - self.label.boundingRect().center())
     self.squares.placeBelow(self.label)
开发者ID:strategist922,项目名称:orange3-datafusion,代码行数:7,代码来源:graphview.py


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