本文整理汇总了Python中PyQt5.QtCore.QLineF.translate方法的典型用法代码示例。如果您正苦于以下问题:Python QLineF.translate方法的具体用法?Python QLineF.translate怎么用?Python QLineF.translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QLineF
的用法示例。
在下文中一共展示了QLineF.translate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setWedgeGizmo
# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import translate [as 别名]
def setWedgeGizmo(self, neighbor_virtual_helix: int,
neighbor_virtual_helix_item: GridVirtualHelixItemT):
"""Adds a WedgeGizmo to oriented toward the specified neighbor vhi.
Called by NucleicAcidPartItem _refreshVirtualHelixItemGizmos, in between
with beginAddWedgeGizmos and endAddWedgeGizmos.
Args:
neighbor_virtual_helix: the id_num of neighboring virtual helix
neighbor_virtual_helix_item:
the neighboring virtual helix item
"""
wg_dict = self.wedge_gizmos
nvhi = neighbor_virtual_helix_item
nvhi_name = nvhi.getProperty('name')
pos = self.scenePos()
line = QLineF(pos, nvhi.scenePos())
line.translate(_RADIUS, _RADIUS)
if line.length() > (_RADIUS*1.99):
color = '#5a8bff'
else:
color = '#cc0000'
nvhi_name = nvhi_name + '*' # mark as invalid
line.setLength(_RADIUS)
if neighbor_virtual_helix in wg_dict:
wedge_item = wg_dict[neighbor_virtual_helix]
else:
wedge_item = WedgeGizmo(_RADIUS, WEDGE_RECT, self)
wg_dict[neighbor_virtual_helix] = wedge_item
wedge_item.showWedge(line.angle(), color, outline_only=False)
self._added_wedge_gizmos.add(neighbor_virtual_helix)
示例2: paint
# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import translate [as 别名]
def paint(self, painter, option, widget=None):
if self.my_start_item.collidesWithItem(self.my_end_item):
return
my_start_item = self.my_start_item
my_end_item = self.my_end_item
my_color = self.my_color
my_pen = self.pen()
my_pen.setColor(self.my_color)
arrow_size = 20.0
painter.setPen(my_pen)
painter.setBrush(my_color)
center_line = QLineF(my_start_item.pos(), my_end_item.pos())
end_polygon = my_end_item.polygon
p1 = end_polygon.first() + my_end_item.pos()
intersect_point = QPointF()
for i in end_polygon:
p2 = i + my_end_item.pos()
poly_line = QLineF(p1, p2)
intersect_type = poly_line.intersect(center_line, intersect_point)
if intersect_type == QLineF.BoundedIntersection:
break
p1 = p2
self.setLine(QLineF(intersect_point, my_start_item.pos()))
line = self.line()
angle = math.acos(line.dx() / line.length())
if line.dy() >= 0:
angle = (math.pi * 2) - angle
arrow_p1 = line.p1() + QPointF(math.sin(angle + math.pi / 3.0) * arrow_size,
math.cos(angle + math.pi / 3) * arrow_size)
arrow_p2 = line.p1() + QPointF(math.sin(angle + math.pi - math.pi / 3.0) * arrow_size,
math.cos(angle + math.pi - math.pi / 3.0) * arrow_size)
self.arrowHead.clear()
for point in [line.p1(), arrow_p1, arrow_p2]:
self.arrowHead.append(point)
painter.drawLine(line)
painter.drawPolygon(self.arrowHead)
if self.isSelected():
painter.setPen(QPen(my_color, 1, Qt.DashLine))
my_line = QLineF(line)
my_line.translate(0, 4.0)
painter.drawLine(my_line)
my_line.translate(0, -8.0)
painter.drawLine(my_line)