PDA

View Full Version : How to avoid calling boundingRect() & shape()



nileshsince1980
3rd October 2007, 15:43
Hi,
I am using GraphicsView to display 15,000 > rectangle & 20,000 > lines joining them.
But rendering speed is too slow ...I checked chip example but chip seems too fast as compare to my application. Even though chip is having more items on screen than my application.
Can anybody tell me how to make it fast ??? any flag need to set ???
Also boundingRect() & shape() function are getting called too many times. Can we avoid calling these functions to improve performance/rendering ? and how ??

marcel
3rd October 2007, 16:01
Well, bitto suggested in a similar post to increase the scene's bspTreeDepth property. If you try this, make sure first that itemIndexMethod is BspTreeIndex.

nileshsince1980
4th October 2007, 06:28
By default item index method is BspTreeIndex, but as I want to move rectangles and lines adjoined it, it becomes very slow .
Can you suggest any other method so that I can use to rendering.
Also loading time is also too slow. How we can add items in Scene fastly & render it ?

rajesh
4th October 2007, 07:15
Can anybody tell me how to make it fast ??? any flag need to set ???


add
setViewport(new QGLWidget);
in your constructor to make it fast.

marcel
4th October 2007, 07:46
By default item index method is BspTreeIndex, but as I want to move rectangles and lines adjoined it, it becomes very slow .
Can you suggest any other method so that I can use to rendering.
Also loading time is also too slow. How we can add items in Scene fastly & render it ?
Have you increased bspTreeDepth?

nileshsince1980
8th October 2007, 12:16
how to set setBspTreeDepth property for scene items ???
Also I have tried setViewport(new OpenGLWidget) but it slowa down rendering,
Is there is another way to make fast rendering ??

Gopala Krishna
8th October 2007, 14:03
http://labs.trolltech.com/page/Projects/DevDays/DevDays2007
The gv presentation might give you some tips to improve rendering speed.

Have you cached the values to be returned in boundingRect() and shape() ? Probably you can inline them..

Also have you profiled your app and tried to find out where exactly it is being slow ?

P.S: Did you try out all the suggestions mentioned in the previous threads in this forum ?

Brandybuck
8th October 2007, 19:10
I have had cases where NoIndex was significantly faster than BspTreeIndex. If not, play around with bspTreeDepth().

Gopala's suggestion to cache bounding rects and shapes is also a good one. Most of the examples show calculating rects and shapes on the fly, but this is not good. Put a QRectF and a QPainterPath member in your item, and return them when requested. Also keep your shapes simple. Sometimes a loose approximation of the shape is sufficient.