本文整理汇总了Python中PyQt5.QtCore.QLineF.angle方法的典型用法代码示例。如果您正苦于以下问题:Python QLineF.angle方法的具体用法?Python QLineF.angle怎么用?Python QLineF.angle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QLineF
的用法示例。
在下文中一共展示了QLineF.angle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setWedgeGizmo
# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import angle [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: image
# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import angle [as 别名]
def image(cls, **kwargs):
"""
Returns an image suitable for the palette.
:rtype: QPixmap
"""
# INITIALIZATION
pixmap = QPixmap(kwargs['w'], kwargs['h'])
pixmap.fill(Qt.transparent)
painter = QPainter(pixmap)
# INIT THE LINE
p1 = QPointF(((kwargs['w'] - 54) / 2), kwargs['h'] / 2)
p2 = QPointF(((kwargs['w'] - 54) / 2) + 54 - 2, kwargs['h'] / 2)
line = QLineF(p1, p2)
# CLACULATE HEAD COORDS
angle = line.angle()
p1 = QPointF(line.p2().x() + 2, line.p2().y())
p2 = p1 - QPointF(sin(angle + M_PI / 3.0) * 8, cos(angle + M_PI / 3.0) * 8)
p3 = p1 - QPointF(sin(angle + M_PI - M_PI / 3.0) * 8, cos(angle + M_PI - M_PI / 3.0) * 8)
# INITIALIZE HEAD
head = QPolygonF([p1, p2, p3])
# DRAW EDGE LINE
painter.setRenderHint(QPainter.Antialiasing)
painter.setPen(QPen(QColor(0, 0, 0), 1.1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
painter.drawLine(line)
# DRAW EDGE HEAD
painter.setPen(QPen(QColor(0, 0, 0), 1.1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
painter.setBrush(QColor(0, 0, 0))
painter.drawPolygon(head)
return pixmap
示例3: image
# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import angle [as 别名]
def image(cls, **kwargs):
"""
Returns an image suitable for the palette.
:rtype: QPixmap
"""
# INITIALIZATION
pixmap = QPixmap(kwargs['w'], kwargs['h'])
pixmap.fill(Qt.transparent)
painter = QPainter(pixmap)
# INITIALIZE EDGE LINE
pp1 = QPointF(((kwargs['w'] - 52) / 2), kwargs['h'] / 2)
pp2 = QPointF(((kwargs['w'] - 52) / 2) + 52 - 2, kwargs['h'] / 2)
line = QLineF(pp1, pp2)
# CALCULATE HEAD COORDINATES
angle = radians(line.angle())
p1 = QPointF(line.p2().x() + 2, line.p2().y())
p2 = p1 - QPointF(sin(angle + M_PI / 3.0) * 8, cos(angle + M_PI / 3.0) * 8)
p3 = p1 - QPointF(sin(angle + M_PI - M_PI / 3.0) * 8, cos(angle + M_PI - M_PI / 3.0) * 8)
# INITIALIZE EDGE HEAD
head = QPolygonF([p1, p2, p3])
# DRAW THE POLYGON
painter.setRenderHint(QPainter.Antialiasing)
painter.setPen(QPen(QColor(0, 0, 0), 1.1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
painter.drawLine(line)
# DRAW HEAD
painter.setPen(QPen(QColor(0, 0, 0), 1.1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
painter.setBrush(QColor(0, 0, 0))
painter.drawPolygon(head)
# DRAW THE TEXT ON TOP OF THE EDGE
space = 2 if Platform.identify() is Platform.Darwin else 0
painter.setFont(Font('Arial', 9, Font.Light))
painter.drawText(pp1.x() + space, (kwargs['h'] / 2) - 4, 'instanceOf')
return pixmap
示例4: mouseMoveEvent
# 需要导入模块: from PyQt5.QtCore import QLineF [as 别名]
# 或者: from PyQt5.QtCore.QLineF import angle [as 别名]
def mouseMoveEvent(self, event):
path, text = self._rulerObject
baseElem = path.elementAt(0)
canvasPos = event.localPos()
if event.modifiers() & Qt.ShiftModifier:
basePos = QPointF(baseElem.x, baseElem.y)
canvasPos = self.clampToOrigin(canvasPos, basePos)
canvasPos = self.magnetPos(canvasPos)
x, y = canvasPos.x(), canvasPos.y()
path.setElementPositionAt(1, x, baseElem.y)
path.setElementPositionAt(2, x, y)
path.setElementPositionAt(3, baseElem.x, baseElem.y)
line = QLineF(baseElem.x, baseElem.y, x, y)
l = line.length()
# angle() doesnt go by trigonometric direction. Weird.
# TODO: maybe split in positive/negative 180s (ff)
a = 360 - line.angle()
line.setP2(QPointF(x, baseElem.y))
h = line.length()
line.setP1(QPointF(x, y))
v = line.length()
text = "%d\n↔ %d\n↕ %d\nα %dº" % (l, h, v, a)
self._rulerObject = (path, text)
self.parent().update()