Exemple #1
0
    def paintEvent(self, event):
        painter = QtGui.QPainter(self)

        width = self.width()
        height = self.height()

        top, bottom = height * .1, height * .8
        left, right = width * .1, width * .8

        rect = QtCore.QRect(left, top, right, bottom)
        painter.fillRect(rect, QtGui.QColor('black'))

        #painter.setWindow(rect)

        dist = bottom - top

        relval = self.threshold.signal.buffer[-1] / self.MAX
        relval = min(1.0, relval)

        reltop = (1.0 - relval) * bottom + top
        relbottom = height * 0.9 - reltop

        rect = QtCore.QRect(left, reltop, right, relbottom)

        color = QtGui.QColor(
            'green' if self.threshold.passfail.buffer[-1] else 'red')
        painter.fillRect(rect, color)

        thr_height = self.threshold.threshold / self.MAX

        thr_top = (1.0 - thr_height) * bottom + top

        rect = QtCore.QRect(left, thr_top, right, 2)
        painter.fillRect(rect, QtGui.QColor('white'))
Exemple #2
0
    def listMouseMoveEvent(self, event):
        pos = event.pos()
        index = self.ui.tableView.indexAt(pos)
        stats = self.getStatsByRow(index.row())
        if not stats:
            return

        # Create candlestick pictures on list mouseover to speed up selection.
        for text in self.getChartsToShow():
            data = stats.dataList[ALL_TIMEFRAMES.index(text)]
            data.calcIndicatorsMakePlots()
            for isVolume in range(2):
                data.createCandlestick(isVolume, self.cg.showTrendBars)

        if event.modifiers() & Qt.ControlModifier:
            # Automatically select the hovered list item, to save clicking.
            self.ui.tableView.setSelection(QtCore.QRect(pos, pos),
                QtGui.QItemSelectionModel.ClearAndSelect |
                QtGui.QItemSelectionModel.Rows)