Feature Request: Expose QPainter methods that accept pointers
Phil Thompson
phil at riverbankcomputing.com
Sat May 7 09:48:33 BST 2022
On 07/05/2022 03:56, Ognyan Moore wrote:
> Hi Phil,
>
> I am one of the maintainers of pyqtgraph, I'd like to request that you
> enable some of the function signatures for QPainter methods that accept
> pointers. The following two would be more beneficial for us:
>
> QPainter::drawLines(const QLineF *lines, int lineCount)
> QPainter::drawPixmapFragments(const QPainter::PixmapFragment
> *fragments,
> int fragmentCount, const QPixmap &pixmap, QPainter::PixmapFragmentHints
> hints = PixmapFragmentHints())
>
> If it would not be too much trouble, enabling some of the other
> QPainter
> methods that enabled referencing pointers could also be beneficial, but
> these won't have the same impact as the ones above
>
> QPainter::drawConvexPolygon(const QPointF *points, int pointCount)
> QPainter::drawPoints(const QPointF *points, int pointCount)
> QPainter::drawPolygon(const QPointF *points, int pointCount,
> Qt::FillRule
> fillRule = Qt::OddEvenFill)
> QPainter::drawRects(const QRectF *rectangles, int rectCount)
> QPainter::drawPolyline(const QPointF *points, int pointCount)
>
> To demonstrate our usage, I'll highlight what we do with the PySide
> bindings. For the QPainter::drawPixmapFragments we're able to do
> something
> resembling the following
>
> import numpy as np
> size = 1_000
> arr = np.empty((size, 10), dtype=np.float64)
> ptrs = shiboken6.wrapInstance(arr.ctypes.data,
> QtGui.QPainter.PixmapFragment)
> ...
> QPainter.drawPixmapFragments(ptrs, size, pixmap)
>
> For the equivalent functionality with PyQt bindings
>
> ptrs = list(map(sip.wrapInstance,
> itertools.count(arr.ctypes.data, arr.strides[0]),
> itertools.repeat(QtGui.QPainter.PixmapFragment, arr.shape[0])))
> QPainter.drawPixmapFragments(ptrs[:size], pixmap)
>
>
> We do this right now with QImage, and in a round-about way with
> QPolygonF
> construction.
All of those methods are supported, but maybe not in the way that you
want.
drawPixmapFragments() takes a list of PixmapFragment. The others takes a
variable number of arguments of the appropriate type, so if you had a
list of QLineF objects (called lines) you would call drawLines(*lines).
Can you clarify?
Phil
More information about the PyQt
mailing list