Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QSGGeometry / scenegraph: how to reuse data from QSGGeometry
Forum Updated to NodeBB v4.3 + New Features

QSGGeometry / scenegraph: how to reuse data from QSGGeometry

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 857 Views 1 Watching
  • 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.
  • T Offline
    T Offline
    t.verstraete
    wrote on last edited by
    #1

    Hi,

    I am using scenegraph to generate a chart and so each x ms I get a new data sample from the input module. Now I regenerate the data constantly using a for loop:
    @
    QSGGeometry* geometryNewLine = mNodeNewLine->geometry();
    geometryNewLine->allocate(mLoopVertices->newLineVertices.count());
    QSGGeometry::ColoredPoint2D *verticesNewLine = geometryNewLine->vertexDataAsColoredPoint2D();

        for (int i=0; i<mLoopVertices->newLineVertices.count(); i++)
        {
            color = mLoopVertices->newLineVertices.at(i).second ? colorInspiration : colorExpiration;
            verticesNewLine[i].set(//adapt vertice
                                   mLoopVertices->newLineVertices.at(i).first.x, mLoopVertices->newLineVertices.at(i).first.y,
                                   //adapt color
                                   color.red(), color.green(), color.blue(), color.alpha()
                                   );
        }
    

    @
    But this is taking quite some time and performance of course ... now I do not seem to see in the documentation a method for updating this with one new sample at the time? Do I always need to copy everything?

    A immediate easy update could be using a QVector in code outside of the updatePaintNode and then get the data as an array out of it and doing a memcopy or some sort (std::copy).

    Still I wonder if there is not an easier way of updating part of the data through QSGGeometry instead of always copying everything,

    thanks in advance,

    kind regards,

    Tim

    [edit, code tags added, koahnig]

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Please check out the "code wrapping section":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 in the forum help. This helps to make your code more readable in the forum.

      Vote the answer(s) that helped you to solve your issue(s)

      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