本文整理汇总了Python中AnyQt.QtWidgets.QGraphicsLineItem.setZValue方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsLineItem.setZValue方法的具体用法?Python QGraphicsLineItem.setZValue怎么用?Python QGraphicsLineItem.setZValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QGraphicsLineItem
的用法示例。
在下文中一共展示了QGraphicsLineItem.setZValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LinePlotViewBox
# 需要导入模块: from AnyQt.QtWidgets import QGraphicsLineItem [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsLineItem import setZValue [as 别名]
class LinePlotViewBox(ViewBox):
selection_changed = Signal(np.ndarray)
def __init__(self):
super().__init__(enableMenu=False)
self._profile_items = None
self._can_select = True
self._graph_state = SELECT
self.setMouseMode(self.PanMode)
pen = mkPen(LinePlotStyle.SELECTION_LINE_COLOR,
width=LinePlotStyle.SELECTION_LINE_WIDTH)
self.selection_line = QGraphicsLineItem()
self.selection_line.setPen(pen)
self.selection_line.setZValue(1e9)
self.addItem(self.selection_line, ignoreBounds=True)
def update_selection_line(self, button_down_pos, current_pos):
p1 = self.childGroup.mapFromParent(button_down_pos)
p2 = self.childGroup.mapFromParent(current_pos)
self.selection_line.setLine(QLineF(p1, p2))
self.selection_line.resetTransform()
self.selection_line.show()
def set_graph_state(self, state):
self._graph_state = state
def enable_selection(self, enable):
self._can_select = enable
def get_selected(self, p1, p2):
if self._profile_items is None:
return np.array(False)
return line_intersects_profiles(np.array([p1.x(), p1.y()]),
np.array([p2.x(), p2.y()]),
self._profile_items)
def add_profiles(self, y):
if sp.issparse(y):
y = y.todense()
self._profile_items = np.array(
[np.vstack((np.full((1, y.shape[0]), i + 1), y[:, i].flatten())).T
for i in range(y.shape[1])])
def remove_profiles(self):
self._profile_items = None
def mouseDragEvent(self, event, axis=None):
if self._graph_state == SELECT and axis is None and self._can_select:
event.accept()
if event.button() == Qt.LeftButton:
self.update_selection_line(event.buttonDownPos(), event.pos())
if event.isFinish():
self.selection_line.hide()
p1 = self.childGroup.mapFromParent(
event.buttonDownPos(event.button()))
p2 = self.childGroup.mapFromParent(event.pos())
self.selection_changed.emit(self.get_selected(p1, p2))
elif self._graph_state == ZOOMING or self._graph_state == PANNING:
event.ignore()
super().mouseDragEvent(event, axis=axis)
else:
event.ignore()
def mouseClickEvent(self, event):
if event.button() == Qt.RightButton:
self.autoRange()
self.enableAutoRange()
else:
event.accept()
self.selection_changed.emit(np.array(False))
def reset(self):
self._profile_items = None
self._can_select = True
self._graph_state = SELECT