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. QRubberBand stuttering
Forum Updated to NodeBB v4.3 + New Features

QRubberBand stuttering

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 4.8k 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.
  • E Offline
    E Offline
    EukeSnud
    wrote on last edited by
    #1

    Hello,

    my qt program visualizes some geo-data for which I am using GraphicsView with custom QGraphicsItems. The program offers the possibility to choose a new sceneRect with a custom QRubberBand. Everything is working fine so far, but everytime I try to perform a selection over areas containing about 215.000 QGraphicsItems the painting of the QRubberBand is stuttering. It's worse when I zoom out so much that the 215.000 QGraphicsItems lie within about 50*50 pixels.

    Any ideas to solve this problem?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      It doesn't make sense to try to display that many items in such a minute area. That's 86 items per pixel... I think you should start optimizing that so that you draw at most 1% of those items at that zoom level, though I guess aiming for 0.1% would be better.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        EukeSnud
        wrote on last edited by
        #3

        Thanks for your reply. That's what I wanted to do anyways, but I thought there might be something I could do before. Is there some way to find out if a pixel is already painted to avoid being redrawn 215.000 times?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          That is the wrong way to go about it. Please study the Graphics View demo with the chips. Also: think about the level of detail you need when you have zoomed out that much. What information is still important? What is not? Take a look at how Google Maps or Marble changes what details are visible on a map at each zoom level, and get some inspiration from that. Use those insights to avoid rendering whole classes of items on your map, and to simplify the rendering of other classes of objects (don't try to render a complex 20 point polygon if it is going to be projected on a 2x2 pixel area anyway).

          1 Reply Last reply
          0
          • E Offline
            E Offline
            EukeSnud
            wrote on last edited by
            #5

            Huh? I cannot remember any level of detail implementation in the chips demo. I guess I'll have to take another look at it.

            Thank you for the help Andre, I see what you mean.

            edit Thread can be closed...

            1 Reply Last reply
            0
            • E Offline
              E Offline
              EukeSnud
              wrote on last edited by
              #6

              I'm afraid it hast nothing to do with the drawing. I cleared the drawing function of my 215.000 elements so they are not drawn at all (no matter what level of detail is...)
              As long as the items lie withing the scene and I try to open my RubberBand in the area where they should be drawn, my RubberBand keeps stuttering.
              Will I have to remove them from the scene and add them again later? My experience with clearing a GraphicsScene is that performance is suffering from that so i won't win anything...

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                No, it has to do with the number of items in the view that has to be intersected with the rubberband area, I think. To solve that, you'll have to do more than disable the drawing, I think. However, my experience with map drawing apps pre-dates QGraphicsView, so it was not based on that.

                1 Reply Last reply
                0
                • E Offline
                  E Offline
                  EukeSnud
                  wrote on last edited by
                  #8

                  I implemented a quadtree, dividing the whole scene into parts. These parts are now QGraphicsItems on which I paint my 215.000 Elements. The scene now only contains about 360 items, which is equivalent to the leafs of my QuadTree and the performance is way better now.

                  But if I do so, I will not be able to choose elements of my 215.000 bulk with itemAt(...). Since the GraphicsView does not seem to be capable of dealing with a huge amount of datasets I think I have to think of a method of making these painted elements selectable, or am I mistaken?

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    I would think of grouping items. At a certain zoom level you cannot distinguish single items anyways.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • E Offline
                      E Offline
                      EukeSnud
                      wrote on last edited by
                      #10

                      If I use

                      @void QGraphicsItemGroup::addToGroup ( QGraphicsItem * item )@

                      will the RubberBand intersection be tested only against the group or will it still be tested against every member of the group?

                      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