def __init__(self, timeStamps=None, names=True, granularity=2, *args):
     QwtScaleDraw.__init__(self, *args)
     self.timeStamps = timeStamps
     self.fmtFull = '%H:%M:%S\n%Y-%m-%d'
     self.fmtTime = '%H:%M:%S'
     self.granularity = granularity
     self.names = names
示例#2
0
 def __init__(self, masterAxis, slaveAxis):
     """Valid input values for masterAxis and slaveAxis are QwtPlot.yLeft,
     QwtPlot.yRight, QwtPlot.xBottom, and QwtPlot.xTop. When masterAxis is
     an x-axis, slaveAxis must be an y-axis; and vice versa."""
     QwtPlotItem.__init__(self)
     self.__axis = masterAxis
     if masterAxis in (QwtPlot.yLeft, QwtPlot.yRight):
         self.setAxes(slaveAxis, masterAxis)
     else:
         self.setAxes(masterAxis, slaveAxis)
     self.scaleDraw = QwtScaleDraw()
     self.scaleDraw.setAlignment((QwtScaleDraw.LeftScale,
                                  QwtScaleDraw.RightScale,
                                  QwtScaleDraw.BottomScale,
                                  QwtScaleDraw.TopScale)[masterAxis])
 def __init__(self, start_value=None, end_value=None, divisor=None):
     QwtScaleDraw.__init__(self)
     self.do_separator = True
     self.start_value = start_value
     self.end_value = end_value
     self.divisor = divisor
     if not self.start_value is None and not self.end_value is None:
         self.delta = self.end_value - self.start_value
         self.separator = self.end_value
         self.divisor = None
     else:
         self.separator = self.divisor
         self.delta = None
         self.start_value = None
         self.end_value = None
 def label(self, v):
     """ Override default QwtScaleDraw generation of labels along axis """
     if not self.end_value is None:
         if v >= self.end_value:
             v = v - self.delta
     else:
         if not self.divisor is None:
             v = v % self.divisor
     return QwtScaleDraw.label(self, v)
示例#5
0
 def __init__(self, masterAxis, slaveAxis):
     """Valid input values for masterAxis and slaveAxis are QwtPlot.yLeft,
     QwtPlot.yRight, QwtPlot.xBottom, and QwtPlot.xTop. When masterAxis is
     an x-axis, slaveAxis must be an y-axis; and vice versa."""
     QwtPlotItem.__init__(self)
     self.__axis = masterAxis
     if masterAxis in (QwtPlot.yLeft, QwtPlot.yRight):
         self.setAxes(slaveAxis, masterAxis)
     else:
         self.setAxes(masterAxis, slaveAxis)
     self.scaleDraw = QwtScaleDraw()
     self.scaleDraw.setAlignment((QwtScaleDraw.LeftScale,
                                  QwtScaleDraw.RightScale,
                                  QwtScaleDraw.BottomScale,
                                  QwtScaleDraw.TopScale)[masterAxis])
 def __init__(self, baseTime, *args):
     QwtScaleDraw.__init__(self, *args)
     self.baseTime = baseTime
示例#7
0
class CartesianAxis(QwtPlotItem):
    """Supports a coordinate system similar to 
    http://en.wikipedia.org/wiki/Image:Cartesian-coordinate-system.svg"""

    def __init__(self, masterAxis, slaveAxis):
        """Valid input values for masterAxis and slaveAxis are QwtPlot.yLeft,
        QwtPlot.yRight, QwtPlot.xBottom, and QwtPlot.xTop. When masterAxis is
        an x-axis, slaveAxis must be an y-axis; and vice versa."""
        QwtPlotItem.__init__(self)
        self.__axis = masterAxis
        if masterAxis in (QwtPlot.yLeft, QwtPlot.yRight):
            self.setAxes(slaveAxis, masterAxis)
        else:
            self.setAxes(masterAxis, slaveAxis)
        self.scaleDraw = QwtScaleDraw()
        self.scaleDraw.setAlignment(
            (QwtScaleDraw.LeftScale, QwtScaleDraw.RightScale, QwtScaleDraw.BottomScale, QwtScaleDraw.TopScale)[
                masterAxis
            ]
        )

    def draw(self, painter, xMap, yMap, rect):
        """Draw an axis on the plot canvas"""
        xtr = xMap.transform
        ytr = yMap.transform
        if self.__axis in (QwtPlot.yLeft, QwtPlot.yRight):
            self.scaleDraw.move(round(xtr(0.0)), yMap.p2())
            self.scaleDraw.setLength(yMap.p1() - yMap.p2())
        elif self.__axis in (QwtPlot.xBottom, QwtPlot.xTop):
            self.scaleDraw.move(xMap.p1(), round(ytr(0.0)))
            self.scaleDraw.setLength(xMap.p2() - xMap.p1())
        self.scaleDraw.setScaleDiv(self.plot().axisScaleDiv(self.__axis))
        self.scaleDraw.draw(painter, self.plot().palette())
示例#8
0
class CartesianAxis(QwtPlotItem):
    """Supports a coordinate system similar to 
    http://en.wikipedia.org/wiki/Image:Cartesian-coordinate-system.svg"""

    def __init__(self, masterAxis, slaveAxis):
        """Valid input values for masterAxis and slaveAxis are QwtPlot.yLeft,
        QwtPlot.yRight, QwtPlot.xBottom, and QwtPlot.xTop. When masterAxis is
        an x-axis, slaveAxis must be an y-axis; and vice versa."""
        QwtPlotItem.__init__(self)
        self.__axis = masterAxis
        if masterAxis in (QwtPlot.yLeft, QwtPlot.yRight):
            self.setAxes(slaveAxis, masterAxis)
        else:
            self.setAxes(masterAxis, slaveAxis)
        self.scaleDraw = QwtScaleDraw()
        self.scaleDraw.setAlignment(
            (
                QwtScaleDraw.LeftScale,
                QwtScaleDraw.RightScale,
                QwtScaleDraw.BottomScale,
                QwtScaleDraw.TopScale,
            )[masterAxis]
        )

    def draw(self, painter, xMap, yMap, rect):
        """Draw an axis on the plot canvas"""
        xtr = xMap.transform
        ytr = yMap.transform
        if self.__axis in (QwtPlot.yLeft, QwtPlot.yRight):
            self.scaleDraw.move(round(xtr(0.0)), yMap.p2())
            self.scaleDraw.setLength(yMap.p1() - yMap.p2())
        elif self.__axis in (QwtPlot.xBottom, QwtPlot.xTop):
            self.scaleDraw.move(xMap.p1(), round(ytr(0.0)))
            self.scaleDraw.setLength(xMap.p2() - xMap.p1())
        self.scaleDraw.setScaleDiv(self.plot().axisScaleDiv(self.__axis))
        self.scaleDraw.draw(painter, self.plot().palette())
示例#9
0
 def __init__(self):
     QwtScaleDraw.__init__(self)
示例#10
0
 def __init__(self, baseTime, *args):
     QwtScaleDraw.__init__(self, *args)
     self.baseTime = baseTime
    def draw(self, painter, dummy):
        # for some reason, in qwt 5 an extra parameter is needed
        # in the above function definition. The corresponding
        # C++ code offers several possibilities, but just a 'dummy'
        # seems adequate ....
        # 1. paint real value ticks as done in C++ code
        # 2. paint imag value ticks with the shift depending on
        #    the dimension and tick spacing
        # 3. draw backbone, if needed

        step_eps = 1.0e-6  # constant value in the c++ equivalent
        majLen = QwtScaleDraw.tickLength(self, QwtScaleDiv.MajorTick)
        medLen = QwtScaleDraw.tickLength(self, QwtScaleDiv.MediumTick)
        minLen = QwtScaleDraw.tickLength(self, QwtScaleDiv.MinorTick)
        #print('majLen medLen ', majLen, ' ', medLen, ' ', minLen)
        #print('lengths ', majLen,' ', medLen,' ', minLen)
        self.offset = 0
        scldiv = QwtScaleDraw.scaleDiv(self)
        # plot major ticks
        # Sometimes, for reasons deep inside Qwt, major_ticks seems to be
        # returned as a null list for reasons I don't understand
        major_ticks = scldiv.ticks(QwtScaleDiv.MajorTick)
        #print('major ticks ', major_ticks)
        major_step = 0.0
        try:
            major_step = major_ticks[1] - major_ticks[0]
        except:
            pass
        major_count = len(major_ticks)
        for i in range(major_count):
            val = major_ticks[i]
            #print('initial major val = ', val)
            if not self.end_value is None:
                v = val
                if val >= self.end_value:
                    v = val - self.delta
            else:
                if not self.divisor is None:
                    v = val % self.divisor
            if self.offset == 0 and v != val:
                self.offset = major_step - v % major_step
            val = val + self.offset
            #print('final major val = ', val)
            QwtScaleDraw.drawTick(self, painter, val, minLen)
            QwtScaleDraw.drawLabel(self, painter, val)

        # also, optionally plot a major tick at the dividing point
        if self.do_separator:
            QwtScaleDraw.drawTick(self, painter, self.separator, majLen)
            QwtScaleDraw.drawLabel(self, painter, self.separator)

        # Sometimes, for reasons deep inside Qwt, minor_ticks seems to be
        # returned as a null list for reasons I don't understand
        minor_ticks = scldiv.ticks(QwtScaleDiv.MinorTick)
        minor_step = 0.0
        try:
            minor_step = minor_ticks[1] - minor_ticks[0]
        except:
            pass
        minor_count = len(minor_ticks)

        # can't handle logs properly, but so what?
        #       if scldiv.logScale():
        #           pass
        #           for i in range(scldiv.minCnt()):
        #               QwtScaleDraw.drawTick(
        #                   self, painter, scldiv.minMark(i), minLen)
        #       else:
        if True:
            minor_ticks = scldiv.ticks(QwtScaleDiv.MinorTick)
            #print('minor ticks ', minor_ticks)
            medium_ticks = scldiv.ticks(QwtScaleDiv.MediumTick)
            #print('medium ticks ', medium_ticks)
            kmax = major_count - 1
            if kmax > 0:
                majTick = major_ticks[0]
                hval = majTick - 0.5 * major_step
                k = 0
                for i in range(minor_count):
                    val = minor_ticks[i]
                    if val > majTick:
                        if k < kmax:
                            k = k + 1
                            majTick = major_ticks[k]
                        else:
                            majTick += (major_ticks[kmax] + major_step)
                        hval = majTick - 0.5 * major_step
                    if abs(val - hval) < step_eps * major_step:
                        QwtScaleDraw.drawTick(self, painter, val, medLen)
                    else:
                        QwtScaleDraw.drawTick(self, painter, val, minLen)

        if QwtScaleDraw.Backbone:
            QwtScaleDraw.drawBackbone(self, painter)