def drawLines(self, painter, xMap, yMap, canvasRect, from_, to): """ Draw lines :param QPainter painter: Painter :param qwt.scale_map.QwtScaleMap xMap: Maps x-values into pixel coordinates. :param qwt.scale_map.QwtScaleMap yMap: Maps y-values into pixel coordinates. :param QRectF canvasRect: Contents rectangle of the canvas :param int from_: Index of the first point to be painted :param int to: Index of the last point to be painted. If to < 0 the curve will be painted to its last point. .. seealso:: :py:meth:`draw()`, :py:meth:`drawDots()`, :py:meth:`drawSteps()`, :py:meth:`drawSticks()` """ if from_ > to: return doAlign = QwtPainter.roundingAlignment(painter) doFill = self.__data.brush.style() != Qt.NoBrush\ and self.__data.brush.color().alpha() > 0 clipRect = QRectF() if self.__data.paintAttributes & self.ClipPolygons: pw = max([1., painter.pen().widthF()]) clipRect = canvasRect.adjusted(-pw, -pw, pw, pw) doIntegers = False if QT_VERSION < 0x040800: if painter.paintEngine().type() == QPaintEngine.Raster: if not doFill: doIntegers = True noDuplicates = self.__data.paintAttributes & self.FilterPoints mapper = QwtPointMapper() mapper.setFlag(QwtPointMapper.RoundPoints, doAlign) mapper.setFlag(QwtPointMapper.WeedOutPoints, noDuplicates) mapper.setBoundingRect(canvasRect) if doIntegers: polyline = mapper.toPolygon(xMap, yMap, self.data(), from_, to) if self.__data.paintAttributes & self.ClipPolygons: polyline = QwtClipper().clipPolygon(clipRect.toAlignedRect(), polyline, False) QwtPainter.drawPolyline(painter, polyline) else: polyline = mapper.toPolygonF(xMap, yMap, self.data(), from_, to) if doFill: if painter.pen().style() != Qt.NoPen: filled = QPolygonF(polyline) self.fillCurve(painter, xMap, yMap, canvasRect, filled) filled.clear() if self.__data.paintAttributes & self.ClipPolygons: polyline = QwtClipper().clipPolygonF( clipRect, polyline, False) QwtPainter.drawPolyline(painter, polyline) else: self.fillCurve(painter, xMap, yMap, canvasRect, polyline) else: if self.__data.paintAttributes & self.ClipPolygons: polyline = QwtClipper().clipPolygonF( clipRect, polyline, False) QwtPainter.drawPolyline(painter, polyline)
def drawSymbols(self, painter, symbol, xMap, yMap, canvasRect, from_, to): """ Draw symbols :param QPainter painter: Painter :param qwt.symbol.QwtSymbol symbol: Curve symbol :param qwt.scale_map.QwtScaleMap xMap: Maps x-values into pixel coordinates. :param qwt.scale_map.QwtScaleMap yMap: Maps y-values into pixel coordinates. :param QRectF canvasRect: Contents rectangle of the canvas :param int from_: Index of the first point to be painted :param int to: Index of the last point to be painted. If to < 0 the curve will be painted to its last point. .. seealso:: :py:meth:`setSymbol()`, :py:meth:`drawSeries()`, :py:meth:`drawCurve()` """ mapper = QwtPointMapper() mapper.setFlag(QwtPointMapper.RoundPoints, QwtPainter.roundingAlignment(painter)) mapper.setFlag(QwtPointMapper.WeedOutPoints, self.testPaintAttribute(QwtPlotCurve.FilterPoints)) mapper.setBoundingRect(canvasRect) chunkSize = 500 for i in range(from_, to + 1, chunkSize): n = min([chunkSize, to - i + 1]) points = mapper.toPointsF(xMap, yMap, self.data(), i, i + n - 1) if points.size() > 0: symbol.drawSymbols(painter, points)
def drawLines(self, painter, xMap, yMap, canvasRect, from_, to): """ Draw lines :param QPainter painter: Painter :param qwt.scale_map.QwtScaleMap xMap: Maps x-values into pixel coordinates. :param qwt.scale_map.QwtScaleMap yMap: Maps y-values into pixel coordinates. :param QRectF canvasRect: Contents rectangle of the canvas :param int from_: Index of the first point to be painted :param int to: Index of the last point to be painted. If to < 0 the curve will be painted to its last point. .. seealso:: :py:meth:`draw()`, :py:meth:`drawDots()`, :py:meth:`drawSteps()`, :py:meth:`drawSticks()` """ if from_ > to: return doAlign = QwtPainter.roundingAlignment(painter) doFill = self.__data.brush.style() != Qt.NoBrush\ and self.__data.brush.color().alpha() > 0 clipRect = QRectF() if self.__data.paintAttributes & self.ClipPolygons: pw = max([1., painter.pen().widthF()]) clipRect = canvasRect.adjusted(-pw, -pw, pw, pw) doIntegers = False if QT_VERSION < 0x040800: if painter.paintEngine().type() == QPaintEngine.Raster: if not doFill: doIntegers = True noDuplicates = self.__data.paintAttributes & self.FilterPoints mapper = QwtPointMapper() mapper.setFlag(QwtPointMapper.RoundPoints, doAlign) mapper.setFlag(QwtPointMapper.WeedOutPoints, noDuplicates) mapper.setBoundingRect(canvasRect) if doIntegers: polyline = mapper.toPolygon(xMap, yMap, self.data(), from_, to) if self.__data.paintAttributes & self.ClipPolygons: polyline = QwtClipper().clipPolygon(clipRect.toAlignedRect(), polyline, False) QwtPainter.drawPolyline(painter, polyline) else: polyline = mapper.toPolygonF(xMap, yMap, self.data(), from_, to) if doFill: if painter.pen().style() != Qt.NoPen: filled = QPolygonF(polyline) self.fillCurve(painter, xMap, yMap, canvasRect, filled) filled.clear() if self.__data.paintAttributes & self.ClipPolygons: polyline = QwtClipper().clipPolygonF(clipRect, polyline, False) QwtPainter.drawPolyline(painter, polyline) else: self.fillCurve(painter, xMap, yMap, canvasRect, polyline) else: if self.__data.paintAttributes & self.ClipPolygons: polyline = QwtClipper().clipPolygonF(clipRect, polyline, False) QwtPainter.drawPolyline(painter, polyline)
def drawSymbols(self, painter, symbol, xMap, yMap, canvasRect, from_, to): """ Draw symbols :param QPainter painter: Painter :param qwt.symbol.QwtSymbol symbol: Curve symbol :param qwt.scale_map.QwtScaleMap xMap: Maps x-values into pixel coordinates. :param qwt.scale_map.QwtScaleMap yMap: Maps y-values into pixel coordinates. :param QRectF canvasRect: Contents rectangle of the canvas :param int from_: Index of the first point to be painted :param int to: Index of the last point to be painted. If to < 0 the curve will be painted to its last point. .. seealso:: :py:meth:`setSymbol()`, :py:meth:`drawSeries()`, :py:meth:`drawCurve()` """ mapper = QwtPointMapper() mapper.setFlag(QwtPointMapper.RoundPoints, QwtPainter.roundingAlignment(painter)) mapper.setFlag(QwtPointMapper.WeedOutPoints, self.testPaintAttribute(QwtPlotCurve.FilterPoints)) mapper.setBoundingRect(canvasRect) chunkSize = 500 for i in range(from_, to+1, chunkSize): n = min([chunkSize, to-i+1]) points = mapper.toPointsF(xMap, yMap, self.data(), i, i+n-1) if points.size() > 0: symbol.drawSymbols(painter, points)
def drawLines(self, painter, xMap, yMap, canvasRect, from_, to): if from_ > to: return doAlign = QwtPainter.roundingAlignment(painter) doFit = (self.__data.attributes & self.Fitted)\ and self.__data.curveFitter doFill = self.__data.brush.style() != Qt.NoBrush\ and self.__data.brush.color().alpha() > 0 clipRect = QRectF() if self.__data.paintAttributes & self.ClipPolygons: pw = max([1., painter.pen().widthF()]) clipRect = canvasRect.adjusted(-pw, -pw, pw, pw) doIntegers = False if QT_VERSION < 0x040800: if painter.paintEngine().type() == QPaintEngine.Raster: if not doFit and not doFill: doIntegers = True noDuplicates = self.__data.paintAttributes & self.FilterPoints mapper = QwtPointMapper() mapper.setFlag(QwtPointMapper.RoundPoints, doAlign) mapper.setFlag(QwtPointMapper.WeedOutPoints, noDuplicates) mapper.setBoundingRect(canvasRect) if doIntegers: polyline = mapper.toPolygon(xMap, yMap, self.data(), from_, to) if self.__data.paintAttributes & self.ClipPolygons: polyline = QwtClipper().clipPolygon(clipRect.toAlignedRect(), polyline, False) QwtPainter.drawPolyline(painter, polyline) else: polyline = mapper.toPolygonF(xMap, yMap, self.data(), from_, to) if doFit: polyline = self.__data.curveFitter.fitCurve(polyline) if doFill: if painter.pen().style() != Qt.NoPen: filled = QPolygonF(polyline) self.fillCurve(painter, xMap, yMap, canvasRect, filled) filled.clear() if self.__data.paintAttributes & self.ClipPolygons: polyline = QwtClipper().clipPolygonF( clipRect, polyline, False) QwtPainter.drawPolyline(painter, polyline) else: self.fillCurve(painter, xMap, yMap, canvasRect, polyline) else: if self.__data.paintAttributes & self.ClipPolygons: polyline = QwtClipper().clipPolygonF( clipRect, polyline, False) QwtPainter.drawPolyline(painter, polyline)
def drawSymbols(self, painter, symbol, xMap, yMap, canvasRect, from_, to): mapper = QwtPointMapper() mapper.setFlag(QwtPointMapper.RoundPoints, QwtPainter.roundingAlignment(painter)) mapper.setFlag(QwtPointMapper.WeedOutPoints, self.testPaintAttribute(QwtPlotCurve.FilterPoints)) mapper.setBoundingRect(canvasRect) chunkSize = 500 for i in range(from_, to + 1, chunkSize): n = min([chunkSize, to - i + 1]) points = mapper.toPointsF(xMap, yMap, self.data(), i, i + n - 1) if points.size() > 0: symbol.drawSymbols(painter, points)
def drawLines(self, painter, xMap, yMap, canvasRect, from_, to): if from_ > to: return doAlign = QwtPainter.roundingAlignment(painter) doFit = (self.__data.attributes & self.Fitted)\ and self.__data.curveFitter doFill = self.__data.brush.style() != Qt.NoBrush\ and self.__data.brush.color().alpha() > 0 clipRect = QRectF() if self.__data.paintAttributes & self.ClipPolygons: pw = max([1., painter.pen().widthF()]) clipRect = canvasRect.adjusted(-pw, -pw, pw, pw) doIntegers = False if QT_VERSION < 0x040800: if painter.paintEngine().type() == QPaintEngine.Raster: if not doFit and not doFill: doIntegers = True noDuplicates = self.__data.paintAttributes & self.FilterPoints mapper = QwtPointMapper() mapper.setFlag(QwtPointMapper.RoundPoints, doAlign) mapper.setFlag(QwtPointMapper.WeedOutPoints, noDuplicates) mapper.setBoundingRect(canvasRect) if doIntegers: polyline = mapper.toPolygon(xMap, yMap, self.data(), from_, to) if self.__data.paintAttributes & self.ClipPolygons: polyline = QwtClipper().clipPolygon(clipRect.toAlignedRect(), polyline, False) QwtPainter.drawPolyline(painter, polyline) else: polyline = mapper.toPolygonF(xMap, yMap, self.data(), from_, to) if doFit: polyline = self.__data.curveFitter.fitCurve(polyline) if doFill: if painter.pen().style() != Qt.NoPen: filled = QPolygonF(polyline) self.fillCurve(painter, xMap, yMap, canvasRect, filled) filled.clear() if self.__data.paintAttributes & self.ClipPolygons: polyline = QwtClipper().clipPolygonF(clipRect, polyline, False) QwtPainter.drawPolyline(painter, polyline) else: self.fillCurve(painter, xMap, yMap, canvasRect, polyline) else: if self.__data.paintAttributes & self.ClipPolygons: polyline = QwtClipper().clipPolygonF(clipRect, polyline, False) QwtPainter.drawPolyline(painter, polyline)
def drawSymbols(self, painter, symbol, xMap, yMap, canvasRect, from_, to): mapper = QwtPointMapper() mapper.setFlag(QwtPointMapper.RoundPoints, QwtPainter.roundingAlignment(painter)) mapper.setFlag(QwtPointMapper.WeedOutPoints, self.testPaintAttribute(QwtPlotCurve.FilterPoints)) mapper.setBoundingRect(canvasRect) chunkSize = 500 for i in range(from_, to+1, chunkSize): n = min([chunkSize, to-i+1]) points = mapper.toPointsF(xMap, yMap, self.data(), i, i+n-1) if points.size() > 0: symbol.drawSymbols(painter, points)
def drawDots(self, painter, xMap, yMap, canvasRect, from_, to): color = painter.pen().color() if painter.pen().style() == Qt.NoPen or color.alpha() == 0: return doFill = self.__data.brush.style() != Qt.NoBrush\ and self.__data.brush.color().alpha() > 0 doAlign = QwtPainter.roundingAlignment(painter) mapper = QwtPointMapper() mapper.setBoundingRect(canvasRect) mapper.setFlag(QwtPointMapper.RoundPoints, doAlign) if self.__data.paintAttributes & self.FilterPoints: if color.alpha() == 255\ and not (painter.renderHints() & QPainter.Antialiasing): mapper.setFlag(QwtPointMapper.WeedOutPoints, True) if doFill: mapper.setFlag(QwtPointMapper.WeedOutPoints, False) points = mapper.toPointsF(xMap, yMap, self.data(), from_, to) QwtPainter.drawPoints(painter, points) self.fillCurve(painter, xMap, yMap, canvasRect, points) elif self.__data.paintAttributes & self.ImageBuffer: image = mapper.toImage(xMap, yMap, self.data(), from_, to, self.__data.pen, painter.testRenderHint(QPainter.Antialiasing), self.renderThreadCount()) painter.drawImage(canvasRect.toAlignedRect(), image) elif self.__data.paintAttributes & self.MinimizeMemory: series = self.data() for i in range(from_, to+1): sample = series.sample(i) xi = xMap.transform(sample.x()) yi = yMap.transform(sample.y()) if doAlign: xi = round(xi) yi = round(yi) QwtPainter.drawPoint(painter, QPointF(xi, yi)) else: if doAlign: points = mapper.toPoints(xMap, yMap, self.data(), from_, to) QwtPainter.drawPoints(painter, points) else: points = mapper.toPointsF(xMap, yMap, self.data(), from_, to) QwtPainter.drawPoints(painter, points)
def drawDots(self, painter, xMap, yMap, canvasRect, from_, to): """ Draw dots :param QPainter painter: Painter :param qwt.scale_map.QwtScaleMap xMap: Maps x-values into pixel coordinates. :param qwt.scale_map.QwtScaleMap yMap: Maps y-values into pixel coordinates. :param QRectF canvasRect: Contents rectangle of the canvas :param int from_: Index of the first point to be painted :param int to: Index of the last point to be painted. If to < 0 the curve will be painted to its last point. .. seealso:: :py:meth:`draw()`, :py:meth:`drawSticks()`, :py:meth:`drawSteps()`, :py:meth:`drawLines()` """ color = painter.pen().color() if painter.pen().style() == Qt.NoPen or color.alpha() == 0: return doFill = self.__data.brush.style() != Qt.NoBrush\ and self.__data.brush.color().alpha() > 0 doAlign = QwtPainter.roundingAlignment(painter) mapper = QwtPointMapper() mapper.setBoundingRect(canvasRect) mapper.setFlag(QwtPointMapper.RoundPoints, doAlign) if self.__data.paintAttributes & self.FilterPoints: if color.alpha() == 255\ and not (painter.renderHints() & QPainter.Antialiasing): mapper.setFlag(QwtPointMapper.WeedOutPoints, True) if doFill: mapper.setFlag(QwtPointMapper.WeedOutPoints, False) points = mapper.toPointsF(xMap, yMap, self.data(), from_, to) QwtPainter.drawPoints(painter, points) self.fillCurve(painter, xMap, yMap, canvasRect, points) elif self.__data.paintAttributes & self.ImageBuffer: image = mapper.toImage(xMap, yMap, self.data(), from_, to, self.__data.pen, painter.testRenderHint(QPainter.Antialiasing)) painter.drawImage(canvasRect.toAlignedRect(), image) else: if doAlign: points = mapper.toPoints(xMap, yMap, self.data(), from_, to) QwtPainter.drawPoints(painter, points) else: points = mapper.toPointsF(xMap, yMap, self.data(), from_, to) QwtPainter.drawPoints(painter, points)
def drawDots(self, painter, xMap, yMap, canvasRect, from_, to): """ Draw dots :param QPainter painter: Painter :param qwt.scale_map.QwtScaleMap xMap: Maps x-values into pixel coordinates. :param qwt.scale_map.QwtScaleMap yMap: Maps y-values into pixel coordinates. :param QRectF canvasRect: Contents rectangle of the canvas :param int from_: Index of the first point to be painted :param int to: Index of the last point to be painted. If to < 0 the curve will be painted to its last point. .. seealso:: :py:meth:`draw()`, :py:meth:`drawSticks()`, :py:meth:`drawSteps()`, :py:meth:`drawLines()` """ color = painter.pen().color() if painter.pen().style() == Qt.NoPen or color.alpha() == 0: return doFill = self.__data.brush.style() != Qt.NoBrush\ and self.__data.brush.color().alpha() > 0 doAlign = QwtPainter.roundingAlignment(painter) mapper = QwtPointMapper() mapper.setBoundingRect(canvasRect) mapper.setFlag(QwtPointMapper.RoundPoints, doAlign) if self.__data.paintAttributes & self.FilterPoints: if color.alpha() == 255\ and not (painter.renderHints() & QPainter.Antialiasing): mapper.setFlag(QwtPointMapper.WeedOutPoints, True) if doFill: mapper.setFlag(QwtPointMapper.WeedOutPoints, False) points = mapper.toPointsF(xMap, yMap, self.data(), from_, to) QwtPainter.drawPoints(painter, points) self.fillCurve(painter, xMap, yMap, canvasRect, points) elif self.__data.paintAttributes & self.ImageBuffer: image = mapper.toImage( xMap, yMap, self.data(), from_, to, self.__data.pen, painter.testRenderHint(QPainter.Antialiasing)) painter.drawImage(canvasRect.toAlignedRect(), image) else: if doAlign: points = mapper.toPoints(xMap, yMap, self.data(), from_, to) QwtPainter.drawPoints(painter, points) else: points = mapper.toPointsF(xMap, yMap, self.data(), from_, to) QwtPainter.drawPoints(painter, points)
def drawDots(self, painter, xMap, yMap, canvasRect, from_, to): color = painter.pen().color() if painter.pen().style() == Qt.NoPen or color.alpha() == 0: return doFill = self.__data.brush.style() != Qt.NoBrush\ and self.__data.brush.color().alpha() > 0 doAlign = QwtPainter.roundingAlignment(painter) mapper = QwtPointMapper() mapper.setBoundingRect(canvasRect) mapper.setFlag(QwtPointMapper.RoundPoints, doAlign) if self.__data.paintAttributes & self.FilterPoints: if color.alpha() == 255\ and not (painter.renderHints() & QPainter.Antialiasing): mapper.setFlag(QwtPointMapper.WeedOutPoints, True) if doFill: mapper.setFlag(QwtPointMapper.WeedOutPoints, False) points = mapper.toPointsF(xMap, yMap, self.data(), from_, to) QwtPainter.drawPoints(painter, points) self.fillCurve(painter, xMap, yMap, canvasRect, points) elif self.__data.paintAttributes & self.ImageBuffer: image = mapper.toImage( xMap, yMap, self.data(), from_, to, self.__data.pen, painter.testRenderHint(QPainter.Antialiasing), self.renderThreadCount()) painter.drawImage(canvasRect.toAlignedRect(), image) elif self.__data.paintAttributes & self.MinimizeMemory: series = self.data() for i in range(from_, to + 1): sample = series.sample(i) xi = xMap.transform(sample.x()) yi = yMap.transform(sample.y()) if doAlign: xi = round(xi) yi = round(yi) QwtPainter.drawPoint(painter, QPointF(xi, yi)) else: if doAlign: points = mapper.toPoints(xMap, yMap, self.data(), from_, to) QwtPainter.drawPoints(painter, points) else: points = mapper.toPointsF(xMap, yMap, self.data(), from_, to) QwtPainter.drawPoints(painter, points)