def __incrementInterval(self): self.__d_interval = Qwt.QwtInterval( self.__d_interval.maxValue(), self.__d_interval.maxValue() + self.__d_interval.width() ) curveData = self.__d_curve.data() curveData.values().clearStaleValues( self.__d_interval.minValue() ) #To avoid, that the grid is jumping, we disable #the autocalculation of the ticks and shift them #manually instead. scaleDiv = self.axisScaleDiv( Qwt.QwtPlot.xBottom ) scaleDiv.setInterval( self.__d_interval ) for i in range( 0, Qwt.QwtScaleDiv.NTickTypes): ticks = scaleDiv.ticks( i ) for j in range(0 , len(ticks)): ticks[j] += self.__d_interval.width() scaleDiv.setTicks( i, ticks ) self.setAxisScaleDiv( Qwt.QwtPlot.xBottom, scaleDiv ) self.__d_origin.setValue( self.__d_interval.minValue() + self.__d_interval.width() / 2.0, 0.0 ) self.__d_paintedPoints = 0 self.replot()
def setValues(self, values): numValues = len(values) #QVector<QwtIntervalSample> samples( numValues ) samples = [] for i in range(numValues): interval = Qwt.QwtInterval(i, i + 1.0) interval.setBorderFlags(Qwt.QwtInterval.ExcludeMaximum) samples.append(Qwt.QwtIntervalSample(values[i], interval)) self.setSamples(samples)
def __init__(self,parent): super().__init__(parent) self.__d_interval = Qwt.QwtInterval( 0.0, 10.0 ) self.__d_timerId = -1 self.__d_directPainter = Qwt.QwtPlotDirectPainter() self.__d_clock = Qwt.QwtSystemClock() self.__d_paintedPoints = 0 self.setAutoReplot( False ) self.setCanvas( Canvas() ) self.plotLayout().setAlignCanvasToScales( True ) self.setAxisTitle( Qwt.QwtPlot.xBottom, "Time [s]" ) self.setAxisScale( Qwt.QwtPlot.xBottom, self.__d_interval.minValue(), self.__d_interval.maxValue() ) self.setAxisScale( Qwt.QwtPlot.yLeft, -200.0, 200.0 ) self.grid = Qwt.QwtPlotGrid() self.grid.setPen( Qt.gray, 0.0, Qt.DotLine ) self.grid.enableX( True ) self.grid.enableXMin( True ) self.grid.enableY( True ) self.grid.enableYMin( False ) self.grid.attach( self ) self.__d_origin = Qwt.QwtPlotMarker() self.__d_origin.setLineStyle( Qwt.QwtPlotMarker.Cross ) self.__d_origin.setValue( self.__d_interval.minValue() + self.__d_interval.width() / 2.0, 0.0 ) self.__d_origin.setLinePen( Qt.gray, 0.0, Qt.DashLine ) self.__d_origin.attach( self ) self.__d_curve = Qwt.QwtPlotCurve() self.__d_curve.setStyle( Qwt.QwtPlotCurve.Lines ) self.__d_curve.setPen( self.canvas().palette().color( QPalette.WindowText ) ) self.__d_curve.setRenderHint( Qwt.QwtPlotItem.RenderAntialiased, True ) self.__d_curve.setPaintAttribute( Qwt.QwtPlotCurve.ClipPolygons, False ) self.__cdata = CurveData() self.__d_curve.setData( self.__cdata ) self.__d_curve.attach( self )