Results 1 to 5 of 5

Thread: Need tricks and tips for Graphics framework

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Need tricks and tips for Graphics framework

    I'd like to accelerate and 'manipulate' my Qgraphics 'world'
    Now, I see how an item added to the graphics scene rises a boundingrect event for all the previous items.
    That is, when I add the 100th item, 'somebodys' rises a boundingrect for the 99 previous. I dont understand why, theese items are currently showed.

    Also, I'm going to need a method to draw a line in 'editing mode' and sincereley I dont know any fast method (I remember the easy xor method of 'basic').

    I also feel the lack of usefull documentation related to improving, accelerate your drawings, etc.
    It seems as I'd have to discover this 'world'.
    You can find some information in the www but....
    Some usefull links ? Thanks.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Need tricks and tips for Graphics framework

    I have no idea what your first paragraph is talking about.

    The Elastic Nodes and Diagram Scene demo both show user interaction with objects in the view. The second example also show a drag-n-draw line capability. Just start "qtdemo" and have a look under Graphics View for more examples.

  3. #3
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Need tricks and tips for Graphics framework

    Thanks Chris.
    I'm trying to explain better.
    I have write some debugs messages for the arrow item of Diagram scene.
    I draw 8 'boxes' and its connecting arrows.

    Ok, If I give the focus to QTcreator, clean the message window and give the focus to the diagram scene again I see the next :

    bounding arrow 0
    bounding arrow 0
    paint arrow 0
    bounding arrow 1
    bounding arrow 1
    paint arrow 1
    bounding arrow 2
    bounding arrow 2
    paint arrow 2
    bounding arrow 3
    bounding arrow 3
    paint arrow 3
    bounding arrow 4
    bounding arrow 4
    paint arrow 4
    bounding arrow 5
    bounding arrow 5
    paint arrow 5
    bounding arrow 6
    bounding arrow 6
    paint arrow 6
    bounding arrow 7
    bounding arrow 7
    paint arrow 7
    bounding arrow 8
    bounding arrow 8
    paint arrow 8
    bounding arrow 0
    bounding arrow 0
    paint arrow 0
    bounding arrow 1
    bounding arrow 1
    paint arrow 1
    bounding arrow 2
    bounding arrow 2
    paint arrow 2
    bounding arrow 3
    bounding arrow 3
    paint arrow 3
    bounding arrow 4
    bounding arrow 4
    paint arrow 4
    bounding arrow 5
    bounding arrow 5
    paint arrow 5
    bounding arrow 6
    bounding arrow 6
    paint arrow 6
    bounding arrow 7
    bounding arrow 7
    paint arrow 7
    bounding arrow 8
    bounding arrow 8
    paint arrow 8

    'bounding arrow' is the message for 'bounding rect event' .
    As you can see, there is two complete cycles (that is, the system paints things two times). And the bounding arrow is called two times before paint...

    Another example of excesive bounding rect calls. First I draw 8 boxes and 8 arrows at left side of my view, set the zomm to 50% and draw two boxes at the right side. Ok, I see again how the bounding rect for the arrows from the left is called. I promise you that I have these first 8 elements at the left extreme of my 21" screen. There is no contact betwen graphic elements, so I dont understand these calls.

    By now I only have seen setCacheMode () for backgrounds, or QStyleOptionGraphicsItem::exposedRect(), which works at item level. (Is there any equivalent for scene or view ?)
    Which is the behavior for primitive items. In example, a QGraphicsPolygonItem() only needs the initial setPolygon() and setFlag's. I dont know if internally are a lot of bounding calls .

    In short, what I'd want to know methods to avoid and/or help to Qgraphics framework does an unneccesary work.
    Thanks

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Need tricks and tips for Graphics framework

    There is no 'bounding rect event'.

    I can only assume you mean the boundingRect() function is called. The computer doesn't have magical intuition that allows it to know that two items don't overlap, it has to calculate it. Using bounding rectangles is the efficient way to determine whether arbitrarily shaped items possibly overlap (or collide if animated), which is necessary to drawing the view. Only if the bounding rectangles overlap is more expensive work done to determine the actual shape of the item should it be needed. In short, calling boundingrect() is not unnecessary work.

    If you are worried about efficiency then don't do anything inefficient in your boundingRect() implementation. The bounding rectangle is generally immutable so you can cache the value.

  5. #5
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Need tricks and tips for Graphics framework

    Ok, thanks.

Similar Threads

  1. Graphics framework + Qt3D problem
    By RenderMan in forum Qt Programming
    Replies: 0
    Last Post: 18th February 2010, 21:26
  2. Problem about Graphics View Framework
    By FinderCheng in forum Qt Programming
    Replies: 5
    Last Post: 3rd November 2009, 09:16
  3. Problem with Graphics View Framework
    By Disperato in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2009, 21:44
  4. Issues with the Graphics View Framework
    By lni in forum Qt Programming
    Replies: 8
    Last Post: 26th April 2009, 15:13
  5. about the contextMenuEvent in graphics view framework
    By bingoking in forum Qt Programming
    Replies: 1
    Last Post: 21st April 2009, 07:04

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.