Results 1 to 13 of 13

Thread: Limitations to QPolygonF?

  1. #1
    Join Date
    Feb 2011
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Limitations to QPolygonF?

    Is there any limitations to how many points a QPolygonF can contain?
    I have in my scene several polygons and when I use my "drawing tool" to draw some lines it crashes. But It only crashes when I add a polygon which contains 130188 points to be exact. If I don't add it everything works just fine.
    I only uploaded the sourcefiles so it will not compile due to some dependencies I haven't included but I thought it would be better than printing whole classes in the thread?

    This is how I populate the scene in graphicView.cpp
    Qt Code:
    1. for(int i=0;i<shp.getPolygons().size();i++)
    2. {
    3. MapLine* t = new MapLine(shp.getPolygons()[i]);
    4. scene->addItem(t);
    5. }
    To copy to clipboard, switch view to plain text mode 

    And on this line it crashes in MyScene.cpp
    Qt Code:
    1. QList<QGraphicsItem*> test = currentDrawItem->collidingItems(Qt::IntersectsItemShape);
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2011
    Posts
    2
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Limitations to QPolygonF?

    Sorry, I don't know how to answer .... for the moment, but I have a little question for someone who play with polygonitems: is it possible to make polygonitems whith no line between last and first point? an "open polygon"

    thanks

  3. #3
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Limitations to QPolygonF?

    "it crashes"?

    How? What does it do? What error messages are displayed?

  4. #4
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Limitations to QPolygonF?

    Quote Originally Posted by roband915 View Post
    Is there any limitations to how many points a QPolygonF can contain?
    I have in my scene several polygons and when I use my "drawing tool" to draw some lines it crashes. But It only crashes when I add a polygon which contains 130188 points to be exact. If I don't add it everything works just fine.
    130188 point for polygon it's a lot! Note that you want to have more points then screen resolution! Definitely first you should optimize you code and prevent adding dummy points (quick calculation: lets say users can drew a curve with speed 10 points per second, to draw curve with 130188 points 3.6 hours is needed, so something is wrong with you code or problem explanation!).
    Last edited by MarekR22; 24th May 2011 at 09:51.

  5. #5
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Limitations to QPolygonF?

    Quote Originally Posted by MarekR22 View Post
    130188 point for polygon it's a lot! Note that you want to have more points then screen resolution! Defenatly first you should optimize you code and prevent adding dumy points (quic calculation: lets say users can drew a curve with speed 10 points per second, to draw curve with 130188 points 3.6 hours is needed, so something is wrong with you code or problem explanation!).
    It's nowhere near "screen resolution" if by that you mean the number of pixels on the screen. A very low resolution 600x800 screen has 480000 pixels; a more typical 1000x1800 screen has almost two million. Both have far more than the number of points in the OP's polygon. And in terms of drawing speed, even low performance graphics hardware is capable of rendering hundreds of thousands of points per second, if not millions.

    The size of the polygon, then, almost certainly is not the issue. Knowing the actual error message would help to pin down what's going on, but couple hundred thousand points shouldn't be any trouble for even a small system.

  6. #6
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Limitations to QPolygonF?

    You have a curve not a list of all points of screen! So consider lines not planes!

  7. #7
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Limitations to QPolygonF?

    130188 point for polygon it's a lot! Note that you want to have more points then screen resolution!
    That's right, but only if you have a 300x400 (or less) screen resolution
    I agree with MarekR22, that count of points is impossible to be managed by human manually.
    Are you adding new point each time a mouse is moved, when selecting this "polygon tool" ? If yes, then I'd suggest some optimizations, for example, there is no need to have two points in distance of 2 pixels to each other, it's just impossible for human to note such small gap. Define some kind of threshold value for minimal distance between two points for your drawing tool, I'm sure the count of points will be significantly reduced.

  8. #8
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Limitations to QPolygonF?

    Actually, polygons of this size and larger are quite common in GIS and other applications. Pruning may be beneficial at wider "zooms", but that sort of optimization needs to be performed by the rendering engine, not on the data itself, in order to support close-in zoom levels.

    I have no idea what the OP is trying to do, just pointing out that without further information it isn't possible to say anything about whether the number of points is excessive or not. Just as it isn't possible to offer much in the way of help without knowing more about what the problem actually is.

  9. #9
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Limitations to QPolygonF?

    1. Ok, but I marked key word "drawing tool". In this kind of application this number of points is just unexpected and must be result of bug in code.
    2. Even if this application would be some GIS kind, before drawing number of points should be adjusted to current resolution for perfomance resons. Most of maps use 3 or more sets of data for different zoom factor for performance reasons and prevent user information flooding.

  10. #10
    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: Limitations to QPolygonF?

    Drawing tools should use a QPainterPath rather than QPolygonF. Then you can easily simplify the path.
    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.


  11. #11
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Limitations to QPolygonF?

    Quote Originally Posted by MarekR22 View Post
    1. Ok, but I marked key word "drawing tool". In this kind of application this number of points is just unexpected and must be result of bug in code.
    2. Even if this application would be some GIS kind, before drawing number of points should be adjusted to current resolution for perfomance resons. Most of maps use 3 or more sets of data for different zoom factor for performance reasons and prevent user information flooding.
    What kind of application? The OP doesn't say, and there's nothing posted that provides any clue.


    QGis, which is written in Qt, routinely handles polygons containing hundreds of thousands of points and does so quickly and well. I seriously doubt that a few hundred thousand points is going to bog down any drawing routine, nor does that have anything to do with the actual problem, which is some sort of unspecified crash.

    There's no point wasting time chasing an optimization that has nothing to do with the problem at hand.

    Quote Originally Posted by wysota View Post
    Drawing tools should use a QPainterPath rather than QPolygonF. Then you can easily simplify the path.
    As noted above, simplifications like this are the job of the rendering engine. Futzing with the data contained in the polygon would be the wrong approach, even if this had something to do with the problem at hand.

  12. #12
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Thanks
    11
    Thanked 16 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Limitations to QPolygonF?

    Quote Originally Posted by roband915 View Post

    And on this line it crashes in MyScene.cpp
    Qt Code:
    1. QList<QGraphicsItem*> test = currentDrawItem->collidingItems(Qt::IntersectsItemShape);
    To copy to clipboard, switch view to plain text mode 
    Sorry, it can not open the tar.gz (file invalid?!), but some guesses:

    Are you sure, that currentDrawItem is valid?
    Maybe the 130188th point is somehow invalid? Did you check that?
    Are you using Threads, that could mess something up?

  13. #13
    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: Limitations to QPolygonF?

    Quote Originally Posted by SixDegrees View Post
    As noted above, simplifications like this are the job of the rendering engine.
    If the data comes directly from the user's input as is interpreted as free-hand drawing then I don't agree. Simplification is part of pre-processing this user-input.
    I understand that you mean a situation when the core of data are points themselves (like when determining a map route) and not the "stroke" where the points are only control points (like with free-hand drawing).
    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. QPolygonF precision?! is it possible?!
    By fatecasino in forum Newbie
    Replies: 11
    Last Post: 27th January 2011, 02:36
  2. QTreeWidget Delegate setModelData limitations
    By kubas in forum Qt Programming
    Replies: 0
    Last Post: 8th September 2009, 08:40
  3. Sorting QPolygonF
    By giusepped in forum Qt Programming
    Replies: 3
    Last Post: 7th January 2009, 08:34
  4. QHttp Limitations?
    By rage in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 25th September 2007, 11:58
  5. QGraphicsScene/QGraphicsView window limitations
    By mistertoony in forum Qt Programming
    Replies: 11
    Last Post: 17th February 2007, 08:10

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.