本文整理汇总了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
示例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)
示例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 )
示例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))
示例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)
示例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)