本文整理汇总了Python中PyQt5.QtCore.QLineF.angleTo方法的典型用法代码示例。如果您正苦于以下问题:Python QLineF.angleTo方法的具体用法?Python QLineF.angleTo怎么用?Python QLineF.angleTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QLineF
的用法示例。
在下文中一共展示了QLineF.angleTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setActive5p
# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import angleTo [as 别名]
def setActive5p(self, is_active, neighbor_item=None):
"""Summary
Args:
is_active (TYPE): Description
neighbor_item (None, optional): Description
"""
phos = self.phos_item
bond = self.bond_3p
if bond is None:
return
if not self.is_active5p and is_active:
self.pre_xover_item_group.virtual_helix_item.setZValue(styles.ZGRIDHELIX + 10)
self.is_active5p = True
if neighbor_item is not None:
n_scene_pos = neighbor_item.scenePos()
p2 = self.mapFromScene(n_scene_pos)
bline = bond.line()
test = QLineF(bline.p1(), p2)
# angle = test.angleTo(bline) + self.theta0 if self.is_fwd else -bline.angleTo(test) + self.theta0
angle = -bline.angleTo(test) + self.theta0 if self.is_fwd else test.angleTo(bline) + self.theta0
else:
p2 = self._active_p2_3p
angle = -90 if self.is_fwd else 90
self.animate(phos, 'rotation', 300, self.theta0, angle)
self.animate(bond, 'bondp2', 300, self._default_p2_3p, p2)
elif self.is_active5p:
self.pre_xover_item_group.virtual_helix_item.setZValue(styles.ZGRIDHELIX)
self.is_active5p = False
self.animate(phos, 'rotation', 300, phos.rotation(), self.theta0)
self.animate(bond, 'bondp2', 300, bond.line().p2(), self._default_p2_3p)
示例2: findNearestPoint
# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import angleTo [as 别名]
def findNearestPoint(self, part_item, target_scenepos):
"""
Args:
part_item (TYPE): Description
target_scenepos (TYPE): Description
"""
li = self._line_item
pos = li.mapFromScene(target_scenepos)
line = li.line()
mouse_point_vec = QLineF(self._CENTER_OF_HELIX, pos)
# Check if the click happened on the origin VH
if mouse_point_vec.length() < self._RADIUS:
# return part_item.mapFromScene(target_scenepos)
return None
angle_min = 9999
direction_min = None
for vector in self.vectors:
angle_new = mouse_point_vec.angleTo(vector)
if angle_new < angle_min:
direction_min = vector
angle_min = angle_new
if direction_min is not None:
li.setLine(direction_min)
return part_item.mapFromItem(li, direction_min.p2())
else:
print("default point")
line.setP2(pos)
li.setLine(line)
return part_item.mapFromItem(li, pos)