本文整理汇总了Python中AnyQt.QtCore.QRectF.adjust方法的典型用法代码示例。如果您正苦于以下问题:Python QRectF.adjust方法的具体用法?Python QRectF.adjust怎么用?Python QRectF.adjust使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtCore.QRectF
的用法示例。
在下文中一共展示了QRectF.adjust方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from AnyQt.QtCore import QRectF [as 别名]
# 或者: from AnyQt.QtCore.QRectF import adjust [as 别名]
def update(self, zoom_only=False):
self.update_ticks()
line_color = self.plot.color(OWPalette.Axis)
text_color = self.plot.color(OWPalette.Text)
if not self.graph_line or not self.scene():
return
self.line_item.setLine(self.graph_line)
self.line_item.setPen(line_color)
if self.title:
self.title_item.setHtml('<b>' + self.title + '</b>')
self.title_item.setDefaultTextColor(text_color)
if self.title_location == AxisMiddle:
title_p = 0.5
elif self.title_location == AxisEnd:
title_p = 0.95
else:
title_p = 0.05
title_pos = self.graph_line.pointAt(title_p)
v = self.graph_line.normalVector().unitVector()
dense_text = False
if hasattr(self, 'title_margin'):
offset = self.title_margin
elif self._ticks:
if self.should_be_expanded():
offset = 55
dense_text = True
else:
offset = 35
else:
offset = 10
if self.title_above:
title_pos += (v.p2() - v.p1()) * (offset + QFontMetrics(self.title_item.font()).height())
else:
title_pos -= (v.p2() - v.p1()) * offset
## TODO: Move it according to self.label_pos
self.title_item.setVisible(self.show_title)
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()))
#.........这里部分代码省略.........