Results 1 to 10 of 10

Thread: QGraphicsScene performance (200000 static items and 1 moving)

  1. #1
    Join Date
    Dec 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsScene performance (200000 static items and 1 moving)

    Hello. I'm making cad-like software. It is for temperature field modeling and visulization. User will work with MANY blocks here. It can be 10000, it can be 10000 or more.

    I obviously use Graphics Scene engine for it. Each block is QGraphicsItem.

    Also I have 1 item there — Anchor. It follows cursor. It is done by signal (from view)l/slot (in Anchor). Slot makes setPos().

    The problem is that setPos() sometimes results in scene reindexing. It is slow, when there is many items.

    I'm thinking about moving that moving item to view (make it as widget there). Any better solution?

    Screenshot discribing why I need many blocks (not so many blocks here): http://obey.su/upload/11-01-23_LOR_QFrost/qfrost2.png
    Last edited by Obey-Kun; 27th January 2011 at 16:38.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QGraphicsScene performance (200000 static items and 1 moving)

    There are several options coming in my mind: disable indexing or "play around" with the various performance tunings the view and scene offers: level of detail, update mode...

    Further (please attach images to the forum, that the post stays valid) it seems that you are composing a grid out of items, and your anchor "frames" one item. If so, skip the anchor, and alter the paint method of your items to draw the focus frame itself. To move the anchor, unset the "highlight frame" from the current one and set it to the other.

  3. #3
    Join Date
    Dec 2009
    Posts
    128
    Thanks
    7
    Thanked 14 Times in 14 Posts
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene performance (200000 static items and 1 moving)

    Maybe I'm wrong but your app makes me think of the Pixelator example (in case you're interested)

  4. #4
    Join Date
    Dec 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsScene performance (200000 static items and 1 moving)

    There are several options coming in my mind: disable indexing or "play around" with the various performance tunings the view and scene offers: level of detail, update mode...
    Disabling index is not ok (coze I need itemAt, itemsAt).
    lod, update mode etc tuning is not a solutions, becouse problem is in index recalculating.

    Maybe I'm wrong but your app makes me think of the Pixelator example (in case you're interested)
    Naah, my app is doing absolutely other thing . It's about temperature field modeling for engineering geocryology needs. And it is more complicated. It already has 7500 lines of code (+ 4000 lines of comments + 2000 empty lines).


    Added after 1 32 minutes:


    If I add all static items as children of other item (so this item is parent for every static items), it works much faster. Nice and weird. Someone can exmplain?
    Last edited by Obey-Kun; 28th January 2011 at 17:13.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsScene performance (200000 static items and 1 moving)

    Disabling indexing doesn't make itemAt stop working but anyway I wouldn't go for this option here. Consider using drawBackground and drawForeground for things such as the grid. You don't have to compose everything from items.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Dec 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsScene performance (200000 static items and 1 moving)

    I already use view's background/foreground for grid etc.
    And the final solution is:
    1) Use more balanced bsp trees (put static items in portions of 10000 doughters of some container items).
    2) Move moving item to view's viewport (as widget).
    Last edited by Obey-Kun; 29th January 2011 at 16:35.

  7. #7
    Join Date
    Dec 2009
    Posts
    128
    Thanks
    7
    Thanked 14 Times in 14 Posts
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene performance (200000 static items and 1 moving)

    Quote Originally Posted by Obey-Kun View Post
    2) Move moving item to view's viewport (as widget).
    could you precise please ?

  8. #8
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QGraphicsScene performance (200000 static items and 1 moving)

    User will work with MANY blocks here
    Maybe that's just wrong assumption. What is the point of using many small blocks to represent one, huge field with constant temperature ? I'd rather consider the other way around - create as many big items as possible, and eventually split them into smaller groups in the areas where you need more precision (some general LODs algorithms may be usefull here).

  9. #9
    Join Date
    Dec 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsScene performance (200000 static items and 1 moving)

    Maybe that's just wrong assumption. What is the point of using many small blocks to represent one, huge field with constant temperature ? I'd rather consider the other way around - create as many big items as possible, and eventually split them into smaller groups in the areas where you need more precision (some general LODs algorithms may be usefull here).
    It is not grid, it's blocks. So it can look like this:
    Qt Code:
    1. _________
    2. |_________|
    3. |____|____|
    To copy to clipboard, switch view to plain text mode 
    So using separate blocks is much easier to code. Later, I maybe will add grid representation. But not shure, that it will be better. Maybe scene indexes will not be going crazy, but paint system will.

    could you precise please ?
    I'll create widget and put it into view's viewport. Will use setRect to move it there. So it will not change scene indexes.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsScene performance (200000 static items and 1 moving)

    You don't need a widget. You can paint your rect on the viewport using QPainter::drawRect(). But then I'm not sure if this is a good idea. One item more or less shouldn't make a difference. I'd focus on reducing the number of items in the scene and optimizing what you already have. There are a couple of threads on this forum where I show how to do that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Garbled marks when moving items in QGraphicsScene
    By extralucas in forum Qt Programming
    Replies: 2
    Last Post: 4th December 2010, 22:23
  2. Moving QGraphicsScene to Left or Right firections
    By augusbas in forum Qt Programming
    Replies: 2
    Last Post: 30th June 2010, 04:45
  3. QGraphicsScene with lots of static items
    By lari in forum Qt Programming
    Replies: 12
    Last Post: 21st April 2010, 11:21
  4. Replies: 6
    Last Post: 5th March 2009, 06:26
  5. Moving an item in QGraphicsScene
    By prosass in forum Newbie
    Replies: 4
    Last Post: 28th March 2007, 14:21

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.