コード例 #1
0
    def mouseMoveEvent(self, event):
        ##Sets the place of the popup in the windows to avoid getout of the screen
        ##frmshow can be a frmShowCasilla or a frmShowFicha
        def placePopUp():
            resultado = QPoint(event.x() + 15, event.y() + 15)
            if event.x() > self.width() - self.popup.width() - 15:
                resultado.setX(event.x() - self.popup.width() - 15)
            if event.y() > self.height() - self.popup.height() - 15:
                resultado.setY(event.y() - self.popup.height() - 15)
            return resultado

        # ---------------------------------------
        if self.popuplock.tryLock() == False:
            event.reject()
            return
        QChartView.mouseMoveEvent(self, event)
        xVal = self.chart().mapToValue(event.pos()).x()
        yVal = self.chart().mapToValue(event.pos()).y()

        maxX = self.axisX.max()
        minX = self.axisX.min()
        maxY = self.axisY.max()
        minY = self.axisY.min()
        if xVal <= maxX and xVal >= minX and yVal <= maxY and yVal >= minY:
            self.popup.move(self.mapToGlobal(placePopUp()))
            self.popup.refresh(self, xVal, yVal)
        self.popuplock.unlock()
コード例 #2
0
    def mouseMoveEvent(self, event):     
        ##Sets the place of the popup in the windows to avoid getout of the screen
        ##frmshow can be a frmShowCasilla or a frmShowFicha
        def placePopUp():
            resultado=QPoint(event.x()+15, event.y()+15)
            if event.x()>self.width()-self.popup.width()-15:
                resultado.setX(event.x()-self.popup.width()-15)
            if event.y()>self.height()-self.popup.height()-15:
                resultado.setY(event.y()-self.popup.height()-15)
            return resultado
        def showCurrentPosition():
            if hasattr(self, "qgstiCurrentX")==False:
                self.qgstiCurrentX=QGraphicsSimpleTextItem(self.chart())
                self.qgstiCurrentY=QGraphicsSimpleTextItem(self.chart())
            self.qgstiCurrentX.setPos(event.pos().x(), maxY-10)
            self.qgstiCurrentY.setPos(self.chart().size().width()-47, event.pos().y())
            self.qgstiCurrentX.setText(str(epochms2dtaware(xVal).date()))
            self.qgstiCurrentY.setText(str(round(yVal,2)))
        # ---------------------------------------
        QChartView.mouseMoveEvent(self, event)
        xVal = self.chart().mapToValue(event.pos()).x()
        yVal = self.chart().mapToValue(event.pos()).y()

        maxX = self.axisX.max().toMSecsSinceEpoch()
        minX = self.axisX.min().toMSecsSinceEpoch()
        maxY = self.axisY.max()
        minY = self.axisY.min()
        if xVal <= maxX and  xVal >= minX and yVal <= maxY and yVal >= minY:
            self.popup.move(self.mapToGlobal(placePopUp()))
            self.popup.refresh(self, xVal, yVal)
            showCurrentPosition()
            self.popup.show()
        else:
            self.popup.hide()
コード例 #3
0
    def mouseMoveEvent(self, event):
        if event.buttons() == Qt.LeftButton and self.chart():
            newValue = self.mapToScene(event.pos())
            delta = newValue - self.m_lastMousePos

            self.chart().scroll(-delta.x(), 0)

            self.m_lastMousePos = newValue

        QChartView.mouseMoveEvent(self, event)
コード例 #4
0
    def mouseMoveEvent(self, event: QMouseEvent):
        if event.buttons() & Qt.MiddleButton:
            dif_pos = event.pos() - self.__last_mouse_pos

            self.chart().scroll(-dif_pos.x(), dif_pos.y())
            event.accept()

            self.__last_mouse_pos = event.pos()

        QChartView.mouseMoveEvent(self, event)
コード例 #5
0
ファイル: ViewPair.py プロジェクト: sgiy/crypto-trader
    def mouseMoveEvent(self, event):
        self._chart_horizontal_line.setLine(0,
                                            event.pos().y(), self.width(),
                                            event.pos().y())
        self._chart_vertical_line.setLine(event.pos().x(), 0,
                                          event.pos().x(), self.height())

        crosshair_coordinates = self.chart.mapToValue(event.pos(),
                                                      self.chart.series()[0])

        self._chart_crosshair.setPlainText(
            " time:\t{0}\n level:\t{1:.8f}".format(
                datetime.fromtimestamp(
                    int(crosshair_coordinates.x() /
                        1000)).strftime('%Y-%m-%d %H:%M:%S'),
                crosshair_coordinates.y()))

        return QChartView.mouseMoveEvent(self, event)