PDA

View Full Version : QGraphicsView and very small scale values



Vladimir
6th July 2007, 10:24
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 ?

wysota
6th July 2007, 12:13
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.

Vladimir
6th July 2007, 12:53
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.

wysota
9th July 2007, 15:33
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.

Vladimir
9th July 2007, 18:03
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 (http://edu.kde.org/step/pics/solar1.png) screenshot was made with Qt4.2, with 4.3 it shows only several planets at the center.