Results 1 to 7 of 7

Thread: Graphics View: Millions of items on the scene. How to improve rendering speed?

  1. #1
    Join Date
    May 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Graphics View: Millions of items on the scene. How to improve rendering speed?

    Hi,

    I have to visualize a map of the Netherlands with millions of LineItems that represent roads. I have the feeling that Qt doesn't spend so much time figuring out what to draw, but actually drawing it takes way to long, especially when the view has to display the whole scene.
    The user should be able to scroll the map and to zoom in/out. Now I thought that maybe I could implement a function that renders the map onto a pixmap and display that instead of the actual scene, until the users clicks the zoom button or something in the scene changes. But it should still be possible to click on a road and select it.

    Okay, I'm pretty new to Qt. In the past two weeks I found that often some of the stuff I needed was already in some form implemented in Qt, I just had to look for it in the right place.
    Does any of you have an idea how I could implement the above (or even something better)?

    Thanks,

    Daniel

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Graphics View: Millions of items on the scene. How to improve rendering speed?

    i guess you will have to consider different levels of detail, depending on the zoo factor. e.g. if you show the whole netherlands then no roads other than the big "motorways" (whatever they are called there) will make sense to draw. otherwise you both overwhelm the user with lots of irrelevant details and your program which has to paint lots of items that maybe are below a pixel in size.

  3. #3
    Join Date
    May 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Graphics View: Millions of items on the scene. How to improve rendering speed?

    Quote Originally Posted by caduel View Post
    i guess you will have to consider different levels of detail, depending on the zoo factor. e.g. if you show the whole netherlands then no roads other than the big "motorways" (whatever they are called there) will make sense to draw. otherwise you both overwhelm the user with lots of irrelevant details and your program which has to paint lots of items that maybe are below a pixel in size.
    Yes, I've arrived at the same conclusion. But how would I do this? I can't add all the items to the same scene, because Qt still would have do decide for each single item if it should be drawn.
    Do I need more than one scene?

  4. #4
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Graphics View: Millions of items on the scene. How to improve rendering speed?

    Quote Originally Posted by Disperato View Post
    Yes, I've arrived at the same conclusion. But how would I do this? I can't add all the items to the same scene, because Qt still would have do decide for each single item if it should be drawn.
    Do I need more than one scene?
    Qt doesn't know what should be drawn and what should not be drawn in different level of detail. It is up to you what should or should not be drawn...

    However, if an item's boundingRect is out of viewing area, Qt will know it and will not draw it... When viewing the whole scene in the view, you will need to decide what to skip, it is your map

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: Graphics View: Millions of items on the scene. How to improve rendering speed?

    Drawing nothing is not very expensive so as long as you don't do any painting operations (based on the level of detail as suggested) you should already gain performance. There is another trick you can do - once you zoom out, hide items from layers you know you don't have to render. This will significantly reduce the number of items that have to be taken into consideration while drawing. Also avoid drawing complex shapes in favour of simple ones. Cheat whenever you can (i.e. draw straight lines instead of curves for small/distant objects).
    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
    May 2009
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Graphics View: Millions of items on the scene. How to improve rendering speed?

    Ok, this is what I did:

    I sorted the roads according to their average travel time and created a QGraphicsItemGroup for each of the travel times. Now I have about 120 Groups and only show some of them, depending on the zoom level.

    But scrolling on the highest levels is still very slow, even if it doesn't paint that many roads. It seems as if Graphics View would still look into all of those hidden groups.
    Any suggestions?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: Graphics View: Millions of items on the scene. How to improve rendering speed?

    Use a profiler to find a bottle neck. Right now you are just guessing.
    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. Scene vs. multiple views
    By lni in forum Qt Programming
    Replies: 16
    Last Post: 19th July 2022, 01:47
  2. Replies: 5
    Last Post: 17th February 2009, 04:35

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.