Graphics View improvements

Posted by Andreas Aardal Hanssen on February 27, 2007 · 21 comments

We’re in the process of closing up the features for 4.3, and I’ve had a little run-down of what’s changed in Graphics View.

In general, you will notice that the graphics run faster, (especially for complex polygons,) collisions are absolutely precise, the rubberband looks 100x better… I think most of our Graphics View followers will be very pleased with the upcoming Qt 4.3.

When the first beta is released, it’s nice if you as a Graphics View developer try out your Qt 4.2 app with 4.3, so that we can nail out any possible regressions (both behavior and speed) before the final version is out. So please, let us know :-) .

Here are some of the new features:

  • QGraphicsView has some new properties.
    • viewportUpdateMode: Now you can fine-tune how the viewport reacts the changes in the scene.
    • rubberBandSelectionMode: For those who want to select items that are inside but don’t intersect with the rubberband…
    • optimizationFlags: If you want faster graphics, away goes the safety net… ;-)
  • All flicker in rubberband mode is gone.
  • You can also transform the view with a QTransform; this works best for small scenes, though. But the effect of seeing your scene with perspective transformations is pretty cool.
  • QGraphicsItem has some new flags.
    • ItemClipsToShape: All item rendering is clipped to its own shape
    • ItemClipsChildrenToShape: Like widgets, the parent item clips all its descendents.
    • ItemIgnoresTransformations: The lovable item that just won’t transform… well.

There’s been some under-the-hood changes too. Where before, if you moved an item, it would always get continuously reindexed (for each mouse move event), now it goes into an intermediate state that keeps the item outside the index until you leave it for a while. When moving a lot of items together, this makes a huge difference. It also means you don’t have to use NoIndex for scenes that combine animated and static items! It’ll still be pretty fast.

Check out the chip demo, or run the Colliding Mice example in one window, and top/Task Manager in the other; it’s faster in Qt 4.3 snapshots!

[no carrier] – /me waits for the first comment going “Hey, it’s not fast at all!” ;-)

QShare(this)

No related posts.


21 comments

1 yannick February 27, 2007 at 9:12 pm
 

when do you think the first beta will be released ?

2 anon February 27, 2007 at 9:16 pm
 

Hey, it’s not fast at all :)

From 20070225 snapshot…

Scaling of pixmaps seems slow to me. Especially when scaling with a factor

3 anon February 27, 2007 at 9:18 pm
 

… err Especially when scaling with a factor

4 anon February 27, 2007 at 9:18 pm
 

buggy comments

5 Marius February 27, 2007 at 9:40 pm
 

anon: You mean a factor of either 1) < 1.0 2) > 1.0?

6 Leo S February 27, 2007 at 9:49 pm
 

Great! All those speed improvements apply directly to the app I’m writing. Can’t wait to try it out.

7 anon February 27, 2007 at 10:09 pm
 

Marius, I mean a factor less than 1.0. Try this…

Add some pixmaps to the portedcanvas example. Specifically, add about 5 really big pixmaps. Say the size of your screen. Then animate them scaling down to thumbnail size all at the same time. Very slow.

8 anon February 27, 2007 at 10:11 pm
 

Btw, they don’t have to be anywhere near that big. It’s just most dramatic ;)

9 Dominic February 28, 2007 at 1:16 am
 

Could you post a screenshot of the hot new rubberband? I am curious…

10 Steve February 28, 2007 at 5:12 am
 

Could you post a screenshot of the hot new rubberband? I am curious…
I don’t think the rubberband was changed…there was just a bug fix for it.

11 Theo February 28, 2007 at 8:53 am
 

I saw some rubberband problems in 4.2 when using OpenGL on Windows. These have been fixed in 4.3 and is is definitely a lot quicker. Unfortunately the fix won’t work for my own rubberband which I use for rectangle zooming.
The 4.3 version is on Windows a lot quicker. So far, times went from 15 minutes per paint event back to 22 seconds. But we have not yet fully implemented our graphics editor. Wait and see if it can handle 1+ million polygons.

12 Andreas February 28, 2007 at 9:36 am
 

The rubberband looks awesome with and without OpenGL (yes, the strange painting errors are all gone), and all flicker is gone. A screenshot wouldn’t really show you what’s improved; it looks just like in 4.2 (still follows the style), but without the rendering errors, and without flicker when you move it around. It feels faster too, and that’s not just because the implementation has improved. It’s also because of Zack’s efforts to speed up shape intersection, and some other cool cut-offs we’ve implemented.

Scaling pixmaps has always been slow on X11. Is it slower now than before? /me goes and bugs the other graphics guys.

13 anon February 28, 2007 at 5:34 pm
 

If it helps, yes I think the scaling down of large pixmaps is slower than usual on X11, but I have no actual metric of interest.

14 Andreas February 28, 2007 at 6:37 pm
 

If you show us metrics, we might be able to fix it. Without metrics, there’s little we can do.

15 Thomas March 6, 2007 at 3:24 pm
 

Hi,

I just checked the performance of the colliding mice demo – and it seems to be quite the same on my machine!
heres an example of 4.3-snapshot (28.02.2007 -btw. there are no snapshots of march???)
51.9 X
38.4 collidingmice

(without any window resizing etc.)

anything I can do about it?

Thomas

16 Andreas March 6, 2007 at 4:48 pm
 

Which platform?

17 Jeremy Friesner March 7, 2007 at 7:27 am
 

Just curious about the ItemIgnoresTransformations flag…. in my app I allow the user to zoom in, which causes everything to be larger, including the text labels. Having big 50-point text labels isn’t terribly useful, and it would be nicer if the text always stayed the same size while everything else magnified as usual. (The text’s location would need to stay the same relative to the other content, of course) Will this flag help me in that regard?

Thanks,
Jeremy

18 Thomas March 7, 2007 at 8:50 am
 

Hi Andreas,

I tested on a SuSE Linux 8.1 (I know old stuff – but that should not influence the performance?), using a GCC 3.2 and Xfree 4.3

Best regards,

Thomas

19 Diego March 7, 2007 at 12:00 pm
 

Jeremy,

I have solved a similar problem (some labels and rectangles need to stay the same size regardless of the zoom factor, however it needs to react to other transformations such as translation), and so far I have solved using a combination of signals triggered when a zoom-in / zoom-out is applied. However, I would like to have a more elegant way of doing so, and I expect that new flag to help me with that task. Andreas, perhaps instead of just one flag (ItemIgnoresTransformations) could it be extended so we can have several independent flags (ItemIgnoresRotation, ItemIgnoresScaling, …)?

Best regards,
Diego

20 Rajesh March 7, 2007 at 12:19 pm
 

I reported a bug in Qt4.2.0
that the background is not drawn completely when you do not call setSceneRect()
Is this bug fixed?

Best regards,

Rajesh

21 Andreas March 7, 2007 at 8:15 pm
 

Jeremy: Yes! This is exactly what the flag does for you.
Diego: No signals necessary, just set this flag. If you need more than this, please file a suggestion.
Rajesh: Have you tried 4.2.3? 4.3.0? 4.4.0? All reported bugs have been fixed for 4.3.0.

Comments on this entry are closed.

Previous post:

Next post: