Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-163

QPainter methods should accept python arrays in place of pointer arguments

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Open
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: dev
    • Component/s: PySide
    • Labels:

      Description

      Many of QPainter's methods accept arrays of simple classes such as QPoint, QRect, and PixmapFragment (for eaxmple, drawPoints, drawLines, drawPixmapFragments, etc). Currently, it is required to pass lists of wrapped objects to access these methods. This is very inefficient, especially if the lists contain thousands of items.

      I would like to suggest that these methods also accept numpy arrays or python's built-in arrays and simply pass the pointer to the array data to the wrapped method. This would vastly improve the performance of graphics rendering for many cases. I am currently accomplishing this using ctypes to access the Qt calls directly; it works quite well.

      The PySide wrapper should automatically fill in the number-of-elements arguments based on the byte size of the array and the size of the pointer argument's structure. For example, for QPainter.drawPoints(QPointF*, int) the user could pass a numpy array of 20 floats (80 or 160 bytes) and PySide would automatically determine that the number of elements is 10. It would be up to the user to ensure that the array is constructed correctly with two floats per point. (But note that only the byte-size of the array should be considered; I would recommend against checking the shape and dtype of the array since there are many different ways to construct these parameters)

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              lcampagn Luke
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Gerrit Reviews

                There are no open Gerrit changes