seneca, thank you! These are my questions
What do you mean saying "logical dots"? How do you calculate them? And how do you apply them to fonts' and geometric objects' sizes?
And there are some questions about your example:
1. The fact of presence of this example implies that scene is mapped to the view 1:1 without taking into account the fact that the view units may be non-square. And to correct this we need to apply appropriate transformation and without it a circle in the scene would look like ellipse if horizontal and vertical dpi values are different. Right?
2. Why you use the same dpi value for both vertical and horizontal scale factors. They can be different - as in my previous example of using 1024x768 resolution on monitor with physical resolution of 1280x1024.
3. You set up mapping scene to view with simple transformation, applying the scale factors to the view. But this transformation affects all scene items - both fonts and graphics. Would the fonts still look correct after this transformation? (I thought about this simple mapping but I doubt in its correctness from the fonts sizes point of view). In Qt4 documentation stated that values of logicalDpi[X|Y]() methods are used to map fonts (quote: "Returns the horizontal resolution of the device in dots per inch, which is used when computing font sizes"). Would your method of mapping cause duplicated use of dpi values for fonts or not?
4. I can use this transformation in my zoom method (I use mouse wheel event handler for this), but where should I use it when printing? (Well, honestly I haven't read anything about printing in Qt4 yet except of a bit of info about QPrinter, so the answer may be absolutely obvious and trivial. Just point me to the right direction in docs.)
wysota,
there is some strangeness in your words. First you write that scene logical units are always square and then you write that there are no scene units at all and then once again write "Logical units are units of the scene". Very strangeHow can coordinate system exist without units of measure? It's absurd from the math point of view. I think these units exist but are abstract meaning they do not tied to any real world units. This type of units is called "logical". This is normal and absolutely clear for me (I have some experience in OpenGL programming and I'm a bit of mathematician).
Second, you write that "These are physical units. Logical units are units of the scene". You are wrong because every LCD monitor (and not only monitors) has both physical and logical pixels. Physical pixels are semiconductor (or whatever else - OLEDs are organic) elements of LCD matrix and you can obtain their dpi value with physicalDpi[X|Y]() methods. These values are always the same for the given device (at least they should be). Logical pixels are pixels used to form picture on the screen and they can vary depending on used resolution of the screen. If you use "native" resolution those pixels (physical and logical) would be the same, but changing resolution to any "non-native" value makes them different. To get logical dpi values you use logicalDpi[X|Y]() pair of methods.This is how I see the situation with output devices. Logical units of the scene is a third level (not second!) of coordinate systems in graphics view and local units of items (their local coordinate system) of the scene is a fourth one. BTW do item's local units are always of the same size as the scene units or they can be different? I see there is the scale() method in QGraphicsItem class - what does it used for? Does it map single item's unit to several scene units (and vice versa if scale factor < 1.0) or just multiplies item's size (bounding rect?) by scale factors? The word "scales" used in documentation can mean both this actions. And does it mirror item if scale factors are negative?
And thank you again wysota and seneca.
Bookmarks