Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23

Thread: how to prevent qgraphicsitem repaint while mouse move on it

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

    Default Re: how to prevent qgraphicsitem repaint while mouse move on it

    Quote Originally Posted by christina123y View Post
    today i have tried that each point as a child qgraphicsitem, and set a coordinate item as their parent, and it did draw correct graph. but, my points is larger then 12,0000
    (they are float type ) ,i found ithat when i zoom in the graph to some extents it become slowly again,fairly slowly ,even make my application dead.
    Zooming in should make your application faster not slower. You must have done something wrong.

    i have look up the reference of BSP , but it is still obscure to me.maybe i should spend some time to investigate this. would you please provide me some relative reference? thank you.
    It's a very popular algorithm. It's 3D version (based on octree) is used in most 3D FPP/TPP games to speed up rendering by cutting out objects that are not in the viewing frustum. I'm sure you'll find lots of materials on the subject.

    what do you mean "automatically use that built-in mechanism "? i make each point as a separate item, and then use QGraphicsItem::setPos() in its parent item. how should i use
    alleged built-in mechanism ? Or Qt does that itself?
    If each point is a separate item then you already use this mechanism.

    but why didn't this way improve the speed. and it still repaint very slowly.
    I'd have to see the code. You can search the forum. Some time ago as a reply to one of Ini's complaints about QGraphicsView functionality I made a proof of concept and posted it here. As far as I remember the application contained 10k points in a form of zoomable graph. You can see an example implementation there.

    i use QGraphicsView for i need to make my application perform other functions such as mouse tracker, and so on.
    You can do the same with a regular widget. There is only one usecase currently where you'd want to use graphics view when having a single item and that's not your usecase.

    and how to use BSP to achieve improving speed of repaint?
    Group your points into clusters. This requires a bit of more computation power when preparing the graph but once it's there you should get a significant speedup. You can use the "K nearest neighbours" and/or "K-Means" algorithms for clustering. The first algorithm is a classification algorithm which can prove useful once you "teach" your graph the characteristics of your data. It will make it possible to quickly find the appropriate cluster for a new point. The second algorithm is a classical clustering algorithm.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    christina123y (17th April 2009)

  3. #22
    Join Date
    Feb 2009
    Posts
    38
    Thanks
    29
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: how to prevent qgraphicsitem repaint while mouse move on it

    First ,thank you very much, these days, i have tried another way to improve the speed of repainting, but it still didn't resovle essential problem. now allow me to depict my method: I still draw all the points in a pixmap ,then draw pixmap to a single item, and draw coordinate system as the same way. when i zoom in the graph, i newly adjust the item's boundingRect with the corresponding proportion. and draw the whole points in the item.only when the item's width and height
    overrun the range (the range within the cache mode--ItemCordinateCache can support), then repaint the graph, however,while the mouse move what i need to do is that to draw pixmap on the item. this really has improve the speed of repaint while mouse move.
    wish i has explain my thought clearly.
    but when zoom in the graph ,the first time to repaint the graph is still slow, and feels very very slowly when you move the scrollbar to see graph in the invisible area.
    maybe i should look up other way for solution.

    Quote Originally Posted by wysota View Post
    Zooming in should make your application faster not slower. You must have done something wrong..
    i have checked out ,i really draw each point as a single item. but it really feels very slowly.


    Quote Originally Posted by wysota View Post
    It's a very popular algorithm. It's 3D version (based on octree) is used in most 3D FPP/TPP games to speed up rendering by cutting out objects that are not in the viewing frustum. I'm sure you'll find lots of materials on the subject.
    hn,i have looked up some reference on it, and i found it very hard, and i still didn't know to to apply to my application. these days , i have given up on this solution, but my solution still didn't works well, maybe i should penetrate into this method.


    Quote Originally Posted by wysota View Post
    I'd have to see the code. You can search the forum. Some time ago as a reply to one of Ini's complaints about QGraphicsView functionality I made a proof of concept and posted it here. As far as I remember the application contained 10k points in a form of zoomable graph. You can see an example implementation there.
    Could you please show me the URL where you post it and the example , i haven't found it , thank you.

    best wishes to you. and looking forward to your reply.

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

    Default Re: how to prevent qgraphicsitem repaint while mouse move on it

    Quote Originally Posted by christina123y View Post
    however,while the mouse move what i need to do is that to draw pixmap on the item. this really has improve the speed of repaint while mouse move.
    That's the first solution I described. And caching works exactly the same way only that it does the bookkeeping itself without you having to care.

    but when zoom in the graph ,the first time to repaint the graph is still slow,
    and feels very very slowly when you move the scrollbar to see graph in the invisible area.
    maybe i should look up other way for solution.
    This is because you have a single item - the whole pixmap has to be regenerated and rendered onto the viewport although only a part of it is visible.

    i have checked out ,i really draw each point as a single item. but it really feels very slowly.
    Zooming should reduce the number of paint operations. If it doesn't (or if it increases it) then there is something wrong with your code.

    hn,i have looked up some reference on it, and i found it very hard, and i still didn't know to to apply to my application. these days , i have given up on this solution, but my solution still didn't works well, maybe i should penetrate into this method.
    It's not that hard, the algorithm is very simple. The only thing is that you have to know why you are doing things you are doing and not just because some fool on QtCentre forum told you to do it

    Could you please show me the URL where you post it and the example , i haven't found it , thank you.
    It's here somewhere. Use the search facilities of the forum to search through threads started by the user I mentioned before.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 9
    Last Post: 22nd June 2008, 22:26
  2. Replies: 4
    Last Post: 3rd March 2008, 22:15
  3. Mouse Move Event
    By merry in forum Newbie
    Replies: 5
    Last Post: 3rd June 2007, 06:26
  4. Move Rectangle on mouse Move
    By vermarajeev in forum Qt Programming
    Replies: 24
    Last Post: 14th May 2007, 05:34
  5. how to display full tree item name on mouse move ?
    By rajesh in forum Qt Programming
    Replies: 5
    Last Post: 15th November 2006, 08:41

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.