def wheelEvent(self, event: QWheelEvent):
        '''
        Wheelevent

        Parameters
        ----------
        event : QWheelEvent
        '''
        event.accept()
        direction = event.angleDelta().y()
        horizontal_bar = self.horizontalScrollBar()
        delta = (20 if direction < 0 else -20)
        horizontal_bar.setValue(self.horizontalScrollBar().value() + delta)
Ejemplo n.º 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()
Ejemplo n.º 3
0
    def wheelEvent(self, event: QtGui.QWheelEvent):
        # limit wheelevents to max N events in T seconds to avoid hanging GUI because of zooming in and out non-stop
        PlotArea.wheelEventsCounter = PlotArea.wheelEventsCounter + 1
        # print(PlotArea.wheelEventsCounter)
        if PlotArea.wheelEventsCounter > 3:
            qInfo('Zooming speed limited to optimize performance.')
            return

        super().wheelEvent(event)
        newRange = self.main_vb.viewRange()[0]
        if self.main_window.selectedView is not None:
            maxX = self.main_window.selectedView.panel.get_max_duration()
        else:
            return
        if newRange[-1] > maxX:
            newRange[-1] = maxX
        if newRange[0] < 0:
            newRange[0] = 0
        if newRange[0] == 0:
            self.main_vb.setXRange(newRange[0], newRange[1], padding=0)
        else:
            self.main_vb.setXRange(newRange[0], newRange[1])
        event.accept()
Ejemplo n.º 4
0
    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()
Ejemplo n.º 5
0
 def wheelEvent(self, event: QtGui.QWheelEvent):
     super().wheelEvent(event)
     event.accept()
 def wheelEvent(self, e: QWheelEvent):
     print("myMouseWheel in Item...")
     self.__m_lastMouseWheel = self.__cloneMouseWheelEvent(e)
     self.__m_lastMouseWheel.ignore()
     e.accept()
     self.update()