本文整理汇总了Python中PyQt4.QtCore.QLineF.normalVector方法的典型用法代码示例。如果您正苦于以下问题:Python QLineF.normalVector方法的具体用法?Python QLineF.normalVector怎么用?Python QLineF.normalVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QLineF
的用法示例。
在下文中一共展示了QLineF.normalVector方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paint
# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import normalVector [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)