Results 1 to 5 of 5

Thread: QGraphicsView and very small scale values

  1. #1
    Join Date
    Jan 2007
    Posts
    45
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QGraphicsView and very small scale values

    Hello All,

    I'm using QGV to render the physical simulation scene using physical units. To fit it on the screen I use QGraphicsView::scale. When I'm trying to render very big scene (i.e. with very big object positions and sizes but small number of objects) and set very small scale value (around 1e-12) a lot of things breaks: sometimes items are not drawn at all, sometimes they can not be selected, rubberband selection does not work at all (it does not even show a selection rectangle). Currently I'm using Qt4.3, with Qt4.2 things where slightly better.

    Is it normal behavior ? Should I just do not use QGraphicsView::scale and perform scalling manually when creating items ?

  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: QGraphicsView and very small scale values

    I'd say this is a normal behaviour - you're approaching limits of the datatype (double, I guess) here. I suggest you just use different units. If you divided everything by 1000000, you'd only use 1e-6, which should be fine.

  3. #3
    Join Date
    Jan 2007
    Posts
    45
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView and very small scale values

    I've thought that limits of double (and float) datatypes are quite higher, on my system DBL_MIN=2.22507e-308, FLT_MIN=1.17549e-38. And in Qt4.2 it worked quite better.

    I can't just divide all values by fixed number since they are not known in advance. It seems that I have to forget about scale() method and use manual scaling.

  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: QGraphicsView and very small scale values

    It's about the resolution, not the highest/lowest possible value. Floating point types can't represent each and every possible value between in its range.

    You don't have to know anything in advance, you can calculate the divisor dynamically.

  5. #5
    Join Date
    Jan 2007
    Posts
    45
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView and very small scale values

    You don't have to know anything in advance, you can calculate the divisor dynamically.
    I'm thinking about going this way. In essential this is manual scaling.

    Actually you can just take a look at my program: http://edu.kde.org/step. This screenshot was made with Qt4.2, with 4.3 it shows only several planets at the center.

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.