Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Efficient autoscale chart

Efficient autoscale chart

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 551 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chimera123
    wrote on last edited by chimera123
    #1

    Hello everyone,

    could you please suggest best (performance-wise) method to draw on a "rolling / moving" chart based on QPixmap. I cannot use QtCharts due to licensing restrictions (and I do not want to use chart.js - not performant enough on mobile platform...). I am building for Andorid.

    My current solution:

    I have a QQuickPaintedItem derived object which is used to paint the chart - here I am painting "already prepared" QPixmap object with drawPixmap method in the paint routine... So, a simple painter->drawPixmap(...) call. No optimizations more to be done here. (currently I am not looking into OpenGL, althoug as far as I understand OpenGL rendering is used).

    The "already prepared" QPixmap is painted on another thread, which takes care of adding new points / lines, manages vertical and horizontal ticks and labels. Since this is a moving chart (with autoscaling) everything needs to be re-painted when a new point is added.

    I am using QMap<QString, QVector<QPointF>* > to enable multiple plot id (hence the QString key). The reason I am using a pointer to QVector<QPointF> is to call reserve method on newly created plot ids. Then it's a simple iteration over QVector<QPointF> for each plot id and painting on QPixmap (prior to painting, the pixmap is cleared using fill(Qt::transparent). Of course, every new point is appended to the QVector<QPointF>.

    When the painting is done, the QPixmap object is sent as a constant reference to the frontend via signal / slot mechanism where the QQuickPainted item is updated...

    Although I get a reasonable performance, I would like to know what improvements can I make to further optimize this?
    Using plain logic, the best way would be to draw only the new points / lines. But I still need to retain a moving / autoscaling chart. Any suggestions please?

    P.S.: Currently, I am using no buffer size limit (I will eventually). In that case I could take the appropriate region of the previous pixmap and paint only the new points / lines on the "chart". Then, I would not need to iterate through the container...

    Thank you for any suggestions.

    Have a nice day,
    K

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NachoFly
      wrote on last edited by NachoFly
      #2

      QWT is no option?

      1 Reply Last reply
      0
      • C Offline
        C Offline
        chimera123
        wrote on last edited by chimera123
        #3

        @NachoFly thank you for the suggestion. I suppose I could look into this - I see that the source code can be kept private by dynamically linking the qwt lib... Do you have any good sources for qwt on Android - I would need QML integration also, but I suppose this shouldn't be such a problem. Still, I don't know if there are any performance improvements as opposed to my current solution?

        Regards,
        K

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved