本文整理汇总了Python中PyQt4.QtCore.QLineF.setAngle方法的典型用法代码示例。如果您正苦于以下问题:Python QLineF.setAngle方法的具体用法?Python QLineF.setAngle怎么用?Python QLineF.setAngle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QLineF
的用法示例。
在下文中一共展示了QLineF.setAngle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dummyLine
# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import setAngle [as 别名]
def dummyLine(self, angle=None, length=None):
if angle is not None and length is not None:
pt1 = QLineF(QPointF(0.0, 0.0), QPointF(0.0, 1.0))
pt1.setAngle(angle)
pt1.setLength(length + 16)
self.__dummyLine = pt1
return
self.__dummyLine = QLineF()
示例2: getLines
# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import setAngle [as 别名]
def getLines(self, count, opposite=False):
angleOffset = 25
inputLines = []
startAngle = QLineF(QPointF(0.0, 0.0), self.boundingRect().topRight()).angle() + angleOffset
endAngle = QLineF(QPointF(0.0, 0.0), self.boundingRect().topLeft()).angle() - angleOffset
if opposite:
startAngle = QLineF(QPointF(0.0, 0.0), self.boundingRect().bottomLeft()).angle() + angleOffset
endAngle = QLineF(QPointF(0.0, 0.0), self.boundingRect().bottomRight()).angle() - angleOffset
step = (endAngle - startAngle) / (count - 1)
for x in range(0, count):
tLine = QLineF(QPointF(0.0, 0.0), QPointF(0, 100))
tLine.setAngle(startAngle)
inputLines.append(tLine)
startAngle += step
return inputLines
示例3: paintArc
# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import setAngle [as 别名]
def paintArc(self, painter, option, widget):
assert self.source is self.dest
node = self.source
def best_angle():
"""...is the one furthest away from all other angles"""
angles = [
QLineF(node.pos(), other.pos()).angle()
for other in chain(
(edge.source for edge in node.edges if edge.dest == node and edge.source != node),
(edge.dest for edge in node.edges if edge.dest != node and edge.source == node),
)
]
angles.sort()
if not angles: # If this self-constraint is the only edge
return 225
deltas = np.array(angles[1:] + [360 + angles[0]]) - angles
return (angles[deltas.argmax()] + deltas.max() / 2) % 360
angle = best_angle()
inf = QPointF(-1e20, -1e20) # Doesn't work with real -np.inf!
line0 = QLineF(node.pos(), inf)
line1 = QLineF(node.pos(), inf)
line2 = QLineF(node.pos(), inf)
line0.setAngle(angle)
line1.setAngle(angle - 13)
line2.setAngle(angle + 13)
p0 = shape_line_intersection(node.shape(), node.pos(), line0)
p1 = shape_line_intersection(node.shape(), node.pos(), line1)
p2 = shape_line_intersection(node.shape(), node.pos(), line2)
path = QtGui.QPainterPath()
path.moveTo(p1)
line = QLineF(node.pos(), p0)
line.setLength(3 * line.length())
pt = line.p2()
path.quadTo(pt, p2)
line = QLineF(node.pos(), pt)
self.setLine(line) # This invalidates DeviceCoordinateCache
painter.drawPath(path)
# Draw arrow head
line = QLineF(pt, p2)
self.arrowHead.clear()
for point in self._arrowhead_points(line):
self.arrowHead.append(point)
painter.setBrush(self.pen().color())
painter.drawPolygon(self.arrowHead)
# Update label position
self.label.setPos(path.pointAtPercent(0.5))
if 90 < angle < 270: # Right-align the label
pos = self.label.pos()
x, y = pos.x(), pos.y()
self.label.setPos(x - self.label.boundingRect().width(), y)
self.squares.placeBelow(self.label)
示例4: update
# 需要导入模块: from PyQt4.QtCore import QLineF [as 别名]
# 或者: from PyQt4.QtCore.QLineF import setAngle [as 别名]
#.........这里部分代码省略.........
self.title_item.setRotation(-self.graph_line.angle())
c = self.title_item.mapToParent(self.title_item.boundingRect().center())
tl = self.title_item.mapToParent(self.title_item.boundingRect().topLeft())
self.title_item.setPos(title_pos - c + tl)
## Arrows
if not zoom_only:
if self.start_arrow_item:
self.scene().removeItem(self.start_arrow_item)
self.start_arrow_item = None
if self.end_arrow_item:
self.scene().removeItem(self.end_arrow_item)
self.end_arrow_item = None
if self.arrows & AxisStart:
if not zoom_only or not self.start_arrow_item:
self.start_arrow_item = QGraphicsPathItem(self.arrow_path, self)
self.start_arrow_item.setPos(self.graph_line.p1())
self.start_arrow_item.setRotation(-self.graph_line.angle() + 180)
self.start_arrow_item.setBrush(line_color)
self.start_arrow_item.setPen(line_color)
if self.arrows & AxisEnd:
if not zoom_only or not self.end_arrow_item:
self.end_arrow_item = QGraphicsPathItem(self.arrow_path, self)
self.end_arrow_item.setPos(self.graph_line.p2())
self.end_arrow_item.setRotation(-self.graph_line.angle())
self.end_arrow_item.setBrush(line_color)
self.end_arrow_item.setPen(line_color)
## Labels
n = len(self._ticks)
resize_plot_item_list(self.label_items, n, QGraphicsTextItem, self)
resize_plot_item_list(self.label_bg_items, n, QGraphicsRectItem, self)
resize_plot_item_list(self.tick_items, n, QGraphicsLineItem, self)
test_rect = QRectF(self.graph_line.p1(), self.graph_line.p2()).normalized()
test_rect.adjust(-1, -1, 1, 1)
n_v = self.graph_line.normalVector().unitVector()
if self.title_above:
n_p = n_v.p2() - n_v.p1()
else:
n_p = n_v.p1() - n_v.p2()
l_v = self.graph_line.unitVector()
l_p = l_v.p2() - l_v.p1()
for i in range(n):
pos, text, size, step = self._ticks[i]
hs = 0.5 * step
tick_pos = self.map_to_graph( pos )
if not test_rect.contains(tick_pos):
self.tick_items[i].setVisible(False)
self.label_items[i].setVisible(False)
continue
item = self.label_items[i]
item.setVisible(True)
if not zoom_only:
if self.id in XAxes or getattr(self, 'is_horizontal', False):
item.setHtml( '<center>' + Qt.escape(text.strip()) + '</center>')
else:
item.setHtml(Qt.escape(text.strip()))
item.setTextWidth(-1)
text_angle = 0
if dense_text:
w = min(item.boundingRect().width(), self.max_text_width)
item.setTextWidth(w)
if self.title_above:
label_pos = tick_pos + n_p * (w + self.text_margin) + l_p * item.boundingRect().height()/2
else:
label_pos = tick_pos + n_p * self.text_margin + l_p * item.boundingRect().height()/2
text_angle = -90 if self.title_above else 90
else:
w = min(item.boundingRect().width(), QLineF(self.map_to_graph(pos - hs), self.map_to_graph(pos + hs) ).length())
label_pos = tick_pos + n_p * self.text_margin - l_p * w/2
item.setTextWidth(w)
if not self.always_horizontal_text:
if self.title_above:
item.setRotation(-self.graph_line.angle() - text_angle)
else:
item.setRotation(self.graph_line.angle() - text_angle)
item.setPos(label_pos)
item.setDefaultTextColor(text_color)
self.label_bg_items[i].setRect(item.boundingRect())
self.label_bg_items[i].setPen(QPen(Qt.NoPen))
self.label_bg_items[i].setBrush(self.plot.color(OWPalette.Canvas))
item = self.tick_items[i]
item.setVisible(True)
tick_line = QLineF(v)
tick_line.translate(-tick_line.p1())
tick_line.setLength(size)
if self.title_above:
tick_line.setAngle(tick_line.angle() + 180)
item.setLine( tick_line )
item.setPen(line_color)
item.setPos(self.map_to_graph(pos))