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
示例#2
0
    def wheelEvent(self, event: QWheelEvent) -> None:
        """Switch function by mouse wheel.

        + Set zoom bar value.
        + Set select mode.
        """
        p = event.angleDelta()
        if QApplication.keyboardModifiers() == Qt.ShiftModifier:
            value = p.y()
        elif p.x() != 0:
            value = p.x()
        elif p.y() != 0:
            value = self.prefer.scale_factor_option * (1 if p.y() > 0 else -1)
            value += self.zoom_value()
            self.set_zoom_bar(value)
            return
        else:
            return
        tags = ("Points", "Links")
        mode = (self.selection_mode() + (-1 if value > 0 else 1)) % len(tags)
        self.selection_mode_wheel(mode)
        QToolTip.showText(event.globalPos(), f"Selection mode: {tags[mode]}", self)
        event.accept()