def wheelEvent(self, event: QWheelEvent) -> None: scale = 1.25 maxZoom = 2 minZoom = 0.5 transform: QTransform = self.transform() zoom = transform.m11() # zoom in and out with the mouse setting origin if (event.angleDelta().y() > 0) and (zoom < maxZoom): self.scale(scale, scale) pos: QPointF = self.mapToScene(event.pos()) self.translate(-(scale - 1) * pos.x(), -(scale - 1) * pos.y()) elif (event.angleDelta().y() < 0) and (zoom > minZoom): self.scale(1 / scale, 1 / scale) pos: QPointF = self.mapToScene(event.pos()) self.translate(-(1 / scale - 1) * pos.x(), -(1 / scale - 1) * pos.y()) event.accept()
def __cloneMouseWheelEvent(self, e: QWheelEvent): pos = e.pos() globalPos = e.globalPos() pixelDelta = e.pixelDelta() angleDelta = e.angleDelta() buttons = e.buttons() modifiers = e.modifiers() phase = e.phase() inverted = e.inverted() clone = QWheelEvent(pos, globalPos, pixelDelta, angleDelta, buttons, modifiers, phase, inverted) clone.ignore() clone.accepted = False return clone
def wheelEvent(self, event: QtGui.QWheelEvent) -> None: cpt = QPoint_to_point(event.pos()) if not event.modifiers(): step = event.angleDelta().y() / 120.0 self.zoom(step, cpt) else: if self.interactionDelegate: step = event.angleDelta().y() / 120.0 if step < 0: step = - step code = EventID.Mouse_WheelDown else: code = EventID.Mouse_WheelUp w_pt = self.viewState.tfV2W(cpt) tool_event = ToolActionEvent(code, cpt, w_pt, step) self.interactionDelegate.tool_event(tool_event) self.update()