本文整理汇总了Python中AnyQt.QtCore.QRectF.contains方法的典型用法代码示例。如果您正苦于以下问题:Python QRectF.contains方法的具体用法?Python QRectF.contains怎么用?Python QRectF.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtCore.QRectF
的用法示例。
在下文中一共展示了QRectF.contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setLine
# 需要导入模块: from AnyQt.QtCore import QRectF [as 别名]
# 或者: from AnyQt.QtCore.QRectF import contains [as 别名]
def setLine(self, line):
"""
Set the arrow base line (a `QLineF` in object coordinates).
"""
if self.__line != line:
self.__line = QLineF(line)
# local item coordinate system
geom = self.geometry().translated(-self.pos())
if geom.isNull() and not line.isNull():
geom = QRectF(0, 0, 1, 1)
arrow_shape = arrow_path_concave(line, self.lineWidth())
arrow_rect = arrow_shape.boundingRect()
if not (geom.contains(arrow_rect)):
geom = geom.united(arrow_rect)
if self.__autoAdjustGeometry:
# Shrink the geometry if required.
geom = geom.intersected(arrow_rect)
# topLeft can move changing the local coordinates.
diff = geom.topLeft()
line = QLineF(line.p1() - diff, line.p2() - diff)
self.__arrowItem.setLine(line)
self.__arrowShadowBase.setLine(line)
self.__line = line
# parent item coordinate system
geom.translate(self.pos())
self.setGeometry(geom)
示例2: adjustGeometry
# 需要导入模块: from AnyQt.QtCore import QRectF [as 别名]
# 或者: from AnyQt.QtCore.QRectF import contains [as 别名]
def adjustGeometry(self):
"""
Adjust the widget geometry to exactly fit the arrow inside
while preserving the arrow path scene geometry.
"""
# local system coordinate
geom = self.geometry().translated(-self.pos())
line = self.__line
arrow_rect = self.__arrowItem.shape().boundingRect()
if geom.isNull() and not line.isNull():
geom = QRectF(0, 0, 1, 1)
if not (geom.contains(arrow_rect)):
geom = geom.united(arrow_rect)
geom = geom.intersected(arrow_rect)
diff = geom.topLeft()
line = QLineF(line.p1() - diff, line.p2() - diff)
geom.translate(self.pos())
self.setGeometry(geom)
self.setLine(line)
示例3: update
# 需要导入模块: from AnyQt.QtCore import QRectF [as 别名]
# 或者: from AnyQt.QtCore.QRectF import contains [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()))
#.........这里部分代码省略.........