Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, May 2007
SVG element bounding box


Message 1 in thread

Hi there,
i was using QGraphicsSvgItem and QGraphicsView to display a single svg
element. That drawing was made with inkscape and it have large borders, but
i noticed that when drawing, the borders were cut - as the bounding box of
the element doesn't include the borders (if the shape is a circle, one could
notice the borders in the angles, since they are still into the bounding
box, but on sides they are cutted)

So i wonder if bounding box actually considers border width in the
calculation, and how to include borders when drawing.

Thanks
Alessandro

Message 2 in thread

On Thursday 17 May 2007, Alessandro Re wrote:
> Hi there,
> i was using QGraphicsSvgItem and QGraphicsView to display a single svg
> element. That drawing was made with inkscape and it have large borders, but
> i noticed that when drawing, the borders were cut - as the bounding box of
> the element doesn't include the borders (if the shape is a circle, one
> could notice the borders in the angles, since they are still into the
> bounding box, but on sides they are cutted)
>
> So i wonder if bounding box actually considers border width in the
> calculation, and how to include borders when drawing.

I've cursed this same thing when I've tried to make pieces for a game in one 
single SVG file. For me the stroke width is not take into account. For a 
rectangle piece with a size of 100x100 and stroke width of 10, the actual 
saved size should be 110x110 (ie. 5+100+5). Inkscape however saves a smaller 
size, something like 95x95 which indeed does follow the rectangle as defined, 
but does not take into account the stroke.

Then when Qt loads the element from the SVG file, it blindly obeys the 
width/height given there and thus some data is cut off. I guess that Qt 
relies on that the given size fully covers all parts of the drawing. So I'm 
ready to blame Inkscape here (but I don't know that the SVG specs say about 
these things).

If you find a solution, please let me know.

-- 
 [ signature omitted ] 

Message 3 in thread

Well, there is a trick to solve this :)
One can group any object with a line which cross diagonally the
bounding box of the object, making the bounding larger than the object
+ it's border.
... Of course the line would be transparent, and the ID should be set
on the group itself.

Actually i didn't find anything about "sizes" in svg specification
(but i should look better), neither in inkscape-generated file, so i
guess that bounds are calculated by qt, not by inkscape.

Bye

--
 [ signature omitted ]