Results 1 to 8 of 8

Thread: how to draw a long curve quickly?

  1. #1
    Join Date
    Mar 2009
    Location
    Gansu,China
    Posts
    188
    Qt products
    Qt4
    Platforms
    Windows

    Default how to draw a long curve quickly?

    I want to draw a curve in QGraphicsScene and it is composed by about 100,000 points. how to draw it quickly?
    I want to draw part of it at first,when user drag mouse,I draw another part according the mouse moves,but i do not know how to realize it?
    do you have the other method?

  2. #2
    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 draw a long curve quickly?

    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.


  3. #3
    Join Date
    Mar 2009
    Location
    Gansu,China
    Posts
    188
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to draw a long curve quickly?

    Thk u for your answer.
    I know that use QPainterPathand QGraphicsPathItem to
    create a curve.
    My question is that when the points number is vevy large ,for example,100,000,how to draw it quickly?

  4. #4
    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 draw a long curve quickly?

    You don't. If the number of points is large then it takes longer to draw them than when there is fewer of them. Optimize your point count and cache whatever you can.
    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.


  5. #5
    Join Date
    Mar 2009
    Location
    Gansu,China
    Posts
    188
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to draw a long curve quickly?

    ”cache whatever you can“,sorry,I do not know what it means.

  6. #6
    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 draw a long curve quickly?

    Keep intermediate values in memory instead of recalculating them each and every time when you need to use them.
    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.


  7. #7
    Join Date
    Mar 2009
    Location
    Gansu,China
    Posts
    188
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to draw a long curve quickly?

    I want to draw a curve in QGraphicsScene and it is composed by about 100,000 points. when I draw it all at
    first,it will cost a long time.
    I think if I should draw apart of it,and draw other part according user's draging the scroll bar.

  8. #8
    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 draw a long curve quickly?

    Yes, you can segment your path and draw only those segments that are visible. You can also render your whole path to a pixmap and then just render the pixmap instead of stroking the path in each frame (especially if your path is static).
    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. draw curve
    By szisziszilvi in forum Qt Programming
    Replies: 6
    Last Post: 25th January 2011, 08:38
  2. Replies: 1
    Last Post: 22nd January 2010, 14:34
  3. draw long text in rect
    By yxtx1984 in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2010, 09:00
  4. Want to draw Curve
    By santhoshv84 in forum Qt Programming
    Replies: 1
    Last Post: 12th September 2008, 07:14
  5. Wants to draw Luminious Curve
    By santhoshv84 in forum Qt Programming
    Replies: 1
    Last Post: 22nd June 2008, 22:45

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.