Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGraphicsScene performing "poorly" on dense scenes
Forum Updated to NodeBB v4.3 + New Features

QGraphicsScene performing "poorly" on dense scenes

Scheduled Pinned Locked Moved Solved General and Desktop
20 Posts 3 Posters 4.7k Views 3 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Hi
    Check out
    http://doc.qt.io/qt-5/qtwidgets-graphicsview-chip-example.html
    It used a LOD to get better performance.
    LOD means level of detail and its simply a way to reduce what needs to be drawn depending
    on the zoom level.
    Maybe you can work out something so when fully zoom not all is drawn.

    This might also give ideas
    https://stackoverflow.com/questions/43826317/how-to-optimize-qgraphicsviews-performance

    rkhaotixR 1 Reply Last reply
    3
    • mrjjM mrjj

      Hi
      Check out
      http://doc.qt.io/qt-5/qtwidgets-graphicsview-chip-example.html
      It used a LOD to get better performance.
      LOD means level of detail and its simply a way to reduce what needs to be drawn depending
      on the zoom level.
      Maybe you can work out something so when fully zoom not all is drawn.

      This might also give ideas
      https://stackoverflow.com/questions/43826317/how-to-optimize-qgraphicsviews-performance

      rkhaotixR Offline
      rkhaotixR Offline
      rkhaotix
      wrote on last edited by
      #5

      Hi @mrjj ! Yeah, I'll try to apply LOD on my scene.

      First I'm refactoring some classes so they can depend less on subitems based on QGraphicSceneItem. I already known the 40000 chips example and I'm studying so I can replicate some of the behaviors there on my application.

      Anyway, thanks for the link to StackOverflow that will help me a lot to make some polishments!

      mrjjM 1 Reply Last reply
      1
      • rkhaotixR rkhaotix

        Hi @mrjj ! Yeah, I'll try to apply LOD on my scene.

        First I'm refactoring some classes so they can depend less on subitems based on QGraphicSceneItem. I already known the 40000 chips example and I'm studying so I can replicate some of the behaviors there on my application.

        Anyway, thanks for the link to StackOverflow that will help me a lot to make some polishments!

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #6

        @rkhaotix
        Btw it looks really cool!
        Love the soft lines :)

        oh, i missed @kenchan already talked about LODS. sorry.

        rkhaotixR 1 Reply Last reply
        0
        • mrjjM mrjj

          @rkhaotix
          Btw it looks really cool!
          Love the soft lines :)

          oh, i missed @kenchan already talked about LODS. sorry.

          rkhaotixR Offline
          rkhaotixR Offline
          rkhaotix
          wrote on last edited by
          #7

          @mrjj Thank you so much! :D

          mrjjM 1 Reply Last reply
          0
          • rkhaotixR rkhaotix

            @mrjj Thank you so much! :D

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #8

            @rkhaotix
            Oh, i almost forgot
            Did you already try fiddling with
            http://doc.qt.io/qt-5/qgraphicsview.html#cacheMode-prop

            rkhaotixR 1 Reply Last reply
            0
            • mrjjM mrjj

              @rkhaotix
              Oh, i almost forgot
              Did you already try fiddling with
              http://doc.qt.io/qt-5/qgraphicsview.html#cacheMode-prop

              rkhaotixR Offline
              rkhaotixR Offline
              rkhaotix
              wrote on last edited by
              #9

              @mrjj Yep! Already using that!

              K 1 Reply Last reply
              1
              • rkhaotixR rkhaotix

                @mrjj Yep! Already using that!

                K Offline
                K Offline
                kenchan
                wrote on last edited by
                #10

                @rkhaotix
                There is some good advice in that StackOverflow link that @mrjj provided. You will need to subclass your own items to implement some of that, this will give you more control over your LOD strategy.

                1 Reply Last reply
                0
                • rkhaotixR Offline
                  rkhaotixR Offline
                  rkhaotix
                  wrote on last edited by rkhaotix
                  #11

                  @mrjj @kenchan I was wondering... Is there a way to make a highly populated scene to ignore completely items that are not visible and/or have the flag QGraphicsItem::ItemHasNoContents set? If there's a way speed up the rendering by just tweaking these settings I can achieve both results I need: higher rendering speed and allow the user to work in a subset of the database model.

                  By the way, I tried cache items, reduce the amount of scene objects per database objects and background caching but the result was the same. :(
                  Didn't tried the LOD yet.

                  K 1 Reply Last reply
                  0
                  • rkhaotixR rkhaotix

                    @mrjj @kenchan I was wondering... Is there a way to make a highly populated scene to ignore completely items that are not visible and/or have the flag QGraphicsItem::ItemHasNoContents set? If there's a way speed up the rendering by just tweaking these settings I can achieve both results I need: higher rendering speed and allow the user to work in a subset of the database model.

                    By the way, I tried cache items, reduce the amount of scene objects per database objects and background caching but the result was the same. :(
                    Didn't tried the LOD yet.

                    K Offline
                    K Offline
                    kenchan
                    wrote on last edited by
                    #12

                    @rkhaotix Did you try to use minimumRenderSize and :levelOfDetailFromTransform?
                    Anything too small or outside the viewport should not be painted, however the bounding boxes must be tested so many items may still have a performance hit.
                    Maybe you could replace the groups with your own containing parent item which contains the children needed to draw the details. If you could draw the details directly in the paint function without using other graphics item, as you would with groups, this might reduce the number of items the engine has to check for boxing when clipping for the viewport? You can also fine tune your LOD for the item when dragging or zooming i.e. just draw the bounding box and not draw the details.

                    Just some ideas for you to consider. Wishing you Good Luck in your efforts.

                    rkhaotixR 1 Reply Last reply
                    0
                    • K kenchan

                      @rkhaotix Did you try to use minimumRenderSize and :levelOfDetailFromTransform?
                      Anything too small or outside the viewport should not be painted, however the bounding boxes must be tested so many items may still have a performance hit.
                      Maybe you could replace the groups with your own containing parent item which contains the children needed to draw the details. If you could draw the details directly in the paint function without using other graphics item, as you would with groups, this might reduce the number of items the engine has to check for boxing when clipping for the viewport? You can also fine tune your LOD for the item when dragging or zooming i.e. just draw the bounding box and not draw the details.

                      Just some ideas for you to consider. Wishing you Good Luck in your efforts.

                      rkhaotixR Offline
                      rkhaotixR Offline
                      rkhaotix
                      wrote on last edited by
                      #13

                      @kenchan The idea of creating my own version of paint() method sounds great! Thanks, never thought this way. This can help me reduce the amount of items used as well experiment the LOD usage.

                      1 Reply Last reply
                      0
                      • rkhaotixR Offline
                        rkhaotixR Offline
                        rkhaotix
                        wrote on last edited by
                        #14

                        @kenchan @mrjj Hey guys!

                        I came back here just to thank you! I did some refactoring on some of my classes responsible to represent database models using some of your hints, a the result was the following:

                        1. I could reduce the amount of scene objects needed to represent a whole database model in ~38%. Putting this in numbers, if we use that huge model above which contains 109630 scene items after the code refactoring the amount of objects is now 67902, an impressive difference of 41728 scene objects! That really makes me happy. I did not make any benchmark but I could notice that the stuttering while moving or zooming diminished sensibly! :)

                        2. Tried several approaches of LOD but they did not contribute in a relevant way to increase the rendering speed. So I concluded that it could be an unecessary and complex implementation (for some objects) which final result was not as good as I needed.

                        3. Using less QGraphicsGroupItems was the key for most of the problems. I'm using them now only in important parts where the usage of nested QGraphicsItem could generated an overhead when calculation position of children in certain situations.

                        4. Fiddling around with all my graphics classes I could determine the main culprit of the performance degradation. The guy in question is the a class based upon QGraphicsGroupItem which represents relationships (the most complex objects in the software). Since these objects carry a considerable number of subitems the scene is having a hard time trying to calculate collisions, do the painting and other operations. So I decided to live with this situation for now... In the right moment I'll improve the class (maybe rewriting it?) so I can squeeze more performance from it.

                        The important thing now is that the overall speed of rendering operations is better. Since I'm an eternal dissatisfied... Soon or later I'll dive into these important bottlenecks and solve them once of all. For now I'm really glad that solve part of my problem and learned new things about this amazing framework!

                        Thank you once more, guys!

                        K mrjjM 2 Replies Last reply
                        4
                        • rkhaotixR rkhaotix

                          @kenchan @mrjj Hey guys!

                          I came back here just to thank you! I did some refactoring on some of my classes responsible to represent database models using some of your hints, a the result was the following:

                          1. I could reduce the amount of scene objects needed to represent a whole database model in ~38%. Putting this in numbers, if we use that huge model above which contains 109630 scene items after the code refactoring the amount of objects is now 67902, an impressive difference of 41728 scene objects! That really makes me happy. I did not make any benchmark but I could notice that the stuttering while moving or zooming diminished sensibly! :)

                          2. Tried several approaches of LOD but they did not contribute in a relevant way to increase the rendering speed. So I concluded that it could be an unecessary and complex implementation (for some objects) which final result was not as good as I needed.

                          3. Using less QGraphicsGroupItems was the key for most of the problems. I'm using them now only in important parts where the usage of nested QGraphicsItem could generated an overhead when calculation position of children in certain situations.

                          4. Fiddling around with all my graphics classes I could determine the main culprit of the performance degradation. The guy in question is the a class based upon QGraphicsGroupItem which represents relationships (the most complex objects in the software). Since these objects carry a considerable number of subitems the scene is having a hard time trying to calculate collisions, do the painting and other operations. So I decided to live with this situation for now... In the right moment I'll improve the class (maybe rewriting it?) so I can squeeze more performance from it.

                          The important thing now is that the overall speed of rendering operations is better. Since I'm an eternal dissatisfied... Soon or later I'll dive into these important bottlenecks and solve them once of all. For now I'm really glad that solve part of my problem and learned new things about this amazing framework!

                          Thank you once more, guys!

                          K Offline
                          K Offline
                          kenchan
                          wrote on last edited by kenchan
                          #15

                          @rkhaotix Great news.
                          Very pleased to hear you have had some success, thanks for getting back to us with that :-). Really hope you have more success with in it the future.

                          rkhaotixR 1 Reply Last reply
                          1
                          • rkhaotixR rkhaotix

                            @kenchan @mrjj Hey guys!

                            I came back here just to thank you! I did some refactoring on some of my classes responsible to represent database models using some of your hints, a the result was the following:

                            1. I could reduce the amount of scene objects needed to represent a whole database model in ~38%. Putting this in numbers, if we use that huge model above which contains 109630 scene items after the code refactoring the amount of objects is now 67902, an impressive difference of 41728 scene objects! That really makes me happy. I did not make any benchmark but I could notice that the stuttering while moving or zooming diminished sensibly! :)

                            2. Tried several approaches of LOD but they did not contribute in a relevant way to increase the rendering speed. So I concluded that it could be an unecessary and complex implementation (for some objects) which final result was not as good as I needed.

                            3. Using less QGraphicsGroupItems was the key for most of the problems. I'm using them now only in important parts where the usage of nested QGraphicsItem could generated an overhead when calculation position of children in certain situations.

                            4. Fiddling around with all my graphics classes I could determine the main culprit of the performance degradation. The guy in question is the a class based upon QGraphicsGroupItem which represents relationships (the most complex objects in the software). Since these objects carry a considerable number of subitems the scene is having a hard time trying to calculate collisions, do the painting and other operations. So I decided to live with this situation for now... In the right moment I'll improve the class (maybe rewriting it?) so I can squeeze more performance from it.

                            The important thing now is that the overall speed of rendering operations is better. Since I'm an eternal dissatisfied... Soon or later I'll dive into these important bottlenecks and solve them once of all. For now I'm really glad that solve part of my problem and learned new things about this amazing framework!

                            Thank you once more, guys!

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #16

                            @rkhaotix

                            That is indeed good news.

                            I have posted a link in
                            https://forum.qt.io/category/8/showcase

                            as its a very good example of full blown Qt program,
                            and maybe the most feature rich Modeler i have seen for PostgreSQL.
                            Thank you for sharing.

                            rkhaotixR 1 Reply Last reply
                            2
                            • K kenchan

                              @rkhaotix Great news.
                              Very pleased to hear you have had some success, thanks for getting back to us with that :-). Really hope you have more success with in it the future.

                              rkhaotixR Offline
                              rkhaotixR Offline
                              rkhaotix
                              wrote on last edited by
                              #17

                              @kenchan Thanks! :D

                              1 Reply Last reply
                              0
                              • mrjjM mrjj

                                @rkhaotix

                                That is indeed good news.

                                I have posted a link in
                                https://forum.qt.io/category/8/showcase

                                as its a very good example of full blown Qt program,
                                and maybe the most feature rich Modeler i have seen for PostgreSQL.
                                Thank you for sharing.

                                rkhaotixR Offline
                                rkhaotixR Offline
                                rkhaotix
                                wrote on last edited by
                                #18

                                @mrjj Wow, thanks for that! I'm working on this project for twelve years and I really want that it can be a reference of database modeler for PostgreSQL ;)

                                mrjjM 1 Reply Last reply
                                0
                                • rkhaotixR rkhaotix

                                  @mrjj Wow, thanks for that! I'm working on this project for twelve years and I really want that it can be a reference of database modeler for PostgreSQL ;)

                                  mrjjM Offline
                                  mrjjM Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #19

                                  Hi
                                  Well its already famous / recognized :)
                                  https://wiki.postgresql.org/wiki/Design_Tools

                                  rkhaotixR 1 Reply Last reply
                                  0
                                  • mrjjM mrjj

                                    Hi
                                    Well its already famous / recognized :)
                                    https://wiki.postgresql.org/wiki/Design_Tools

                                    rkhaotixR Offline
                                    rkhaotixR Offline
                                    rkhaotix
                                    wrote on last edited by
                                    #20

                                    @mrjj Yeah... I'm aware of that entry on PostgreSQL wiki :D

                                    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