Results 1 to 14 of 14

Thread: Graphics View Queries

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Posts
    31
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Graphics View Queries

    Thanks for the reply.

    I have enhanced my small application to do much more work.

    Now it does the following:

    1. it has a background which are nothing but six concentric circles (shown always)

    2. An elliptical item is drawn at the outermost position and its position is moved every 10msec around the ellipse in steps of 10deg.

    3. I have Zoom feature around the center, also panning is done through scroll option provided by QGraphicsView.

    4. An option to remove the Pan.

    I have severe time constraints to my application and i need to draw somewhere around 500 items at a time with worst case refresh rate of 30msec.

    When i try to pan around using mouse , the refresh rate is dropped...

    Can someone please have a look at the source and let me know if there is any serious design flaw? so that it doesnt carry on further in my code...
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Graphics View Queries

    1. Get rid of updateCapPos(). Use QGraphicsScene::advance() or QGraphicsItemAnimation instead.

    2. Disable hover for MyItem and GvHmiBgItem, you're not using it anyway so it's a plain waste of processing power.

    3. Don't disable indexing in the scene unless you know you won't need it, you have only a few items so updating the index yields practically no overhead.

    4. If you don't use mouse events with the scene and items, call QGraphicsView::setInteractive(false).

    This should get you some speedup. I'd also suggest disabling ItemIgnoresTransformations and rely on the scene to recalulate proper item sizes, currently your implementation is incorrect as the scene doesn't see boundingRect() changes of your items, so it uses a too large boundingRect and redraws your items much too often.

  3. #3
    Join Date
    Dec 2008
    Posts
    31
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Graphics View Queries

    Thanks for the response
    But i need to Ignore the Transformation for some items as they are required to retain the size independent of zoom level.

    I didnt get your point, when you said "currently your implementation is incorrect as the scene doesn't see boundingRect() changes of your items, so it uses a too large boundingRect and redraws your items much too often".

    Which item are you referring to ? The background item or the elliptical item?

    I have also observing a strange behaviour,

    When i set the update interval as 1msec, and run my app, the elllipse moves very fast but if i dont interact with the scene and leave the application alone, i dont see the movement of the item.
    what could be the problem?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Graphics View Queries

    Quote Originally Posted by linuxdev View Post
    But i need to Ignore the Transformation for some items as they are required to retain the size independent of zoom level.
    That's not what your code does.

    I didnt get your point, when you said "currently your implementation is incorrect as the scene doesn't see boundingRect() changes of your items, so it uses a too large boundingRect and redraws your items much too often".
    Your boundingRect() implementation returns a variable size but you never inform graphics view that this size has actually changed so it always uses the bounding rect that was returned the first time and this will slow down painting if the rect is bigger than you actually need it to be.

    Which item are you referring to ? The background item or the elliptical item?
    Both, as far as I remember.

    When i set the update interval as 1msec, and run my app, the elllipse moves very fast but if i dont interact with the scene and leave the application alone, i dont see the movement of the item.
    what could be the problem?
    I'd say that's a combined problem resulting from what I described earlier. Your usecase is very simple and you make it way too complicated.

  5. #5
    Join Date
    Dec 2008
    Posts
    31
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Graphics View Queries

    Quote Originally Posted by wysota View Post
    That's not what your code does.
    "i need to Ignore the Transformation for some items as they are required to retain the size independent of zoom level."
    for this i have just set the flag "item3->setFlag(QGraphicsItem::ItemIgnoresTransformations , true);"
    This should satisfy my requirement right? what's my code doing, where am i going wrong?



    Quote Originally Posted by wysota View Post
    Both, as far as I remember.
    I have used Standard EllipseItem of the Framework, this should take care of the issue automatically right?
    I think i need to call "prepareGeometryChange();" for custom item , should i do this in the Resize Event?




    Quote Originally Posted by wysota View Post
    Your usecase is very simple and you make it way too complicated.
    I guess there is a design flaw somewhere , how can it be simplified ? can you help me rectify my attached code ?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Graphics View Queries

    What exactly is your application meant to do? I ran the code you provided but I don't see much

  7. #7
    Join Date
    Dec 2008
    Posts
    31
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Graphics View Queries

    Hmm

    I didnt want to go deep into it, now that you have asked for, i think you would have to read completely

    My application is a Radar Display System,
    I receive data from radar , through network which represent aircrafts in space.
    The data received is to be plotted on to the display. the concentric circle represent the PPI view.
    Origin represents the radar and rings are mapped to 10Km , 20 and so on ....

    a. Application receives data from Network continuously.
    b. This data has to be processed and then drawn on to the scene.
    c. There can be as many as 600 data items for every 4 secs or even lesser interval.
    d. data which is old by one interval should be changed to a different color and that those which are old by two intervals should be deleted/erased from the display. (aircraft gone away)

    I have done bulk of my Coding in QPainter, its not living to expected performance, now i am planning to do the same in GraphicsView. (Following the way showed by you )

    The Application i have done now , is to test whether GraphicsView Framework will do my job at much better performance boost.
    For that,
    a. I have not added the network part in this miniature app.
    b. Instead to test performance , i am drawing only one data at an interval of 10msec. (Planning to put 500 more items)

    Will this workout ?
    Should i still need to use QThread for Network or its fine with the GraphicsView Framework.

    The radar is quite fast , it rotates at 24 Rpm. Pumping data upto 600 data in one rotation.
    I have to display them efficiently, giving much better User Response. (As he will do a lot of other things)


    This is my Story, hope to receive some help so that i can make a movie

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Graphics View Queries

    In that case I would draw the crosshair using drawBackground() or drawForeground() and the aircrafts and other potential objects using items of the graphics view. I would probably not use scaling even if you want to have different zoom levels, as most objects would have to ignore transformations anyway, so it might be easier to move them around instead of scaling - losing transformations altogether would make things much faster. Bare QPainter is fine too but you'd have to do some caching to avoid recalculating everything.

  9. The following user says thank you to wysota for this useful post:

    linuxdev (8th January 2009)

Similar Threads

  1. Qt Coordinate System and the Graphics View Framework
    By djurodrljaca in forum Qt Programming
    Replies: 14
    Last Post: 17th February 2012, 11:19
  2. Replies: 4
    Last Post: 5th August 2008, 19:55
  3. Graphics View Event Propagation
    By pherthyl in forum Qt Programming
    Replies: 10
    Last Post: 3rd July 2008, 10:39
  4. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  5. Adding Rectangular overlay on graphics view
    By forrestfsu in forum Qt Programming
    Replies: 10
    Last Post: 21st November 2006, 19:42

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
  •  
Qt is a trademark of The Qt Company.